documentation.d.ts 2.9 MB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443244442444524446244472444824449244502445124452244532445424455244562445724458244592446024461244622446324464244652446624467244682446924470244712447224473244742447524476244772447824479244802448124482244832448424485244862448724488244892449024491244922449324494244952449624497244982449924500245012450224503245042450524506245072450824509245102451124512245132451424515245162451724518245192452024521245222452324524245252452624527245282452924530245312453224533245342453524536245372453824539245402454124542245432454424545245462454724548245492455024551245522455324554245552455624557245582455924560245612456224563245642456524566245672456824569245702457124572245732457424575245762457724578245792458024581245822458324584245852458624587245882458924590245912459224593245942459524596245972459824599246002460124602246032460424605246062460724608246092461024611246122461324614246152461624617246182461924620246212462224623246242462524626246272462824629246302463124632246332463424635246362463724638246392464024641246422464324644246452464624647246482464924650246512465224653246542465524656246572465824659246602466124662246632466424665246662466724668246692467024671246722467324674246752467624677246782467924680246812468224683246842468524686246872468824689246902469124692246932469424695246962469724698246992470024701247022470324704247052470624707247082470924710247112471224713247142471524716247172471824719247202472124722247232472424725247262472724728247292473024731247322473324734247352473624737247382473924740247412474224743247442474524746247472474824749247502475124752247532475424755247562475724758247592476024761247622476324764247652476624767247682476924770247712477224773247742477524776247772477824779247802478124782247832478424785247862478724788247892479024791247922479324794247952479624797247982479924800248012480224803248042480524806248072480824809248102481124812248132481424815248162481724818248192482024821248222482324824248252482624827248282482924830248312483224833248342483524836248372483824839248402484124842248432484424845248462484724848248492485024851248522485324854248552485624857248582485924860248612486224863248642486524866248672486824869248702487124872248732487424875248762487724878248792488024881248822488324884248852488624887248882488924890248912489224893248942489524896248972489824899249002490124902249032490424905249062490724908249092491024911249122491324914249152491624917249182491924920249212492224923249242492524926249272492824929249302493124932249332493424935249362493724938249392494024941249422494324944249452494624947249482494924950249512495224953249542495524956249572495824959249602496124962249632496424965249662496724968249692497024971249722497324974249752497624977249782497924980249812498224983249842498524986249872498824989249902499124992249932499424995249962499724998249992500025001250022500325004250052500625007250082500925010250112501225013250142501525016250172501825019250202502125022250232502425025250262502725028250292503025031250322503325034250352503625037250382503925040250412504225043250442504525046250472504825049250502505125052250532505425055250562505725058250592506025061250622506325064250652506625067250682506925070250712507225073250742507525076250772507825079250802508125082250832508425085250862508725088250892509025091250922509325094250952509625097250982509925100251012510225103251042510525106251072510825109251102511125112251132511425115251162511725118251192512025121251222512325124251252512625127251282512925130251312513225133251342513525136251372513825139251402514125142251432514425145251462514725148251492515025151251522515325154251552515625157251582515925160251612516225163251642516525166251672516825169251702517125172251732517425175251762517725178251792518025181251822518325184251852518625187251882518925190251912519225193251942519525196251972519825199252002520125202252032520425205252062520725208252092521025211252122521325214252152521625217252182521925220252212522225223252242522525226252272522825229252302523125232252332523425235252362523725238252392524025241252422524325244252452524625247252482524925250252512525225253252542525525256252572525825259252602526125262252632526425265252662526725268252692527025271252722527325274252752527625277252782527925280252812528225283252842528525286252872528825289252902529125292252932529425295252962529725298252992530025301253022530325304253052530625307253082530925310253112531225313253142531525316253172531825319253202532125322253232532425325253262532725328253292533025331253322533325334253352533625337253382533925340253412534225343253442534525346253472534825349253502535125352253532535425355253562535725358253592536025361253622536325364253652536625367253682536925370253712537225373253742537525376253772537825379253802538125382253832538425385253862538725388253892539025391253922539325394253952539625397253982539925400254012540225403254042540525406254072540825409254102541125412254132541425415254162541725418254192542025421254222542325424254252542625427254282542925430254312543225433254342543525436254372543825439254402544125442254432544425445254462544725448254492545025451254522545325454254552545625457254582545925460254612546225463254642546525466254672546825469254702547125472254732547425475254762547725478254792548025481254822548325484254852548625487254882548925490254912549225493254942549525496254972549825499255002550125502255032550425505255062550725508255092551025511255122551325514255152551625517255182551925520255212552225523255242552525526255272552825529255302553125532255332553425535255362553725538255392554025541255422554325544255452554625547255482554925550255512555225553255542555525556255572555825559255602556125562255632556425565255662556725568255692557025571255722557325574255752557625577255782557925580255812558225583255842558525586255872558825589255902559125592255932559425595255962559725598255992560025601256022560325604256052560625607256082560925610256112561225613256142561525616256172561825619256202562125622256232562425625256262562725628256292563025631256322563325634256352563625637256382563925640256412564225643256442564525646256472564825649256502565125652256532565425655256562565725658256592566025661256622566325664256652566625667256682566925670256712567225673256742567525676256772567825679256802568125682256832568425685256862568725688256892569025691256922569325694256952569625697256982569925700257012570225703257042570525706257072570825709257102571125712257132571425715257162571725718257192572025721257222572325724257252572625727257282572925730257312573225733257342573525736257372573825739257402574125742257432574425745257462574725748257492575025751257522575325754257552575625757257582575925760257612576225763257642576525766257672576825769257702577125772257732577425775257762577725778257792578025781257822578325784257852578625787257882578925790257912579225793257942579525796257972579825799258002580125802258032580425805258062580725808258092581025811258122581325814258152581625817258182581925820258212582225823258242582525826258272582825829258302583125832258332583425835258362583725838258392584025841258422584325844258452584625847258482584925850258512585225853258542585525856258572585825859258602586125862258632586425865258662586725868258692587025871258722587325874258752587625877258782587925880258812588225883258842588525886258872588825889258902589125892258932589425895258962589725898258992590025901259022590325904259052590625907259082590925910259112591225913259142591525916259172591825919259202592125922259232592425925259262592725928259292593025931259322593325934259352593625937259382593925940259412594225943259442594525946259472594825949259502595125952259532595425955259562595725958259592596025961259622596325964259652596625967259682596925970259712597225973259742597525976259772597825979259802598125982259832598425985259862598725988259892599025991259922599325994259952599625997259982599926000260012600226003260042600526006260072600826009260102601126012260132601426015260162601726018260192602026021260222602326024260252602626027260282602926030260312603226033260342603526036260372603826039260402604126042260432604426045260462604726048260492605026051260522605326054260552605626057260582605926060260612606226063260642606526066260672606826069260702607126072260732607426075260762607726078260792608026081260822608326084260852608626087260882608926090260912609226093260942609526096260972609826099261002610126102261032610426105261062610726108261092611026111261122611326114261152611626117261182611926120261212612226123261242612526126261272612826129261302613126132261332613426135261362613726138261392614026141261422614326144261452614626147261482614926150261512615226153261542615526156261572615826159261602616126162261632616426165261662616726168261692617026171261722617326174261752617626177261782617926180261812618226183261842618526186261872618826189261902619126192261932619426195261962619726198261992620026201262022620326204262052620626207262082620926210262112621226213262142621526216262172621826219262202622126222262232622426225262262622726228262292623026231262322623326234262352623626237262382623926240262412624226243262442624526246262472624826249262502625126252262532625426255262562625726258262592626026261262622626326264262652626626267262682626926270262712627226273262742627526276262772627826279262802628126282262832628426285262862628726288262892629026291262922629326294262952629626297262982629926300263012630226303263042630526306263072630826309263102631126312263132631426315263162631726318263192632026321263222632326324263252632626327263282632926330263312633226333263342633526336263372633826339263402634126342263432634426345263462634726348263492635026351263522635326354263552635626357263582635926360263612636226363263642636526366263672636826369263702637126372263732637426375263762637726378263792638026381263822638326384263852638626387263882638926390263912639226393263942639526396263972639826399264002640126402264032640426405264062640726408264092641026411264122641326414264152641626417264182641926420264212642226423264242642526426264272642826429264302643126432264332643426435264362643726438264392644026441264422644326444264452644626447264482644926450264512645226453264542645526456264572645826459264602646126462264632646426465264662646726468264692647026471264722647326474264752647626477264782647926480264812648226483264842648526486264872648826489264902649126492264932649426495264962649726498264992650026501265022650326504265052650626507265082650926510265112651226513265142651526516265172651826519265202652126522265232652426525265262652726528265292653026531265322653326534265352653626537265382653926540265412654226543265442654526546265472654826549265502655126552265532655426555265562655726558265592656026561265622656326564265652656626567265682656926570265712657226573265742657526576265772657826579265802658126582265832658426585265862658726588265892659026591265922659326594265952659626597265982659926600266012660226603266042660526606266072660826609266102661126612266132661426615266162661726618266192662026621266222662326624266252662626627266282662926630266312663226633266342663526636266372663826639266402664126642266432664426645266462664726648266492665026651266522665326654266552665626657266582665926660266612666226663266642666526666266672666826669266702667126672266732667426675266762667726678266792668026681266822668326684266852668626687266882668926690266912669226693266942669526696266972669826699267002670126702267032670426705267062670726708267092671026711267122671326714267152671626717267182671926720267212672226723267242672526726267272672826729267302673126732267332673426735267362673726738267392674026741267422674326744267452674626747267482674926750267512675226753267542675526756267572675826759267602676126762267632676426765267662676726768267692677026771267722677326774267752677626777267782677926780267812678226783267842678526786267872678826789267902679126792267932679426795267962679726798267992680026801268022680326804268052680626807268082680926810268112681226813268142681526816268172681826819268202682126822268232682426825268262682726828268292683026831268322683326834268352683626837268382683926840268412684226843268442684526846268472684826849268502685126852268532685426855268562685726858268592686026861268622686326864268652686626867268682686926870268712687226873268742687526876268772687826879268802688126882268832688426885268862688726888268892689026891268922689326894268952689626897268982689926900269012690226903269042690526906269072690826909269102691126912269132691426915269162691726918269192692026921269222692326924269252692626927269282692926930269312693226933269342693526936269372693826939269402694126942269432694426945269462694726948269492695026951269522695326954269552695626957269582695926960269612696226963269642696526966269672696826969269702697126972269732697426975269762697726978269792698026981269822698326984269852698626987269882698926990269912699226993269942699526996269972699826999270002700127002270032700427005270062700727008270092701027011270122701327014270152701627017270182701927020270212702227023270242702527026270272702827029270302703127032270332703427035270362703727038270392704027041270422704327044270452704627047270482704927050270512705227053270542705527056270572705827059270602706127062270632706427065270662706727068270692707027071270722707327074270752707627077270782707927080270812708227083270842708527086270872708827089270902709127092270932709427095270962709727098270992710027101271022710327104271052710627107271082710927110271112711227113271142711527116271172711827119271202712127122271232712427125271262712727128271292713027131271322713327134271352713627137271382713927140271412714227143271442714527146271472714827149271502715127152271532715427155271562715727158271592716027161271622716327164271652716627167271682716927170271712717227173271742717527176271772717827179271802718127182271832718427185271862718727188271892719027191271922719327194271952719627197271982719927200272012720227203272042720527206272072720827209272102721127212272132721427215272162721727218272192722027221272222722327224272252722627227272282722927230272312723227233272342723527236272372723827239272402724127242272432724427245272462724727248272492725027251272522725327254272552725627257272582725927260272612726227263272642726527266272672726827269272702727127272272732727427275272762727727278272792728027281272822728327284272852728627287272882728927290272912729227293272942729527296272972729827299273002730127302273032730427305273062730727308273092731027311273122731327314273152731627317273182731927320273212732227323273242732527326273272732827329273302733127332273332733427335273362733727338273392734027341273422734327344273452734627347273482734927350273512735227353273542735527356273572735827359273602736127362273632736427365273662736727368273692737027371273722737327374273752737627377273782737927380273812738227383273842738527386273872738827389273902739127392273932739427395273962739727398273992740027401274022740327404274052740627407274082740927410274112741227413274142741527416274172741827419274202742127422274232742427425274262742727428274292743027431274322743327434274352743627437274382743927440274412744227443274442744527446274472744827449274502745127452274532745427455274562745727458274592746027461274622746327464274652746627467274682746927470274712747227473274742747527476274772747827479274802748127482274832748427485274862748727488274892749027491274922749327494274952749627497274982749927500275012750227503275042750527506275072750827509275102751127512275132751427515275162751727518275192752027521275222752327524275252752627527275282752927530275312753227533275342753527536275372753827539275402754127542275432754427545275462754727548275492755027551275522755327554275552755627557275582755927560275612756227563275642756527566275672756827569275702757127572275732757427575275762757727578275792758027581275822758327584275852758627587275882758927590275912759227593275942759527596275972759827599276002760127602276032760427605276062760727608276092761027611276122761327614276152761627617276182761927620276212762227623276242762527626276272762827629276302763127632276332763427635276362763727638276392764027641276422764327644276452764627647276482764927650276512765227653276542765527656276572765827659276602766127662276632766427665276662766727668276692767027671276722767327674276752767627677276782767927680276812768227683276842768527686276872768827689276902769127692276932769427695276962769727698276992770027701277022770327704277052770627707277082770927710277112771227713277142771527716277172771827719277202772127722277232772427725277262772727728277292773027731277322773327734277352773627737277382773927740277412774227743277442774527746277472774827749277502775127752277532775427755277562775727758277592776027761277622776327764277652776627767277682776927770277712777227773277742777527776277772777827779277802778127782277832778427785277862778727788277892779027791277922779327794277952779627797277982779927800278012780227803278042780527806278072780827809278102781127812278132781427815278162781727818278192782027821278222782327824278252782627827278282782927830278312783227833278342783527836278372783827839278402784127842278432784427845278462784727848278492785027851278522785327854278552785627857278582785927860278612786227863278642786527866278672786827869278702787127872278732787427875278762787727878278792788027881278822788327884278852788627887278882788927890278912789227893278942789527896278972789827899279002790127902279032790427905279062790727908279092791027911279122791327914279152791627917279182791927920279212792227923279242792527926279272792827929279302793127932279332793427935279362793727938279392794027941279422794327944279452794627947279482794927950279512795227953279542795527956279572795827959279602796127962279632796427965279662796727968279692797027971279722797327974279752797627977279782797927980279812798227983279842798527986279872798827989279902799127992279932799427995279962799727998279992800028001280022800328004280052800628007280082800928010280112801228013280142801528016280172801828019280202802128022280232802428025280262802728028280292803028031280322803328034280352803628037280382803928040280412804228043280442804528046280472804828049280502805128052280532805428055280562805728058280592806028061280622806328064280652806628067280682806928070280712807228073280742807528076280772807828079280802808128082280832808428085280862808728088280892809028091280922809328094280952809628097280982809928100281012810228103281042810528106281072810828109281102811128112281132811428115281162811728118281192812028121281222812328124281252812628127281282812928130281312813228133281342813528136281372813828139281402814128142281432814428145281462814728148281492815028151281522815328154281552815628157281582815928160281612816228163281642816528166281672816828169281702817128172281732817428175281762817728178281792818028181281822818328184281852818628187281882818928190281912819228193281942819528196281972819828199282002820128202282032820428205282062820728208282092821028211282122821328214282152821628217282182821928220282212822228223282242822528226282272822828229282302823128232282332823428235282362823728238282392824028241282422824328244282452824628247282482824928250282512825228253282542825528256282572825828259282602826128262282632826428265282662826728268282692827028271282722827328274282752827628277282782827928280282812828228283282842828528286282872828828289282902829128292282932829428295282962829728298282992830028301283022830328304283052830628307283082830928310283112831228313283142831528316283172831828319283202832128322283232832428325283262832728328283292833028331283322833328334283352833628337283382833928340283412834228343283442834528346283472834828349283502835128352283532835428355283562835728358283592836028361283622836328364283652836628367283682836928370283712837228373283742837528376283772837828379283802838128382283832838428385283862838728388283892839028391283922839328394283952839628397283982839928400284012840228403284042840528406284072840828409284102841128412284132841428415284162841728418284192842028421284222842328424284252842628427284282842928430284312843228433284342843528436284372843828439284402844128442284432844428445284462844728448284492845028451284522845328454284552845628457284582845928460284612846228463284642846528466284672846828469284702847128472284732847428475284762847728478284792848028481284822848328484284852848628487284882848928490284912849228493284942849528496284972849828499285002850128502285032850428505285062850728508285092851028511285122851328514285152851628517285182851928520285212852228523285242852528526285272852828529285302853128532285332853428535285362853728538285392854028541285422854328544285452854628547285482854928550285512855228553285542855528556285572855828559285602856128562285632856428565285662856728568285692857028571285722857328574285752857628577285782857928580285812858228583285842858528586285872858828589285902859128592285932859428595285962859728598285992860028601286022860328604286052860628607286082860928610286112861228613286142861528616286172861828619286202862128622286232862428625286262862728628286292863028631286322863328634286352863628637286382863928640286412864228643286442864528646286472864828649286502865128652286532865428655286562865728658286592866028661286622866328664286652866628667286682866928670286712867228673286742867528676286772867828679286802868128682286832868428685286862868728688286892869028691286922869328694286952869628697286982869928700287012870228703287042870528706287072870828709287102871128712287132871428715287162871728718287192872028721287222872328724287252872628727287282872928730287312873228733287342873528736287372873828739287402874128742287432874428745287462874728748287492875028751287522875328754287552875628757287582875928760287612876228763287642876528766287672876828769287702877128772287732877428775287762877728778287792878028781287822878328784287852878628787287882878928790287912879228793287942879528796287972879828799288002880128802288032880428805288062880728808288092881028811288122881328814288152881628817288182881928820288212882228823288242882528826288272882828829288302883128832288332883428835288362883728838288392884028841288422884328844288452884628847288482884928850288512885228853288542885528856288572885828859288602886128862288632886428865288662886728868288692887028871288722887328874288752887628877288782887928880288812888228883288842888528886288872888828889288902889128892288932889428895288962889728898288992890028901289022890328904289052890628907289082890928910289112891228913289142891528916289172891828919289202892128922289232892428925289262892728928289292893028931289322893328934289352893628937289382893928940289412894228943289442894528946289472894828949289502895128952289532895428955289562895728958289592896028961289622896328964289652896628967289682896928970289712897228973289742897528976289772897828979289802898128982289832898428985289862898728988289892899028991289922899328994289952899628997289982899929000290012900229003290042900529006290072900829009290102901129012290132901429015290162901729018290192902029021290222902329024290252902629027290282902929030290312903229033290342903529036290372903829039290402904129042290432904429045290462904729048290492905029051290522905329054290552905629057290582905929060290612906229063290642906529066290672906829069290702907129072290732907429075290762907729078290792908029081290822908329084290852908629087290882908929090290912909229093290942909529096290972909829099291002910129102291032910429105291062910729108291092911029111291122911329114291152911629117291182911929120291212912229123291242912529126291272912829129291302913129132291332913429135291362913729138291392914029141291422914329144291452914629147291482914929150291512915229153291542915529156291572915829159291602916129162291632916429165291662916729168291692917029171291722917329174291752917629177291782917929180291812918229183291842918529186291872918829189291902919129192291932919429195291962919729198291992920029201292022920329204292052920629207292082920929210292112921229213292142921529216292172921829219292202922129222292232922429225292262922729228292292923029231292322923329234292352923629237292382923929240292412924229243292442924529246292472924829249292502925129252292532925429255292562925729258292592926029261292622926329264292652926629267292682926929270292712927229273292742927529276292772927829279292802928129282292832928429285292862928729288292892929029291292922929329294292952929629297292982929929300293012930229303293042930529306293072930829309293102931129312293132931429315293162931729318293192932029321293222932329324293252932629327293282932929330293312933229333293342933529336293372933829339293402934129342293432934429345293462934729348293492935029351293522935329354293552935629357293582935929360293612936229363293642936529366293672936829369293702937129372293732937429375293762937729378293792938029381293822938329384293852938629387293882938929390293912939229393293942939529396293972939829399294002940129402294032940429405294062940729408294092941029411294122941329414294152941629417294182941929420294212942229423294242942529426294272942829429294302943129432294332943429435294362943729438294392944029441294422944329444294452944629447294482944929450294512945229453294542945529456294572945829459294602946129462294632946429465294662946729468294692947029471294722947329474294752947629477294782947929480294812948229483294842948529486294872948829489294902949129492294932949429495294962949729498294992950029501295022950329504295052950629507295082950929510295112951229513295142951529516295172951829519295202952129522295232952429525295262952729528295292953029531295322953329534295352953629537295382953929540295412954229543295442954529546295472954829549295502955129552295532955429555295562955729558295592956029561295622956329564295652956629567295682956929570295712957229573295742957529576295772957829579295802958129582295832958429585295862958729588295892959029591295922959329594295952959629597295982959929600296012960229603296042960529606296072960829609296102961129612296132961429615296162961729618296192962029621296222962329624296252962629627296282962929630296312963229633296342963529636296372963829639296402964129642296432964429645296462964729648296492965029651296522965329654296552965629657296582965929660296612966229663296642966529666296672966829669296702967129672296732967429675296762967729678296792968029681296822968329684296852968629687296882968929690296912969229693296942969529696296972969829699297002970129702297032970429705297062970729708297092971029711297122971329714297152971629717297182971929720297212972229723297242972529726297272972829729297302973129732297332973429735297362973729738297392974029741297422974329744297452974629747297482974929750297512975229753297542975529756297572975829759297602976129762297632976429765297662976729768297692977029771297722977329774297752977629777297782977929780297812978229783297842978529786297872978829789297902979129792297932979429795297962979729798297992980029801298022980329804298052980629807298082980929810298112981229813298142981529816298172981829819298202982129822298232982429825298262982729828298292983029831298322983329834298352983629837298382983929840298412984229843298442984529846298472984829849298502985129852298532985429855298562985729858298592986029861298622986329864298652986629867298682986929870298712987229873298742987529876298772987829879298802988129882298832988429885298862988729888298892989029891298922989329894298952989629897298982989929900299012990229903299042990529906299072990829909299102991129912299132991429915299162991729918299192992029921299222992329924299252992629927299282992929930299312993229933299342993529936299372993829939299402994129942299432994429945299462994729948299492995029951299522995329954299552995629957299582995929960299612996229963299642996529966299672996829969299702997129972299732997429975299762997729978299792998029981299822998329984299852998629987299882998929990299912999229993299942999529996299972999829999300003000130002300033000430005300063000730008300093001030011300123001330014300153001630017300183001930020300213002230023300243002530026300273002830029300303003130032300333003430035300363003730038300393004030041300423004330044300453004630047300483004930050300513005230053300543005530056300573005830059300603006130062300633006430065300663006730068300693007030071300723007330074300753007630077300783007930080300813008230083300843008530086300873008830089300903009130092300933009430095300963009730098300993010030101301023010330104301053010630107301083010930110301113011230113301143011530116301173011830119301203012130122301233012430125301263012730128301293013030131301323013330134301353013630137301383013930140301413014230143301443014530146301473014830149301503015130152301533015430155301563015730158301593016030161301623016330164301653016630167301683016930170301713017230173301743017530176301773017830179301803018130182301833018430185301863018730188301893019030191301923019330194301953019630197301983019930200302013020230203302043020530206302073020830209302103021130212302133021430215302163021730218302193022030221302223022330224302253022630227302283022930230302313023230233302343023530236302373023830239302403024130242302433024430245302463024730248302493025030251302523025330254302553025630257302583025930260302613026230263302643026530266302673026830269302703027130272302733027430275302763027730278302793028030281302823028330284302853028630287302883028930290302913029230293302943029530296302973029830299303003030130302303033030430305303063030730308303093031030311303123031330314303153031630317303183031930320303213032230323303243032530326303273032830329303303033130332303333033430335303363033730338303393034030341303423034330344303453034630347303483034930350303513035230353303543035530356303573035830359303603036130362303633036430365303663036730368303693037030371303723037330374303753037630377303783037930380303813038230383303843038530386303873038830389303903039130392303933039430395303963039730398303993040030401304023040330404304053040630407304083040930410304113041230413304143041530416304173041830419304203042130422304233042430425304263042730428304293043030431304323043330434304353043630437304383043930440304413044230443304443044530446304473044830449304503045130452304533045430455304563045730458304593046030461304623046330464304653046630467304683046930470304713047230473304743047530476304773047830479304803048130482304833048430485304863048730488304893049030491304923049330494304953049630497304983049930500305013050230503305043050530506305073050830509305103051130512305133051430515305163051730518305193052030521305223052330524305253052630527305283052930530305313053230533305343053530536305373053830539305403054130542305433054430545305463054730548305493055030551305523055330554305553055630557305583055930560305613056230563305643056530566305673056830569305703057130572305733057430575305763057730578305793058030581305823058330584305853058630587305883058930590305913059230593305943059530596305973059830599306003060130602306033060430605306063060730608306093061030611306123061330614306153061630617306183061930620306213062230623306243062530626306273062830629306303063130632306333063430635306363063730638306393064030641306423064330644306453064630647306483064930650306513065230653306543065530656306573065830659306603066130662306633066430665306663066730668306693067030671306723067330674306753067630677306783067930680306813068230683306843068530686306873068830689306903069130692306933069430695306963069730698306993070030701307023070330704307053070630707307083070930710307113071230713307143071530716307173071830719307203072130722307233072430725307263072730728307293073030731307323073330734307353073630737307383073930740307413074230743307443074530746307473074830749307503075130752307533075430755307563075730758307593076030761307623076330764307653076630767307683076930770307713077230773307743077530776307773077830779307803078130782307833078430785307863078730788307893079030791307923079330794307953079630797307983079930800308013080230803308043080530806308073080830809308103081130812308133081430815308163081730818308193082030821308223082330824308253082630827308283082930830308313083230833308343083530836308373083830839308403084130842308433084430845308463084730848308493085030851308523085330854308553085630857308583085930860308613086230863308643086530866308673086830869308703087130872308733087430875308763087730878308793088030881308823088330884308853088630887308883088930890308913089230893308943089530896308973089830899309003090130902309033090430905309063090730908309093091030911309123091330914309153091630917309183091930920309213092230923309243092530926309273092830929309303093130932309333093430935309363093730938309393094030941309423094330944309453094630947309483094930950309513095230953309543095530956309573095830959309603096130962309633096430965309663096730968309693097030971309723097330974309753097630977309783097930980309813098230983309843098530986309873098830989309903099130992309933099430995309963099730998309993100031001310023100331004310053100631007310083100931010310113101231013310143101531016310173101831019310203102131022310233102431025310263102731028310293103031031310323103331034310353103631037310383103931040310413104231043310443104531046310473104831049310503105131052310533105431055310563105731058310593106031061310623106331064310653106631067310683106931070310713107231073310743107531076310773107831079310803108131082310833108431085310863108731088310893109031091310923109331094310953109631097310983109931100311013110231103311043110531106311073110831109311103111131112311133111431115311163111731118311193112031121311223112331124311253112631127311283112931130311313113231133311343113531136311373113831139311403114131142311433114431145311463114731148311493115031151311523115331154311553115631157311583115931160311613116231163311643116531166311673116831169311703117131172311733117431175311763117731178311793118031181311823118331184311853118631187311883118931190311913119231193311943119531196311973119831199312003120131202312033120431205312063120731208312093121031211312123121331214312153121631217312183121931220312213122231223312243122531226312273122831229312303123131232312333123431235312363123731238312393124031241312423124331244312453124631247312483124931250312513125231253312543125531256312573125831259312603126131262312633126431265312663126731268312693127031271312723127331274312753127631277312783127931280312813128231283312843128531286312873128831289312903129131292312933129431295312963129731298312993130031301313023130331304313053130631307313083130931310313113131231313313143131531316313173131831319313203132131322313233132431325313263132731328313293133031331313323133331334313353133631337313383133931340313413134231343313443134531346313473134831349313503135131352313533135431355313563135731358313593136031361313623136331364313653136631367313683136931370313713137231373313743137531376313773137831379313803138131382313833138431385313863138731388313893139031391313923139331394313953139631397313983139931400314013140231403314043140531406314073140831409314103141131412314133141431415314163141731418314193142031421314223142331424314253142631427314283142931430314313143231433314343143531436314373143831439314403144131442314433144431445314463144731448314493145031451314523145331454314553145631457314583145931460314613146231463314643146531466314673146831469314703147131472314733147431475314763147731478314793148031481314823148331484314853148631487314883148931490314913149231493314943149531496314973149831499315003150131502315033150431505315063150731508315093151031511315123151331514315153151631517315183151931520315213152231523315243152531526315273152831529315303153131532315333153431535315363153731538315393154031541315423154331544315453154631547315483154931550315513155231553315543155531556315573155831559315603156131562315633156431565315663156731568315693157031571315723157331574315753157631577315783157931580315813158231583315843158531586315873158831589315903159131592315933159431595315963159731598315993160031601316023160331604316053160631607316083160931610316113161231613316143161531616316173161831619316203162131622316233162431625316263162731628316293163031631316323163331634316353163631637316383163931640316413164231643316443164531646316473164831649316503165131652316533165431655316563165731658316593166031661316623166331664316653166631667316683166931670316713167231673316743167531676316773167831679316803168131682316833168431685316863168731688316893169031691316923169331694316953169631697316983169931700317013170231703317043170531706317073170831709317103171131712317133171431715317163171731718317193172031721317223172331724317253172631727317283172931730317313173231733317343173531736317373173831739317403174131742317433174431745317463174731748317493175031751317523175331754317553175631757317583175931760317613176231763317643176531766317673176831769317703177131772317733177431775317763177731778317793178031781317823178331784317853178631787317883178931790317913179231793317943179531796317973179831799318003180131802318033180431805318063180731808318093181031811318123181331814318153181631817318183181931820318213182231823318243182531826318273182831829318303183131832318333183431835318363183731838318393184031841318423184331844318453184631847318483184931850318513185231853318543185531856318573185831859318603186131862318633186431865318663186731868318693187031871318723187331874318753187631877318783187931880318813188231883318843188531886318873188831889318903189131892318933189431895318963189731898318993190031901319023190331904319053190631907319083190931910319113191231913319143191531916319173191831919319203192131922319233192431925319263192731928319293193031931319323193331934319353193631937319383193931940319413194231943319443194531946319473194831949319503195131952319533195431955319563195731958319593196031961319623196331964319653196631967319683196931970319713197231973319743197531976319773197831979319803198131982319833198431985319863198731988319893199031991319923199331994319953199631997319983199932000320013200232003320043200532006320073200832009320103201132012320133201432015320163201732018320193202032021320223202332024320253202632027320283202932030320313203232033320343203532036320373203832039320403204132042320433204432045320463204732048320493205032051320523205332054320553205632057320583205932060320613206232063320643206532066320673206832069320703207132072320733207432075320763207732078320793208032081320823208332084320853208632087320883208932090320913209232093320943209532096320973209832099321003210132102321033210432105321063210732108321093211032111321123211332114321153211632117321183211932120321213212232123321243212532126321273212832129321303213132132321333213432135321363213732138321393214032141321423214332144321453214632147321483214932150321513215232153321543215532156321573215832159321603216132162321633216432165321663216732168321693217032171321723217332174321753217632177321783217932180321813218232183321843218532186321873218832189321903219132192321933219432195321963219732198321993220032201322023220332204322053220632207322083220932210322113221232213322143221532216322173221832219322203222132222322233222432225322263222732228322293223032231322323223332234322353223632237322383223932240322413224232243322443224532246322473224832249322503225132252322533225432255322563225732258322593226032261322623226332264322653226632267322683226932270322713227232273322743227532276322773227832279322803228132282322833228432285322863228732288322893229032291322923229332294322953229632297322983229932300323013230232303323043230532306323073230832309323103231132312323133231432315323163231732318323193232032321323223232332324323253232632327323283232932330323313233232333323343233532336323373233832339323403234132342323433234432345323463234732348323493235032351323523235332354323553235632357323583235932360323613236232363323643236532366323673236832369323703237132372323733237432375323763237732378323793238032381323823238332384323853238632387323883238932390323913239232393323943239532396323973239832399324003240132402324033240432405324063240732408324093241032411324123241332414324153241632417324183241932420324213242232423324243242532426324273242832429324303243132432324333243432435324363243732438324393244032441324423244332444324453244632447324483244932450324513245232453324543245532456324573245832459324603246132462324633246432465324663246732468324693247032471324723247332474324753247632477324783247932480324813248232483324843248532486324873248832489324903249132492324933249432495324963249732498324993250032501325023250332504325053250632507325083250932510325113251232513325143251532516325173251832519325203252132522325233252432525325263252732528325293253032531325323253332534325353253632537325383253932540325413254232543325443254532546325473254832549325503255132552325533255432555325563255732558325593256032561325623256332564325653256632567325683256932570325713257232573325743257532576325773257832579325803258132582325833258432585325863258732588325893259032591325923259332594325953259632597325983259932600326013260232603326043260532606326073260832609326103261132612326133261432615326163261732618326193262032621326223262332624326253262632627326283262932630326313263232633326343263532636326373263832639326403264132642326433264432645326463264732648326493265032651326523265332654326553265632657326583265932660326613266232663326643266532666326673266832669326703267132672326733267432675326763267732678326793268032681326823268332684326853268632687326883268932690326913269232693326943269532696326973269832699327003270132702327033270432705327063270732708327093271032711327123271332714327153271632717327183271932720327213272232723327243272532726327273272832729327303273132732327333273432735327363273732738327393274032741327423274332744327453274632747327483274932750327513275232753327543275532756327573275832759327603276132762327633276432765327663276732768327693277032771327723277332774327753277632777327783277932780327813278232783327843278532786327873278832789327903279132792327933279432795327963279732798327993280032801328023280332804328053280632807328083280932810328113281232813328143281532816328173281832819328203282132822328233282432825328263282732828328293283032831328323283332834328353283632837328383283932840328413284232843328443284532846328473284832849328503285132852328533285432855328563285732858328593286032861328623286332864328653286632867328683286932870328713287232873328743287532876328773287832879328803288132882328833288432885328863288732888328893289032891328923289332894328953289632897328983289932900329013290232903329043290532906329073290832909329103291132912329133291432915329163291732918329193292032921329223292332924329253292632927329283292932930329313293232933329343293532936329373293832939329403294132942329433294432945329463294732948329493295032951329523295332954329553295632957329583295932960329613296232963329643296532966329673296832969329703297132972329733297432975329763297732978329793298032981329823298332984329853298632987329883298932990329913299232993329943299532996329973299832999330003300133002330033300433005330063300733008330093301033011330123301333014330153301633017330183301933020330213302233023330243302533026330273302833029330303303133032330333303433035330363303733038330393304033041330423304333044330453304633047330483304933050330513305233053330543305533056330573305833059330603306133062330633306433065330663306733068330693307033071330723307333074330753307633077330783307933080330813308233083330843308533086330873308833089330903309133092330933309433095330963309733098330993310033101331023310333104331053310633107331083310933110331113311233113331143311533116331173311833119331203312133122331233312433125331263312733128331293313033131331323313333134331353313633137331383313933140331413314233143331443314533146331473314833149331503315133152331533315433155331563315733158331593316033161331623316333164331653316633167331683316933170331713317233173331743317533176331773317833179331803318133182331833318433185331863318733188331893319033191331923319333194331953319633197331983319933200332013320233203332043320533206332073320833209332103321133212332133321433215332163321733218332193322033221332223322333224332253322633227332283322933230332313323233233332343323533236332373323833239332403324133242332433324433245332463324733248332493325033251332523325333254332553325633257332583325933260332613326233263332643326533266332673326833269332703327133272332733327433275332763327733278332793328033281332823328333284332853328633287332883328933290332913329233293332943329533296332973329833299333003330133302333033330433305333063330733308333093331033311333123331333314333153331633317333183331933320333213332233323333243332533326333273332833329333303333133332333333333433335333363333733338333393334033341333423334333344333453334633347333483334933350333513335233353333543335533356333573335833359333603336133362333633336433365333663336733368333693337033371333723337333374333753337633377333783337933380333813338233383333843338533386333873338833389333903339133392333933339433395333963339733398333993340033401334023340333404334053340633407334083340933410334113341233413334143341533416334173341833419334203342133422334233342433425334263342733428334293343033431334323343333434334353343633437334383343933440334413344233443334443344533446334473344833449334503345133452334533345433455334563345733458334593346033461334623346333464334653346633467334683346933470334713347233473334743347533476334773347833479334803348133482334833348433485334863348733488334893349033491334923349333494334953349633497334983349933500335013350233503335043350533506335073350833509335103351133512335133351433515335163351733518335193352033521335223352333524335253352633527335283352933530335313353233533335343353533536335373353833539335403354133542335433354433545335463354733548335493355033551335523355333554335553355633557335583355933560335613356233563335643356533566335673356833569335703357133572335733357433575335763357733578335793358033581335823358333584335853358633587335883358933590335913359233593335943359533596335973359833599336003360133602336033360433605336063360733608336093361033611336123361333614336153361633617336183361933620336213362233623336243362533626336273362833629336303363133632336333363433635336363363733638336393364033641336423364333644336453364633647336483364933650336513365233653336543365533656336573365833659336603366133662336633366433665336663366733668336693367033671336723367333674336753367633677336783367933680336813368233683336843368533686336873368833689336903369133692336933369433695336963369733698336993370033701337023370333704337053370633707337083370933710337113371233713337143371533716337173371833719337203372133722337233372433725337263372733728337293373033731337323373333734337353373633737337383373933740337413374233743337443374533746337473374833749337503375133752337533375433755337563375733758337593376033761337623376333764337653376633767337683376933770337713377233773337743377533776337773377833779337803378133782337833378433785337863378733788337893379033791337923379333794337953379633797337983379933800338013380233803338043380533806338073380833809338103381133812338133381433815338163381733818338193382033821338223382333824338253382633827338283382933830338313383233833338343383533836338373383833839338403384133842338433384433845338463384733848338493385033851338523385333854338553385633857338583385933860338613386233863338643386533866338673386833869338703387133872338733387433875338763387733878338793388033881338823388333884338853388633887338883388933890338913389233893338943389533896338973389833899339003390133902339033390433905339063390733908339093391033911339123391333914339153391633917339183391933920339213392233923339243392533926339273392833929339303393133932339333393433935339363393733938339393394033941339423394333944339453394633947339483394933950339513395233953339543395533956339573395833959339603396133962339633396433965339663396733968339693397033971339723397333974339753397633977339783397933980339813398233983339843398533986339873398833989339903399133992339933399433995339963399733998339993400034001340023400334004340053400634007340083400934010340113401234013340143401534016340173401834019340203402134022340233402434025340263402734028340293403034031340323403334034340353403634037340383403934040340413404234043340443404534046340473404834049340503405134052340533405434055340563405734058340593406034061340623406334064340653406634067340683406934070340713407234073340743407534076340773407834079340803408134082340833408434085340863408734088340893409034091340923409334094340953409634097340983409934100341013410234103341043410534106341073410834109341103411134112341133411434115341163411734118341193412034121341223412334124341253412634127341283412934130341313413234133341343413534136341373413834139341403414134142341433414434145341463414734148341493415034151341523415334154341553415634157341583415934160341613416234163341643416534166341673416834169341703417134172341733417434175341763417734178341793418034181341823418334184341853418634187341883418934190341913419234193341943419534196341973419834199342003420134202342033420434205342063420734208342093421034211342123421334214342153421634217342183421934220342213422234223342243422534226342273422834229342303423134232342333423434235342363423734238342393424034241342423424334244342453424634247342483424934250342513425234253342543425534256342573425834259342603426134262342633426434265342663426734268342693427034271342723427334274342753427634277342783427934280342813428234283342843428534286342873428834289342903429134292342933429434295342963429734298342993430034301343023430334304343053430634307343083430934310343113431234313343143431534316343173431834319343203432134322343233432434325343263432734328343293433034331343323433334334343353433634337343383433934340343413434234343343443434534346343473434834349343503435134352343533435434355343563435734358343593436034361343623436334364343653436634367343683436934370343713437234373343743437534376343773437834379343803438134382343833438434385343863438734388343893439034391343923439334394343953439634397343983439934400344013440234403344043440534406344073440834409344103441134412344133441434415344163441734418344193442034421344223442334424344253442634427344283442934430344313443234433344343443534436344373443834439344403444134442344433444434445344463444734448344493445034451344523445334454344553445634457344583445934460344613446234463344643446534466344673446834469344703447134472344733447434475344763447734478344793448034481344823448334484344853448634487344883448934490344913449234493344943449534496344973449834499345003450134502345033450434505345063450734508345093451034511345123451334514345153451634517345183451934520345213452234523345243452534526345273452834529345303453134532345333453434535345363453734538345393454034541345423454334544345453454634547345483454934550345513455234553345543455534556345573455834559345603456134562345633456434565345663456734568345693457034571345723457334574345753457634577345783457934580345813458234583345843458534586345873458834589345903459134592345933459434595345963459734598345993460034601346023460334604346053460634607346083460934610346113461234613346143461534616346173461834619346203462134622346233462434625346263462734628346293463034631346323463334634346353463634637346383463934640346413464234643346443464534646346473464834649346503465134652346533465434655346563465734658346593466034661346623466334664346653466634667346683466934670346713467234673346743467534676346773467834679346803468134682346833468434685346863468734688346893469034691346923469334694346953469634697346983469934700347013470234703347043470534706347073470834709347103471134712347133471434715347163471734718347193472034721347223472334724347253472634727347283472934730347313473234733347343473534736347373473834739347403474134742347433474434745347463474734748347493475034751347523475334754347553475634757347583475934760347613476234763347643476534766347673476834769347703477134772347733477434775347763477734778347793478034781347823478334784347853478634787347883478934790347913479234793347943479534796347973479834799348003480134802348033480434805348063480734808348093481034811348123481334814348153481634817348183481934820348213482234823348243482534826348273482834829348303483134832348333483434835348363483734838348393484034841348423484334844348453484634847348483484934850348513485234853348543485534856348573485834859348603486134862348633486434865348663486734868348693487034871348723487334874348753487634877348783487934880348813488234883348843488534886348873488834889348903489134892348933489434895348963489734898348993490034901349023490334904349053490634907349083490934910349113491234913349143491534916349173491834919349203492134922349233492434925349263492734928349293493034931349323493334934349353493634937349383493934940349413494234943349443494534946349473494834949349503495134952349533495434955349563495734958349593496034961349623496334964349653496634967349683496934970349713497234973349743497534976349773497834979349803498134982349833498434985349863498734988349893499034991349923499334994349953499634997349983499935000350013500235003350043500535006350073500835009350103501135012350133501435015350163501735018350193502035021350223502335024350253502635027350283502935030350313503235033350343503535036350373503835039350403504135042350433504435045350463504735048350493505035051350523505335054350553505635057350583505935060350613506235063350643506535066350673506835069350703507135072350733507435075350763507735078350793508035081350823508335084350853508635087350883508935090350913509235093350943509535096350973509835099351003510135102351033510435105351063510735108351093511035111351123511335114351153511635117351183511935120351213512235123351243512535126351273512835129351303513135132351333513435135351363513735138351393514035141351423514335144351453514635147351483514935150351513515235153351543515535156351573515835159351603516135162351633516435165351663516735168351693517035171351723517335174351753517635177351783517935180351813518235183351843518535186351873518835189351903519135192351933519435195351963519735198351993520035201352023520335204352053520635207352083520935210352113521235213352143521535216352173521835219352203522135222352233522435225352263522735228352293523035231352323523335234352353523635237352383523935240352413524235243352443524535246352473524835249352503525135252352533525435255352563525735258352593526035261352623526335264352653526635267352683526935270352713527235273352743527535276352773527835279352803528135282352833528435285352863528735288352893529035291352923529335294352953529635297352983529935300353013530235303353043530535306353073530835309353103531135312353133531435315353163531735318353193532035321353223532335324353253532635327353283532935330353313533235333353343533535336353373533835339353403534135342353433534435345353463534735348353493535035351353523535335354353553535635357353583535935360353613536235363353643536535366353673536835369353703537135372353733537435375353763537735378353793538035381353823538335384353853538635387353883538935390353913539235393353943539535396353973539835399354003540135402354033540435405354063540735408354093541035411354123541335414354153541635417354183541935420354213542235423354243542535426354273542835429354303543135432354333543435435354363543735438354393544035441354423544335444354453544635447354483544935450354513545235453354543545535456354573545835459354603546135462354633546435465354663546735468354693547035471354723547335474354753547635477354783547935480354813548235483354843548535486354873548835489354903549135492354933549435495354963549735498354993550035501355023550335504355053550635507355083550935510355113551235513355143551535516355173551835519355203552135522355233552435525355263552735528355293553035531355323553335534355353553635537355383553935540355413554235543355443554535546355473554835549355503555135552355533555435555355563555735558355593556035561355623556335564355653556635567355683556935570355713557235573355743557535576355773557835579355803558135582355833558435585355863558735588355893559035591355923559335594355953559635597355983559935600356013560235603356043560535606356073560835609356103561135612356133561435615356163561735618356193562035621356223562335624356253562635627356283562935630356313563235633356343563535636356373563835639356403564135642356433564435645356463564735648356493565035651356523565335654356553565635657356583565935660356613566235663356643566535666356673566835669356703567135672356733567435675356763567735678356793568035681356823568335684356853568635687356883568935690356913569235693356943569535696356973569835699357003570135702357033570435705357063570735708357093571035711357123571335714357153571635717357183571935720357213572235723357243572535726357273572835729357303573135732357333573435735357363573735738357393574035741357423574335744357453574635747357483574935750357513575235753357543575535756357573575835759357603576135762357633576435765357663576735768357693577035771357723577335774357753577635777357783577935780357813578235783357843578535786357873578835789357903579135792357933579435795357963579735798357993580035801358023580335804358053580635807358083580935810358113581235813358143581535816358173581835819358203582135822358233582435825358263582735828358293583035831358323583335834358353583635837358383583935840358413584235843358443584535846358473584835849358503585135852358533585435855358563585735858358593586035861358623586335864358653586635867358683586935870358713587235873358743587535876358773587835879358803588135882358833588435885358863588735888358893589035891358923589335894358953589635897358983589935900359013590235903359043590535906359073590835909359103591135912359133591435915359163591735918359193592035921359223592335924359253592635927359283592935930359313593235933359343593535936359373593835939359403594135942359433594435945359463594735948359493595035951359523595335954359553595635957359583595935960359613596235963359643596535966359673596835969359703597135972359733597435975359763597735978359793598035981359823598335984359853598635987359883598935990359913599235993359943599535996359973599835999360003600136002360033600436005360063600736008360093601036011360123601336014360153601636017360183601936020360213602236023360243602536026360273602836029360303603136032360333603436035360363603736038360393604036041360423604336044360453604636047360483604936050360513605236053360543605536056360573605836059360603606136062360633606436065360663606736068360693607036071360723607336074360753607636077360783607936080360813608236083360843608536086360873608836089360903609136092360933609436095360963609736098360993610036101361023610336104361053610636107361083610936110361113611236113361143611536116361173611836119361203612136122361233612436125361263612736128361293613036131361323613336134361353613636137361383613936140361413614236143361443614536146361473614836149361503615136152361533615436155361563615736158361593616036161361623616336164361653616636167361683616936170361713617236173361743617536176361773617836179361803618136182361833618436185361863618736188361893619036191361923619336194361953619636197361983619936200362013620236203362043620536206362073620836209362103621136212362133621436215362163621736218362193622036221362223622336224362253622636227362283622936230362313623236233362343623536236362373623836239362403624136242362433624436245362463624736248362493625036251362523625336254362553625636257362583625936260362613626236263362643626536266362673626836269362703627136272362733627436275362763627736278362793628036281362823628336284362853628636287362883628936290362913629236293362943629536296362973629836299363003630136302363033630436305363063630736308363093631036311363123631336314363153631636317363183631936320363213632236323363243632536326363273632836329363303633136332363333633436335363363633736338363393634036341363423634336344363453634636347363483634936350363513635236353363543635536356363573635836359363603636136362363633636436365363663636736368363693637036371363723637336374363753637636377363783637936380363813638236383363843638536386363873638836389363903639136392363933639436395363963639736398363993640036401364023640336404364053640636407364083640936410364113641236413364143641536416364173641836419364203642136422364233642436425364263642736428364293643036431364323643336434364353643636437364383643936440364413644236443364443644536446364473644836449364503645136452364533645436455364563645736458364593646036461364623646336464364653646636467364683646936470364713647236473364743647536476364773647836479364803648136482364833648436485364863648736488364893649036491364923649336494364953649636497364983649936500365013650236503365043650536506365073650836509365103651136512365133651436515365163651736518365193652036521365223652336524365253652636527365283652936530365313653236533365343653536536365373653836539365403654136542365433654436545365463654736548365493655036551365523655336554365553655636557365583655936560365613656236563365643656536566365673656836569365703657136572365733657436575365763657736578365793658036581365823658336584365853658636587365883658936590365913659236593365943659536596365973659836599366003660136602366033660436605366063660736608366093661036611366123661336614366153661636617366183661936620366213662236623366243662536626366273662836629366303663136632366333663436635366363663736638366393664036641366423664336644366453664636647366483664936650366513665236653366543665536656366573665836659366603666136662366633666436665366663666736668366693667036671366723667336674366753667636677366783667936680366813668236683366843668536686366873668836689366903669136692366933669436695366963669736698366993670036701367023670336704367053670636707367083670936710367113671236713367143671536716367173671836719367203672136722367233672436725367263672736728367293673036731367323673336734367353673636737367383673936740367413674236743367443674536746367473674836749367503675136752367533675436755367563675736758367593676036761367623676336764367653676636767367683676936770367713677236773367743677536776367773677836779367803678136782367833678436785367863678736788367893679036791367923679336794367953679636797367983679936800368013680236803368043680536806368073680836809368103681136812368133681436815368163681736818368193682036821368223682336824368253682636827368283682936830368313683236833368343683536836368373683836839368403684136842368433684436845368463684736848368493685036851368523685336854368553685636857368583685936860368613686236863368643686536866368673686836869368703687136872368733687436875368763687736878368793688036881368823688336884368853688636887368883688936890368913689236893368943689536896368973689836899369003690136902369033690436905369063690736908369093691036911369123691336914369153691636917369183691936920369213692236923369243692536926369273692836929369303693136932369333693436935369363693736938369393694036941369423694336944369453694636947369483694936950369513695236953369543695536956369573695836959369603696136962369633696436965369663696736968369693697036971369723697336974369753697636977369783697936980369813698236983369843698536986369873698836989369903699136992369933699436995369963699736998369993700037001370023700337004370053700637007370083700937010370113701237013370143701537016370173701837019370203702137022370233702437025370263702737028370293703037031370323703337034370353703637037370383703937040370413704237043370443704537046370473704837049370503705137052370533705437055370563705737058370593706037061370623706337064370653706637067370683706937070370713707237073370743707537076370773707837079370803708137082370833708437085370863708737088370893709037091370923709337094370953709637097370983709937100371013710237103371043710537106371073710837109371103711137112371133711437115371163711737118371193712037121371223712337124371253712637127371283712937130371313713237133371343713537136371373713837139371403714137142371433714437145371463714737148371493715037151371523715337154371553715637157371583715937160371613716237163371643716537166371673716837169371703717137172371733717437175371763717737178371793718037181371823718337184371853718637187371883718937190371913719237193371943719537196371973719837199372003720137202372033720437205372063720737208372093721037211372123721337214372153721637217372183721937220372213722237223372243722537226372273722837229372303723137232372333723437235372363723737238372393724037241372423724337244372453724637247372483724937250372513725237253372543725537256372573725837259372603726137262372633726437265372663726737268372693727037271372723727337274372753727637277372783727937280372813728237283372843728537286372873728837289372903729137292372933729437295372963729737298372993730037301373023730337304373053730637307373083730937310373113731237313373143731537316373173731837319373203732137322373233732437325373263732737328373293733037331373323733337334373353733637337373383733937340373413734237343373443734537346373473734837349373503735137352373533735437355373563735737358373593736037361373623736337364373653736637367373683736937370373713737237373373743737537376373773737837379373803738137382373833738437385373863738737388373893739037391373923739337394373953739637397373983739937400374013740237403374043740537406374073740837409374103741137412374133741437415374163741737418374193742037421374223742337424374253742637427374283742937430374313743237433374343743537436374373743837439374403744137442374433744437445374463744737448374493745037451374523745337454374553745637457374583745937460374613746237463374643746537466374673746837469374703747137472374733747437475374763747737478374793748037481374823748337484374853748637487374883748937490374913749237493374943749537496374973749837499375003750137502375033750437505375063750737508375093751037511375123751337514375153751637517375183751937520375213752237523375243752537526375273752837529375303753137532375333753437535375363753737538375393754037541375423754337544375453754637547375483754937550375513755237553375543755537556375573755837559375603756137562375633756437565375663756737568375693757037571375723757337574375753757637577375783757937580375813758237583375843758537586375873758837589375903759137592375933759437595375963759737598375993760037601376023760337604376053760637607376083760937610376113761237613376143761537616376173761837619376203762137622376233762437625376263762737628376293763037631376323763337634376353763637637376383763937640376413764237643376443764537646376473764837649376503765137652376533765437655376563765737658376593766037661376623766337664376653766637667376683766937670376713767237673376743767537676376773767837679376803768137682376833768437685376863768737688376893769037691376923769337694376953769637697376983769937700377013770237703377043770537706377073770837709377103771137712377133771437715377163771737718377193772037721377223772337724377253772637727377283772937730377313773237733377343773537736377373773837739377403774137742377433774437745377463774737748377493775037751377523775337754377553775637757377583775937760377613776237763377643776537766377673776837769377703777137772377733777437775377763777737778377793778037781377823778337784377853778637787377883778937790377913779237793377943779537796377973779837799378003780137802378033780437805378063780737808378093781037811378123781337814378153781637817378183781937820378213782237823378243782537826378273782837829378303783137832378333783437835378363783737838378393784037841378423784337844378453784637847378483784937850378513785237853378543785537856378573785837859378603786137862378633786437865378663786737868378693787037871378723787337874378753787637877378783787937880378813788237883378843788537886378873788837889378903789137892378933789437895378963789737898378993790037901379023790337904379053790637907379083790937910379113791237913379143791537916379173791837919379203792137922379233792437925379263792737928379293793037931379323793337934379353793637937379383793937940379413794237943379443794537946379473794837949379503795137952379533795437955379563795737958379593796037961379623796337964379653796637967379683796937970379713797237973379743797537976379773797837979379803798137982379833798437985379863798737988379893799037991379923799337994379953799637997379983799938000380013800238003380043800538006380073800838009380103801138012380133801438015380163801738018380193802038021380223802338024380253802638027380283802938030380313803238033380343803538036380373803838039380403804138042380433804438045380463804738048380493805038051380523805338054380553805638057380583805938060380613806238063380643806538066380673806838069380703807138072380733807438075380763807738078380793808038081380823808338084380853808638087380883808938090380913809238093380943809538096380973809838099381003810138102381033810438105381063810738108381093811038111381123811338114381153811638117381183811938120381213812238123381243812538126381273812838129381303813138132381333813438135381363813738138381393814038141381423814338144381453814638147381483814938150381513815238153381543815538156381573815838159381603816138162381633816438165381663816738168381693817038171381723817338174381753817638177381783817938180381813818238183381843818538186381873818838189381903819138192381933819438195381963819738198381993820038201382023820338204382053820638207382083820938210382113821238213382143821538216382173821838219382203822138222382233822438225382263822738228382293823038231382323823338234382353823638237382383823938240382413824238243382443824538246382473824838249382503825138252382533825438255382563825738258382593826038261382623826338264382653826638267382683826938270382713827238273382743827538276382773827838279382803828138282382833828438285382863828738288382893829038291382923829338294382953829638297382983829938300383013830238303383043830538306383073830838309383103831138312383133831438315383163831738318383193832038321383223832338324383253832638327383283832938330383313833238333383343833538336383373833838339383403834138342383433834438345383463834738348383493835038351383523835338354383553835638357383583835938360383613836238363383643836538366383673836838369383703837138372383733837438375383763837738378383793838038381383823838338384383853838638387383883838938390383913839238393383943839538396383973839838399384003840138402384033840438405384063840738408384093841038411384123841338414384153841638417384183841938420384213842238423384243842538426384273842838429384303843138432384333843438435384363843738438384393844038441384423844338444384453844638447384483844938450384513845238453384543845538456384573845838459384603846138462384633846438465384663846738468384693847038471384723847338474384753847638477384783847938480384813848238483384843848538486384873848838489384903849138492384933849438495384963849738498384993850038501385023850338504385053850638507385083850938510385113851238513385143851538516385173851838519385203852138522385233852438525385263852738528385293853038531385323853338534385353853638537385383853938540385413854238543385443854538546385473854838549385503855138552385533855438555385563855738558385593856038561385623856338564385653856638567385683856938570385713857238573385743857538576385773857838579385803858138582385833858438585385863858738588385893859038591385923859338594385953859638597385983859938600386013860238603386043860538606386073860838609386103861138612386133861438615386163861738618386193862038621386223862338624386253862638627386283862938630386313863238633386343863538636386373863838639386403864138642386433864438645386463864738648386493865038651386523865338654386553865638657386583865938660386613866238663386643866538666386673866838669386703867138672386733867438675386763867738678386793868038681386823868338684386853868638687386883868938690386913869238693386943869538696386973869838699387003870138702387033870438705387063870738708387093871038711387123871338714387153871638717387183871938720387213872238723387243872538726387273872838729387303873138732387333873438735387363873738738387393874038741387423874338744387453874638747387483874938750387513875238753387543875538756387573875838759387603876138762387633876438765387663876738768387693877038771387723877338774387753877638777387783877938780387813878238783387843878538786387873878838789387903879138792387933879438795387963879738798387993880038801388023880338804388053880638807388083880938810388113881238813388143881538816388173881838819388203882138822388233882438825388263882738828388293883038831388323883338834388353883638837388383883938840388413884238843388443884538846388473884838849388503885138852388533885438855388563885738858388593886038861388623886338864388653886638867388683886938870388713887238873388743887538876388773887838879388803888138882388833888438885388863888738888388893889038891388923889338894388953889638897388983889938900389013890238903389043890538906389073890838909389103891138912389133891438915389163891738918389193892038921389223892338924389253892638927389283892938930389313893238933389343893538936389373893838939389403894138942389433894438945389463894738948389493895038951389523895338954389553895638957389583895938960389613896238963389643896538966389673896838969389703897138972389733897438975389763897738978389793898038981389823898338984389853898638987389883898938990389913899238993389943899538996389973899838999390003900139002390033900439005390063900739008390093901039011390123901339014390153901639017390183901939020390213902239023390243902539026390273902839029390303903139032390333903439035390363903739038390393904039041390423904339044390453904639047390483904939050390513905239053390543905539056390573905839059390603906139062390633906439065390663906739068390693907039071390723907339074390753907639077390783907939080390813908239083390843908539086390873908839089390903909139092390933909439095390963909739098390993910039101391023910339104391053910639107391083910939110391113911239113391143911539116391173911839119391203912139122391233912439125391263912739128391293913039131391323913339134391353913639137391383913939140391413914239143391443914539146391473914839149391503915139152391533915439155391563915739158391593916039161391623916339164391653916639167391683916939170391713917239173391743917539176391773917839179391803918139182391833918439185391863918739188391893919039191391923919339194391953919639197391983919939200392013920239203392043920539206392073920839209392103921139212392133921439215392163921739218392193922039221392223922339224392253922639227392283922939230392313923239233392343923539236392373923839239392403924139242392433924439245392463924739248392493925039251392523925339254392553925639257392583925939260392613926239263392643926539266392673926839269392703927139272392733927439275392763927739278392793928039281392823928339284392853928639287392883928939290392913929239293392943929539296392973929839299393003930139302393033930439305393063930739308393093931039311393123931339314393153931639317393183931939320393213932239323393243932539326393273932839329393303933139332393333933439335393363933739338393393934039341393423934339344393453934639347393483934939350393513935239353393543935539356393573935839359393603936139362393633936439365393663936739368393693937039371393723937339374393753937639377393783937939380393813938239383393843938539386393873938839389393903939139392393933939439395393963939739398393993940039401394023940339404394053940639407394083940939410394113941239413394143941539416394173941839419394203942139422394233942439425394263942739428394293943039431394323943339434394353943639437394383943939440394413944239443394443944539446394473944839449394503945139452394533945439455394563945739458394593946039461394623946339464394653946639467394683946939470394713947239473394743947539476394773947839479394803948139482394833948439485394863948739488394893949039491394923949339494394953949639497394983949939500395013950239503395043950539506395073950839509395103951139512395133951439515395163951739518395193952039521395223952339524395253952639527395283952939530395313953239533395343953539536395373953839539395403954139542395433954439545395463954739548395493955039551395523955339554395553955639557395583955939560395613956239563395643956539566395673956839569395703957139572395733957439575395763957739578395793958039581395823958339584395853958639587395883958939590395913959239593395943959539596395973959839599396003960139602396033960439605396063960739608396093961039611396123961339614396153961639617396183961939620396213962239623396243962539626396273962839629396303963139632396333963439635396363963739638396393964039641396423964339644396453964639647396483964939650396513965239653396543965539656396573965839659396603966139662396633966439665396663966739668396693967039671396723967339674396753967639677396783967939680396813968239683396843968539686396873968839689396903969139692396933969439695396963969739698396993970039701397023970339704397053970639707397083970939710397113971239713397143971539716397173971839719397203972139722397233972439725397263972739728397293973039731397323973339734397353973639737397383973939740397413974239743397443974539746397473974839749397503975139752397533975439755397563975739758397593976039761397623976339764397653976639767397683976939770397713977239773397743977539776397773977839779397803978139782397833978439785397863978739788397893979039791397923979339794397953979639797397983979939800398013980239803398043980539806398073980839809398103981139812398133981439815398163981739818398193982039821398223982339824398253982639827398283982939830398313983239833398343983539836398373983839839398403984139842398433984439845398463984739848398493985039851398523985339854398553985639857398583985939860398613986239863398643986539866398673986839869398703987139872398733987439875398763987739878398793988039881398823988339884398853988639887398883988939890398913989239893398943989539896398973989839899399003990139902399033990439905399063990739908399093991039911399123991339914399153991639917399183991939920399213992239923399243992539926399273992839929399303993139932399333993439935399363993739938399393994039941399423994339944399453994639947399483994939950399513995239953399543995539956399573995839959399603996139962399633996439965399663996739968399693997039971399723997339974399753997639977399783997939980399813998239983399843998539986399873998839989399903999139992399933999439995399963999739998399994000040001400024000340004400054000640007400084000940010400114001240013400144001540016400174001840019400204002140022400234002440025400264002740028400294003040031400324003340034400354003640037400384003940040400414004240043400444004540046400474004840049400504005140052400534005440055400564005740058400594006040061400624006340064400654006640067400684006940070400714007240073400744007540076400774007840079400804008140082400834008440085400864008740088400894009040091400924009340094400954009640097400984009940100401014010240103401044010540106401074010840109401104011140112401134011440115401164011740118401194012040121401224012340124401254012640127401284012940130401314013240133401344013540136401374013840139401404014140142401434014440145401464014740148401494015040151401524015340154401554015640157401584015940160401614016240163401644016540166401674016840169401704017140172401734017440175401764017740178401794018040181401824018340184401854018640187401884018940190401914019240193401944019540196401974019840199402004020140202402034020440205402064020740208402094021040211402124021340214402154021640217402184021940220402214022240223402244022540226402274022840229402304023140232402334023440235402364023740238402394024040241402424024340244402454024640247402484024940250402514025240253402544025540256402574025840259402604026140262402634026440265402664026740268402694027040271402724027340274402754027640277402784027940280402814028240283402844028540286402874028840289402904029140292402934029440295402964029740298402994030040301403024030340304403054030640307403084030940310403114031240313403144031540316403174031840319403204032140322403234032440325403264032740328403294033040331403324033340334403354033640337403384033940340403414034240343403444034540346403474034840349403504035140352403534035440355403564035740358403594036040361403624036340364403654036640367403684036940370403714037240373403744037540376403774037840379403804038140382403834038440385403864038740388403894039040391403924039340394403954039640397403984039940400404014040240403404044040540406404074040840409404104041140412404134041440415404164041740418404194042040421404224042340424404254042640427404284042940430404314043240433404344043540436404374043840439404404044140442404434044440445404464044740448404494045040451404524045340454404554045640457404584045940460404614046240463404644046540466404674046840469404704047140472404734047440475404764047740478404794048040481404824048340484404854048640487404884048940490404914049240493404944049540496404974049840499405004050140502405034050440505405064050740508405094051040511405124051340514405154051640517405184051940520405214052240523405244052540526405274052840529405304053140532405334053440535405364053740538405394054040541405424054340544405454054640547405484054940550405514055240553405544055540556405574055840559405604056140562405634056440565405664056740568405694057040571405724057340574405754057640577405784057940580405814058240583405844058540586405874058840589405904059140592405934059440595405964059740598405994060040601406024060340604406054060640607406084060940610406114061240613406144061540616406174061840619406204062140622406234062440625406264062740628406294063040631406324063340634406354063640637406384063940640406414064240643406444064540646406474064840649406504065140652406534065440655406564065740658406594066040661406624066340664406654066640667406684066940670406714067240673406744067540676406774067840679406804068140682406834068440685406864068740688406894069040691406924069340694406954069640697406984069940700407014070240703407044070540706407074070840709407104071140712407134071440715407164071740718407194072040721407224072340724407254072640727407284072940730407314073240733407344073540736407374073840739407404074140742407434074440745407464074740748407494075040751407524075340754407554075640757407584075940760407614076240763407644076540766407674076840769407704077140772407734077440775407764077740778407794078040781407824078340784407854078640787407884078940790407914079240793407944079540796407974079840799408004080140802408034080440805408064080740808408094081040811408124081340814408154081640817408184081940820408214082240823408244082540826408274082840829408304083140832408334083440835408364083740838408394084040841408424084340844408454084640847408484084940850408514085240853408544085540856408574085840859408604086140862408634086440865408664086740868408694087040871408724087340874408754087640877408784087940880408814088240883408844088540886408874088840889408904089140892408934089440895408964089740898408994090040901409024090340904409054090640907409084090940910409114091240913409144091540916409174091840919409204092140922409234092440925409264092740928409294093040931409324093340934409354093640937409384093940940409414094240943409444094540946409474094840949409504095140952409534095440955409564095740958409594096040961409624096340964409654096640967409684096940970409714097240973409744097540976409774097840979409804098140982409834098440985409864098740988409894099040991409924099340994409954099640997409984099941000410014100241003410044100541006410074100841009410104101141012410134101441015410164101741018410194102041021410224102341024410254102641027410284102941030410314103241033410344103541036410374103841039410404104141042410434104441045410464104741048410494105041051410524105341054410554105641057410584105941060410614106241063410644106541066410674106841069410704107141072410734107441075410764107741078410794108041081410824108341084410854108641087410884108941090410914109241093410944109541096410974109841099411004110141102411034110441105411064110741108411094111041111411124111341114411154111641117411184111941120411214112241123411244112541126411274112841129411304113141132411334113441135411364113741138411394114041141411424114341144411454114641147411484114941150411514115241153411544115541156411574115841159411604116141162411634116441165411664116741168411694117041171411724117341174411754117641177411784117941180411814118241183411844118541186411874118841189411904119141192411934119441195411964119741198411994120041201412024120341204412054120641207412084120941210412114121241213412144121541216412174121841219412204122141222412234122441225412264122741228412294123041231412324123341234412354123641237412384123941240412414124241243412444124541246412474124841249412504125141252412534125441255412564125741258412594126041261412624126341264412654126641267412684126941270412714127241273412744127541276412774127841279412804128141282412834128441285412864128741288412894129041291412924129341294412954129641297412984129941300413014130241303413044130541306413074130841309413104131141312413134131441315413164131741318413194132041321413224132341324413254132641327413284132941330413314133241333413344133541336413374133841339413404134141342413434134441345413464134741348413494135041351413524135341354413554135641357413584135941360413614136241363413644136541366413674136841369413704137141372413734137441375413764137741378413794138041381413824138341384413854138641387413884138941390413914139241393413944139541396413974139841399414004140141402414034140441405414064140741408414094141041411414124141341414414154141641417414184141941420414214142241423414244142541426414274142841429414304143141432414334143441435414364143741438414394144041441414424144341444414454144641447414484144941450414514145241453414544145541456414574145841459414604146141462414634146441465414664146741468414694147041471414724147341474414754147641477414784147941480414814148241483414844148541486414874148841489414904149141492414934149441495414964149741498414994150041501415024150341504415054150641507415084150941510415114151241513415144151541516415174151841519415204152141522415234152441525415264152741528415294153041531415324153341534415354153641537415384153941540415414154241543415444154541546415474154841549415504155141552415534155441555415564155741558415594156041561415624156341564415654156641567415684156941570415714157241573415744157541576415774157841579415804158141582415834158441585415864158741588415894159041591415924159341594415954159641597415984159941600416014160241603416044160541606416074160841609416104161141612416134161441615416164161741618416194162041621416224162341624416254162641627416284162941630416314163241633416344163541636416374163841639416404164141642416434164441645416464164741648416494165041651416524165341654416554165641657416584165941660416614166241663416644166541666416674166841669416704167141672416734167441675416764167741678416794168041681416824168341684416854168641687416884168941690416914169241693416944169541696416974169841699417004170141702417034170441705417064170741708417094171041711417124171341714417154171641717417184171941720417214172241723417244172541726417274172841729417304173141732417334173441735417364173741738417394174041741417424174341744417454174641747417484174941750417514175241753417544175541756417574175841759417604176141762417634176441765417664176741768417694177041771417724177341774417754177641777417784177941780417814178241783417844178541786417874178841789417904179141792417934179441795417964179741798417994180041801418024180341804418054180641807418084180941810418114181241813418144181541816418174181841819418204182141822418234182441825418264182741828418294183041831418324183341834418354183641837418384183941840418414184241843418444184541846418474184841849418504185141852418534185441855418564185741858418594186041861418624186341864418654186641867418684186941870418714187241873418744187541876418774187841879418804188141882418834188441885418864188741888418894189041891418924189341894418954189641897418984189941900419014190241903419044190541906419074190841909419104191141912419134191441915419164191741918419194192041921419224192341924419254192641927419284192941930419314193241933419344193541936419374193841939419404194141942419434194441945419464194741948419494195041951419524195341954419554195641957419584195941960419614196241963419644196541966419674196841969419704197141972419734197441975419764197741978419794198041981419824198341984419854198641987419884198941990419914199241993419944199541996419974199841999420004200142002420034200442005420064200742008420094201042011420124201342014420154201642017420184201942020420214202242023420244202542026420274202842029420304203142032420334203442035420364203742038420394204042041420424204342044420454204642047420484204942050420514205242053420544205542056420574205842059420604206142062420634206442065420664206742068420694207042071420724207342074420754207642077420784207942080420814208242083420844208542086420874208842089420904209142092420934209442095420964209742098420994210042101421024210342104421054210642107421084210942110421114211242113421144211542116421174211842119421204212142122421234212442125421264212742128421294213042131421324213342134421354213642137421384213942140421414214242143421444214542146421474214842149421504215142152421534215442155421564215742158421594216042161421624216342164421654216642167421684216942170421714217242173421744217542176421774217842179421804218142182421834218442185421864218742188421894219042191421924219342194421954219642197421984219942200422014220242203422044220542206422074220842209422104221142212422134221442215422164221742218422194222042221422224222342224422254222642227422284222942230422314223242233422344223542236422374223842239422404224142242422434224442245422464224742248422494225042251422524225342254422554225642257422584225942260422614226242263422644226542266422674226842269422704227142272422734227442275422764227742278422794228042281422824228342284422854228642287422884228942290422914229242293422944229542296422974229842299423004230142302423034230442305423064230742308423094231042311423124231342314423154231642317423184231942320423214232242323423244232542326423274232842329423304233142332423334233442335423364233742338423394234042341423424234342344423454234642347423484234942350423514235242353423544235542356423574235842359423604236142362423634236442365423664236742368423694237042371423724237342374423754237642377423784237942380423814238242383423844238542386423874238842389423904239142392423934239442395423964239742398423994240042401424024240342404424054240642407424084240942410424114241242413424144241542416424174241842419424204242142422424234242442425424264242742428424294243042431424324243342434424354243642437424384243942440424414244242443424444244542446424474244842449424504245142452424534245442455424564245742458424594246042461424624246342464424654246642467424684246942470424714247242473424744247542476424774247842479424804248142482424834248442485424864248742488424894249042491424924249342494424954249642497424984249942500425014250242503425044250542506425074250842509425104251142512425134251442515425164251742518425194252042521425224252342524425254252642527425284252942530425314253242533425344253542536425374253842539425404254142542425434254442545425464254742548425494255042551425524255342554425554255642557425584255942560425614256242563425644256542566425674256842569425704257142572425734257442575425764257742578425794258042581425824258342584425854258642587425884258942590425914259242593425944259542596425974259842599426004260142602426034260442605426064260742608426094261042611426124261342614426154261642617426184261942620426214262242623426244262542626426274262842629426304263142632426334263442635426364263742638426394264042641426424264342644426454264642647426484264942650426514265242653426544265542656426574265842659426604266142662426634266442665426664266742668426694267042671426724267342674426754267642677426784267942680426814268242683426844268542686426874268842689426904269142692426934269442695426964269742698426994270042701427024270342704427054270642707427084270942710427114271242713427144271542716427174271842719427204272142722427234272442725427264272742728427294273042731427324273342734427354273642737427384273942740427414274242743427444274542746427474274842749427504275142752427534275442755427564275742758427594276042761427624276342764427654276642767427684276942770427714277242773427744277542776427774277842779427804278142782427834278442785427864278742788427894279042791427924279342794427954279642797427984279942800428014280242803428044280542806428074280842809428104281142812428134281442815428164281742818428194282042821428224282342824428254282642827428284282942830428314283242833428344283542836428374283842839428404284142842428434284442845428464284742848428494285042851428524285342854428554285642857428584285942860428614286242863428644286542866428674286842869428704287142872428734287442875428764287742878428794288042881428824288342884428854288642887428884288942890428914289242893428944289542896428974289842899429004290142902429034290442905429064290742908429094291042911429124291342914429154291642917429184291942920429214292242923429244292542926429274292842929429304293142932429334293442935429364293742938429394294042941429424294342944429454294642947429484294942950429514295242953429544295542956429574295842959429604296142962429634296442965429664296742968429694297042971429724297342974429754297642977429784297942980429814298242983429844298542986429874298842989429904299142992429934299442995429964299742998429994300043001430024300343004430054300643007430084300943010430114301243013430144301543016430174301843019430204302143022430234302443025430264302743028430294303043031430324303343034430354303643037430384303943040430414304243043430444304543046430474304843049430504305143052430534305443055430564305743058430594306043061430624306343064430654306643067430684306943070430714307243073430744307543076430774307843079430804308143082430834308443085430864308743088430894309043091430924309343094430954309643097430984309943100431014310243103431044310543106431074310843109431104311143112431134311443115431164311743118431194312043121431224312343124431254312643127431284312943130431314313243133431344313543136431374313843139431404314143142431434314443145431464314743148431494315043151431524315343154431554315643157431584315943160431614316243163431644316543166431674316843169431704317143172431734317443175431764317743178431794318043181431824318343184431854318643187431884318943190431914319243193431944319543196431974319843199432004320143202432034320443205432064320743208432094321043211432124321343214432154321643217432184321943220432214322243223432244322543226432274322843229432304323143232432334323443235432364323743238432394324043241432424324343244432454324643247432484324943250432514325243253432544325543256432574325843259432604326143262432634326443265432664326743268432694327043271432724327343274432754327643277432784327943280432814328243283432844328543286432874328843289432904329143292432934329443295432964329743298432994330043301433024330343304433054330643307433084330943310433114331243313433144331543316433174331843319433204332143322433234332443325433264332743328433294333043331433324333343334433354333643337433384333943340433414334243343433444334543346433474334843349433504335143352433534335443355433564335743358433594336043361433624336343364433654336643367433684336943370433714337243373433744337543376433774337843379433804338143382433834338443385433864338743388433894339043391433924339343394433954339643397433984339943400434014340243403434044340543406434074340843409434104341143412434134341443415434164341743418434194342043421434224342343424434254342643427434284342943430434314343243433434344343543436434374343843439434404344143442434434344443445434464344743448434494345043451434524345343454434554345643457434584345943460434614346243463434644346543466434674346843469434704347143472434734347443475434764347743478434794348043481434824348343484434854348643487434884348943490434914349243493434944349543496434974349843499435004350143502435034350443505435064350743508435094351043511435124351343514435154351643517435184351943520435214352243523435244352543526435274352843529435304353143532435334353443535435364353743538435394354043541435424354343544435454354643547435484354943550435514355243553435544355543556435574355843559435604356143562435634356443565435664356743568435694357043571435724357343574435754357643577435784357943580435814358243583435844358543586435874358843589435904359143592435934359443595435964359743598435994360043601436024360343604436054360643607436084360943610436114361243613436144361543616436174361843619436204362143622436234362443625436264362743628436294363043631436324363343634436354363643637436384363943640436414364243643436444364543646436474364843649436504365143652436534365443655436564365743658436594366043661436624366343664436654366643667436684366943670436714367243673436744367543676436774367843679436804368143682436834368443685436864368743688436894369043691436924369343694436954369643697436984369943700437014370243703437044370543706437074370843709437104371143712437134371443715437164371743718437194372043721437224372343724437254372643727437284372943730437314373243733437344373543736437374373843739437404374143742437434374443745437464374743748437494375043751437524375343754437554375643757437584375943760437614376243763437644376543766437674376843769437704377143772437734377443775437764377743778437794378043781437824378343784437854378643787437884378943790437914379243793437944379543796437974379843799438004380143802438034380443805438064380743808438094381043811438124381343814438154381643817438184381943820438214382243823438244382543826438274382843829438304383143832438334383443835438364383743838438394384043841438424384343844438454384643847438484384943850438514385243853438544385543856438574385843859438604386143862438634386443865438664386743868438694387043871438724387343874438754387643877438784387943880438814388243883438844388543886438874388843889438904389143892438934389443895438964389743898438994390043901439024390343904439054390643907439084390943910439114391243913439144391543916439174391843919439204392143922439234392443925439264392743928439294393043931439324393343934439354393643937439384393943940439414394243943439444394543946439474394843949439504395143952439534395443955439564395743958439594396043961439624396343964439654396643967439684396943970439714397243973439744397543976439774397843979439804398143982439834398443985439864398743988439894399043991439924399343994439954399643997439984399944000440014400244003440044400544006440074400844009440104401144012440134401444015440164401744018440194402044021440224402344024440254402644027440284402944030440314403244033440344403544036440374403844039440404404144042440434404444045440464404744048440494405044051440524405344054440554405644057440584405944060440614406244063440644406544066440674406844069440704407144072440734407444075440764407744078440794408044081440824408344084440854408644087440884408944090440914409244093440944409544096440974409844099441004410144102441034410444105441064410744108441094411044111441124411344114441154411644117441184411944120441214412244123441244412544126441274412844129441304413144132441334413444135441364413744138441394414044141441424414344144441454414644147441484414944150441514415244153441544415544156441574415844159441604416144162441634416444165441664416744168441694417044171441724417344174441754417644177441784417944180441814418244183441844418544186441874418844189441904419144192441934419444195441964419744198441994420044201442024420344204442054420644207442084420944210442114421244213442144421544216442174421844219442204422144222442234422444225442264422744228442294423044231442324423344234442354423644237442384423944240442414424244243442444424544246442474424844249442504425144252442534425444255442564425744258442594426044261442624426344264442654426644267442684426944270442714427244273442744427544276442774427844279442804428144282442834428444285442864428744288442894429044291442924429344294442954429644297442984429944300443014430244303443044430544306443074430844309443104431144312443134431444315443164431744318443194432044321443224432344324443254432644327443284432944330443314433244333443344433544336443374433844339443404434144342443434434444345443464434744348443494435044351443524435344354443554435644357443584435944360443614436244363443644436544366443674436844369443704437144372443734437444375443764437744378443794438044381443824438344384443854438644387443884438944390443914439244393443944439544396443974439844399444004440144402444034440444405444064440744408444094441044411444124441344414444154441644417444184441944420444214442244423444244442544426444274442844429444304443144432444334443444435444364443744438444394444044441444424444344444444454444644447444484444944450444514445244453444544445544456444574445844459444604446144462444634446444465444664446744468444694447044471444724447344474444754447644477444784447944480444814448244483444844448544486444874448844489444904449144492444934449444495444964449744498444994450044501445024450344504445054450644507445084450944510445114451244513445144451544516445174451844519445204452144522445234452444525445264452744528445294453044531445324453344534445354453644537445384453944540445414454244543445444454544546445474454844549445504455144552445534455444555445564455744558445594456044561445624456344564445654456644567445684456944570445714457244573445744457544576445774457844579445804458144582445834458444585445864458744588445894459044591445924459344594445954459644597445984459944600446014460244603446044460544606446074460844609446104461144612446134461444615446164461744618446194462044621446224462344624446254462644627446284462944630446314463244633446344463544636446374463844639446404464144642446434464444645446464464744648446494465044651446524465344654446554465644657446584465944660446614466244663446644466544666446674466844669446704467144672446734467444675446764467744678446794468044681446824468344684446854468644687446884468944690446914469244693446944469544696446974469844699447004470144702447034470444705447064470744708447094471044711447124471344714447154471644717447184471944720447214472244723447244472544726447274472844729447304473144732447334473444735447364473744738447394474044741447424474344744447454474644747447484474944750447514475244753447544475544756447574475844759447604476144762447634476444765447664476744768447694477044771447724477344774447754477644777447784477944780447814478244783447844478544786447874478844789447904479144792447934479444795447964479744798447994480044801448024480344804448054480644807448084480944810448114481244813448144481544816448174481844819448204482144822448234482444825448264482744828448294483044831448324483344834448354483644837448384483944840448414484244843448444484544846448474484844849448504485144852448534485444855448564485744858448594486044861448624486344864448654486644867448684486944870448714487244873448744487544876448774487844879448804488144882448834488444885448864488744888448894489044891448924489344894448954489644897448984489944900449014490244903449044490544906449074490844909449104491144912449134491444915449164491744918449194492044921449224492344924449254492644927449284492944930449314493244933449344493544936449374493844939449404494144942449434494444945449464494744948449494495044951449524495344954449554495644957449584495944960449614496244963449644496544966449674496844969449704497144972449734497444975449764497744978449794498044981449824498344984449854498644987449884498944990449914499244993449944499544996449974499844999450004500145002450034500445005450064500745008450094501045011450124501345014450154501645017450184501945020450214502245023450244502545026450274502845029450304503145032450334503445035450364503745038450394504045041450424504345044450454504645047450484504945050450514505245053450544505545056450574505845059450604506145062450634506445065450664506745068450694507045071450724507345074450754507645077450784507945080450814508245083450844508545086450874508845089450904509145092450934509445095450964509745098450994510045101451024510345104451054510645107451084510945110451114511245113451144511545116451174511845119451204512145122451234512445125451264512745128451294513045131451324513345134451354513645137451384513945140451414514245143451444514545146451474514845149451504515145152451534515445155451564515745158451594516045161451624516345164451654516645167451684516945170451714517245173451744517545176451774517845179451804518145182451834518445185451864518745188451894519045191451924519345194451954519645197451984519945200452014520245203452044520545206452074520845209452104521145212452134521445215452164521745218452194522045221452224522345224452254522645227452284522945230452314523245233452344523545236452374523845239452404524145242452434524445245452464524745248452494525045251452524525345254452554525645257452584525945260452614526245263452644526545266452674526845269452704527145272452734527445275452764527745278452794528045281452824528345284452854528645287452884528945290452914529245293452944529545296452974529845299453004530145302453034530445305453064530745308453094531045311453124531345314453154531645317453184531945320453214532245323453244532545326453274532845329453304533145332453334533445335453364533745338453394534045341453424534345344453454534645347453484534945350453514535245353453544535545356453574535845359453604536145362453634536445365453664536745368453694537045371453724537345374453754537645377453784537945380453814538245383453844538545386453874538845389453904539145392453934539445395453964539745398453994540045401454024540345404454054540645407454084540945410454114541245413454144541545416454174541845419454204542145422454234542445425454264542745428454294543045431454324543345434454354543645437454384543945440454414544245443454444544545446454474544845449454504545145452454534545445455454564545745458454594546045461454624546345464454654546645467454684546945470454714547245473454744547545476454774547845479454804548145482454834548445485454864548745488454894549045491454924549345494454954549645497454984549945500455014550245503455044550545506455074550845509455104551145512455134551445515455164551745518455194552045521455224552345524455254552645527455284552945530455314553245533455344553545536455374553845539455404554145542455434554445545455464554745548455494555045551455524555345554455554555645557455584555945560455614556245563455644556545566455674556845569455704557145572455734557445575455764557745578455794558045581455824558345584455854558645587455884558945590455914559245593455944559545596455974559845599456004560145602456034560445605456064560745608456094561045611456124561345614456154561645617456184561945620456214562245623456244562545626456274562845629456304563145632456334563445635456364563745638456394564045641456424564345644456454564645647456484564945650456514565245653456544565545656456574565845659456604566145662456634566445665456664566745668456694567045671456724567345674456754567645677456784567945680456814568245683456844568545686456874568845689456904569145692456934569445695456964569745698456994570045701457024570345704457054570645707457084570945710457114571245713457144571545716457174571845719457204572145722457234572445725457264572745728457294573045731457324573345734457354573645737457384573945740457414574245743457444574545746457474574845749457504575145752457534575445755457564575745758457594576045761457624576345764457654576645767457684576945770457714577245773457744577545776457774577845779457804578145782457834578445785457864578745788457894579045791457924579345794457954579645797457984579945800458014580245803458044580545806458074580845809458104581145812458134581445815458164581745818458194582045821458224582345824458254582645827458284582945830458314583245833458344583545836458374583845839458404584145842458434584445845458464584745848458494585045851458524585345854458554585645857458584585945860458614586245863458644586545866458674586845869458704587145872458734587445875458764587745878458794588045881458824588345884458854588645887458884588945890458914589245893458944589545896458974589845899459004590145902459034590445905459064590745908459094591045911459124591345914459154591645917459184591945920459214592245923459244592545926459274592845929459304593145932459334593445935459364593745938459394594045941459424594345944459454594645947459484594945950459514595245953459544595545956459574595845959459604596145962459634596445965459664596745968459694597045971459724597345974459754597645977459784597945980459814598245983459844598545986459874598845989459904599145992459934599445995459964599745998459994600046001460024600346004460054600646007460084600946010460114601246013460144601546016460174601846019460204602146022460234602446025460264602746028460294603046031460324603346034460354603646037460384603946040460414604246043460444604546046460474604846049460504605146052460534605446055460564605746058460594606046061460624606346064460654606646067460684606946070460714607246073460744607546076460774607846079460804608146082460834608446085460864608746088460894609046091460924609346094460954609646097460984609946100461014610246103461044610546106461074610846109461104611146112461134611446115461164611746118461194612046121461224612346124461254612646127461284612946130461314613246133461344613546136461374613846139461404614146142461434614446145461464614746148461494615046151461524615346154461554615646157461584615946160461614616246163461644616546166461674616846169461704617146172461734617446175461764617746178461794618046181461824618346184461854618646187461884618946190461914619246193461944619546196461974619846199462004620146202462034620446205462064620746208462094621046211462124621346214462154621646217462184621946220462214622246223462244622546226462274622846229462304623146232462334623446235462364623746238462394624046241462424624346244462454624646247462484624946250462514625246253462544625546256462574625846259462604626146262462634626446265462664626746268462694627046271462724627346274462754627646277462784627946280462814628246283462844628546286462874628846289462904629146292462934629446295462964629746298462994630046301463024630346304463054630646307463084630946310463114631246313463144631546316463174631846319463204632146322463234632446325463264632746328463294633046331463324633346334463354633646337463384633946340463414634246343463444634546346463474634846349463504635146352463534635446355463564635746358463594636046361463624636346364463654636646367463684636946370463714637246373463744637546376463774637846379463804638146382463834638446385463864638746388463894639046391463924639346394463954639646397463984639946400464014640246403464044640546406464074640846409464104641146412464134641446415464164641746418464194642046421464224642346424464254642646427464284642946430464314643246433464344643546436464374643846439464404644146442464434644446445464464644746448464494645046451464524645346454464554645646457464584645946460464614646246463464644646546466464674646846469464704647146472464734647446475464764647746478464794648046481464824648346484464854648646487464884648946490464914649246493464944649546496464974649846499465004650146502465034650446505465064650746508465094651046511465124651346514465154651646517465184651946520465214652246523465244652546526465274652846529465304653146532465334653446535465364653746538465394654046541465424654346544465454654646547465484654946550465514655246553465544655546556465574655846559465604656146562465634656446565465664656746568465694657046571465724657346574465754657646577465784657946580465814658246583465844658546586465874658846589465904659146592465934659446595465964659746598465994660046601466024660346604466054660646607466084660946610466114661246613466144661546616466174661846619466204662146622466234662446625466264662746628466294663046631466324663346634466354663646637466384663946640466414664246643466444664546646466474664846649466504665146652466534665446655466564665746658466594666046661466624666346664466654666646667466684666946670466714667246673466744667546676466774667846679466804668146682466834668446685466864668746688466894669046691466924669346694466954669646697466984669946700467014670246703467044670546706467074670846709467104671146712467134671446715467164671746718467194672046721467224672346724467254672646727467284672946730467314673246733467344673546736467374673846739467404674146742467434674446745467464674746748467494675046751467524675346754467554675646757467584675946760467614676246763467644676546766467674676846769467704677146772467734677446775467764677746778467794678046781467824678346784467854678646787467884678946790467914679246793467944679546796467974679846799468004680146802468034680446805468064680746808468094681046811468124681346814468154681646817468184681946820468214682246823468244682546826468274682846829468304683146832468334683446835468364683746838468394684046841468424684346844468454684646847468484684946850468514685246853468544685546856468574685846859468604686146862468634686446865468664686746868468694687046871468724687346874468754687646877468784687946880468814688246883468844688546886468874688846889468904689146892468934689446895468964689746898468994690046901469024690346904469054690646907469084690946910469114691246913469144691546916469174691846919469204692146922469234692446925469264692746928469294693046931469324693346934469354693646937469384693946940469414694246943469444694546946469474694846949469504695146952469534695446955469564695746958469594696046961469624696346964469654696646967469684696946970469714697246973469744697546976469774697846979469804698146982469834698446985469864698746988469894699046991469924699346994469954699646997469984699947000470014700247003470044700547006470074700847009470104701147012470134701447015470164701747018470194702047021470224702347024470254702647027470284702947030470314703247033470344703547036470374703847039470404704147042470434704447045470464704747048470494705047051470524705347054470554705647057470584705947060470614706247063470644706547066470674706847069470704707147072470734707447075470764707747078470794708047081470824708347084470854708647087470884708947090470914709247093470944709547096470974709847099471004710147102471034710447105471064710747108471094711047111471124711347114471154711647117471184711947120471214712247123471244712547126471274712847129471304713147132471334713447135471364713747138471394714047141471424714347144471454714647147471484714947150471514715247153471544715547156471574715847159471604716147162471634716447165471664716747168471694717047171471724717347174471754717647177471784717947180471814718247183471844718547186471874718847189471904719147192471934719447195471964719747198471994720047201472024720347204472054720647207472084720947210472114721247213472144721547216472174721847219472204722147222472234722447225472264722747228472294723047231472324723347234472354723647237472384723947240472414724247243472444724547246472474724847249472504725147252472534725447255472564725747258472594726047261472624726347264472654726647267472684726947270472714727247273472744727547276472774727847279472804728147282472834728447285472864728747288472894729047291472924729347294472954729647297472984729947300473014730247303473044730547306473074730847309473104731147312473134731447315473164731747318473194732047321473224732347324473254732647327473284732947330473314733247333473344733547336473374733847339473404734147342473434734447345473464734747348473494735047351473524735347354473554735647357473584735947360473614736247363473644736547366473674736847369473704737147372473734737447375473764737747378473794738047381473824738347384473854738647387473884738947390473914739247393473944739547396473974739847399474004740147402474034740447405474064740747408474094741047411474124741347414474154741647417474184741947420474214742247423474244742547426474274742847429474304743147432474334743447435474364743747438474394744047441474424744347444474454744647447474484744947450474514745247453474544745547456474574745847459474604746147462474634746447465474664746747468474694747047471474724747347474474754747647477474784747947480474814748247483474844748547486474874748847489474904749147492474934749447495474964749747498474994750047501475024750347504475054750647507475084750947510475114751247513475144751547516475174751847519475204752147522475234752447525475264752747528475294753047531475324753347534475354753647537475384753947540475414754247543475444754547546475474754847549475504755147552475534755447555475564755747558475594756047561475624756347564475654756647567475684756947570475714757247573475744757547576475774757847579475804758147582475834758447585475864758747588475894759047591475924759347594475954759647597475984759947600476014760247603476044760547606476074760847609476104761147612476134761447615476164761747618476194762047621476224762347624476254762647627476284762947630476314763247633476344763547636476374763847639476404764147642476434764447645476464764747648476494765047651476524765347654476554765647657476584765947660476614766247663476644766547666476674766847669476704767147672476734767447675476764767747678476794768047681476824768347684476854768647687476884768947690476914769247693476944769547696476974769847699477004770147702477034770447705477064770747708477094771047711477124771347714477154771647717477184771947720477214772247723477244772547726477274772847729477304773147732477334773447735477364773747738477394774047741477424774347744477454774647747477484774947750477514775247753477544775547756477574775847759477604776147762477634776447765477664776747768477694777047771477724777347774477754777647777477784777947780477814778247783477844778547786477874778847789477904779147792477934779447795477964779747798477994780047801478024780347804478054780647807478084780947810478114781247813478144781547816478174781847819478204782147822478234782447825478264782747828478294783047831478324783347834478354783647837478384783947840478414784247843478444784547846478474784847849478504785147852478534785447855478564785747858478594786047861478624786347864478654786647867478684786947870478714787247873478744787547876478774787847879478804788147882478834788447885478864788747888478894789047891478924789347894478954789647897478984789947900479014790247903479044790547906479074790847909479104791147912479134791447915479164791747918479194792047921479224792347924479254792647927479284792947930479314793247933479344793547936479374793847939479404794147942479434794447945479464794747948479494795047951479524795347954479554795647957479584795947960479614796247963479644796547966479674796847969479704797147972479734797447975479764797747978479794798047981479824798347984479854798647987479884798947990479914799247993479944799547996479974799847999480004800148002480034800448005480064800748008480094801048011480124801348014480154801648017480184801948020480214802248023480244802548026480274802848029480304803148032480334803448035480364803748038480394804048041480424804348044480454804648047480484804948050480514805248053480544805548056480574805848059480604806148062480634806448065480664806748068480694807048071480724807348074480754807648077480784807948080480814808248083480844808548086480874808848089480904809148092480934809448095480964809748098480994810048101481024810348104481054810648107481084810948110481114811248113481144811548116481174811848119481204812148122481234812448125481264812748128481294813048131481324813348134481354813648137481384813948140481414814248143481444814548146481474814848149481504815148152481534815448155481564815748158481594816048161481624816348164481654816648167481684816948170481714817248173481744817548176481774817848179481804818148182481834818448185481864818748188481894819048191481924819348194481954819648197481984819948200482014820248203482044820548206482074820848209482104821148212482134821448215482164821748218482194822048221482224822348224482254822648227482284822948230482314823248233482344823548236482374823848239482404824148242482434824448245482464824748248482494825048251482524825348254482554825648257482584825948260482614826248263482644826548266482674826848269482704827148272482734827448275482764827748278482794828048281482824828348284482854828648287482884828948290482914829248293482944829548296482974829848299483004830148302483034830448305483064830748308483094831048311483124831348314483154831648317483184831948320483214832248323483244832548326483274832848329483304833148332483334833448335483364833748338483394834048341483424834348344483454834648347483484834948350483514835248353483544835548356483574835848359483604836148362483634836448365483664836748368483694837048371483724837348374483754837648377483784837948380483814838248383483844838548386483874838848389483904839148392483934839448395483964839748398483994840048401484024840348404484054840648407484084840948410484114841248413484144841548416484174841848419484204842148422484234842448425484264842748428484294843048431484324843348434484354843648437484384843948440484414844248443484444844548446484474844848449484504845148452484534845448455484564845748458484594846048461484624846348464484654846648467484684846948470484714847248473484744847548476484774847848479484804848148482484834848448485484864848748488484894849048491484924849348494484954849648497484984849948500485014850248503485044850548506485074850848509485104851148512485134851448515485164851748518485194852048521485224852348524485254852648527485284852948530485314853248533485344853548536485374853848539485404854148542485434854448545485464854748548485494855048551485524855348554485554855648557485584855948560485614856248563485644856548566485674856848569485704857148572485734857448575485764857748578485794858048581485824858348584485854858648587485884858948590485914859248593485944859548596485974859848599486004860148602486034860448605486064860748608486094861048611486124861348614486154861648617486184861948620486214862248623486244862548626486274862848629486304863148632486334863448635486364863748638486394864048641486424864348644486454864648647486484864948650486514865248653486544865548656486574865848659486604866148662486634866448665486664866748668486694867048671486724867348674486754867648677486784867948680486814868248683486844868548686486874868848689486904869148692486934869448695486964869748698486994870048701487024870348704487054870648707487084870948710487114871248713487144871548716487174871848719487204872148722487234872448725487264872748728487294873048731487324873348734487354873648737487384873948740487414874248743487444874548746487474874848749487504875148752487534875448755487564875748758487594876048761487624876348764487654876648767487684876948770487714877248773487744877548776487774877848779487804878148782487834878448785487864878748788487894879048791487924879348794487954879648797487984879948800488014880248803488044880548806488074880848809488104881148812488134881448815488164881748818488194882048821488224882348824488254882648827488284882948830488314883248833488344883548836488374883848839488404884148842488434884448845488464884748848488494885048851488524885348854488554885648857488584885948860488614886248863488644886548866488674886848869488704887148872488734887448875488764887748878488794888048881488824888348884488854888648887488884888948890488914889248893488944889548896488974889848899489004890148902489034890448905489064890748908489094891048911489124891348914489154891648917489184891948920489214892248923489244892548926489274892848929489304893148932489334893448935489364893748938489394894048941489424894348944489454894648947489484894948950489514895248953489544895548956489574895848959489604896148962489634896448965489664896748968489694897048971489724897348974489754897648977489784897948980489814898248983489844898548986489874898848989489904899148992489934899448995489964899748998489994900049001490024900349004490054900649007490084900949010490114901249013490144901549016490174901849019490204902149022490234902449025490264902749028490294903049031490324903349034490354903649037490384903949040490414904249043490444904549046490474904849049490504905149052490534905449055490564905749058490594906049061490624906349064490654906649067490684906949070490714907249073490744907549076490774907849079490804908149082490834908449085490864908749088490894909049091490924909349094490954909649097490984909949100491014910249103491044910549106491074910849109491104911149112491134911449115491164911749118491194912049121491224912349124491254912649127491284912949130491314913249133491344913549136491374913849139491404914149142491434914449145491464914749148491494915049151491524915349154491554915649157491584915949160491614916249163491644916549166491674916849169491704917149172491734917449175491764917749178491794918049181491824918349184491854918649187491884918949190491914919249193491944919549196491974919849199492004920149202492034920449205492064920749208492094921049211492124921349214492154921649217492184921949220492214922249223492244922549226492274922849229492304923149232492334923449235492364923749238492394924049241492424924349244492454924649247492484924949250492514925249253492544925549256492574925849259492604926149262492634926449265492664926749268492694927049271492724927349274492754927649277492784927949280492814928249283492844928549286492874928849289492904929149292492934929449295492964929749298492994930049301493024930349304493054930649307493084930949310493114931249313493144931549316493174931849319493204932149322493234932449325493264932749328493294933049331493324933349334493354933649337493384933949340493414934249343493444934549346493474934849349493504935149352493534935449355493564935749358493594936049361493624936349364493654936649367493684936949370493714937249373493744937549376493774937849379493804938149382493834938449385493864938749388493894939049391493924939349394493954939649397493984939949400494014940249403494044940549406494074940849409494104941149412494134941449415494164941749418494194942049421494224942349424494254942649427494284942949430494314943249433494344943549436494374943849439494404944149442494434944449445494464944749448494494945049451494524945349454494554945649457494584945949460494614946249463494644946549466494674946849469494704947149472494734947449475494764947749478494794948049481494824948349484494854948649487494884948949490494914949249493494944949549496494974949849499495004950149502495034950449505495064950749508495094951049511495124951349514495154951649517495184951949520495214952249523495244952549526495274952849529495304953149532495334953449535495364953749538495394954049541495424954349544495454954649547495484954949550495514955249553495544955549556495574955849559495604956149562495634956449565495664956749568495694957049571495724957349574495754957649577495784957949580495814958249583495844958549586495874958849589495904959149592495934959449595495964959749598495994960049601496024960349604496054960649607496084960949610496114961249613496144961549616496174961849619496204962149622496234962449625496264962749628496294963049631496324963349634496354963649637496384963949640496414964249643496444964549646496474964849649496504965149652496534965449655496564965749658496594966049661496624966349664496654966649667496684966949670496714967249673496744967549676496774967849679496804968149682496834968449685496864968749688496894969049691496924969349694496954969649697496984969949700497014970249703497044970549706497074970849709497104971149712497134971449715497164971749718497194972049721497224972349724497254972649727497284972949730497314973249733497344973549736497374973849739497404974149742497434974449745497464974749748497494975049751497524975349754497554975649757497584975949760497614976249763497644976549766497674976849769497704977149772497734977449775497764977749778497794978049781497824978349784497854978649787497884978949790497914979249793497944979549796497974979849799498004980149802498034980449805498064980749808498094981049811498124981349814498154981649817498184981949820498214982249823498244982549826498274982849829498304983149832498334983449835498364983749838498394984049841498424984349844498454984649847498484984949850498514985249853498544985549856498574985849859498604986149862498634986449865498664986749868498694987049871498724987349874498754987649877498784987949880498814988249883498844988549886498874988849889498904989149892498934989449895498964989749898498994990049901499024990349904499054990649907499084990949910499114991249913499144991549916499174991849919499204992149922499234992449925499264992749928499294993049931499324993349934499354993649937499384993949940499414994249943499444994549946499474994849949499504995149952499534995449955499564995749958499594996049961499624996349964499654996649967499684996949970499714997249973499744997549976499774997849979499804998149982499834998449985499864998749988499894999049991499924999349994499954999649997499984999950000500015000250003500045000550006500075000850009500105001150012500135001450015500165001750018500195002050021500225002350024500255002650027500285002950030500315003250033500345003550036500375003850039500405004150042500435004450045500465004750048500495005050051500525005350054500555005650057500585005950060500615006250063500645006550066500675006850069500705007150072500735007450075500765007750078500795008050081500825008350084500855008650087500885008950090500915009250093500945009550096500975009850099501005010150102501035010450105501065010750108501095011050111501125011350114501155011650117501185011950120501215012250123501245012550126501275012850129501305013150132501335013450135501365013750138501395014050141501425014350144501455014650147501485014950150501515015250153501545015550156501575015850159501605016150162501635016450165501665016750168501695017050171501725017350174501755017650177501785017950180501815018250183501845018550186501875018850189501905019150192501935019450195501965019750198501995020050201502025020350204502055020650207502085020950210502115021250213502145021550216502175021850219502205022150222502235022450225502265022750228502295023050231502325023350234502355023650237502385023950240502415024250243502445024550246502475024850249502505025150252502535025450255502565025750258502595026050261502625026350264502655026650267502685026950270502715027250273502745027550276502775027850279502805028150282502835028450285502865028750288502895029050291502925029350294502955029650297502985029950300503015030250303503045030550306503075030850309503105031150312503135031450315503165031750318503195032050321503225032350324503255032650327503285032950330503315033250333503345033550336503375033850339503405034150342503435034450345503465034750348503495035050351503525035350354503555035650357503585035950360503615036250363503645036550366503675036850369503705037150372503735037450375503765037750378503795038050381503825038350384503855038650387503885038950390503915039250393503945039550396503975039850399504005040150402504035040450405504065040750408504095041050411504125041350414504155041650417504185041950420504215042250423504245042550426504275042850429504305043150432504335043450435504365043750438504395044050441504425044350444504455044650447504485044950450504515045250453504545045550456504575045850459504605046150462504635046450465504665046750468504695047050471504725047350474504755047650477504785047950480504815048250483504845048550486504875048850489504905049150492504935049450495504965049750498504995050050501505025050350504505055050650507505085050950510505115051250513505145051550516505175051850519505205052150522505235052450525505265052750528505295053050531505325053350534505355053650537505385053950540505415054250543505445054550546505475054850549505505055150552505535055450555505565055750558505595056050561505625056350564505655056650567505685056950570505715057250573505745057550576505775057850579505805058150582505835058450585505865058750588505895059050591505925059350594505955059650597505985059950600506015060250603506045060550606506075060850609506105061150612506135061450615506165061750618506195062050621506225062350624506255062650627506285062950630506315063250633506345063550636506375063850639506405064150642506435064450645506465064750648506495065050651506525065350654506555065650657506585065950660506615066250663506645066550666506675066850669506705067150672506735067450675506765067750678506795068050681506825068350684506855068650687506885068950690506915069250693506945069550696506975069850699507005070150702507035070450705507065070750708507095071050711507125071350714507155071650717507185071950720507215072250723507245072550726507275072850729507305073150732507335073450735507365073750738507395074050741507425074350744507455074650747507485074950750507515075250753507545075550756507575075850759507605076150762507635076450765507665076750768507695077050771507725077350774507755077650777507785077950780507815078250783507845078550786507875078850789507905079150792507935079450795507965079750798507995080050801508025080350804508055080650807508085080950810508115081250813508145081550816508175081850819508205082150822508235082450825508265082750828508295083050831508325083350834508355083650837508385083950840508415084250843508445084550846508475084850849508505085150852508535085450855508565085750858508595086050861508625086350864508655086650867508685086950870508715087250873508745087550876508775087850879508805088150882508835088450885508865088750888508895089050891508925089350894508955089650897508985089950900509015090250903509045090550906509075090850909509105091150912509135091450915509165091750918509195092050921509225092350924509255092650927509285092950930509315093250933509345093550936509375093850939509405094150942509435094450945509465094750948509495095050951509525095350954509555095650957509585095950960509615096250963509645096550966509675096850969509705097150972509735097450975509765097750978509795098050981509825098350984509855098650987509885098950990509915099250993509945099550996509975099850999510005100151002510035100451005510065100751008510095101051011510125101351014510155101651017510185101951020510215102251023510245102551026510275102851029510305103151032510335103451035510365103751038510395104051041510425104351044510455104651047510485104951050510515105251053510545105551056510575105851059510605106151062510635106451065510665106751068510695107051071510725107351074510755107651077510785107951080510815108251083510845108551086510875108851089510905109151092510935109451095510965109751098510995110051101511025110351104511055110651107511085110951110511115111251113511145111551116511175111851119511205112151122511235112451125511265112751128511295113051131511325113351134511355113651137511385113951140511415114251143511445114551146511475114851149511505115151152511535115451155511565115751158511595116051161511625116351164511655116651167511685116951170511715117251173511745117551176511775117851179511805118151182511835118451185511865118751188511895119051191511925119351194511955119651197511985119951200512015120251203512045120551206512075120851209512105121151212512135121451215512165121751218512195122051221512225122351224512255122651227512285122951230512315123251233512345123551236512375123851239512405124151242512435124451245512465124751248512495125051251512525125351254512555125651257512585125951260512615126251263512645126551266512675126851269512705127151272512735127451275512765127751278512795128051281512825128351284512855128651287512885128951290512915129251293512945129551296512975129851299513005130151302513035130451305513065130751308513095131051311513125131351314513155131651317513185131951320513215132251323513245132551326513275132851329513305133151332513335133451335513365133751338513395134051341513425134351344513455134651347513485134951350513515135251353513545135551356513575135851359513605136151362513635136451365513665136751368513695137051371513725137351374513755137651377513785137951380513815138251383513845138551386513875138851389513905139151392513935139451395513965139751398513995140051401514025140351404514055140651407514085140951410514115141251413514145141551416514175141851419514205142151422514235142451425514265142751428514295143051431514325143351434514355143651437514385143951440514415144251443514445144551446514475144851449514505145151452514535145451455514565145751458514595146051461514625146351464514655146651467514685146951470514715147251473514745147551476514775147851479514805148151482514835148451485514865148751488514895149051491514925149351494514955149651497514985149951500515015150251503515045150551506515075150851509515105151151512515135151451515515165151751518515195152051521515225152351524515255152651527515285152951530515315153251533515345153551536515375153851539515405154151542515435154451545515465154751548515495155051551515525155351554515555155651557515585155951560515615156251563515645156551566515675156851569515705157151572515735157451575515765157751578515795158051581515825158351584515855158651587515885158951590515915159251593515945159551596515975159851599516005160151602516035160451605516065160751608516095161051611516125161351614516155161651617516185161951620516215162251623516245162551626516275162851629516305163151632516335163451635516365163751638516395164051641516425164351644516455164651647516485164951650516515165251653516545165551656516575165851659516605166151662516635166451665516665166751668516695167051671516725167351674516755167651677516785167951680516815168251683516845168551686516875168851689516905169151692516935169451695516965169751698516995170051701517025170351704517055170651707517085170951710517115171251713517145171551716517175171851719517205172151722517235172451725517265172751728517295173051731517325173351734517355173651737517385173951740517415174251743517445174551746517475174851749517505175151752517535175451755517565175751758517595176051761517625176351764517655176651767517685176951770517715177251773517745177551776517775177851779517805178151782517835178451785517865178751788517895179051791517925179351794517955179651797517985179951800518015180251803518045180551806518075180851809518105181151812518135181451815518165181751818518195182051821518225182351824518255182651827518285182951830518315183251833518345183551836518375183851839518405184151842518435184451845518465184751848518495185051851518525185351854518555185651857518585185951860518615186251863518645186551866518675186851869518705187151872518735187451875518765187751878518795188051881518825188351884518855188651887518885188951890518915189251893518945189551896518975189851899519005190151902519035190451905519065190751908519095191051911519125191351914519155191651917519185191951920519215192251923519245192551926519275192851929519305193151932519335193451935519365193751938519395194051941519425194351944519455194651947519485194951950519515195251953519545195551956519575195851959519605196151962519635196451965519665196751968519695197051971519725197351974519755197651977519785197951980519815198251983519845198551986519875198851989519905199151992519935199451995519965199751998519995200052001520025200352004520055200652007520085200952010520115201252013520145201552016520175201852019520205202152022520235202452025520265202752028520295203052031520325203352034520355203652037520385203952040520415204252043520445204552046520475204852049520505205152052520535205452055520565205752058520595206052061520625206352064520655206652067520685206952070520715207252073520745207552076520775207852079520805208152082520835208452085520865208752088520895209052091520925209352094520955209652097520985209952100521015210252103521045210552106521075210852109521105211152112521135211452115521165211752118521195212052121521225212352124521255212652127521285212952130521315213252133521345213552136521375213852139521405214152142521435214452145521465214752148521495215052151521525215352154521555215652157521585215952160521615216252163521645216552166521675216852169521705217152172521735217452175521765217752178521795218052181521825218352184521855218652187521885218952190521915219252193521945219552196521975219852199522005220152202522035220452205522065220752208522095221052211522125221352214522155221652217522185221952220522215222252223522245222552226522275222852229522305223152232522335223452235522365223752238522395224052241522425224352244522455224652247522485224952250522515225252253522545225552256522575225852259522605226152262522635226452265522665226752268522695227052271522725227352274522755227652277522785227952280522815228252283522845228552286522875228852289522905229152292522935229452295522965229752298522995230052301523025230352304523055230652307523085230952310523115231252313523145231552316523175231852319523205232152322523235232452325523265232752328523295233052331523325233352334523355233652337523385233952340523415234252343523445234552346523475234852349523505235152352523535235452355523565235752358523595236052361523625236352364523655236652367523685236952370523715237252373523745237552376523775237852379523805238152382523835238452385523865238752388523895239052391523925239352394523955239652397523985239952400524015240252403524045240552406524075240852409524105241152412524135241452415524165241752418524195242052421524225242352424524255242652427524285242952430524315243252433524345243552436524375243852439524405244152442524435244452445524465244752448524495245052451524525245352454524555245652457524585245952460524615246252463524645246552466524675246852469524705247152472524735247452475524765247752478524795248052481524825248352484524855248652487524885248952490524915249252493524945249552496524975249852499525005250152502525035250452505525065250752508525095251052511525125251352514525155251652517525185251952520525215252252523525245252552526525275252852529525305253152532525335253452535525365253752538525395254052541525425254352544525455254652547525485254952550525515255252553525545255552556525575255852559525605256152562525635256452565525665256752568525695257052571525725257352574525755257652577525785257952580525815258252583525845258552586525875258852589525905259152592525935259452595525965259752598525995260052601526025260352604526055260652607526085260952610526115261252613526145261552616526175261852619526205262152622526235262452625526265262752628526295263052631526325263352634526355263652637526385263952640526415264252643526445264552646526475264852649526505265152652526535265452655526565265752658526595266052661526625266352664526655266652667526685266952670526715267252673526745267552676526775267852679526805268152682526835268452685526865268752688526895269052691526925269352694526955269652697526985269952700527015270252703527045270552706527075270852709527105271152712527135271452715527165271752718527195272052721527225272352724527255272652727527285272952730527315273252733527345273552736527375273852739527405274152742527435274452745527465274752748527495275052751527525275352754527555275652757527585275952760527615276252763527645276552766527675276852769527705277152772527735277452775527765277752778527795278052781527825278352784527855278652787527885278952790527915279252793527945279552796527975279852799528005280152802528035280452805528065280752808528095281052811528125281352814528155281652817528185281952820528215282252823528245282552826528275282852829528305283152832528335283452835528365283752838528395284052841528425284352844528455284652847528485284952850528515285252853528545285552856528575285852859528605286152862528635286452865528665286752868528695287052871528725287352874528755287652877528785287952880528815288252883528845288552886528875288852889528905289152892528935289452895528965289752898528995290052901529025290352904529055290652907529085290952910529115291252913529145291552916529175291852919529205292152922529235292452925529265292752928529295293052931529325293352934529355293652937529385293952940529415294252943529445294552946529475294852949529505295152952529535295452955529565295752958529595296052961529625296352964529655296652967529685296952970529715297252973529745297552976529775297852979529805298152982529835298452985529865298752988529895299052991529925299352994529955299652997529985299953000530015300253003530045300553006530075300853009530105301153012530135301453015530165301753018530195302053021530225302353024530255302653027530285302953030530315303253033530345303553036530375303853039530405304153042530435304453045530465304753048530495305053051530525305353054530555305653057530585305953060530615306253063530645306553066530675306853069530705307153072530735307453075530765307753078530795308053081530825308353084530855308653087530885308953090530915309253093530945309553096530975309853099531005310153102531035310453105531065310753108531095311053111531125311353114531155311653117531185311953120531215312253123531245312553126531275312853129531305313153132531335313453135531365313753138531395314053141531425314353144531455314653147531485314953150531515315253153531545315553156531575315853159531605316153162531635316453165531665316753168531695317053171531725317353174531755317653177531785317953180531815318253183531845318553186531875318853189531905319153192531935319453195531965319753198531995320053201532025320353204532055320653207532085320953210532115321253213532145321553216532175321853219532205322153222532235322453225532265322753228532295323053231532325323353234532355323653237532385323953240532415324253243532445324553246532475324853249532505325153252532535325453255532565325753258532595326053261532625326353264532655326653267532685326953270532715327253273532745327553276532775327853279532805328153282532835328453285532865328753288532895329053291532925329353294532955329653297532985329953300533015330253303533045330553306533075330853309533105331153312533135331453315533165331753318533195332053321533225332353324533255332653327533285332953330533315333253333533345333553336533375333853339533405334153342533435334453345533465334753348533495335053351533525335353354533555335653357533585335953360533615336253363533645336553366533675336853369533705337153372533735337453375533765337753378533795338053381533825338353384533855338653387533885338953390533915339253393533945339553396533975339853399534005340153402534035340453405534065340753408534095341053411534125341353414534155341653417534185341953420534215342253423534245342553426534275342853429534305343153432534335343453435534365343753438534395344053441534425344353444534455344653447534485344953450534515345253453534545345553456534575345853459534605346153462534635346453465534665346753468534695347053471534725347353474534755347653477534785347953480534815348253483534845348553486534875348853489534905349153492534935349453495534965349753498534995350053501535025350353504535055350653507535085350953510535115351253513535145351553516535175351853519535205352153522535235352453525535265352753528535295353053531535325353353534535355353653537535385353953540535415354253543535445354553546535475354853549535505355153552535535355453555535565355753558535595356053561535625356353564535655356653567535685356953570535715357253573535745357553576535775357853579535805358153582535835358453585535865358753588535895359053591535925359353594535955359653597535985359953600536015360253603536045360553606536075360853609536105361153612536135361453615536165361753618536195362053621536225362353624536255362653627536285362953630536315363253633536345363553636536375363853639536405364153642536435364453645536465364753648536495365053651536525365353654536555365653657536585365953660536615366253663536645366553666536675366853669536705367153672536735367453675536765367753678536795368053681536825368353684536855368653687536885368953690536915369253693536945369553696536975369853699537005370153702537035370453705537065370753708537095371053711537125371353714537155371653717537185371953720537215372253723537245372553726537275372853729537305373153732537335373453735537365373753738537395374053741537425374353744537455374653747537485374953750537515375253753537545375553756537575375853759537605376153762537635376453765537665376753768537695377053771537725377353774537755377653777537785377953780537815378253783537845378553786537875378853789537905379153792537935379453795537965379753798537995380053801538025380353804538055380653807538085380953810538115381253813538145381553816538175381853819538205382153822538235382453825538265382753828538295383053831538325383353834538355383653837538385383953840538415384253843538445384553846538475384853849538505385153852538535385453855538565385753858538595386053861538625386353864538655386653867538685386953870538715387253873538745387553876538775387853879538805388153882538835388453885538865388753888538895389053891538925389353894538955389653897538985389953900539015390253903539045390553906539075390853909539105391153912539135391453915539165391753918539195392053921539225392353924539255392653927539285392953930539315393253933539345393553936539375393853939539405394153942539435394453945539465394753948539495395053951539525395353954539555395653957539585395953960539615396253963539645396553966539675396853969539705397153972539735397453975539765397753978539795398053981539825398353984539855398653987539885398953990539915399253993539945399553996539975399853999540005400154002540035400454005540065400754008540095401054011540125401354014540155401654017540185401954020540215402254023540245402554026540275402854029540305403154032540335403454035540365403754038540395404054041540425404354044540455404654047540485404954050540515405254053540545405554056540575405854059540605406154062540635406454065540665406754068540695407054071540725407354074540755407654077540785407954080540815408254083540845408554086540875408854089540905409154092540935409454095540965409754098540995410054101541025410354104541055410654107541085410954110541115411254113541145411554116541175411854119541205412154122541235412454125541265412754128541295413054131541325413354134541355413654137541385413954140541415414254143541445414554146541475414854149541505415154152541535415454155541565415754158541595416054161541625416354164541655416654167541685416954170541715417254173541745417554176541775417854179541805418154182541835418454185541865418754188541895419054191541925419354194541955419654197541985419954200542015420254203542045420554206542075420854209542105421154212542135421454215542165421754218542195422054221542225422354224542255422654227542285422954230542315423254233542345423554236542375423854239542405424154242542435424454245542465424754248542495425054251542525425354254542555425654257542585425954260542615426254263542645426554266542675426854269542705427154272542735427454275542765427754278542795428054281542825428354284542855428654287542885428954290542915429254293542945429554296542975429854299543005430154302543035430454305543065430754308543095431054311543125431354314543155431654317543185431954320543215432254323543245432554326543275432854329543305433154332543335433454335543365433754338543395434054341543425434354344543455434654347543485434954350543515435254353543545435554356543575435854359543605436154362543635436454365543665436754368543695437054371543725437354374543755437654377543785437954380543815438254383543845438554386543875438854389543905439154392543935439454395543965439754398543995440054401544025440354404544055440654407544085440954410544115441254413544145441554416544175441854419544205442154422544235442454425544265442754428544295443054431544325443354434544355443654437544385443954440544415444254443544445444554446544475444854449544505445154452544535445454455544565445754458544595446054461544625446354464544655446654467544685446954470544715447254473544745447554476544775447854479544805448154482544835448454485544865448754488544895449054491544925449354494544955449654497544985449954500545015450254503545045450554506545075450854509545105451154512545135451454515545165451754518545195452054521545225452354524545255452654527545285452954530545315453254533545345453554536545375453854539545405454154542545435454454545545465454754548545495455054551545525455354554545555455654557545585455954560545615456254563545645456554566545675456854569545705457154572545735457454575545765457754578545795458054581545825458354584545855458654587545885458954590545915459254593545945459554596545975459854599546005460154602546035460454605546065460754608546095461054611546125461354614546155461654617546185461954620546215462254623546245462554626546275462854629546305463154632546335463454635546365463754638546395464054641546425464354644546455464654647546485464954650546515465254653546545465554656546575465854659546605466154662546635466454665546665466754668546695467054671546725467354674546755467654677546785467954680546815468254683546845468554686546875468854689546905469154692546935469454695546965469754698546995470054701547025470354704547055470654707547085470954710547115471254713547145471554716547175471854719547205472154722547235472454725547265472754728547295473054731547325473354734547355473654737547385473954740547415474254743547445474554746547475474854749547505475154752547535475454755547565475754758547595476054761547625476354764547655476654767547685476954770547715477254773547745477554776547775477854779547805478154782547835478454785547865478754788547895479054791547925479354794547955479654797547985479954800548015480254803548045480554806548075480854809548105481154812548135481454815548165481754818548195482054821548225482354824548255482654827548285482954830548315483254833548345483554836548375483854839548405484154842548435484454845548465484754848548495485054851548525485354854548555485654857548585485954860548615486254863548645486554866548675486854869548705487154872548735487454875548765487754878548795488054881548825488354884548855488654887548885488954890548915489254893548945489554896548975489854899549005490154902549035490454905549065490754908549095491054911549125491354914549155491654917549185491954920549215492254923549245492554926549275492854929549305493154932549335493454935549365493754938549395494054941549425494354944549455494654947549485494954950549515495254953549545495554956549575495854959549605496154962549635496454965549665496754968549695497054971549725497354974549755497654977549785497954980549815498254983549845498554986549875498854989549905499154992549935499454995549965499754998549995500055001550025500355004550055500655007550085500955010550115501255013550145501555016550175501855019550205502155022550235502455025550265502755028550295503055031550325503355034550355503655037550385503955040550415504255043550445504555046550475504855049550505505155052550535505455055550565505755058550595506055061550625506355064550655506655067550685506955070550715507255073550745507555076550775507855079550805508155082550835508455085550865508755088550895509055091550925509355094550955509655097550985509955100551015510255103551045510555106551075510855109551105511155112551135511455115551165511755118551195512055121551225512355124551255512655127551285512955130551315513255133551345513555136551375513855139551405514155142551435514455145551465514755148551495515055151551525515355154551555515655157551585515955160551615516255163551645516555166551675516855169551705517155172551735517455175551765517755178551795518055181551825518355184551855518655187551885518955190551915519255193551945519555196551975519855199552005520155202552035520455205552065520755208552095521055211552125521355214552155521655217552185521955220552215522255223552245522555226552275522855229552305523155232552335523455235552365523755238552395524055241552425524355244552455524655247552485524955250552515525255253552545525555256552575525855259552605526155262552635526455265552665526755268552695527055271552725527355274552755527655277552785527955280552815528255283552845528555286552875528855289552905529155292552935529455295552965529755298552995530055301553025530355304553055530655307553085530955310553115531255313553145531555316553175531855319553205532155322553235532455325553265532755328553295533055331553325533355334553355533655337553385533955340553415534255343553445534555346553475534855349553505535155352553535535455355553565535755358553595536055361553625536355364553655536655367553685536955370553715537255373553745537555376553775537855379553805538155382553835538455385553865538755388553895539055391553925539355394553955539655397553985539955400554015540255403554045540555406554075540855409554105541155412554135541455415554165541755418554195542055421554225542355424554255542655427554285542955430554315543255433554345543555436554375543855439554405544155442554435544455445554465544755448554495545055451554525545355454554555545655457554585545955460554615546255463554645546555466554675546855469554705547155472554735547455475554765547755478554795548055481554825548355484554855548655487554885548955490554915549255493554945549555496554975549855499555005550155502555035550455505555065550755508555095551055511555125551355514555155551655517555185551955520555215552255523555245552555526555275552855529555305553155532555335553455535555365553755538555395554055541555425554355544555455554655547555485554955550555515555255553555545555555556555575555855559555605556155562555635556455565555665556755568555695557055571555725557355574555755557655577555785557955580555815558255583555845558555586555875558855589555905559155592555935559455595555965559755598555995560055601556025560355604556055560655607556085560955610556115561255613556145561555616556175561855619556205562155622556235562455625556265562755628556295563055631556325563355634556355563655637556385563955640556415564255643556445564555646556475564855649556505565155652556535565455655556565565755658556595566055661556625566355664556655566655667556685566955670556715567255673556745567555676556775567855679556805568155682556835568455685556865568755688556895569055691556925569355694556955569655697556985569955700557015570255703557045570555706557075570855709557105571155712557135571455715557165571755718557195572055721557225572355724557255572655727557285572955730557315573255733557345573555736557375573855739557405574155742557435574455745557465574755748557495575055751557525575355754557555575655757557585575955760557615576255763557645576555766557675576855769557705577155772557735577455775557765577755778557795578055781557825578355784557855578655787557885578955790557915579255793557945579555796557975579855799558005580155802558035580455805558065580755808558095581055811558125581355814558155581655817558185581955820558215582255823558245582555826558275582855829558305583155832558335583455835558365583755838558395584055841558425584355844558455584655847558485584955850558515585255853558545585555856558575585855859558605586155862558635586455865558665586755868558695587055871558725587355874558755587655877558785587955880558815588255883558845588555886558875588855889558905589155892558935589455895558965589755898558995590055901559025590355904559055590655907559085590955910559115591255913559145591555916559175591855919559205592155922559235592455925559265592755928559295593055931559325593355934559355593655937559385593955940559415594255943559445594555946559475594855949559505595155952559535595455955559565595755958559595596055961559625596355964559655596655967559685596955970559715597255973559745597555976559775597855979559805598155982559835598455985559865598755988559895599055991559925599355994559955599655997559985599956000560015600256003560045600556006560075600856009560105601156012560135601456015560165601756018560195602056021560225602356024560255602656027560285602956030560315603256033560345603556036560375603856039560405604156042560435604456045560465604756048560495605056051560525605356054560555605656057560585605956060560615606256063560645606556066560675606856069560705607156072560735607456075560765607756078560795608056081560825608356084560855608656087560885608956090560915609256093560945609556096560975609856099561005610156102561035610456105561065610756108561095611056111561125611356114561155611656117561185611956120561215612256123561245612556126561275612856129561305613156132561335613456135561365613756138561395614056141561425614356144561455614656147561485614956150561515615256153561545615556156561575615856159561605616156162561635616456165561665616756168561695617056171561725617356174561755617656177561785617956180561815618256183561845618556186561875618856189561905619156192561935619456195561965619756198561995620056201562025620356204562055620656207562085620956210562115621256213562145621556216562175621856219562205622156222562235622456225562265622756228562295623056231562325623356234562355623656237562385623956240562415624256243562445624556246562475624856249562505625156252562535625456255562565625756258562595626056261562625626356264562655626656267562685626956270562715627256273562745627556276562775627856279562805628156282562835628456285562865628756288562895629056291562925629356294562955629656297562985629956300563015630256303563045630556306563075630856309563105631156312563135631456315563165631756318563195632056321563225632356324563255632656327563285632956330563315633256333563345633556336563375633856339563405634156342563435634456345563465634756348563495635056351563525635356354563555635656357563585635956360563615636256363563645636556366563675636856369563705637156372563735637456375563765637756378563795638056381563825638356384563855638656387563885638956390563915639256393563945639556396563975639856399564005640156402564035640456405564065640756408564095641056411564125641356414564155641656417564185641956420564215642256423564245642556426564275642856429564305643156432564335643456435564365643756438564395644056441564425644356444564455644656447564485644956450564515645256453564545645556456564575645856459564605646156462564635646456465564665646756468564695647056471564725647356474564755647656477564785647956480564815648256483564845648556486564875648856489564905649156492564935649456495564965649756498564995650056501565025650356504565055650656507565085650956510565115651256513565145651556516565175651856519565205652156522565235652456525565265652756528565295653056531565325653356534565355653656537565385653956540565415654256543565445654556546565475654856549565505655156552565535655456555565565655756558565595656056561565625656356564565655656656567565685656956570565715657256573565745657556576565775657856579565805658156582565835658456585565865658756588565895659056591565925659356594565955659656597565985659956600566015660256603566045660556606566075660856609566105661156612566135661456615566165661756618566195662056621566225662356624566255662656627566285662956630566315663256633566345663556636566375663856639566405664156642566435664456645566465664756648566495665056651566525665356654566555665656657566585665956660566615666256663566645666556666566675666856669566705667156672566735667456675566765667756678566795668056681566825668356684566855668656687566885668956690566915669256693566945669556696566975669856699567005670156702567035670456705567065670756708567095671056711567125671356714567155671656717567185671956720567215672256723567245672556726567275672856729567305673156732567335673456735567365673756738567395674056741567425674356744567455674656747567485674956750567515675256753567545675556756567575675856759567605676156762567635676456765567665676756768567695677056771567725677356774567755677656777567785677956780567815678256783567845678556786567875678856789567905679156792567935679456795567965679756798567995680056801568025680356804568055680656807568085680956810568115681256813568145681556816568175681856819568205682156822568235682456825568265682756828568295683056831568325683356834568355683656837568385683956840568415684256843568445684556846568475684856849568505685156852568535685456855568565685756858568595686056861568625686356864568655686656867568685686956870568715687256873568745687556876568775687856879568805688156882568835688456885568865688756888568895689056891568925689356894568955689656897568985689956900569015690256903569045690556906569075690856909569105691156912569135691456915569165691756918569195692056921569225692356924569255692656927569285692956930569315693256933569345693556936569375693856939569405694156942569435694456945569465694756948569495695056951569525695356954569555695656957569585695956960569615696256963569645696556966569675696856969569705697156972569735697456975569765697756978569795698056981569825698356984569855698656987569885698956990569915699256993569945699556996569975699856999570005700157002570035700457005570065700757008570095701057011570125701357014570155701657017570185701957020570215702257023570245702557026570275702857029570305703157032570335703457035570365703757038570395704057041570425704357044570455704657047570485704957050570515705257053570545705557056570575705857059570605706157062570635706457065570665706757068570695707057071570725707357074570755707657077570785707957080570815708257083570845708557086570875708857089570905709157092570935709457095570965709757098570995710057101571025710357104571055710657107571085710957110571115711257113571145711557116571175711857119571205712157122571235712457125571265712757128571295713057131571325713357134571355713657137571385713957140571415714257143571445714557146571475714857149571505715157152571535715457155571565715757158571595716057161571625716357164571655716657167571685716957170571715717257173571745717557176571775717857179571805718157182571835718457185571865718757188571895719057191571925719357194571955719657197571985719957200572015720257203572045720557206572075720857209572105721157212572135721457215572165721757218572195722057221572225722357224572255722657227572285722957230572315723257233572345723557236572375723857239572405724157242572435724457245572465724757248572495725057251572525725357254572555725657257572585725957260572615726257263572645726557266572675726857269572705727157272572735727457275572765727757278572795728057281572825728357284572855728657287572885728957290572915729257293572945729557296572975729857299573005730157302573035730457305573065730757308573095731057311573125731357314573155731657317573185731957320573215732257323573245732557326573275732857329573305733157332573335733457335573365733757338573395734057341573425734357344573455734657347573485734957350573515735257353573545735557356573575735857359573605736157362573635736457365573665736757368573695737057371573725737357374573755737657377573785737957380573815738257383573845738557386573875738857389573905739157392573935739457395573965739757398573995740057401574025740357404574055740657407574085740957410574115741257413574145741557416574175741857419574205742157422574235742457425574265742757428574295743057431574325743357434574355743657437574385743957440574415744257443574445744557446574475744857449574505745157452574535745457455574565745757458574595746057461574625746357464574655746657467574685746957470574715747257473574745747557476574775747857479574805748157482574835748457485574865748757488574895749057491574925749357494574955749657497574985749957500575015750257503575045750557506575075750857509575105751157512575135751457515575165751757518575195752057521575225752357524575255752657527575285752957530575315753257533575345753557536575375753857539575405754157542575435754457545575465754757548575495755057551575525755357554575555755657557575585755957560575615756257563575645756557566575675756857569575705757157572575735757457575575765757757578575795758057581575825758357584575855758657587575885758957590575915759257593575945759557596575975759857599576005760157602576035760457605576065760757608576095761057611576125761357614576155761657617576185761957620576215762257623576245762557626576275762857629576305763157632576335763457635576365763757638576395764057641576425764357644576455764657647576485764957650576515765257653576545765557656576575765857659576605766157662576635766457665576665766757668576695767057671576725767357674576755767657677576785767957680576815768257683576845768557686576875768857689576905769157692576935769457695576965769757698576995770057701577025770357704577055770657707577085770957710577115771257713577145771557716577175771857719577205772157722577235772457725577265772757728577295773057731577325773357734577355773657737577385773957740577415774257743577445774557746577475774857749577505775157752577535775457755577565775757758577595776057761577625776357764577655776657767577685776957770577715777257773577745777557776577775777857779577805778157782577835778457785577865778757788577895779057791577925779357794577955779657797577985779957800578015780257803578045780557806578075780857809578105781157812578135781457815578165781757818578195782057821578225782357824578255782657827578285782957830578315783257833578345783557836578375783857839578405784157842578435784457845578465784757848578495785057851578525785357854578555785657857578585785957860578615786257863578645786557866578675786857869578705787157872578735787457875578765787757878578795788057881578825788357884578855788657887578885788957890578915789257893578945789557896578975789857899579005790157902579035790457905579065790757908579095791057911579125791357914579155791657917579185791957920579215792257923579245792557926579275792857929579305793157932579335793457935579365793757938579395794057941579425794357944579455794657947579485794957950579515795257953579545795557956579575795857959579605796157962579635796457965579665796757968579695797057971579725797357974579755797657977579785797957980579815798257983579845798557986579875798857989579905799157992579935799457995579965799757998579995800058001580025800358004580055800658007580085800958010580115801258013580145801558016580175801858019580205802158022580235802458025580265802758028580295803058031580325803358034580355803658037580385803958040580415804258043580445804558046580475804858049580505805158052580535805458055580565805758058580595806058061580625806358064580655806658067580685806958070580715807258073580745807558076580775807858079580805808158082580835808458085580865808758088580895809058091580925809358094580955809658097580985809958100581015810258103581045810558106581075810858109581105811158112581135811458115581165811758118581195812058121581225812358124581255812658127581285812958130581315813258133581345813558136581375813858139581405814158142581435814458145581465814758148581495815058151581525815358154581555815658157581585815958160581615816258163581645816558166581675816858169581705817158172581735817458175581765817758178581795818058181581825818358184581855818658187581885818958190581915819258193581945819558196581975819858199582005820158202582035820458205582065820758208582095821058211582125821358214582155821658217582185821958220582215822258223582245822558226582275822858229582305823158232582335823458235582365823758238582395824058241582425824358244582455824658247582485824958250582515825258253582545825558256582575825858259582605826158262582635826458265582665826758268582695827058271582725827358274582755827658277582785827958280582815828258283582845828558286582875828858289582905829158292582935829458295582965829758298582995830058301583025830358304583055830658307583085830958310583115831258313583145831558316583175831858319583205832158322583235832458325583265832758328583295833058331583325833358334583355833658337583385833958340583415834258343583445834558346583475834858349583505835158352583535835458355583565835758358583595836058361583625836358364583655836658367583685836958370583715837258373583745837558376583775837858379583805838158382583835838458385583865838758388583895839058391583925839358394583955839658397583985839958400584015840258403584045840558406584075840858409584105841158412584135841458415584165841758418584195842058421584225842358424584255842658427584285842958430584315843258433584345843558436584375843858439584405844158442584435844458445584465844758448584495845058451584525845358454584555845658457584585845958460584615846258463584645846558466584675846858469584705847158472584735847458475584765847758478584795848058481584825848358484584855848658487584885848958490584915849258493584945849558496584975849858499585005850158502585035850458505585065850758508585095851058511585125851358514585155851658517585185851958520585215852258523585245852558526585275852858529585305853158532585335853458535585365853758538585395854058541585425854358544585455854658547585485854958550585515855258553585545855558556585575855858559585605856158562585635856458565585665856758568585695857058571585725857358574585755857658577585785857958580585815858258583585845858558586585875858858589585905859158592585935859458595585965859758598585995860058601586025860358604586055860658607586085860958610586115861258613586145861558616586175861858619586205862158622586235862458625586265862758628586295863058631586325863358634586355863658637586385863958640586415864258643586445864558646586475864858649586505865158652586535865458655586565865758658586595866058661586625866358664586655866658667586685866958670586715867258673586745867558676586775867858679586805868158682586835868458685586865868758688586895869058691586925869358694586955869658697586985869958700587015870258703587045870558706587075870858709587105871158712587135871458715587165871758718587195872058721587225872358724587255872658727587285872958730587315873258733587345873558736587375873858739587405874158742587435874458745587465874758748587495875058751587525875358754587555875658757587585875958760587615876258763587645876558766587675876858769587705877158772587735877458775587765877758778587795878058781587825878358784587855878658787587885878958790587915879258793587945879558796587975879858799588005880158802588035880458805588065880758808588095881058811588125881358814588155881658817588185881958820588215882258823588245882558826588275882858829588305883158832588335883458835588365883758838588395884058841588425884358844588455884658847588485884958850588515885258853588545885558856588575885858859588605886158862588635886458865588665886758868588695887058871588725887358874588755887658877588785887958880588815888258883588845888558886588875888858889588905889158892588935889458895588965889758898588995890058901589025890358904589055890658907589085890958910589115891258913589145891558916589175891858919589205892158922589235892458925589265892758928589295893058931589325893358934589355893658937589385893958940589415894258943589445894558946589475894858949589505895158952589535895458955589565895758958589595896058961589625896358964589655896658967589685896958970589715897258973589745897558976589775897858979589805898158982589835898458985589865898758988589895899058991589925899358994589955899658997589985899959000590015900259003590045900559006590075900859009590105901159012590135901459015590165901759018590195902059021590225902359024590255902659027590285902959030590315903259033590345903559036590375903859039590405904159042590435904459045590465904759048590495905059051590525905359054590555905659057590585905959060590615906259063590645906559066590675906859069590705907159072590735907459075590765907759078590795908059081590825908359084590855908659087590885908959090590915909259093590945909559096590975909859099591005910159102591035910459105591065910759108591095911059111591125911359114591155911659117591185911959120591215912259123591245912559126591275912859129591305913159132591335913459135591365913759138591395914059141591425914359144591455914659147591485914959150591515915259153591545915559156591575915859159591605916159162591635916459165591665916759168591695917059171591725917359174591755917659177591785917959180591815918259183591845918559186591875918859189591905919159192591935919459195591965919759198591995920059201592025920359204592055920659207592085920959210592115921259213592145921559216592175921859219592205922159222592235922459225592265922759228592295923059231592325923359234592355923659237592385923959240592415924259243592445924559246592475924859249592505925159252592535925459255592565925759258592595926059261592625926359264592655926659267592685926959270592715927259273592745927559276592775927859279592805928159282592835928459285592865928759288592895929059291592925929359294592955929659297592985929959300593015930259303593045930559306593075930859309593105931159312593135931459315593165931759318593195932059321593225932359324593255932659327593285932959330593315933259333593345933559336593375933859339593405934159342593435934459345593465934759348593495935059351593525935359354593555935659357593585935959360593615936259363593645936559366593675936859369593705937159372593735937459375593765937759378593795938059381593825938359384593855938659387593885938959390593915939259393593945939559396593975939859399594005940159402594035940459405594065940759408594095941059411594125941359414594155941659417594185941959420594215942259423594245942559426594275942859429594305943159432594335943459435594365943759438594395944059441594425944359444594455944659447594485944959450594515945259453594545945559456594575945859459594605946159462594635946459465594665946759468594695947059471594725947359474594755947659477594785947959480594815948259483594845948559486594875948859489594905949159492594935949459495594965949759498594995950059501595025950359504595055950659507595085950959510595115951259513595145951559516595175951859519595205952159522595235952459525595265952759528595295953059531595325953359534595355953659537595385953959540595415954259543595445954559546595475954859549595505955159552595535955459555595565955759558595595956059561595625956359564595655956659567595685956959570595715957259573595745957559576595775957859579595805958159582595835958459585595865958759588595895959059591595925959359594595955959659597595985959959600596015960259603596045960559606596075960859609596105961159612596135961459615596165961759618596195962059621596225962359624596255962659627596285962959630596315963259633596345963559636596375963859639596405964159642596435964459645596465964759648596495965059651596525965359654596555965659657596585965959660596615966259663596645966559666596675966859669596705967159672596735967459675596765967759678596795968059681596825968359684596855968659687596885968959690596915969259693596945969559696596975969859699597005970159702597035970459705597065970759708597095971059711597125971359714597155971659717597185971959720597215972259723597245972559726597275972859729597305973159732597335973459735597365973759738597395974059741597425974359744597455974659747597485974959750597515975259753597545975559756597575975859759597605976159762597635976459765597665976759768597695977059771597725977359774597755977659777597785977959780597815978259783597845978559786597875978859789597905979159792597935979459795597965979759798597995980059801598025980359804598055980659807598085980959810598115981259813598145981559816598175981859819598205982159822598235982459825598265982759828598295983059831598325983359834598355983659837598385983959840598415984259843598445984559846598475984859849598505985159852598535985459855598565985759858598595986059861598625986359864598655986659867598685986959870598715987259873598745987559876598775987859879598805988159882598835988459885598865988759888598895989059891598925989359894598955989659897598985989959900599015990259903599045990559906599075990859909599105991159912599135991459915599165991759918599195992059921599225992359924599255992659927599285992959930599315993259933599345993559936599375993859939599405994159942599435994459945599465994759948599495995059951599525995359954599555995659957599585995959960599615996259963599645996559966599675996859969599705997159972599735997459975599765997759978599795998059981599825998359984599855998659987599885998959990599915999259993599945999559996599975999859999600006000160002600036000460005600066000760008600096001060011600126001360014600156001660017600186001960020600216002260023600246002560026600276002860029600306003160032600336003460035600366003760038600396004060041600426004360044600456004660047600486004960050600516005260053600546005560056600576005860059600606006160062600636006460065600666006760068600696007060071600726007360074600756007660077600786007960080600816008260083600846008560086600876008860089600906009160092600936009460095600966009760098600996010060101601026010360104601056010660107601086010960110601116011260113601146011560116601176011860119601206012160122601236012460125601266012760128601296013060131601326013360134601356013660137601386013960140601416014260143601446014560146601476014860149601506015160152601536015460155601566015760158601596016060161601626016360164601656016660167601686016960170601716017260173601746017560176601776017860179601806018160182601836018460185601866018760188601896019060191601926019360194601956019660197601986019960200602016020260203602046020560206602076020860209602106021160212602136021460215602166021760218602196022060221602226022360224602256022660227602286022960230602316023260233602346023560236602376023860239602406024160242602436024460245602466024760248602496025060251602526025360254602556025660257602586025960260602616026260263602646026560266602676026860269602706027160272602736027460275602766027760278602796028060281602826028360284602856028660287602886028960290602916029260293602946029560296602976029860299603006030160302603036030460305603066030760308603096031060311603126031360314603156031660317603186031960320603216032260323603246032560326603276032860329603306033160332603336033460335603366033760338603396034060341603426034360344603456034660347603486034960350603516035260353603546035560356603576035860359603606036160362603636036460365603666036760368603696037060371603726037360374603756037660377603786037960380603816038260383603846038560386603876038860389603906039160392603936039460395603966039760398603996040060401604026040360404604056040660407604086040960410604116041260413604146041560416604176041860419604206042160422604236042460425604266042760428604296043060431604326043360434604356043660437604386043960440604416044260443604446044560446604476044860449604506045160452604536045460455604566045760458604596046060461604626046360464604656046660467604686046960470604716047260473604746047560476604776047860479604806048160482604836048460485604866048760488604896049060491604926049360494604956049660497604986049960500605016050260503605046050560506605076050860509605106051160512605136051460515605166051760518605196052060521605226052360524605256052660527605286052960530605316053260533605346053560536605376053860539605406054160542605436054460545605466054760548605496055060551605526055360554605556055660557605586055960560605616056260563605646056560566605676056860569605706057160572605736057460575605766057760578605796058060581605826058360584605856058660587605886058960590605916059260593605946059560596605976059860599606006060160602606036060460605606066060760608606096061060611606126061360614606156061660617606186061960620606216062260623606246062560626606276062860629606306063160632606336063460635606366063760638606396064060641606426064360644606456064660647606486064960650606516065260653606546065560656606576065860659606606066160662606636066460665606666066760668606696067060671606726067360674606756067660677606786067960680606816068260683606846068560686606876068860689606906069160692606936069460695606966069760698606996070060701607026070360704607056070660707607086070960710607116071260713607146071560716607176071860719607206072160722607236072460725607266072760728607296073060731607326073360734607356073660737607386073960740607416074260743607446074560746607476074860749607506075160752607536075460755607566075760758607596076060761607626076360764607656076660767607686076960770607716077260773607746077560776607776077860779607806078160782607836078460785607866078760788607896079060791607926079360794607956079660797607986079960800608016080260803608046080560806608076080860809608106081160812608136081460815608166081760818608196082060821608226082360824608256082660827608286082960830608316083260833608346083560836608376083860839608406084160842608436084460845608466084760848608496085060851608526085360854608556085660857608586085960860608616086260863608646086560866608676086860869608706087160872608736087460875608766087760878608796088060881608826088360884608856088660887608886088960890608916089260893608946089560896608976089860899609006090160902609036090460905609066090760908609096091060911609126091360914609156091660917609186091960920609216092260923609246092560926609276092860929609306093160932609336093460935609366093760938609396094060941609426094360944609456094660947609486094960950609516095260953609546095560956609576095860959609606096160962609636096460965609666096760968609696097060971609726097360974609756097660977609786097960980609816098260983609846098560986609876098860989609906099160992609936099460995609966099760998609996100061001610026100361004610056100661007610086100961010610116101261013610146101561016610176101861019610206102161022610236102461025610266102761028610296103061031610326103361034610356103661037610386103961040610416104261043610446104561046610476104861049610506105161052610536105461055610566105761058610596106061061610626106361064610656106661067610686106961070610716107261073610746107561076610776107861079610806108161082610836108461085610866108761088610896109061091610926109361094610956109661097610986109961100611016110261103611046110561106611076110861109611106111161112611136111461115611166111761118611196112061121611226112361124611256112661127611286112961130611316113261133611346113561136611376113861139611406114161142611436114461145611466114761148611496115061151611526115361154611556115661157611586115961160611616116261163611646116561166611676116861169611706117161172611736117461175611766117761178611796118061181611826118361184611856118661187611886118961190611916119261193611946119561196611976119861199612006120161202612036120461205612066120761208612096121061211612126121361214612156121661217612186121961220612216122261223612246122561226612276122861229612306123161232612336123461235612366123761238612396124061241612426124361244612456124661247612486124961250612516125261253612546125561256612576125861259612606126161262612636126461265612666126761268612696127061271612726127361274612756127661277612786127961280612816128261283612846128561286612876128861289612906129161292612936129461295612966129761298612996130061301613026130361304613056130661307613086130961310613116131261313613146131561316613176131861319613206132161322613236132461325613266132761328613296133061331613326133361334613356133661337613386133961340613416134261343613446134561346613476134861349613506135161352613536135461355613566135761358613596136061361613626136361364613656136661367613686136961370613716137261373613746137561376613776137861379613806138161382613836138461385613866138761388613896139061391613926139361394613956139661397613986139961400614016140261403614046140561406614076140861409614106141161412614136141461415614166141761418614196142061421614226142361424614256142661427614286142961430614316143261433614346143561436614376143861439614406144161442614436144461445614466144761448614496145061451614526145361454614556145661457614586145961460614616146261463614646146561466614676146861469614706147161472614736147461475614766147761478614796148061481614826148361484614856148661487614886148961490614916149261493614946149561496614976149861499615006150161502615036150461505615066150761508615096151061511615126151361514615156151661517615186151961520615216152261523615246152561526615276152861529615306153161532615336153461535615366153761538615396154061541615426154361544615456154661547615486154961550615516155261553615546155561556615576155861559615606156161562615636156461565615666156761568615696157061571615726157361574615756157661577615786157961580615816158261583615846158561586615876158861589615906159161592615936159461595615966159761598615996160061601616026160361604616056160661607616086160961610616116161261613616146161561616616176161861619616206162161622616236162461625616266162761628616296163061631616326163361634616356163661637616386163961640616416164261643616446164561646616476164861649616506165161652616536165461655616566165761658616596166061661616626166361664616656166661667616686166961670616716167261673616746167561676616776167861679616806168161682616836168461685616866168761688616896169061691616926169361694616956169661697616986169961700617016170261703617046170561706617076170861709617106171161712617136171461715617166171761718617196172061721617226172361724617256172661727617286172961730617316173261733617346173561736617376173861739617406174161742617436174461745617466174761748617496175061751617526175361754617556175661757617586175961760617616176261763617646176561766617676176861769617706177161772617736177461775617766177761778617796178061781617826178361784617856178661787617886178961790617916179261793617946179561796617976179861799618006180161802618036180461805618066180761808618096181061811618126181361814618156181661817618186181961820618216182261823618246182561826618276182861829618306183161832618336183461835618366183761838618396184061841618426184361844618456184661847618486184961850618516185261853618546185561856618576185861859618606186161862618636186461865618666186761868618696187061871618726187361874618756187661877618786187961880618816188261883618846188561886618876188861889618906189161892618936189461895618966189761898618996190061901619026190361904619056190661907619086190961910619116191261913619146191561916619176191861919619206192161922619236192461925619266192761928619296193061931619326193361934619356193661937619386193961940619416194261943619446194561946619476194861949619506195161952619536195461955619566195761958619596196061961619626196361964619656196661967619686196961970619716197261973619746197561976619776197861979619806198161982619836198461985619866198761988619896199061991619926199361994619956199661997619986199962000620016200262003620046200562006620076200862009620106201162012620136201462015620166201762018620196202062021620226202362024620256202662027620286202962030620316203262033620346203562036620376203862039620406204162042620436204462045620466204762048620496205062051620526205362054620556205662057620586205962060620616206262063620646206562066620676206862069620706207162072620736207462075620766207762078620796208062081620826208362084620856208662087620886208962090620916209262093620946209562096620976209862099621006210162102621036210462105621066210762108621096211062111621126211362114621156211662117621186211962120621216212262123621246212562126621276212862129621306213162132621336213462135621366213762138621396214062141621426214362144621456214662147621486214962150621516215262153621546215562156621576215862159621606216162162621636216462165621666216762168621696217062171621726217362174621756217662177621786217962180621816218262183621846218562186621876218862189621906219162192621936219462195621966219762198621996220062201622026220362204622056220662207622086220962210622116221262213622146221562216622176221862219622206222162222622236222462225622266222762228622296223062231622326223362234622356223662237622386223962240622416224262243622446224562246622476224862249622506225162252622536225462255622566225762258622596226062261622626226362264622656226662267622686226962270622716227262273622746227562276622776227862279622806228162282622836228462285622866228762288622896229062291622926229362294622956229662297622986229962300623016230262303623046230562306623076230862309623106231162312623136231462315623166231762318623196232062321623226232362324623256232662327623286232962330623316233262333623346233562336623376233862339623406234162342623436234462345623466234762348623496235062351623526235362354623556235662357623586235962360623616236262363623646236562366623676236862369623706237162372623736237462375623766237762378623796238062381623826238362384623856238662387623886238962390623916239262393623946239562396623976239862399624006240162402624036240462405624066240762408624096241062411624126241362414624156241662417624186241962420624216242262423624246242562426624276242862429624306243162432624336243462435624366243762438624396244062441624426244362444624456244662447624486244962450624516245262453624546245562456624576245862459624606246162462624636246462465624666246762468624696247062471624726247362474624756247662477624786247962480624816248262483624846248562486624876248862489624906249162492624936249462495624966249762498624996250062501625026250362504625056250662507625086250962510625116251262513625146251562516625176251862519625206252162522625236252462525625266252762528625296253062531625326253362534625356253662537625386253962540625416254262543625446254562546625476254862549625506255162552625536255462555625566255762558625596256062561625626256362564625656256662567625686256962570625716257262573625746257562576625776257862579625806258162582625836258462585625866258762588625896259062591625926259362594625956259662597625986259962600626016260262603626046260562606626076260862609626106261162612626136261462615626166261762618626196262062621626226262362624626256262662627626286262962630626316263262633626346263562636626376263862639626406264162642626436264462645626466264762648626496265062651626526265362654626556265662657626586265962660626616266262663626646266562666626676266862669626706267162672626736267462675626766267762678626796268062681626826268362684626856268662687626886268962690626916269262693626946269562696626976269862699627006270162702627036270462705627066270762708627096271062711627126271362714627156271662717627186271962720627216272262723627246272562726627276272862729627306273162732627336273462735627366273762738627396274062741627426274362744627456274662747627486274962750627516275262753627546275562756627576275862759627606276162762627636276462765627666276762768627696277062771627726277362774627756277662777627786277962780627816278262783627846278562786627876278862789627906279162792627936279462795627966279762798627996280062801628026280362804628056280662807628086280962810628116281262813628146281562816628176281862819628206282162822628236282462825628266282762828628296283062831628326283362834628356283662837628386283962840628416284262843628446284562846628476284862849628506285162852628536285462855628566285762858628596286062861628626286362864628656286662867628686286962870628716287262873628746287562876628776287862879628806288162882628836288462885628866288762888628896289062891628926289362894628956289662897628986289962900629016290262903629046290562906629076290862909629106291162912629136291462915629166291762918629196292062921629226292362924629256292662927629286292962930629316293262933629346293562936629376293862939629406294162942629436294462945629466294762948629496295062951629526295362954629556295662957629586295962960629616296262963629646296562966629676296862969629706297162972629736297462975629766297762978629796298062981629826298362984629856298662987629886298962990629916299262993629946299562996629976299862999630006300163002630036300463005630066300763008630096301063011630126301363014630156301663017630186301963020630216302263023630246302563026630276302863029630306303163032630336303463035630366303763038630396304063041630426304363044630456304663047630486304963050630516305263053630546305563056630576305863059630606306163062630636306463065630666306763068630696307063071630726307363074630756307663077630786307963080630816308263083630846308563086630876308863089630906309163092630936309463095630966309763098630996310063101631026310363104631056310663107631086310963110631116311263113631146311563116631176311863119631206312163122631236312463125631266312763128631296313063131631326313363134631356313663137631386313963140631416314263143631446314563146631476314863149631506315163152631536315463155631566315763158631596316063161631626316363164631656316663167631686316963170631716317263173631746317563176631776317863179631806318163182631836318463185631866318763188631896319063191631926319363194631956319663197631986319963200632016320263203632046320563206632076320863209632106321163212632136321463215632166321763218632196322063221632226322363224632256322663227632286322963230632316323263233632346323563236632376323863239632406324163242632436324463245632466324763248632496325063251632526325363254632556325663257632586325963260632616326263263632646326563266632676326863269632706327163272632736327463275632766327763278632796328063281632826328363284632856328663287632886328963290632916329263293632946329563296632976329863299633006330163302633036330463305633066330763308633096331063311633126331363314633156331663317633186331963320633216332263323633246332563326633276332863329633306333163332633336333463335633366333763338633396334063341633426334363344633456334663347633486334963350633516335263353633546335563356633576335863359633606336163362633636336463365633666336763368633696337063371633726337363374633756337663377633786337963380633816338263383633846338563386633876338863389633906339163392633936339463395633966339763398633996340063401634026340363404634056340663407634086340963410634116341263413634146341563416634176341863419634206342163422634236342463425634266342763428634296343063431634326343363434634356343663437634386343963440634416344263443634446344563446634476344863449634506345163452634536345463455634566345763458634596346063461634626346363464634656346663467634686346963470634716347263473634746347563476634776347863479634806348163482634836348463485634866348763488634896349063491634926349363494634956349663497634986349963500635016350263503635046350563506635076350863509635106351163512635136351463515635166351763518635196352063521635226352363524635256352663527635286352963530635316353263533635346353563536635376353863539635406354163542635436354463545635466354763548635496355063551635526355363554635556355663557635586355963560635616356263563635646356563566635676356863569635706357163572635736357463575635766357763578635796358063581635826358363584635856358663587635886358963590635916359263593635946359563596635976359863599636006360163602636036360463605636066360763608636096361063611636126361363614636156361663617636186361963620636216362263623636246362563626636276362863629636306363163632636336363463635636366363763638636396364063641636426364363644636456364663647636486364963650636516365263653636546365563656636576365863659636606366163662636636366463665636666366763668636696367063671636726367363674636756367663677636786367963680636816368263683636846368563686636876368863689636906369163692636936369463695636966369763698636996370063701637026370363704637056370663707637086370963710637116371263713637146371563716637176371863719637206372163722637236372463725637266372763728637296373063731637326373363734637356373663737637386373963740637416374263743637446374563746637476374863749637506375163752637536375463755637566375763758637596376063761637626376363764637656376663767637686376963770637716377263773637746377563776637776377863779637806378163782637836378463785637866378763788637896379063791637926379363794637956379663797637986379963800638016380263803638046380563806638076380863809638106381163812638136381463815638166381763818638196382063821638226382363824638256382663827638286382963830638316383263833638346383563836638376383863839638406384163842638436384463845638466384763848638496385063851638526385363854638556385663857638586385963860638616386263863638646386563866638676386863869638706387163872638736387463875638766387763878638796388063881638826388363884638856388663887638886388963890638916389263893638946389563896638976389863899639006390163902639036390463905639066390763908639096391063911639126391363914639156391663917639186391963920639216392263923639246392563926639276392863929639306393163932639336393463935639366393763938639396394063941639426394363944639456394663947639486394963950639516395263953639546395563956639576395863959639606396163962639636396463965639666396763968639696397063971639726397363974639756397663977639786397963980639816398263983639846398563986639876398863989639906399163992639936399463995639966399763998639996400064001640026400364004640056400664007640086400964010640116401264013640146401564016640176401864019640206402164022640236402464025640266402764028640296403064031640326403364034640356403664037640386403964040640416404264043640446404564046640476404864049640506405164052640536405464055640566405764058640596406064061640626406364064640656406664067640686406964070640716407264073640746407564076640776407864079640806408164082640836408464085640866408764088640896409064091640926409364094640956409664097640986409964100641016410264103641046410564106641076410864109641106411164112641136411464115641166411764118641196412064121641226412364124641256412664127641286412964130641316413264133641346413564136641376413864139641406414164142641436414464145641466414764148641496415064151641526415364154641556415664157641586415964160641616416264163641646416564166641676416864169641706417164172641736417464175641766417764178641796418064181641826418364184641856418664187641886418964190641916419264193641946419564196641976419864199642006420164202642036420464205642066420764208642096421064211642126421364214642156421664217642186421964220642216422264223642246422564226642276422864229642306423164232642336423464235642366423764238642396424064241642426424364244642456424664247642486424964250642516425264253642546425564256642576425864259642606426164262642636426464265642666426764268642696427064271642726427364274642756427664277642786427964280642816428264283642846428564286642876428864289642906429164292642936429464295642966429764298642996430064301643026430364304643056430664307643086430964310643116431264313643146431564316643176431864319643206432164322643236432464325643266432764328643296433064331643326433364334643356433664337643386433964340643416434264343643446434564346643476434864349643506435164352643536435464355643566435764358643596436064361643626436364364643656436664367643686436964370643716437264373643746437564376643776437864379643806438164382643836438464385643866438764388643896439064391643926439364394643956439664397643986439964400644016440264403644046440564406644076440864409644106441164412644136441464415644166441764418644196442064421644226442364424644256442664427644286442964430644316443264433644346443564436644376443864439644406444164442644436444464445644466444764448644496445064451644526445364454644556445664457644586445964460644616446264463644646446564466644676446864469644706447164472644736447464475644766447764478644796448064481644826448364484644856448664487644886448964490644916449264493644946449564496644976449864499645006450164502645036450464505645066450764508645096451064511645126451364514645156451664517645186451964520645216452264523645246452564526645276452864529645306453164532645336453464535645366453764538645396454064541645426454364544645456454664547645486454964550645516455264553645546455564556645576455864559645606456164562645636456464565645666456764568645696457064571645726457364574645756457664577645786457964580645816458264583645846458564586645876458864589645906459164592645936459464595645966459764598645996460064601646026460364604646056460664607646086460964610646116461264613646146461564616646176461864619646206462164622646236462464625646266462764628646296463064631646326463364634646356463664637646386463964640646416464264643646446464564646646476464864649646506465164652646536465464655646566465764658646596466064661646626466364664646656466664667646686466964670646716467264673646746467564676646776467864679646806468164682646836468464685646866468764688646896469064691646926469364694646956469664697646986469964700647016470264703647046470564706647076470864709647106471164712647136471464715647166471764718647196472064721647226472364724647256472664727647286472964730647316473264733647346473564736647376473864739647406474164742647436474464745647466474764748647496475064751647526475364754647556475664757647586475964760647616476264763647646476564766647676476864769647706477164772647736477464775647766477764778647796478064781647826478364784647856478664787647886478964790647916479264793647946479564796647976479864799648006480164802648036480464805648066480764808648096481064811648126481364814648156481664817648186481964820648216482264823648246482564826648276482864829648306483164832648336483464835648366483764838648396484064841648426484364844648456484664847648486484964850648516485264853648546485564856648576485864859648606486164862648636486464865648666486764868648696487064871648726487364874648756487664877648786487964880648816488264883648846488564886648876488864889648906489164892648936489464895648966489764898648996490064901649026490364904649056490664907649086490964910649116491264913649146491564916649176491864919649206492164922649236492464925649266492764928649296493064931649326493364934649356493664937649386493964940649416494264943649446494564946649476494864949649506495164952649536495464955649566495764958649596496064961649626496364964649656496664967649686496964970649716497264973649746497564976649776497864979649806498164982649836498464985649866498764988649896499064991649926499364994649956499664997649986499965000650016500265003650046500565006650076500865009650106501165012650136501465015650166501765018650196502065021650226502365024650256502665027650286502965030650316503265033650346503565036650376503865039650406504165042650436504465045650466504765048650496505065051650526505365054650556505665057650586505965060650616506265063650646506565066650676506865069650706507165072650736507465075650766507765078650796508065081650826508365084650856508665087650886508965090650916509265093650946509565096650976509865099651006510165102651036510465105651066510765108651096511065111651126511365114651156511665117651186511965120651216512265123651246512565126651276512865129651306513165132651336513465135651366513765138651396514065141651426514365144651456514665147651486514965150651516515265153651546515565156651576515865159651606516165162651636516465165651666516765168651696517065171651726517365174651756517665177651786517965180651816518265183651846518565186651876518865189651906519165192651936519465195651966519765198651996520065201652026520365204652056520665207652086520965210652116521265213652146521565216652176521865219652206522165222652236522465225652266522765228652296523065231652326523365234652356523665237652386523965240652416524265243652446524565246652476524865249652506525165252652536525465255652566525765258652596526065261652626526365264652656526665267652686526965270652716527265273652746527565276652776527865279652806528165282652836528465285652866528765288652896529065291652926529365294652956529665297652986529965300653016530265303653046530565306653076530865309653106531165312653136531465315653166531765318653196532065321653226532365324653256532665327653286532965330653316533265333653346533565336653376533865339653406534165342653436534465345653466534765348653496535065351653526535365354653556535665357653586535965360653616536265363653646536565366653676536865369653706537165372653736537465375653766537765378653796538065381653826538365384653856538665387653886538965390653916539265393653946539565396653976539865399654006540165402654036540465405654066540765408654096541065411654126541365414654156541665417654186541965420654216542265423654246542565426654276542865429654306543165432654336543465435654366543765438654396544065441654426544365444654456544665447654486544965450654516545265453654546545565456654576545865459654606546165462654636546465465654666546765468654696547065471654726547365474654756547665477654786547965480654816548265483654846548565486654876548865489654906549165492654936549465495654966549765498654996550065501655026550365504655056550665507655086550965510655116551265513655146551565516655176551865519655206552165522655236552465525655266552765528655296553065531655326553365534655356553665537655386553965540655416554265543655446554565546655476554865549655506555165552655536555465555655566555765558655596556065561655626556365564655656556665567655686556965570655716557265573655746557565576655776557865579655806558165582655836558465585655866558765588655896559065591655926559365594655956559665597655986559965600656016560265603656046560565606656076560865609656106561165612656136561465615656166561765618656196562065621656226562365624656256562665627656286562965630656316563265633656346563565636656376563865639656406564165642656436564465645656466564765648656496565065651656526565365654656556565665657656586565965660656616566265663656646566565666656676566865669656706567165672656736567465675656766567765678656796568065681656826568365684656856568665687656886568965690656916569265693656946569565696656976569865699657006570165702657036570465705657066570765708657096571065711657126571365714657156571665717657186571965720657216572265723657246572565726657276572865729657306573165732657336573465735657366573765738657396574065741657426574365744657456574665747657486574965750657516575265753657546575565756657576575865759657606576165762657636576465765657666576765768657696577065771657726577365774657756577665777657786577965780657816578265783657846578565786657876578865789657906579165792657936579465795657966579765798657996580065801658026580365804658056580665807658086580965810658116581265813658146581565816658176581865819658206582165822658236582465825658266582765828658296583065831658326583365834658356583665837658386583965840658416584265843658446584565846658476584865849658506585165852658536585465855658566585765858658596586065861658626586365864658656586665867658686586965870658716587265873658746587565876658776587865879658806588165882658836588465885658866588765888658896589065891658926589365894658956589665897658986589965900659016590265903659046590565906659076590865909659106591165912659136591465915659166591765918659196592065921659226592365924659256592665927659286592965930659316593265933659346593565936659376593865939659406594165942659436594465945659466594765948659496595065951659526595365954659556595665957659586595965960659616596265963659646596565966659676596865969659706597165972659736597465975659766597765978659796598065981659826598365984659856598665987659886598965990659916599265993659946599565996659976599865999660006600166002660036600466005660066600766008660096601066011660126601366014660156601666017660186601966020660216602266023660246602566026660276602866029660306603166032660336603466035660366603766038660396604066041660426604366044660456604666047660486604966050660516605266053660546605566056660576605866059660606606166062660636606466065660666606766068660696607066071660726607366074660756607666077660786607966080660816608266083660846608566086660876608866089660906609166092660936609466095660966609766098660996610066101661026610366104661056610666107661086610966110661116611266113661146611566116661176611866119661206612166122661236612466125661266612766128661296613066131661326613366134661356613666137661386613966140661416614266143661446614566146661476614866149661506615166152661536615466155661566615766158661596616066161661626616366164661656616666167661686616966170661716617266173661746617566176661776617866179661806618166182661836618466185661866618766188661896619066191661926619366194661956619666197661986619966200662016620266203662046620566206662076620866209662106621166212662136621466215662166621766218662196622066221662226622366224662256622666227662286622966230662316623266233662346623566236662376623866239662406624166242662436624466245662466624766248662496625066251662526625366254662556625666257662586625966260662616626266263662646626566266662676626866269662706627166272662736627466275662766627766278662796628066281662826628366284662856628666287662886628966290662916629266293662946629566296662976629866299663006630166302663036630466305663066630766308663096631066311663126631366314663156631666317663186631966320663216632266323663246632566326663276632866329663306633166332663336633466335663366633766338663396634066341663426634366344663456634666347663486634966350663516635266353663546635566356663576635866359663606636166362663636636466365663666636766368663696637066371663726637366374663756637666377663786637966380663816638266383663846638566386663876638866389663906639166392663936639466395663966639766398663996640066401664026640366404664056640666407664086640966410664116641266413664146641566416664176641866419664206642166422664236642466425664266642766428664296643066431664326643366434664356643666437664386643966440664416644266443664446644566446664476644866449664506645166452664536645466455664566645766458664596646066461664626646366464664656646666467664686646966470664716647266473664746647566476664776647866479664806648166482664836648466485664866648766488664896649066491664926649366494664956649666497664986649966500665016650266503665046650566506665076650866509665106651166512665136651466515665166651766518665196652066521665226652366524665256652666527665286652966530665316653266533665346653566536665376653866539665406654166542665436654466545665466654766548665496655066551665526655366554665556655666557665586655966560665616656266563665646656566566665676656866569665706657166572665736657466575665766657766578665796658066581665826658366584665856658666587665886658966590665916659266593665946659566596665976659866599666006660166602666036660466605666066660766608666096661066611666126661366614666156661666617666186661966620666216662266623666246662566626666276662866629666306663166632666336663466635666366663766638666396664066641666426664366644666456664666647666486664966650666516665266653666546665566656666576665866659666606666166662666636666466665666666666766668666696667066671666726667366674666756667666677666786667966680666816668266683666846668566686666876668866689666906669166692666936669466695666966669766698666996670066701667026670366704667056670666707667086670966710667116671266713667146671566716667176671866719667206672166722667236672466725667266672766728667296673066731667326673366734667356673666737667386673966740667416674266743667446674566746667476674866749667506675166752667536675466755667566675766758667596676066761667626676366764667656676666767667686676966770667716677266773667746677566776667776677866779667806678166782667836678466785667866678766788667896679066791667926679366794667956679666797667986679966800668016680266803668046680566806668076680866809668106681166812668136681466815668166681766818668196682066821668226682366824668256682666827668286682966830668316683266833668346683566836668376683866839668406684166842668436684466845668466684766848668496685066851668526685366854668556685666857668586685966860668616686266863668646686566866668676686866869668706687166872668736687466875668766687766878668796688066881668826688366884668856688666887668886688966890668916689266893668946689566896668976689866899669006690166902669036690466905669066690766908669096691066911669126691366914669156691666917669186691966920669216692266923669246692566926669276692866929669306693166932669336693466935669366693766938669396694066941669426694366944669456694666947669486694966950669516695266953669546695566956669576695866959669606696166962669636696466965669666696766968669696697066971669726697366974669756697666977669786697966980669816698266983669846698566986669876698866989669906699166992669936699466995669966699766998669996700067001670026700367004670056700667007670086700967010670116701267013670146701567016670176701867019670206702167022670236702467025670266702767028670296703067031670326703367034670356703667037670386703967040670416704267043670446704567046670476704867049670506705167052670536705467055670566705767058670596706067061670626706367064670656706667067670686706967070670716707267073670746707567076670776707867079670806708167082670836708467085670866708767088670896709067091670926709367094670956709667097670986709967100671016710267103671046710567106671076710867109671106711167112671136711467115671166711767118671196712067121671226712367124671256712667127671286712967130671316713267133671346713567136671376713867139671406714167142671436714467145671466714767148671496715067151671526715367154671556715667157671586715967160671616716267163671646716567166671676716867169671706717167172671736717467175671766717767178671796718067181671826718367184671856718667187671886718967190671916719267193671946719567196671976719867199672006720167202672036720467205672066720767208672096721067211672126721367214672156721667217672186721967220672216722267223672246722567226672276722867229672306723167232672336723467235672366723767238672396724067241672426724367244672456724667247672486724967250672516725267253672546725567256672576725867259672606726167262672636726467265672666726767268672696727067271672726727367274672756727667277672786727967280672816728267283672846728567286672876728867289672906729167292672936729467295672966729767298672996730067301673026730367304673056730667307673086730967310673116731267313673146731567316673176731867319673206732167322673236732467325673266732767328673296733067331673326733367334673356733667337673386733967340673416734267343673446734567346673476734867349673506735167352673536735467355673566735767358673596736067361673626736367364673656736667367673686736967370673716737267373673746737567376673776737867379673806738167382673836738467385673866738767388673896739067391673926739367394673956739667397673986739967400674016740267403674046740567406674076740867409674106741167412674136741467415674166741767418674196742067421674226742367424674256742667427674286742967430674316743267433674346743567436674376743867439674406744167442674436744467445674466744767448674496745067451674526745367454674556745667457674586745967460674616746267463674646746567466674676746867469674706747167472674736747467475674766747767478674796748067481674826748367484674856748667487674886748967490674916749267493674946749567496674976749867499675006750167502675036750467505675066750767508675096751067511675126751367514675156751667517675186751967520675216752267523675246752567526675276752867529675306753167532675336753467535675366753767538675396754067541675426754367544675456754667547675486754967550675516755267553675546755567556675576755867559675606756167562675636756467565675666756767568675696757067571675726757367574675756757667577675786757967580675816758267583675846758567586675876758867589675906759167592675936759467595675966759767598675996760067601676026760367604676056760667607676086760967610676116761267613676146761567616676176761867619676206762167622676236762467625676266762767628676296763067631676326763367634676356763667637676386763967640676416764267643676446764567646676476764867649676506765167652676536765467655676566765767658676596766067661676626766367664676656766667667676686766967670676716767267673676746767567676676776767867679676806768167682676836768467685676866768767688676896769067691676926769367694676956769667697676986769967700677016770267703677046770567706677076770867709677106771167712677136771467715677166771767718677196772067721677226772367724677256772667727677286772967730677316773267733677346773567736677376773867739677406774167742677436774467745677466774767748677496775067751677526775367754677556775667757677586775967760677616776267763677646776567766677676776867769677706777167772677736777467775677766777767778677796778067781677826778367784677856778667787677886778967790677916779267793677946779567796677976779867799678006780167802678036780467805678066780767808678096781067811678126781367814678156781667817678186781967820678216782267823678246782567826678276782867829678306783167832678336783467835678366783767838678396784067841678426784367844678456784667847678486784967850678516785267853678546785567856678576785867859678606786167862678636786467865678666786767868678696787067871678726787367874678756787667877678786787967880678816788267883678846788567886678876788867889678906789167892678936789467895678966789767898678996790067901679026790367904679056790667907679086790967910679116791267913679146791567916679176791867919679206792167922679236792467925679266792767928679296793067931679326793367934679356793667937679386793967940679416794267943679446794567946679476794867949679506795167952679536795467955679566795767958679596796067961679626796367964679656796667967679686796967970679716797267973679746797567976679776797867979679806798167982679836798467985679866798767988679896799067991679926799367994679956799667997679986799968000680016800268003680046800568006680076800868009680106801168012680136801468015680166801768018680196802068021680226802368024680256802668027680286802968030680316803268033680346803568036680376803868039680406804168042680436804468045680466804768048680496805068051680526805368054680556805668057680586805968060680616806268063680646806568066680676806868069680706807168072680736807468075680766807768078680796808068081680826808368084680856808668087680886808968090680916809268093680946809568096680976809868099681006810168102681036810468105681066810768108681096811068111681126811368114681156811668117681186811968120681216812268123681246812568126681276812868129681306813168132681336813468135681366813768138681396814068141681426814368144681456814668147681486814968150681516815268153681546815568156681576815868159681606816168162681636816468165681666816768168681696817068171681726817368174681756817668177681786817968180681816818268183681846818568186681876818868189681906819168192681936819468195681966819768198681996820068201682026820368204682056820668207682086820968210682116821268213682146821568216682176821868219682206822168222682236822468225682266822768228682296823068231682326823368234682356823668237682386823968240682416824268243682446824568246682476824868249682506825168252682536825468255682566825768258682596826068261682626826368264682656826668267682686826968270682716827268273682746827568276682776827868279682806828168282682836828468285682866828768288682896829068291682926829368294682956829668297682986829968300683016830268303683046830568306683076830868309683106831168312683136831468315683166831768318683196832068321683226832368324683256832668327683286832968330683316833268333683346833568336683376833868339683406834168342683436834468345683466834768348683496835068351683526835368354683556835668357683586835968360683616836268363683646836568366683676836868369683706837168372683736837468375683766837768378683796838068381683826838368384683856838668387683886838968390683916839268393683946839568396683976839868399684006840168402684036840468405684066840768408684096841068411684126841368414684156841668417684186841968420684216842268423684246842568426684276842868429684306843168432684336843468435684366843768438684396844068441684426844368444684456844668447684486844968450684516845268453684546845568456684576845868459684606846168462684636846468465684666846768468684696847068471684726847368474684756847668477684786847968480684816848268483684846848568486684876848868489684906849168492684936849468495684966849768498684996850068501685026850368504685056850668507685086850968510685116851268513685146851568516685176851868519685206852168522685236852468525685266852768528685296853068531685326853368534685356853668537685386853968540685416854268543685446854568546685476854868549685506855168552685536855468555685566855768558685596856068561685626856368564685656856668567685686856968570685716857268573685746857568576685776857868579685806858168582685836858468585685866858768588685896859068591685926859368594685956859668597685986859968600686016860268603686046860568606686076860868609686106861168612686136861468615686166861768618686196862068621686226862368624686256862668627686286862968630686316863268633686346863568636686376863868639686406864168642686436864468645686466864768648686496865068651686526865368654686556865668657686586865968660686616866268663686646866568666686676866868669686706867168672686736867468675686766867768678686796868068681686826868368684686856868668687686886868968690686916869268693686946869568696686976869868699687006870168702687036870468705687066870768708687096871068711687126871368714687156871668717687186871968720687216872268723687246872568726
  1. declare module BABYLON {
  2. /** Alias type for value that can be null */
  3. export type Nullable<T> = T | null;
  4. /**
  5. * Alias type for number that are floats
  6. * @ignorenaming
  7. */
  8. export type float = number;
  9. /**
  10. * Alias type for number that are doubles.
  11. * @ignorenaming
  12. */
  13. export type double = number;
  14. /**
  15. * Alias type for number that are integer
  16. * @ignorenaming
  17. */
  18. export type int = number;
  19. /** Alias type for number array or Float32Array */
  20. export type FloatArray = number[] | Float32Array;
  21. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  22. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  23. /**
  24. * Alias for types that can be used by a Buffer or VertexBuffer.
  25. */
  26. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  27. /**
  28. * Alias type for primitive types
  29. * @ignorenaming
  30. */
  31. type Primitive = undefined | null | boolean | string | number | Function;
  32. /**
  33. * Type modifier to make all the properties of an object Readonly
  34. */
  35. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  36. /**
  37. * Type modifier to make all the properties of an object Readonly recursively
  38. */
  39. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  40. /** @hidden */
  41. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  42. }
  43. /** @hidden */
  44. /** @hidden */
  45. type DeepImmutableObject<T> = {
  46. readonly [K in keyof T]: DeepImmutable<T[K]>;
  47. };
  48. }
  49. declare module BABYLON {
  50. /**
  51. * Class containing a set of static utilities functions for arrays.
  52. */
  53. export class ArrayTools {
  54. /**
  55. * Returns an array of the given size filled with element built from the given constructor and the paramters
  56. * @param size the number of element to construct and put in the array
  57. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  58. * @returns a new array filled with new objects
  59. */
  60. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  61. }
  62. }
  63. declare module BABYLON {
  64. /**
  65. * Scalar computation library
  66. */
  67. export class Scalar {
  68. /**
  69. * Two pi constants convenient for computation.
  70. */
  71. static TwoPi: number;
  72. /**
  73. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  74. * @param a number
  75. * @param b number
  76. * @param epsilon (default = 1.401298E-45)
  77. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  78. */
  79. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  80. /**
  81. * Returns a string : the upper case translation of the number i to hexadecimal.
  82. * @param i number
  83. * @returns the upper case translation of the number i to hexadecimal.
  84. */
  85. static ToHex(i: number): string;
  86. /**
  87. * Returns -1 if value is negative and +1 is value is positive.
  88. * @param value the value
  89. * @returns the value itself if it's equal to zero.
  90. */
  91. static Sign(value: number): number;
  92. /**
  93. * Returns the value itself if it's between min and max.
  94. * Returns min if the value is lower than min.
  95. * Returns max if the value is greater than max.
  96. * @param value the value to clmap
  97. * @param min the min value to clamp to (default: 0)
  98. * @param max the max value to clamp to (default: 1)
  99. * @returns the clamped value
  100. */
  101. static Clamp(value: number, min?: number, max?: number): number;
  102. /**
  103. * the log2 of value.
  104. * @param value the value to compute log2 of
  105. * @returns the log2 of value.
  106. */
  107. static Log2(value: number): number;
  108. /**
  109. * Loops the value, so that it is never larger than length and never smaller than 0.
  110. *
  111. * This is similar to the modulo operator but it works with floating point numbers.
  112. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  113. * With t = 5 and length = 2.5, the result would be 0.0.
  114. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  115. * @param value the value
  116. * @param length the length
  117. * @returns the looped value
  118. */
  119. static Repeat(value: number, length: number): number;
  120. /**
  121. * Normalize the value between 0.0 and 1.0 using min and max values
  122. * @param value value to normalize
  123. * @param min max to normalize between
  124. * @param max min to normalize between
  125. * @returns the normalized value
  126. */
  127. static Normalize(value: number, min: number, max: number): number;
  128. /**
  129. * Denormalize the value from 0.0 and 1.0 using min and max values
  130. * @param normalized value to denormalize
  131. * @param min max to denormalize between
  132. * @param max min to denormalize between
  133. * @returns the denormalized value
  134. */
  135. static Denormalize(normalized: number, min: number, max: number): number;
  136. /**
  137. * Calculates the shortest difference between two given angles given in degrees.
  138. * @param current current angle in degrees
  139. * @param target target angle in degrees
  140. * @returns the delta
  141. */
  142. static DeltaAngle(current: number, target: number): number;
  143. /**
  144. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  145. * @param tx value
  146. * @param length length
  147. * @returns The returned value will move back and forth between 0 and length
  148. */
  149. static PingPong(tx: number, length: number): number;
  150. /**
  151. * Interpolates between min and max with smoothing at the limits.
  152. *
  153. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  154. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  155. * @param from from
  156. * @param to to
  157. * @param tx value
  158. * @returns the smooth stepped value
  159. */
  160. static SmoothStep(from: number, to: number, tx: number): number;
  161. /**
  162. * Moves a value current towards target.
  163. *
  164. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  165. * Negative values of maxDelta pushes the value away from target.
  166. * @param current current value
  167. * @param target target value
  168. * @param maxDelta max distance to move
  169. * @returns resulting value
  170. */
  171. static MoveTowards(current: number, target: number, maxDelta: number): number;
  172. /**
  173. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  174. *
  175. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  176. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  177. * @param current current value
  178. * @param target target value
  179. * @param maxDelta max distance to move
  180. * @returns resulting angle
  181. */
  182. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  183. /**
  184. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  185. * @param start start value
  186. * @param end target value
  187. * @param amount amount to lerp between
  188. * @returns the lerped value
  189. */
  190. static Lerp(start: number, end: number, amount: number): number;
  191. /**
  192. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  193. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  194. * @param start start value
  195. * @param end target value
  196. * @param amount amount to lerp between
  197. * @returns the lerped value
  198. */
  199. static LerpAngle(start: number, end: number, amount: number): number;
  200. /**
  201. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  202. * @param a start value
  203. * @param b target value
  204. * @param value value between a and b
  205. * @returns the inverseLerp value
  206. */
  207. static InverseLerp(a: number, b: number, value: number): number;
  208. /**
  209. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  210. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  211. * @param value1 spline value
  212. * @param tangent1 spline value
  213. * @param value2 spline value
  214. * @param tangent2 spline value
  215. * @param amount input value
  216. * @returns hermite result
  217. */
  218. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  219. /**
  220. * Returns a random float number between and min and max values
  221. * @param min min value of random
  222. * @param max max value of random
  223. * @returns random value
  224. */
  225. static RandomRange(min: number, max: number): number;
  226. /**
  227. * This function returns percentage of a number in a given range.
  228. *
  229. * RangeToPercent(40,20,60) will return 0.5 (50%)
  230. * RangeToPercent(34,0,100) will return 0.34 (34%)
  231. * @param number to convert to percentage
  232. * @param min min range
  233. * @param max max range
  234. * @returns the percentage
  235. */
  236. static RangeToPercent(number: number, min: number, max: number): number;
  237. /**
  238. * This function returns number that corresponds to the percentage in a given range.
  239. *
  240. * PercentToRange(0.34,0,100) will return 34.
  241. * @param percent to convert to number
  242. * @param min min range
  243. * @param max max range
  244. * @returns the number
  245. */
  246. static PercentToRange(percent: number, min: number, max: number): number;
  247. /**
  248. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  249. * @param angle The angle to normalize in radian.
  250. * @return The converted angle.
  251. */
  252. static NormalizeRadians(angle: number): number;
  253. }
  254. }
  255. declare module BABYLON {
  256. /**
  257. * Constant used to convert a value to gamma space
  258. * @ignorenaming
  259. */
  260. export const ToGammaSpace: number;
  261. /**
  262. * Constant used to convert a value to linear space
  263. * @ignorenaming
  264. */
  265. export const ToLinearSpace = 2.2;
  266. /**
  267. * Constant used to define the minimal number value in Babylon.js
  268. * @ignorenaming
  269. */
  270. let Epsilon: number;
  271. /**
  272. * Class used to hold a RBG color
  273. */
  274. export class Color3 {
  275. /**
  276. * Defines the red component (between 0 and 1, default is 0)
  277. */
  278. r: number;
  279. /**
  280. * Defines the green component (between 0 and 1, default is 0)
  281. */
  282. g: number;
  283. /**
  284. * Defines the blue component (between 0 and 1, default is 0)
  285. */
  286. b: number;
  287. /**
  288. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  289. * @param r defines the red component (between 0 and 1, default is 0)
  290. * @param g defines the green component (between 0 and 1, default is 0)
  291. * @param b defines the blue component (between 0 and 1, default is 0)
  292. */
  293. constructor(
  294. /**
  295. * Defines the red component (between 0 and 1, default is 0)
  296. */
  297. r?: number,
  298. /**
  299. * Defines the green component (between 0 and 1, default is 0)
  300. */
  301. g?: number,
  302. /**
  303. * Defines the blue component (between 0 and 1, default is 0)
  304. */
  305. b?: number);
  306. /**
  307. * Creates a string with the Color3 current values
  308. * @returns the string representation of the Color3 object
  309. */
  310. toString(): string;
  311. /**
  312. * Returns the string "Color3"
  313. * @returns "Color3"
  314. */
  315. getClassName(): string;
  316. /**
  317. * Compute the Color3 hash code
  318. * @returns an unique number that can be used to hash Color3 objects
  319. */
  320. getHashCode(): number;
  321. /**
  322. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  323. * @param array defines the array where to store the r,g,b components
  324. * @param index defines an optional index in the target array to define where to start storing values
  325. * @returns the current Color3 object
  326. */
  327. toArray(array: FloatArray, index?: number): Color3;
  328. /**
  329. * Returns a new Color4 object from the current Color3 and the given alpha
  330. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  331. * @returns a new Color4 object
  332. */
  333. toColor4(alpha?: number): Color4;
  334. /**
  335. * Returns a new array populated with 3 numeric elements : red, green and blue values
  336. * @returns the new array
  337. */
  338. asArray(): number[];
  339. /**
  340. * Returns the luminance value
  341. * @returns a float value
  342. */
  343. toLuminance(): number;
  344. /**
  345. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  346. * @param otherColor defines the second operand
  347. * @returns the new Color3 object
  348. */
  349. multiply(otherColor: DeepImmutable<Color3>): Color3;
  350. /**
  351. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  352. * @param otherColor defines the second operand
  353. * @param result defines the Color3 object where to store the result
  354. * @returns the current Color3
  355. */
  356. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  357. /**
  358. * Determines equality between Color3 objects
  359. * @param otherColor defines the second operand
  360. * @returns true if the rgb values are equal to the given ones
  361. */
  362. equals(otherColor: DeepImmutable<Color3>): boolean;
  363. /**
  364. * Determines equality between the current Color3 object and a set of r,b,g values
  365. * @param r defines the red component to check
  366. * @param g defines the green component to check
  367. * @param b defines the blue component to check
  368. * @returns true if the rgb values are equal to the given ones
  369. */
  370. equalsFloats(r: number, g: number, b: number): boolean;
  371. /**
  372. * Multiplies in place each rgb value by scale
  373. * @param scale defines the scaling factor
  374. * @returns the updated Color3
  375. */
  376. scale(scale: number): Color3;
  377. /**
  378. * Multiplies the rgb values by scale and stores the result into "result"
  379. * @param scale defines the scaling factor
  380. * @param result defines the Color3 object where to store the result
  381. * @returns the unmodified current Color3
  382. */
  383. scaleToRef(scale: number, result: Color3): Color3;
  384. /**
  385. * Scale the current Color3 values by a factor and add the result to a given Color3
  386. * @param scale defines the scale factor
  387. * @param result defines color to store the result into
  388. * @returns the unmodified current Color3
  389. */
  390. scaleAndAddToRef(scale: number, result: Color3): Color3;
  391. /**
  392. * Clamps the rgb values by the min and max values and stores the result into "result"
  393. * @param min defines minimum clamping value (default is 0)
  394. * @param max defines maximum clamping value (default is 1)
  395. * @param result defines color to store the result into
  396. * @returns the original Color3
  397. */
  398. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  399. /**
  400. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  401. * @param otherColor defines the second operand
  402. * @returns the new Color3
  403. */
  404. add(otherColor: DeepImmutable<Color3>): Color3;
  405. /**
  406. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  407. * @param otherColor defines the second operand
  408. * @param result defines Color3 object to store the result into
  409. * @returns the unmodified current Color3
  410. */
  411. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  412. /**
  413. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  414. * @param otherColor defines the second operand
  415. * @returns the new Color3
  416. */
  417. subtract(otherColor: DeepImmutable<Color3>): Color3;
  418. /**
  419. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  420. * @param otherColor defines the second operand
  421. * @param result defines Color3 object to store the result into
  422. * @returns the unmodified current Color3
  423. */
  424. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  425. /**
  426. * Copy the current object
  427. * @returns a new Color3 copied the current one
  428. */
  429. clone(): Color3;
  430. /**
  431. * Copies the rgb values from the source in the current Color3
  432. * @param source defines the source Color3 object
  433. * @returns the updated Color3 object
  434. */
  435. copyFrom(source: DeepImmutable<Color3>): Color3;
  436. /**
  437. * Updates the Color3 rgb values from the given floats
  438. * @param r defines the red component to read from
  439. * @param g defines the green component to read from
  440. * @param b defines the blue component to read from
  441. * @returns the current Color3 object
  442. */
  443. copyFromFloats(r: number, g: number, b: number): Color3;
  444. /**
  445. * Updates the Color3 rgb values from the given floats
  446. * @param r defines the red component to read from
  447. * @param g defines the green component to read from
  448. * @param b defines the blue component to read from
  449. * @returns the current Color3 object
  450. */
  451. set(r: number, g: number, b: number): Color3;
  452. /**
  453. * Compute the Color3 hexadecimal code as a string
  454. * @returns a string containing the hexadecimal representation of the Color3 object
  455. */
  456. toHexString(): string;
  457. /**
  458. * Computes a new Color3 converted from the current one to linear space
  459. * @returns a new Color3 object
  460. */
  461. toLinearSpace(): Color3;
  462. /**
  463. * Converts current color in rgb space to HSV values
  464. * @returns a new color3 representing the HSV values
  465. */
  466. toHSV(): Color3;
  467. /**
  468. * Converts current color in rgb space to HSV values
  469. * @param result defines the Color3 where to store the HSV values
  470. */
  471. toHSVToRef(result: Color3): void;
  472. /**
  473. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  474. * @param convertedColor defines the Color3 object where to store the linear space version
  475. * @returns the unmodified Color3
  476. */
  477. toLinearSpaceToRef(convertedColor: Color3): Color3;
  478. /**
  479. * Computes a new Color3 converted from the current one to gamma space
  480. * @returns a new Color3 object
  481. */
  482. toGammaSpace(): Color3;
  483. /**
  484. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  485. * @param convertedColor defines the Color3 object where to store the gamma space version
  486. * @returns the unmodified Color3
  487. */
  488. toGammaSpaceToRef(convertedColor: Color3): Color3;
  489. private static _BlackReadOnly;
  490. /**
  491. * Convert Hue, saturation and value to a Color3 (RGB)
  492. * @param hue defines the hue
  493. * @param saturation defines the saturation
  494. * @param value defines the value
  495. * @param result defines the Color3 where to store the RGB values
  496. */
  497. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  498. /**
  499. * Creates a new Color3 from the string containing valid hexadecimal values
  500. * @param hex defines a string containing valid hexadecimal values
  501. * @returns a new Color3 object
  502. */
  503. static FromHexString(hex: string): Color3;
  504. /**
  505. * Creates a new Color3 from the starting index of the given array
  506. * @param array defines the source array
  507. * @param offset defines an offset in the source array
  508. * @returns a new Color3 object
  509. */
  510. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  511. /**
  512. * Creates a new Color3 from integer values (< 256)
  513. * @param r defines the red component to read from (value between 0 and 255)
  514. * @param g defines the green component to read from (value between 0 and 255)
  515. * @param b defines the blue component to read from (value between 0 and 255)
  516. * @returns a new Color3 object
  517. */
  518. static FromInts(r: number, g: number, b: number): Color3;
  519. /**
  520. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  521. * @param start defines the start Color3 value
  522. * @param end defines the end Color3 value
  523. * @param amount defines the gradient value between start and end
  524. * @returns a new Color3 object
  525. */
  526. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  527. /**
  528. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  529. * @param left defines the start value
  530. * @param right defines the end value
  531. * @param amount defines the gradient factor
  532. * @param result defines the Color3 object where to store the result
  533. */
  534. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  535. /**
  536. * Returns a Color3 value containing a red color
  537. * @returns a new Color3 object
  538. */
  539. static Red(): Color3;
  540. /**
  541. * Returns a Color3 value containing a green color
  542. * @returns a new Color3 object
  543. */
  544. static Green(): Color3;
  545. /**
  546. * Returns a Color3 value containing a blue color
  547. * @returns a new Color3 object
  548. */
  549. static Blue(): Color3;
  550. /**
  551. * Returns a Color3 value containing a black color
  552. * @returns a new Color3 object
  553. */
  554. static Black(): Color3;
  555. /**
  556. * Gets a Color3 value containing a black color that must not be updated
  557. */
  558. static readonly BlackReadOnly: DeepImmutable<Color3>;
  559. /**
  560. * Returns a Color3 value containing a white color
  561. * @returns a new Color3 object
  562. */
  563. static White(): Color3;
  564. /**
  565. * Returns a Color3 value containing a purple color
  566. * @returns a new Color3 object
  567. */
  568. static Purple(): Color3;
  569. /**
  570. * Returns a Color3 value containing a magenta color
  571. * @returns a new Color3 object
  572. */
  573. static Magenta(): Color3;
  574. /**
  575. * Returns a Color3 value containing a yellow color
  576. * @returns a new Color3 object
  577. */
  578. static Yellow(): Color3;
  579. /**
  580. * Returns a Color3 value containing a gray color
  581. * @returns a new Color3 object
  582. */
  583. static Gray(): Color3;
  584. /**
  585. * Returns a Color3 value containing a teal color
  586. * @returns a new Color3 object
  587. */
  588. static Teal(): Color3;
  589. /**
  590. * Returns a Color3 value containing a random color
  591. * @returns a new Color3 object
  592. */
  593. static Random(): Color3;
  594. }
  595. /**
  596. * Class used to hold a RBGA color
  597. */
  598. export class Color4 {
  599. /**
  600. * Defines the red component (between 0 and 1, default is 0)
  601. */
  602. r: number;
  603. /**
  604. * Defines the green component (between 0 and 1, default is 0)
  605. */
  606. g: number;
  607. /**
  608. * Defines the blue component (between 0 and 1, default is 0)
  609. */
  610. b: number;
  611. /**
  612. * Defines the alpha component (between 0 and 1, default is 1)
  613. */
  614. a: number;
  615. /**
  616. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  617. * @param r defines the red component (between 0 and 1, default is 0)
  618. * @param g defines the green component (between 0 and 1, default is 0)
  619. * @param b defines the blue component (between 0 and 1, default is 0)
  620. * @param a defines the alpha component (between 0 and 1, default is 1)
  621. */
  622. constructor(
  623. /**
  624. * Defines the red component (between 0 and 1, default is 0)
  625. */
  626. r?: number,
  627. /**
  628. * Defines the green component (between 0 and 1, default is 0)
  629. */
  630. g?: number,
  631. /**
  632. * Defines the blue component (between 0 and 1, default is 0)
  633. */
  634. b?: number,
  635. /**
  636. * Defines the alpha component (between 0 and 1, default is 1)
  637. */
  638. a?: number);
  639. /**
  640. * Adds in place the given Color4 values to the current Color4 object
  641. * @param right defines the second operand
  642. * @returns the current updated Color4 object
  643. */
  644. addInPlace(right: DeepImmutable<Color4>): Color4;
  645. /**
  646. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  647. * @returns the new array
  648. */
  649. asArray(): number[];
  650. /**
  651. * Stores from the starting index in the given array the Color4 successive values
  652. * @param array defines the array where to store the r,g,b components
  653. * @param index defines an optional index in the target array to define where to start storing values
  654. * @returns the current Color4 object
  655. */
  656. toArray(array: number[], index?: number): Color4;
  657. /**
  658. * Determines equality between Color4 objects
  659. * @param otherColor defines the second operand
  660. * @returns true if the rgba values are equal to the given ones
  661. */
  662. equals(otherColor: DeepImmutable<Color4>): boolean;
  663. /**
  664. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  665. * @param right defines the second operand
  666. * @returns a new Color4 object
  667. */
  668. add(right: DeepImmutable<Color4>): Color4;
  669. /**
  670. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  671. * @param right defines the second operand
  672. * @returns a new Color4 object
  673. */
  674. subtract(right: DeepImmutable<Color4>): Color4;
  675. /**
  676. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  677. * @param right defines the second operand
  678. * @param result defines the Color4 object where to store the result
  679. * @returns the current Color4 object
  680. */
  681. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  682. /**
  683. * Creates a new Color4 with the current Color4 values multiplied by scale
  684. * @param scale defines the scaling factor to apply
  685. * @returns a new Color4 object
  686. */
  687. scale(scale: number): Color4;
  688. /**
  689. * Multiplies the current Color4 values by scale and stores the result in "result"
  690. * @param scale defines the scaling factor to apply
  691. * @param result defines the Color4 object where to store the result
  692. * @returns the current unmodified Color4
  693. */
  694. scaleToRef(scale: number, result: Color4): Color4;
  695. /**
  696. * Scale the current Color4 values by a factor and add the result to a given Color4
  697. * @param scale defines the scale factor
  698. * @param result defines the Color4 object where to store the result
  699. * @returns the unmodified current Color4
  700. */
  701. scaleAndAddToRef(scale: number, result: Color4): Color4;
  702. /**
  703. * Clamps the rgb values by the min and max values and stores the result into "result"
  704. * @param min defines minimum clamping value (default is 0)
  705. * @param max defines maximum clamping value (default is 1)
  706. * @param result defines color to store the result into.
  707. * @returns the cuurent Color4
  708. */
  709. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  710. /**
  711. * Multipy an Color4 value by another and return a new Color4 object
  712. * @param color defines the Color4 value to multiply by
  713. * @returns a new Color4 object
  714. */
  715. multiply(color: Color4): Color4;
  716. /**
  717. * Multipy a Color4 value by another and push the result in a reference value
  718. * @param color defines the Color4 value to multiply by
  719. * @param result defines the Color4 to fill the result in
  720. * @returns the result Color4
  721. */
  722. multiplyToRef(color: Color4, result: Color4): Color4;
  723. /**
  724. * Creates a string with the Color4 current values
  725. * @returns the string representation of the Color4 object
  726. */
  727. toString(): string;
  728. /**
  729. * Returns the string "Color4"
  730. * @returns "Color4"
  731. */
  732. getClassName(): string;
  733. /**
  734. * Compute the Color4 hash code
  735. * @returns an unique number that can be used to hash Color4 objects
  736. */
  737. getHashCode(): number;
  738. /**
  739. * Creates a new Color4 copied from the current one
  740. * @returns a new Color4 object
  741. */
  742. clone(): Color4;
  743. /**
  744. * Copies the given Color4 values into the current one
  745. * @param source defines the source Color4 object
  746. * @returns the current updated Color4 object
  747. */
  748. copyFrom(source: Color4): Color4;
  749. /**
  750. * Copies the given float values into the current one
  751. * @param r defines the red component to read from
  752. * @param g defines the green component to read from
  753. * @param b defines the blue component to read from
  754. * @param a defines the alpha component to read from
  755. * @returns the current updated Color4 object
  756. */
  757. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  758. /**
  759. * Copies the given float values into the current one
  760. * @param r defines the red component to read from
  761. * @param g defines the green component to read from
  762. * @param b defines the blue component to read from
  763. * @param a defines the alpha component to read from
  764. * @returns the current updated Color4 object
  765. */
  766. set(r: number, g: number, b: number, a: number): Color4;
  767. /**
  768. * Compute the Color4 hexadecimal code as a string
  769. * @returns a string containing the hexadecimal representation of the Color4 object
  770. */
  771. toHexString(): string;
  772. /**
  773. * Computes a new Color4 converted from the current one to linear space
  774. * @returns a new Color4 object
  775. */
  776. toLinearSpace(): Color4;
  777. /**
  778. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  779. * @param convertedColor defines the Color4 object where to store the linear space version
  780. * @returns the unmodified Color4
  781. */
  782. toLinearSpaceToRef(convertedColor: Color4): Color4;
  783. /**
  784. * Computes a new Color4 converted from the current one to gamma space
  785. * @returns a new Color4 object
  786. */
  787. toGammaSpace(): Color4;
  788. /**
  789. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  790. * @param convertedColor defines the Color4 object where to store the gamma space version
  791. * @returns the unmodified Color4
  792. */
  793. toGammaSpaceToRef(convertedColor: Color4): Color4;
  794. /**
  795. * Creates a new Color4 from the string containing valid hexadecimal values
  796. * @param hex defines a string containing valid hexadecimal values
  797. * @returns a new Color4 object
  798. */
  799. static FromHexString(hex: string): Color4;
  800. /**
  801. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  802. * @param left defines the start value
  803. * @param right defines the end value
  804. * @param amount defines the gradient factor
  805. * @returns a new Color4 object
  806. */
  807. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  808. /**
  809. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  810. * @param left defines the start value
  811. * @param right defines the end value
  812. * @param amount defines the gradient factor
  813. * @param result defines the Color4 object where to store data
  814. */
  815. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  816. /**
  817. * Creates a new Color4 from a Color3 and an alpha value
  818. * @param color3 defines the source Color3 to read from
  819. * @param alpha defines the alpha component (1.0 by default)
  820. * @returns a new Color4 object
  821. */
  822. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  823. /**
  824. * Creates a new Color4 from the starting index element of the given array
  825. * @param array defines the source array to read from
  826. * @param offset defines the offset in the source array
  827. * @returns a new Color4 object
  828. */
  829. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  830. /**
  831. * Creates a new Color3 from integer values (< 256)
  832. * @param r defines the red component to read from (value between 0 and 255)
  833. * @param g defines the green component to read from (value between 0 and 255)
  834. * @param b defines the blue component to read from (value between 0 and 255)
  835. * @param a defines the alpha component to read from (value between 0 and 255)
  836. * @returns a new Color3 object
  837. */
  838. static FromInts(r: number, g: number, b: number, a: number): Color4;
  839. /**
  840. * Check the content of a given array and convert it to an array containing RGBA data
  841. * If the original array was already containing count * 4 values then it is returned directly
  842. * @param colors defines the array to check
  843. * @param count defines the number of RGBA data to expect
  844. * @returns an array containing count * 4 values (RGBA)
  845. */
  846. static CheckColors4(colors: number[], count: number): number[];
  847. }
  848. /**
  849. * Class representing a vector containing 2 coordinates
  850. */
  851. export class Vector2 {
  852. /** defines the first coordinate */
  853. x: number;
  854. /** defines the second coordinate */
  855. y: number;
  856. /**
  857. * Creates a new Vector2 from the given x and y coordinates
  858. * @param x defines the first coordinate
  859. * @param y defines the second coordinate
  860. */
  861. constructor(
  862. /** defines the first coordinate */
  863. x?: number,
  864. /** defines the second coordinate */
  865. y?: number);
  866. /**
  867. * Gets a string with the Vector2 coordinates
  868. * @returns a string with the Vector2 coordinates
  869. */
  870. toString(): string;
  871. /**
  872. * Gets class name
  873. * @returns the string "Vector2"
  874. */
  875. getClassName(): string;
  876. /**
  877. * Gets current vector hash code
  878. * @returns the Vector2 hash code as a number
  879. */
  880. getHashCode(): number;
  881. /**
  882. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  883. * @param array defines the source array
  884. * @param index defines the offset in source array
  885. * @returns the current Vector2
  886. */
  887. toArray(array: FloatArray, index?: number): Vector2;
  888. /**
  889. * Copy the current vector to an array
  890. * @returns a new array with 2 elements: the Vector2 coordinates.
  891. */
  892. asArray(): number[];
  893. /**
  894. * Sets the Vector2 coordinates with the given Vector2 coordinates
  895. * @param source defines the source Vector2
  896. * @returns the current updated Vector2
  897. */
  898. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  899. /**
  900. * Sets the Vector2 coordinates with the given floats
  901. * @param x defines the first coordinate
  902. * @param y defines the second coordinate
  903. * @returns the current updated Vector2
  904. */
  905. copyFromFloats(x: number, y: number): Vector2;
  906. /**
  907. * Sets the Vector2 coordinates with the given floats
  908. * @param x defines the first coordinate
  909. * @param y defines the second coordinate
  910. * @returns the current updated Vector2
  911. */
  912. set(x: number, y: number): Vector2;
  913. /**
  914. * Add another vector with the current one
  915. * @param otherVector defines the other vector
  916. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  917. */
  918. add(otherVector: DeepImmutable<Vector2>): Vector2;
  919. /**
  920. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  921. * @param otherVector defines the other vector
  922. * @param result defines the target vector
  923. * @returns the unmodified current Vector2
  924. */
  925. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  926. /**
  927. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  928. * @param otherVector defines the other vector
  929. * @returns the current updated Vector2
  930. */
  931. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  932. /**
  933. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  934. * @param otherVector defines the other vector
  935. * @returns a new Vector2
  936. */
  937. addVector3(otherVector: Vector3): Vector2;
  938. /**
  939. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  940. * @param otherVector defines the other vector
  941. * @returns a new Vector2
  942. */
  943. subtract(otherVector: Vector2): Vector2;
  944. /**
  945. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  946. * @param otherVector defines the other vector
  947. * @param result defines the target vector
  948. * @returns the unmodified current Vector2
  949. */
  950. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  951. /**
  952. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  953. * @param otherVector defines the other vector
  954. * @returns the current updated Vector2
  955. */
  956. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  957. /**
  958. * Multiplies in place the current Vector2 coordinates by the given ones
  959. * @param otherVector defines the other vector
  960. * @returns the current updated Vector2
  961. */
  962. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  963. /**
  964. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  965. * @param otherVector defines the other vector
  966. * @returns a new Vector2
  967. */
  968. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  969. /**
  970. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  971. * @param otherVector defines the other vector
  972. * @param result defines the target vector
  973. * @returns the unmodified current Vector2
  974. */
  975. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  976. /**
  977. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  978. * @param x defines the first coordinate
  979. * @param y defines the second coordinate
  980. * @returns a new Vector2
  981. */
  982. multiplyByFloats(x: number, y: number): Vector2;
  983. /**
  984. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  985. * @param otherVector defines the other vector
  986. * @returns a new Vector2
  987. */
  988. divide(otherVector: Vector2): Vector2;
  989. /**
  990. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  991. * @param otherVector defines the other vector
  992. * @param result defines the target vector
  993. * @returns the unmodified current Vector2
  994. */
  995. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  996. /**
  997. * Divides the current Vector2 coordinates by the given ones
  998. * @param otherVector defines the other vector
  999. * @returns the current updated Vector2
  1000. */
  1001. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1002. /**
  1003. * Gets a new Vector2 with current Vector2 negated coordinates
  1004. * @returns a new Vector2
  1005. */
  1006. negate(): Vector2;
  1007. /**
  1008. * Multiply the Vector2 coordinates by scale
  1009. * @param scale defines the scaling factor
  1010. * @returns the current updated Vector2
  1011. */
  1012. scaleInPlace(scale: number): Vector2;
  1013. /**
  1014. * Returns a new Vector2 scaled by "scale" from the current Vector2
  1015. * @param scale defines the scaling factor
  1016. * @returns a new Vector2
  1017. */
  1018. scale(scale: number): Vector2;
  1019. /**
  1020. * Scale the current Vector2 values by a factor to a given Vector2
  1021. * @param scale defines the scale factor
  1022. * @param result defines the Vector2 object where to store the result
  1023. * @returns the unmodified current Vector2
  1024. */
  1025. scaleToRef(scale: number, result: Vector2): Vector2;
  1026. /**
  1027. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  1028. * @param scale defines the scale factor
  1029. * @param result defines the Vector2 object where to store the result
  1030. * @returns the unmodified current Vector2
  1031. */
  1032. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  1033. /**
  1034. * Gets a boolean if two vectors are equals
  1035. * @param otherVector defines the other vector
  1036. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  1037. */
  1038. equals(otherVector: DeepImmutable<Vector2>): boolean;
  1039. /**
  1040. * Gets a boolean if two vectors are equals (using an epsilon value)
  1041. * @param otherVector defines the other vector
  1042. * @param epsilon defines the minimal distance to consider equality
  1043. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  1044. */
  1045. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  1046. /**
  1047. * Gets a new Vector2 from current Vector2 floored values
  1048. * @returns a new Vector2
  1049. */
  1050. floor(): Vector2;
  1051. /**
  1052. * Gets a new Vector2 from current Vector2 floored values
  1053. * @returns a new Vector2
  1054. */
  1055. fract(): Vector2;
  1056. /**
  1057. * Gets the length of the vector
  1058. * @returns the vector length (float)
  1059. */
  1060. length(): number;
  1061. /**
  1062. * Gets the vector squared length
  1063. * @returns the vector squared length (float)
  1064. */
  1065. lengthSquared(): number;
  1066. /**
  1067. * Normalize the vector
  1068. * @returns the current updated Vector2
  1069. */
  1070. normalize(): Vector2;
  1071. /**
  1072. * Gets a new Vector2 copied from the Vector2
  1073. * @returns a new Vector2
  1074. */
  1075. clone(): Vector2;
  1076. /**
  1077. * Gets a new Vector2(0, 0)
  1078. * @returns a new Vector2
  1079. */
  1080. static Zero(): Vector2;
  1081. /**
  1082. * Gets a new Vector2(1, 1)
  1083. * @returns a new Vector2
  1084. */
  1085. static One(): Vector2;
  1086. /**
  1087. * Gets a new Vector2 set from the given index element of the given array
  1088. * @param array defines the data source
  1089. * @param offset defines the offset in the data source
  1090. * @returns a new Vector2
  1091. */
  1092. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  1093. /**
  1094. * Sets "result" from the given index element of the given array
  1095. * @param array defines the data source
  1096. * @param offset defines the offset in the data source
  1097. * @param result defines the target vector
  1098. */
  1099. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  1100. /**
  1101. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  1102. * @param value1 defines 1st point of control
  1103. * @param value2 defines 2nd point of control
  1104. * @param value3 defines 3rd point of control
  1105. * @param value4 defines 4th point of control
  1106. * @param amount defines the interpolation factor
  1107. * @returns a new Vector2
  1108. */
  1109. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  1110. /**
  1111. * Returns a new Vector2 set with same the coordinates than "value" ones if the vector "value" is in the square defined by "min" and "max".
  1112. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  1113. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  1114. * @param value defines the value to clamp
  1115. * @param min defines the lower limit
  1116. * @param max defines the upper limit
  1117. * @returns a new Vector2
  1118. */
  1119. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  1120. /**
  1121. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  1122. * @param value1 defines the 1st control point
  1123. * @param tangent1 defines the outgoing tangent
  1124. * @param value2 defines the 2nd control point
  1125. * @param tangent2 defines the incoming tangent
  1126. * @param amount defines the interpolation factor
  1127. * @returns a new Vector2
  1128. */
  1129. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  1130. /**
  1131. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  1132. * @param start defines the start vector
  1133. * @param end defines the end vector
  1134. * @param amount defines the interpolation factor
  1135. * @returns a new Vector2
  1136. */
  1137. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  1138. /**
  1139. * Gets the dot product of the vector "left" and the vector "right"
  1140. * @param left defines first vector
  1141. * @param right defines second vector
  1142. * @returns the dot product (float)
  1143. */
  1144. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  1145. /**
  1146. * Returns a new Vector2 equal to the normalized given vector
  1147. * @param vector defines the vector to normalize
  1148. * @returns a new Vector2
  1149. */
  1150. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  1151. /**
  1152. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  1153. * @param left defines 1st vector
  1154. * @param right defines 2nd vector
  1155. * @returns a new Vector2
  1156. */
  1157. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1158. /**
  1159. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  1160. * @param left defines 1st vector
  1161. * @param right defines 2nd vector
  1162. * @returns a new Vector2
  1163. */
  1164. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1165. /**
  1166. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  1167. * @param vector defines the vector to transform
  1168. * @param transformation defines the matrix to apply
  1169. * @returns a new Vector2
  1170. */
  1171. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  1172. /**
  1173. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  1174. * @param vector defines the vector to transform
  1175. * @param transformation defines the matrix to apply
  1176. * @param result defines the target vector
  1177. */
  1178. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  1179. /**
  1180. * Determines if a given vector is included in a triangle
  1181. * @param p defines the vector to test
  1182. * @param p0 defines 1st triangle point
  1183. * @param p1 defines 2nd triangle point
  1184. * @param p2 defines 3rd triangle point
  1185. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  1186. */
  1187. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  1188. /**
  1189. * Gets the distance between the vectors "value1" and "value2"
  1190. * @param value1 defines first vector
  1191. * @param value2 defines second vector
  1192. * @returns the distance between vectors
  1193. */
  1194. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1195. /**
  1196. * Returns the squared distance between the vectors "value1" and "value2"
  1197. * @param value1 defines first vector
  1198. * @param value2 defines second vector
  1199. * @returns the squared distance between vectors
  1200. */
  1201. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1202. /**
  1203. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  1204. * @param value1 defines first vector
  1205. * @param value2 defines second vector
  1206. * @returns a new Vector2
  1207. */
  1208. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  1209. /**
  1210. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  1211. * @param p defines the middle point
  1212. * @param segA defines one point of the segment
  1213. * @param segB defines the other point of the segment
  1214. * @returns the shortest distance
  1215. */
  1216. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  1217. }
  1218. /**
  1219. * Classed used to store (x,y,z) vector representation
  1220. * A Vector3 is the main object used in 3D geometry
  1221. * It can represent etiher the coordinates of a point the space, either a direction
  1222. * Reminder: js uses a left handed forward facing system
  1223. */
  1224. export class Vector3 {
  1225. /**
  1226. * Defines the first coordinates (on X axis)
  1227. */
  1228. x: number;
  1229. /**
  1230. * Defines the second coordinates (on Y axis)
  1231. */
  1232. y: number;
  1233. /**
  1234. * Defines the third coordinates (on Z axis)
  1235. */
  1236. z: number;
  1237. private static _UpReadOnly;
  1238. private static _ZeroReadOnly;
  1239. /**
  1240. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  1241. * @param x defines the first coordinates (on X axis)
  1242. * @param y defines the second coordinates (on Y axis)
  1243. * @param z defines the third coordinates (on Z axis)
  1244. */
  1245. constructor(
  1246. /**
  1247. * Defines the first coordinates (on X axis)
  1248. */
  1249. x?: number,
  1250. /**
  1251. * Defines the second coordinates (on Y axis)
  1252. */
  1253. y?: number,
  1254. /**
  1255. * Defines the third coordinates (on Z axis)
  1256. */
  1257. z?: number);
  1258. /**
  1259. * Creates a string representation of the Vector3
  1260. * @returns a string with the Vector3 coordinates.
  1261. */
  1262. toString(): string;
  1263. /**
  1264. * Gets the class name
  1265. * @returns the string "Vector3"
  1266. */
  1267. getClassName(): string;
  1268. /**
  1269. * Creates the Vector3 hash code
  1270. * @returns a number which tends to be unique between Vector3 instances
  1271. */
  1272. getHashCode(): number;
  1273. /**
  1274. * Creates an array containing three elements : the coordinates of the Vector3
  1275. * @returns a new array of numbers
  1276. */
  1277. asArray(): number[];
  1278. /**
  1279. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  1280. * @param array defines the destination array
  1281. * @param index defines the offset in the destination array
  1282. * @returns the current Vector3
  1283. */
  1284. toArray(array: FloatArray, index?: number): Vector3;
  1285. /**
  1286. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  1287. * @returns a new Quaternion object, computed from the Vector3 coordinates
  1288. */
  1289. toQuaternion(): Quaternion;
  1290. /**
  1291. * Adds the given vector to the current Vector3
  1292. * @param otherVector defines the second operand
  1293. * @returns the current updated Vector3
  1294. */
  1295. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1296. /**
  1297. * Adds the given coordinates to the current Vector3
  1298. * @param x defines the x coordinate of the operand
  1299. * @param y defines the y coordinate of the operand
  1300. * @param z defines the z coordinate of the operand
  1301. * @returns the current updated Vector3
  1302. */
  1303. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1304. /**
  1305. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  1306. * @param otherVector defines the second operand
  1307. * @returns the resulting Vector3
  1308. */
  1309. add(otherVector: DeepImmutable<Vector3>): Vector3;
  1310. /**
  1311. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  1312. * @param otherVector defines the second operand
  1313. * @param result defines the Vector3 object where to store the result
  1314. * @returns the current Vector3
  1315. */
  1316. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1317. /**
  1318. * Subtract the given vector from the current Vector3
  1319. * @param otherVector defines the second operand
  1320. * @returns the current updated Vector3
  1321. */
  1322. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1323. /**
  1324. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  1325. * @param otherVector defines the second operand
  1326. * @returns the resulting Vector3
  1327. */
  1328. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  1329. /**
  1330. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  1331. * @param otherVector defines the second operand
  1332. * @param result defines the Vector3 object where to store the result
  1333. * @returns the current Vector3
  1334. */
  1335. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1336. /**
  1337. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  1338. * @param x defines the x coordinate of the operand
  1339. * @param y defines the y coordinate of the operand
  1340. * @param z defines the z coordinate of the operand
  1341. * @returns the resulting Vector3
  1342. */
  1343. subtractFromFloats(x: number, y: number, z: number): Vector3;
  1344. /**
  1345. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  1346. * @param x defines the x coordinate of the operand
  1347. * @param y defines the y coordinate of the operand
  1348. * @param z defines the z coordinate of the operand
  1349. * @param result defines the Vector3 object where to store the result
  1350. * @returns the current Vector3
  1351. */
  1352. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  1353. /**
  1354. * Gets a new Vector3 set with the current Vector3 negated coordinates
  1355. * @returns a new Vector3
  1356. */
  1357. negate(): Vector3;
  1358. /**
  1359. * Multiplies the Vector3 coordinates by the float "scale"
  1360. * @param scale defines the multiplier factor
  1361. * @returns the current updated Vector3
  1362. */
  1363. scaleInPlace(scale: number): Vector3;
  1364. /**
  1365. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  1366. * @param scale defines the multiplier factor
  1367. * @returns a new Vector3
  1368. */
  1369. scale(scale: number): Vector3;
  1370. /**
  1371. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  1372. * @param scale defines the multiplier factor
  1373. * @param result defines the Vector3 object where to store the result
  1374. * @returns the current Vector3
  1375. */
  1376. scaleToRef(scale: number, result: Vector3): Vector3;
  1377. /**
  1378. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  1379. * @param scale defines the scale factor
  1380. * @param result defines the Vector3 object where to store the result
  1381. * @returns the unmodified current Vector3
  1382. */
  1383. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  1384. /**
  1385. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  1386. * @param otherVector defines the second operand
  1387. * @returns true if both vectors are equals
  1388. */
  1389. equals(otherVector: DeepImmutable<Vector3>): boolean;
  1390. /**
  1391. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  1392. * @param otherVector defines the second operand
  1393. * @param epsilon defines the minimal distance to define values as equals
  1394. * @returns true if both vectors are distant less than epsilon
  1395. */
  1396. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  1397. /**
  1398. * Returns true if the current Vector3 coordinates equals the given floats
  1399. * @param x defines the x coordinate of the operand
  1400. * @param y defines the y coordinate of the operand
  1401. * @param z defines the z coordinate of the operand
  1402. * @returns true if both vectors are equals
  1403. */
  1404. equalsToFloats(x: number, y: number, z: number): boolean;
  1405. /**
  1406. * Multiplies the current Vector3 coordinates by the given ones
  1407. * @param otherVector defines the second operand
  1408. * @returns the current updated Vector3
  1409. */
  1410. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1411. /**
  1412. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  1413. * @param otherVector defines the second operand
  1414. * @returns the new Vector3
  1415. */
  1416. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  1417. /**
  1418. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  1419. * @param otherVector defines the second operand
  1420. * @param result defines the Vector3 object where to store the result
  1421. * @returns the current Vector3
  1422. */
  1423. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1424. /**
  1425. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  1426. * @param x defines the x coordinate of the operand
  1427. * @param y defines the y coordinate of the operand
  1428. * @param z defines the z coordinate of the operand
  1429. * @returns the new Vector3
  1430. */
  1431. multiplyByFloats(x: number, y: number, z: number): Vector3;
  1432. /**
  1433. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  1434. * @param otherVector defines the second operand
  1435. * @returns the new Vector3
  1436. */
  1437. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  1438. /**
  1439. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  1440. * @param otherVector defines the second operand
  1441. * @param result defines the Vector3 object where to store the result
  1442. * @returns the current Vector3
  1443. */
  1444. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1445. /**
  1446. * Divides the current Vector3 coordinates by the given ones.
  1447. * @param otherVector defines the second operand
  1448. * @returns the current updated Vector3
  1449. */
  1450. divideInPlace(otherVector: Vector3): Vector3;
  1451. /**
  1452. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  1453. * @param other defines the second operand
  1454. * @returns the current updated Vector3
  1455. */
  1456. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1457. /**
  1458. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  1459. * @param other defines the second operand
  1460. * @returns the current updated Vector3
  1461. */
  1462. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1463. /**
  1464. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  1465. * @param x defines the x coordinate of the operand
  1466. * @param y defines the y coordinate of the operand
  1467. * @param z defines the z coordinate of the operand
  1468. * @returns the current updated Vector3
  1469. */
  1470. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1471. /**
  1472. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  1473. * @param x defines the x coordinate of the operand
  1474. * @param y defines the y coordinate of the operand
  1475. * @param z defines the z coordinate of the operand
  1476. * @returns the current updated Vector3
  1477. */
  1478. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1479. /**
  1480. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  1481. * Check if is non uniform within a certain amount of decimal places to account for this
  1482. * @param epsilon the amount the values can differ
  1483. * @returns if the the vector is non uniform to a certain number of decimal places
  1484. */
  1485. isNonUniformWithinEpsilon(epsilon: number): boolean;
  1486. /**
  1487. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  1488. */
  1489. readonly isNonUniform: boolean;
  1490. /**
  1491. * Gets a new Vector3 from current Vector3 floored values
  1492. * @returns a new Vector3
  1493. */
  1494. floor(): Vector3;
  1495. /**
  1496. * Gets a new Vector3 from current Vector3 floored values
  1497. * @returns a new Vector3
  1498. */
  1499. fract(): Vector3;
  1500. /**
  1501. * Gets the length of the Vector3
  1502. * @returns the length of the Vector3
  1503. */
  1504. length(): number;
  1505. /**
  1506. * Gets the squared length of the Vector3
  1507. * @returns squared length of the Vector3
  1508. */
  1509. lengthSquared(): number;
  1510. /**
  1511. * Normalize the current Vector3.
  1512. * Please note that this is an in place operation.
  1513. * @returns the current updated Vector3
  1514. */
  1515. normalize(): Vector3;
  1516. /**
  1517. * Reorders the x y z properties of the vector in place
  1518. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  1519. * @returns the current updated vector
  1520. */
  1521. reorderInPlace(order: string): this;
  1522. /**
  1523. * Rotates the vector around 0,0,0 by a quaternion
  1524. * @param quaternion the rotation quaternion
  1525. * @param result vector to store the result
  1526. * @returns the resulting vector
  1527. */
  1528. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  1529. /**
  1530. * Rotates a vector around a given point
  1531. * @param quaternion the rotation quaternion
  1532. * @param point the point to rotate around
  1533. * @param result vector to store the result
  1534. * @returns the resulting vector
  1535. */
  1536. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  1537. /**
  1538. * Normalize the current Vector3 with the given input length.
  1539. * Please note that this is an in place operation.
  1540. * @param len the length of the vector
  1541. * @returns the current updated Vector3
  1542. */
  1543. normalizeFromLength(len: number): Vector3;
  1544. /**
  1545. * Normalize the current Vector3 to a new vector
  1546. * @returns the new Vector3
  1547. */
  1548. normalizeToNew(): Vector3;
  1549. /**
  1550. * Normalize the current Vector3 to the reference
  1551. * @param reference define the Vector3 to update
  1552. * @returns the updated Vector3
  1553. */
  1554. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  1555. /**
  1556. * Creates a new Vector3 copied from the current Vector3
  1557. * @returns the new Vector3
  1558. */
  1559. clone(): Vector3;
  1560. /**
  1561. * Copies the given vector coordinates to the current Vector3 ones
  1562. * @param source defines the source Vector3
  1563. * @returns the current updated Vector3
  1564. */
  1565. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  1566. /**
  1567. * Copies the given floats to the current Vector3 coordinates
  1568. * @param x defines the x coordinate of the operand
  1569. * @param y defines the y coordinate of the operand
  1570. * @param z defines the z coordinate of the operand
  1571. * @returns the current updated Vector3
  1572. */
  1573. copyFromFloats(x: number, y: number, z: number): Vector3;
  1574. /**
  1575. * Copies the given floats to the current Vector3 coordinates
  1576. * @param x defines the x coordinate of the operand
  1577. * @param y defines the y coordinate of the operand
  1578. * @param z defines the z coordinate of the operand
  1579. * @returns the current updated Vector3
  1580. */
  1581. set(x: number, y: number, z: number): Vector3;
  1582. /**
  1583. * Copies the given float to the current Vector3 coordinates
  1584. * @param v defines the x, y and z coordinates of the operand
  1585. * @returns the current updated Vector3
  1586. */
  1587. setAll(v: number): Vector3;
  1588. /**
  1589. * Get the clip factor between two vectors
  1590. * @param vector0 defines the first operand
  1591. * @param vector1 defines the second operand
  1592. * @param axis defines the axis to use
  1593. * @param size defines the size along the axis
  1594. * @returns the clip factor
  1595. */
  1596. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  1597. /**
  1598. * Get angle between two vectors
  1599. * @param vector0 angle between vector0 and vector1
  1600. * @param vector1 angle between vector0 and vector1
  1601. * @param normal direction of the normal
  1602. * @return the angle between vector0 and vector1
  1603. */
  1604. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  1605. /**
  1606. * Returns a new Vector3 set from the index "offset" of the given array
  1607. * @param array defines the source array
  1608. * @param offset defines the offset in the source array
  1609. * @returns the new Vector3
  1610. */
  1611. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  1612. /**
  1613. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  1614. * This function is deprecated. Use FromArray instead
  1615. * @param array defines the source array
  1616. * @param offset defines the offset in the source array
  1617. * @returns the new Vector3
  1618. */
  1619. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  1620. /**
  1621. * Sets the given vector "result" with the element values from the index "offset" of the given array
  1622. * @param array defines the source array
  1623. * @param offset defines the offset in the source array
  1624. * @param result defines the Vector3 where to store the result
  1625. */
  1626. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  1627. /**
  1628. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  1629. * This function is deprecated. Use FromArrayToRef instead.
  1630. * @param array defines the source array
  1631. * @param offset defines the offset in the source array
  1632. * @param result defines the Vector3 where to store the result
  1633. */
  1634. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  1635. /**
  1636. * Sets the given vector "result" with the given floats.
  1637. * @param x defines the x coordinate of the source
  1638. * @param y defines the y coordinate of the source
  1639. * @param z defines the z coordinate of the source
  1640. * @param result defines the Vector3 where to store the result
  1641. */
  1642. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  1643. /**
  1644. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  1645. * @returns a new empty Vector3
  1646. */
  1647. static Zero(): Vector3;
  1648. /**
  1649. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  1650. * @returns a new unit Vector3
  1651. */
  1652. static One(): Vector3;
  1653. /**
  1654. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  1655. * @returns a new up Vector3
  1656. */
  1657. static Up(): Vector3;
  1658. /**
  1659. * Gets a up Vector3 that must not be updated
  1660. */
  1661. static readonly UpReadOnly: DeepImmutable<Vector3>;
  1662. /**
  1663. * Gets a zero Vector3 that must not be updated
  1664. */
  1665. static readonly ZeroReadOnly: DeepImmutable<Vector3>;
  1666. /**
  1667. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  1668. * @returns a new down Vector3
  1669. */
  1670. static Down(): Vector3;
  1671. /**
  1672. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  1673. * @returns a new forward Vector3
  1674. */
  1675. static Forward(): Vector3;
  1676. /**
  1677. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  1678. * @returns a new forward Vector3
  1679. */
  1680. static Backward(): Vector3;
  1681. /**
  1682. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  1683. * @returns a new right Vector3
  1684. */
  1685. static Right(): Vector3;
  1686. /**
  1687. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  1688. * @returns a new left Vector3
  1689. */
  1690. static Left(): Vector3;
  1691. /**
  1692. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  1693. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  1694. * @param vector defines the Vector3 to transform
  1695. * @param transformation defines the transformation matrix
  1696. * @returns the transformed Vector3
  1697. */
  1698. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  1699. /**
  1700. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  1701. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  1702. * @param vector defines the Vector3 to transform
  1703. * @param transformation defines the transformation matrix
  1704. * @param result defines the Vector3 where to store the result
  1705. */
  1706. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1707. /**
  1708. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  1709. * This method computes tranformed coordinates only, not transformed direction vectors
  1710. * @param x define the x coordinate of the source vector
  1711. * @param y define the y coordinate of the source vector
  1712. * @param z define the z coordinate of the source vector
  1713. * @param transformation defines the transformation matrix
  1714. * @param result defines the Vector3 where to store the result
  1715. */
  1716. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1717. /**
  1718. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  1719. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1720. * @param vector defines the Vector3 to transform
  1721. * @param transformation defines the transformation matrix
  1722. * @returns the new Vector3
  1723. */
  1724. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  1725. /**
  1726. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  1727. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1728. * @param vector defines the Vector3 to transform
  1729. * @param transformation defines the transformation matrix
  1730. * @param result defines the Vector3 where to store the result
  1731. */
  1732. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1733. /**
  1734. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  1735. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1736. * @param x define the x coordinate of the source vector
  1737. * @param y define the y coordinate of the source vector
  1738. * @param z define the z coordinate of the source vector
  1739. * @param transformation defines the transformation matrix
  1740. * @param result defines the Vector3 where to store the result
  1741. */
  1742. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1743. /**
  1744. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  1745. * @param value1 defines the first control point
  1746. * @param value2 defines the second control point
  1747. * @param value3 defines the third control point
  1748. * @param value4 defines the fourth control point
  1749. * @param amount defines the amount on the spline to use
  1750. * @returns the new Vector3
  1751. */
  1752. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  1753. /**
  1754. * Returns a new Vector3 set with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  1755. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  1756. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  1757. * @param value defines the current value
  1758. * @param min defines the lower range value
  1759. * @param max defines the upper range value
  1760. * @returns the new Vector3
  1761. */
  1762. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  1763. /**
  1764. * Sets the given vector "result" with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  1765. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  1766. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  1767. * @param value defines the current value
  1768. * @param min defines the lower range value
  1769. * @param max defines the upper range value
  1770. * @param result defines the Vector3 where to store the result
  1771. */
  1772. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  1773. /**
  1774. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  1775. * @param value1 defines the first control point
  1776. * @param tangent1 defines the first tangent vector
  1777. * @param value2 defines the second control point
  1778. * @param tangent2 defines the second tangent vector
  1779. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  1780. * @returns the new Vector3
  1781. */
  1782. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  1783. /**
  1784. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  1785. * @param start defines the start value
  1786. * @param end defines the end value
  1787. * @param amount max defines amount between both (between 0 and 1)
  1788. * @returns the new Vector3
  1789. */
  1790. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  1791. /**
  1792. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  1793. * @param start defines the start value
  1794. * @param end defines the end value
  1795. * @param amount max defines amount between both (between 0 and 1)
  1796. * @param result defines the Vector3 where to store the result
  1797. */
  1798. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  1799. /**
  1800. * Returns the dot product (float) between the vectors "left" and "right"
  1801. * @param left defines the left operand
  1802. * @param right defines the right operand
  1803. * @returns the dot product
  1804. */
  1805. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  1806. /**
  1807. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  1808. * The cross product is then orthogonal to both "left" and "right"
  1809. * @param left defines the left operand
  1810. * @param right defines the right operand
  1811. * @returns the cross product
  1812. */
  1813. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1814. /**
  1815. * Sets the given vector "result" with the cross product of "left" and "right"
  1816. * The cross product is then orthogonal to both "left" and "right"
  1817. * @param left defines the left operand
  1818. * @param right defines the right operand
  1819. * @param result defines the Vector3 where to store the result
  1820. */
  1821. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  1822. /**
  1823. * Returns a new Vector3 as the normalization of the given vector
  1824. * @param vector defines the Vector3 to normalize
  1825. * @returns the new Vector3
  1826. */
  1827. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  1828. /**
  1829. * Sets the given vector "result" with the normalization of the given first vector
  1830. * @param vector defines the Vector3 to normalize
  1831. * @param result defines the Vector3 where to store the result
  1832. */
  1833. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  1834. /**
  1835. * Project a Vector3 onto screen space
  1836. * @param vector defines the Vector3 to project
  1837. * @param world defines the world matrix to use
  1838. * @param transform defines the transform (view x projection) matrix to use
  1839. * @param viewport defines the screen viewport to use
  1840. * @returns the new Vector3
  1841. */
  1842. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  1843. /** @hidden */
  1844. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  1845. /**
  1846. * Unproject from screen space to object space
  1847. * @param source defines the screen space Vector3 to use
  1848. * @param viewportWidth defines the current width of the viewport
  1849. * @param viewportHeight defines the current height of the viewport
  1850. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1851. * @param transform defines the transform (view x projection) matrix to use
  1852. * @returns the new Vector3
  1853. */
  1854. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  1855. /**
  1856. * Unproject from screen space to object space
  1857. * @param source defines the screen space Vector3 to use
  1858. * @param viewportWidth defines the current width of the viewport
  1859. * @param viewportHeight defines the current height of the viewport
  1860. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1861. * @param view defines the view matrix to use
  1862. * @param projection defines the projection matrix to use
  1863. * @returns the new Vector3
  1864. */
  1865. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  1866. /**
  1867. * Unproject from screen space to object space
  1868. * @param source defines the screen space Vector3 to use
  1869. * @param viewportWidth defines the current width of the viewport
  1870. * @param viewportHeight defines the current height of the viewport
  1871. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1872. * @param view defines the view matrix to use
  1873. * @param projection defines the projection matrix to use
  1874. * @param result defines the Vector3 where to store the result
  1875. */
  1876. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  1877. /**
  1878. * Unproject from screen space to object space
  1879. * @param sourceX defines the screen space x coordinate to use
  1880. * @param sourceY defines the screen space y coordinate to use
  1881. * @param sourceZ defines the screen space z coordinate to use
  1882. * @param viewportWidth defines the current width of the viewport
  1883. * @param viewportHeight defines the current height of the viewport
  1884. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1885. * @param view defines the view matrix to use
  1886. * @param projection defines the projection matrix to use
  1887. * @param result defines the Vector3 where to store the result
  1888. */
  1889. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  1890. /**
  1891. * Gets the minimal coordinate values between two Vector3
  1892. * @param left defines the first operand
  1893. * @param right defines the second operand
  1894. * @returns the new Vector3
  1895. */
  1896. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1897. /**
  1898. * Gets the maximal coordinate values between two Vector3
  1899. * @param left defines the first operand
  1900. * @param right defines the second operand
  1901. * @returns the new Vector3
  1902. */
  1903. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1904. /**
  1905. * Returns the distance between the vectors "value1" and "value2"
  1906. * @param value1 defines the first operand
  1907. * @param value2 defines the second operand
  1908. * @returns the distance
  1909. */
  1910. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  1911. /**
  1912. * Returns the squared distance between the vectors "value1" and "value2"
  1913. * @param value1 defines the first operand
  1914. * @param value2 defines the second operand
  1915. * @returns the squared distance
  1916. */
  1917. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  1918. /**
  1919. * Returns a new Vector3 located at the center between "value1" and "value2"
  1920. * @param value1 defines the first operand
  1921. * @param value2 defines the second operand
  1922. * @returns the new Vector3
  1923. */
  1924. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  1925. /**
  1926. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  1927. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  1928. * to something in order to rotate it from its local system to the given target system
  1929. * Note: axis1, axis2 and axis3 are normalized during this operation
  1930. * @param axis1 defines the first axis
  1931. * @param axis2 defines the second axis
  1932. * @param axis3 defines the third axis
  1933. * @returns a new Vector3
  1934. */
  1935. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  1936. /**
  1937. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  1938. * @param axis1 defines the first axis
  1939. * @param axis2 defines the second axis
  1940. * @param axis3 defines the third axis
  1941. * @param ref defines the Vector3 where to store the result
  1942. */
  1943. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  1944. }
  1945. /**
  1946. * Vector4 class created for EulerAngle class conversion to Quaternion
  1947. */
  1948. export class Vector4 {
  1949. /** x value of the vector */
  1950. x: number;
  1951. /** y value of the vector */
  1952. y: number;
  1953. /** z value of the vector */
  1954. z: number;
  1955. /** w value of the vector */
  1956. w: number;
  1957. /**
  1958. * Creates a Vector4 object from the given floats.
  1959. * @param x x value of the vector
  1960. * @param y y value of the vector
  1961. * @param z z value of the vector
  1962. * @param w w value of the vector
  1963. */
  1964. constructor(
  1965. /** x value of the vector */
  1966. x: number,
  1967. /** y value of the vector */
  1968. y: number,
  1969. /** z value of the vector */
  1970. z: number,
  1971. /** w value of the vector */
  1972. w: number);
  1973. /**
  1974. * Returns the string with the Vector4 coordinates.
  1975. * @returns a string containing all the vector values
  1976. */
  1977. toString(): string;
  1978. /**
  1979. * Returns the string "Vector4".
  1980. * @returns "Vector4"
  1981. */
  1982. getClassName(): string;
  1983. /**
  1984. * Returns the Vector4 hash code.
  1985. * @returns a unique hash code
  1986. */
  1987. getHashCode(): number;
  1988. /**
  1989. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  1990. * @returns the resulting array
  1991. */
  1992. asArray(): number[];
  1993. /**
  1994. * Populates the given array from the given index with the Vector4 coordinates.
  1995. * @param array array to populate
  1996. * @param index index of the array to start at (default: 0)
  1997. * @returns the Vector4.
  1998. */
  1999. toArray(array: FloatArray, index?: number): Vector4;
  2000. /**
  2001. * Adds the given vector to the current Vector4.
  2002. * @param otherVector the vector to add
  2003. * @returns the updated Vector4.
  2004. */
  2005. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2006. /**
  2007. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  2008. * @param otherVector the vector to add
  2009. * @returns the resulting vector
  2010. */
  2011. add(otherVector: DeepImmutable<Vector4>): Vector4;
  2012. /**
  2013. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  2014. * @param otherVector the vector to add
  2015. * @param result the vector to store the result
  2016. * @returns the current Vector4.
  2017. */
  2018. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2019. /**
  2020. * Subtract in place the given vector from the current Vector4.
  2021. * @param otherVector the vector to subtract
  2022. * @returns the updated Vector4.
  2023. */
  2024. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2025. /**
  2026. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  2027. * @param otherVector the vector to add
  2028. * @returns the new vector with the result
  2029. */
  2030. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  2031. /**
  2032. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  2033. * @param otherVector the vector to subtract
  2034. * @param result the vector to store the result
  2035. * @returns the current Vector4.
  2036. */
  2037. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2038. /**
  2039. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2040. */
  2041. /**
  2042. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2043. * @param x value to subtract
  2044. * @param y value to subtract
  2045. * @param z value to subtract
  2046. * @param w value to subtract
  2047. * @returns new vector containing the result
  2048. */
  2049. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2050. /**
  2051. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2052. * @param x value to subtract
  2053. * @param y value to subtract
  2054. * @param z value to subtract
  2055. * @param w value to subtract
  2056. * @param result the vector to store the result in
  2057. * @returns the current Vector4.
  2058. */
  2059. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  2060. /**
  2061. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  2062. * @returns a new vector with the negated values
  2063. */
  2064. negate(): Vector4;
  2065. /**
  2066. * Multiplies the current Vector4 coordinates by scale (float).
  2067. * @param scale the number to scale with
  2068. * @returns the updated Vector4.
  2069. */
  2070. scaleInPlace(scale: number): Vector4;
  2071. /**
  2072. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  2073. * @param scale the number to scale with
  2074. * @returns a new vector with the result
  2075. */
  2076. scale(scale: number): Vector4;
  2077. /**
  2078. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  2079. * @param scale the number to scale with
  2080. * @param result a vector to store the result in
  2081. * @returns the current Vector4.
  2082. */
  2083. scaleToRef(scale: number, result: Vector4): Vector4;
  2084. /**
  2085. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  2086. * @param scale defines the scale factor
  2087. * @param result defines the Vector4 object where to store the result
  2088. * @returns the unmodified current Vector4
  2089. */
  2090. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  2091. /**
  2092. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  2093. * @param otherVector the vector to compare against
  2094. * @returns true if they are equal
  2095. */
  2096. equals(otherVector: DeepImmutable<Vector4>): boolean;
  2097. /**
  2098. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  2099. * @param otherVector vector to compare against
  2100. * @param epsilon (Default: very small number)
  2101. * @returns true if they are equal
  2102. */
  2103. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  2104. /**
  2105. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  2106. * @param x x value to compare against
  2107. * @param y y value to compare against
  2108. * @param z z value to compare against
  2109. * @param w w value to compare against
  2110. * @returns true if equal
  2111. */
  2112. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  2113. /**
  2114. * Multiplies in place the current Vector4 by the given one.
  2115. * @param otherVector vector to multiple with
  2116. * @returns the updated Vector4.
  2117. */
  2118. multiplyInPlace(otherVector: Vector4): Vector4;
  2119. /**
  2120. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  2121. * @param otherVector vector to multiple with
  2122. * @returns resulting new vector
  2123. */
  2124. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  2125. /**
  2126. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  2127. * @param otherVector vector to multiple with
  2128. * @param result vector to store the result
  2129. * @returns the current Vector4.
  2130. */
  2131. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2132. /**
  2133. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  2134. * @param x x value multiply with
  2135. * @param y y value multiply with
  2136. * @param z z value multiply with
  2137. * @param w w value multiply with
  2138. * @returns resulting new vector
  2139. */
  2140. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  2141. /**
  2142. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  2143. * @param otherVector vector to devide with
  2144. * @returns resulting new vector
  2145. */
  2146. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  2147. /**
  2148. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  2149. * @param otherVector vector to devide with
  2150. * @param result vector to store the result
  2151. * @returns the current Vector4.
  2152. */
  2153. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2154. /**
  2155. * Divides the current Vector3 coordinates by the given ones.
  2156. * @param otherVector vector to devide with
  2157. * @returns the updated Vector3.
  2158. */
  2159. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2160. /**
  2161. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  2162. * @param other defines the second operand
  2163. * @returns the current updated Vector4
  2164. */
  2165. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2166. /**
  2167. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  2168. * @param other defines the second operand
  2169. * @returns the current updated Vector4
  2170. */
  2171. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2172. /**
  2173. * Gets a new Vector4 from current Vector4 floored values
  2174. * @returns a new Vector4
  2175. */
  2176. floor(): Vector4;
  2177. /**
  2178. * Gets a new Vector4 from current Vector3 floored values
  2179. * @returns a new Vector4
  2180. */
  2181. fract(): Vector4;
  2182. /**
  2183. * Returns the Vector4 length (float).
  2184. * @returns the length
  2185. */
  2186. length(): number;
  2187. /**
  2188. * Returns the Vector4 squared length (float).
  2189. * @returns the length squared
  2190. */
  2191. lengthSquared(): number;
  2192. /**
  2193. * Normalizes in place the Vector4.
  2194. * @returns the updated Vector4.
  2195. */
  2196. normalize(): Vector4;
  2197. /**
  2198. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  2199. * @returns this converted to a new vector3
  2200. */
  2201. toVector3(): Vector3;
  2202. /**
  2203. * Returns a new Vector4 copied from the current one.
  2204. * @returns the new cloned vector
  2205. */
  2206. clone(): Vector4;
  2207. /**
  2208. * Updates the current Vector4 with the given one coordinates.
  2209. * @param source the source vector to copy from
  2210. * @returns the updated Vector4.
  2211. */
  2212. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  2213. /**
  2214. * Updates the current Vector4 coordinates with the given floats.
  2215. * @param x float to copy from
  2216. * @param y float to copy from
  2217. * @param z float to copy from
  2218. * @param w float to copy from
  2219. * @returns the updated Vector4.
  2220. */
  2221. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2222. /**
  2223. * Updates the current Vector4 coordinates with the given floats.
  2224. * @param x float to set from
  2225. * @param y float to set from
  2226. * @param z float to set from
  2227. * @param w float to set from
  2228. * @returns the updated Vector4.
  2229. */
  2230. set(x: number, y: number, z: number, w: number): Vector4;
  2231. /**
  2232. * Copies the given float to the current Vector3 coordinates
  2233. * @param v defines the x, y, z and w coordinates of the operand
  2234. * @returns the current updated Vector3
  2235. */
  2236. setAll(v: number): Vector4;
  2237. /**
  2238. * Returns a new Vector4 set from the starting index of the given array.
  2239. * @param array the array to pull values from
  2240. * @param offset the offset into the array to start at
  2241. * @returns the new vector
  2242. */
  2243. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  2244. /**
  2245. * Updates the given vector "result" from the starting index of the given array.
  2246. * @param array the array to pull values from
  2247. * @param offset the offset into the array to start at
  2248. * @param result the vector to store the result in
  2249. */
  2250. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  2251. /**
  2252. * Updates the given vector "result" from the starting index of the given Float32Array.
  2253. * @param array the array to pull values from
  2254. * @param offset the offset into the array to start at
  2255. * @param result the vector to store the result in
  2256. */
  2257. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  2258. /**
  2259. * Updates the given vector "result" coordinates from the given floats.
  2260. * @param x float to set from
  2261. * @param y float to set from
  2262. * @param z float to set from
  2263. * @param w float to set from
  2264. * @param result the vector to the floats in
  2265. */
  2266. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  2267. /**
  2268. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  2269. * @returns the new vector
  2270. */
  2271. static Zero(): Vector4;
  2272. /**
  2273. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  2274. * @returns the new vector
  2275. */
  2276. static One(): Vector4;
  2277. /**
  2278. * Returns a new normalized Vector4 from the given one.
  2279. * @param vector the vector to normalize
  2280. * @returns the vector
  2281. */
  2282. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  2283. /**
  2284. * Updates the given vector "result" from the normalization of the given one.
  2285. * @param vector the vector to normalize
  2286. * @param result the vector to store the result in
  2287. */
  2288. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  2289. /**
  2290. * Returns a vector with the minimum values from the left and right vectors
  2291. * @param left left vector to minimize
  2292. * @param right right vector to minimize
  2293. * @returns a new vector with the minimum of the left and right vector values
  2294. */
  2295. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2296. /**
  2297. * Returns a vector with the maximum values from the left and right vectors
  2298. * @param left left vector to maximize
  2299. * @param right right vector to maximize
  2300. * @returns a new vector with the maximum of the left and right vector values
  2301. */
  2302. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2303. /**
  2304. * Returns the distance (float) between the vectors "value1" and "value2".
  2305. * @param value1 value to calulate the distance between
  2306. * @param value2 value to calulate the distance between
  2307. * @return the distance between the two vectors
  2308. */
  2309. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2310. /**
  2311. * Returns the squared distance (float) between the vectors "value1" and "value2".
  2312. * @param value1 value to calulate the distance between
  2313. * @param value2 value to calulate the distance between
  2314. * @return the distance between the two vectors squared
  2315. */
  2316. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2317. /**
  2318. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  2319. * @param value1 value to calulate the center between
  2320. * @param value2 value to calulate the center between
  2321. * @return the center between the two vectors
  2322. */
  2323. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  2324. /**
  2325. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  2326. * This methods computes transformed normalized direction vectors only.
  2327. * @param vector the vector to transform
  2328. * @param transformation the transformation matrix to apply
  2329. * @returns the new vector
  2330. */
  2331. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  2332. /**
  2333. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  2334. * This methods computes transformed normalized direction vectors only.
  2335. * @param vector the vector to transform
  2336. * @param transformation the transformation matrix to apply
  2337. * @param result the vector to store the result in
  2338. */
  2339. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2340. /**
  2341. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  2342. * This methods computes transformed normalized direction vectors only.
  2343. * @param x value to transform
  2344. * @param y value to transform
  2345. * @param z value to transform
  2346. * @param w value to transform
  2347. * @param transformation the transformation matrix to apply
  2348. * @param result the vector to store the results in
  2349. */
  2350. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2351. /**
  2352. * Creates a new Vector4 from a Vector3
  2353. * @param source defines the source data
  2354. * @param w defines the 4th component (default is 0)
  2355. * @returns a new Vector4
  2356. */
  2357. static FromVector3(source: Vector3, w?: number): Vector4;
  2358. }
  2359. /**
  2360. * Interface for the size containing width and height
  2361. */
  2362. export interface ISize {
  2363. /**
  2364. * Width
  2365. */
  2366. width: number;
  2367. /**
  2368. * Heighht
  2369. */
  2370. height: number;
  2371. }
  2372. /**
  2373. * Size containing widht and height
  2374. */
  2375. export class Size implements ISize {
  2376. /**
  2377. * Width
  2378. */
  2379. width: number;
  2380. /**
  2381. * Height
  2382. */
  2383. height: number;
  2384. /**
  2385. * Creates a Size object from the given width and height (floats).
  2386. * @param width width of the new size
  2387. * @param height height of the new size
  2388. */
  2389. constructor(width: number, height: number);
  2390. /**
  2391. * Returns a string with the Size width and height
  2392. * @returns a string with the Size width and height
  2393. */
  2394. toString(): string;
  2395. /**
  2396. * "Size"
  2397. * @returns the string "Size"
  2398. */
  2399. getClassName(): string;
  2400. /**
  2401. * Returns the Size hash code.
  2402. * @returns a hash code for a unique width and height
  2403. */
  2404. getHashCode(): number;
  2405. /**
  2406. * Updates the current size from the given one.
  2407. * @param src the given size
  2408. */
  2409. copyFrom(src: Size): void;
  2410. /**
  2411. * Updates in place the current Size from the given floats.
  2412. * @param width width of the new size
  2413. * @param height height of the new size
  2414. * @returns the updated Size.
  2415. */
  2416. copyFromFloats(width: number, height: number): Size;
  2417. /**
  2418. * Updates in place the current Size from the given floats.
  2419. * @param width width to set
  2420. * @param height height to set
  2421. * @returns the updated Size.
  2422. */
  2423. set(width: number, height: number): Size;
  2424. /**
  2425. * Multiplies the width and height by numbers
  2426. * @param w factor to multiple the width by
  2427. * @param h factor to multiple the height by
  2428. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  2429. */
  2430. multiplyByFloats(w: number, h: number): Size;
  2431. /**
  2432. * Clones the size
  2433. * @returns a new Size copied from the given one.
  2434. */
  2435. clone(): Size;
  2436. /**
  2437. * True if the current Size and the given one width and height are strictly equal.
  2438. * @param other the other size to compare against
  2439. * @returns True if the current Size and the given one width and height are strictly equal.
  2440. */
  2441. equals(other: Size): boolean;
  2442. /**
  2443. * The surface of the Size : width * height (float).
  2444. */
  2445. readonly surface: number;
  2446. /**
  2447. * Create a new size of zero
  2448. * @returns a new Size set to (0.0, 0.0)
  2449. */
  2450. static Zero(): Size;
  2451. /**
  2452. * Sums the width and height of two sizes
  2453. * @param otherSize size to add to this size
  2454. * @returns a new Size set as the addition result of the current Size and the given one.
  2455. */
  2456. add(otherSize: Size): Size;
  2457. /**
  2458. * Subtracts the width and height of two
  2459. * @param otherSize size to subtract to this size
  2460. * @returns a new Size set as the subtraction result of the given one from the current Size.
  2461. */
  2462. subtract(otherSize: Size): Size;
  2463. /**
  2464. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  2465. * @param start starting size to lerp between
  2466. * @param end end size to lerp between
  2467. * @param amount amount to lerp between the start and end values
  2468. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  2469. */
  2470. static Lerp(start: Size, end: Size, amount: number): Size;
  2471. }
  2472. /**
  2473. * Class used to store quaternion data
  2474. * @see https://en.wikipedia.org/wiki/Quaternion
  2475. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  2476. */
  2477. export class Quaternion {
  2478. /** defines the first component (0 by default) */
  2479. x: number;
  2480. /** defines the second component (0 by default) */
  2481. y: number;
  2482. /** defines the third component (0 by default) */
  2483. z: number;
  2484. /** defines the fourth component (1.0 by default) */
  2485. w: number;
  2486. /**
  2487. * Creates a new Quaternion from the given floats
  2488. * @param x defines the first component (0 by default)
  2489. * @param y defines the second component (0 by default)
  2490. * @param z defines the third component (0 by default)
  2491. * @param w defines the fourth component (1.0 by default)
  2492. */
  2493. constructor(
  2494. /** defines the first component (0 by default) */
  2495. x?: number,
  2496. /** defines the second component (0 by default) */
  2497. y?: number,
  2498. /** defines the third component (0 by default) */
  2499. z?: number,
  2500. /** defines the fourth component (1.0 by default) */
  2501. w?: number);
  2502. /**
  2503. * Gets a string representation for the current quaternion
  2504. * @returns a string with the Quaternion coordinates
  2505. */
  2506. toString(): string;
  2507. /**
  2508. * Gets the class name of the quaternion
  2509. * @returns the string "Quaternion"
  2510. */
  2511. getClassName(): string;
  2512. /**
  2513. * Gets a hash code for this quaternion
  2514. * @returns the quaternion hash code
  2515. */
  2516. getHashCode(): number;
  2517. /**
  2518. * Copy the quaternion to an array
  2519. * @returns a new array populated with 4 elements from the quaternion coordinates
  2520. */
  2521. asArray(): number[];
  2522. /**
  2523. * Check if two quaternions are equals
  2524. * @param otherQuaternion defines the second operand
  2525. * @return true if the current quaternion and the given one coordinates are strictly equals
  2526. */
  2527. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  2528. /**
  2529. * Clone the current quaternion
  2530. * @returns a new quaternion copied from the current one
  2531. */
  2532. clone(): Quaternion;
  2533. /**
  2534. * Copy a quaternion to the current one
  2535. * @param other defines the other quaternion
  2536. * @returns the updated current quaternion
  2537. */
  2538. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  2539. /**
  2540. * Updates the current quaternion with the given float coordinates
  2541. * @param x defines the x coordinate
  2542. * @param y defines the y coordinate
  2543. * @param z defines the z coordinate
  2544. * @param w defines the w coordinate
  2545. * @returns the updated current quaternion
  2546. */
  2547. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  2548. /**
  2549. * Updates the current quaternion from the given float coordinates
  2550. * @param x defines the x coordinate
  2551. * @param y defines the y coordinate
  2552. * @param z defines the z coordinate
  2553. * @param w defines the w coordinate
  2554. * @returns the updated current quaternion
  2555. */
  2556. set(x: number, y: number, z: number, w: number): Quaternion;
  2557. /**
  2558. * Adds two quaternions
  2559. * @param other defines the second operand
  2560. * @returns a new quaternion as the addition result of the given one and the current quaternion
  2561. */
  2562. add(other: DeepImmutable<Quaternion>): Quaternion;
  2563. /**
  2564. * Add a quaternion to the current one
  2565. * @param other defines the quaternion to add
  2566. * @returns the current quaternion
  2567. */
  2568. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  2569. /**
  2570. * Subtract two quaternions
  2571. * @param other defines the second operand
  2572. * @returns a new quaternion as the subtraction result of the given one from the current one
  2573. */
  2574. subtract(other: Quaternion): Quaternion;
  2575. /**
  2576. * Multiplies the current quaternion by a scale factor
  2577. * @param value defines the scale factor
  2578. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  2579. */
  2580. scale(value: number): Quaternion;
  2581. /**
  2582. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  2583. * @param scale defines the scale factor
  2584. * @param result defines the Quaternion object where to store the result
  2585. * @returns the unmodified current quaternion
  2586. */
  2587. scaleToRef(scale: number, result: Quaternion): Quaternion;
  2588. /**
  2589. * Multiplies in place the current quaternion by a scale factor
  2590. * @param value defines the scale factor
  2591. * @returns the current modified quaternion
  2592. */
  2593. scaleInPlace(value: number): Quaternion;
  2594. /**
  2595. * Scale the current quaternion values by a factor and add the result to a given quaternion
  2596. * @param scale defines the scale factor
  2597. * @param result defines the Quaternion object where to store the result
  2598. * @returns the unmodified current quaternion
  2599. */
  2600. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  2601. /**
  2602. * Multiplies two quaternions
  2603. * @param q1 defines the second operand
  2604. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  2605. */
  2606. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  2607. /**
  2608. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  2609. * @param q1 defines the second operand
  2610. * @param result defines the target quaternion
  2611. * @returns the current quaternion
  2612. */
  2613. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  2614. /**
  2615. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  2616. * @param q1 defines the second operand
  2617. * @returns the currentupdated quaternion
  2618. */
  2619. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  2620. /**
  2621. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  2622. * @param ref defines the target quaternion
  2623. * @returns the current quaternion
  2624. */
  2625. conjugateToRef(ref: Quaternion): Quaternion;
  2626. /**
  2627. * Conjugates in place (1-q) the current quaternion
  2628. * @returns the current updated quaternion
  2629. */
  2630. conjugateInPlace(): Quaternion;
  2631. /**
  2632. * Conjugates in place (1-q) the current quaternion
  2633. * @returns a new quaternion
  2634. */
  2635. conjugate(): Quaternion;
  2636. /**
  2637. * Gets length of current quaternion
  2638. * @returns the quaternion length (float)
  2639. */
  2640. length(): number;
  2641. /**
  2642. * Normalize in place the current quaternion
  2643. * @returns the current updated quaternion
  2644. */
  2645. normalize(): Quaternion;
  2646. /**
  2647. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  2648. * @param order is a reserved parameter and is ignore for now
  2649. * @returns a new Vector3 containing the Euler angles
  2650. */
  2651. toEulerAngles(order?: string): Vector3;
  2652. /**
  2653. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  2654. * @param result defines the vector which will be filled with the Euler angles
  2655. * @param order is a reserved parameter and is ignore for now
  2656. * @returns the current unchanged quaternion
  2657. */
  2658. toEulerAnglesToRef(result: Vector3): Quaternion;
  2659. /**
  2660. * Updates the given rotation matrix with the current quaternion values
  2661. * @param result defines the target matrix
  2662. * @returns the current unchanged quaternion
  2663. */
  2664. toRotationMatrix(result: Matrix): Quaternion;
  2665. /**
  2666. * Updates the current quaternion from the given rotation matrix values
  2667. * @param matrix defines the source matrix
  2668. * @returns the current updated quaternion
  2669. */
  2670. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  2671. /**
  2672. * Creates a new quaternion from a rotation matrix
  2673. * @param matrix defines the source matrix
  2674. * @returns a new quaternion created from the given rotation matrix values
  2675. */
  2676. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  2677. /**
  2678. * Updates the given quaternion with the given rotation matrix values
  2679. * @param matrix defines the source matrix
  2680. * @param result defines the target quaternion
  2681. */
  2682. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  2683. /**
  2684. * Returns the dot product (float) between the quaternions "left" and "right"
  2685. * @param left defines the left operand
  2686. * @param right defines the right operand
  2687. * @returns the dot product
  2688. */
  2689. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  2690. /**
  2691. * Checks if the two quaternions are close to each other
  2692. * @param quat0 defines the first quaternion to check
  2693. * @param quat1 defines the second quaternion to check
  2694. * @returns true if the two quaternions are close to each other
  2695. */
  2696. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  2697. /**
  2698. * Creates an empty quaternion
  2699. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  2700. */
  2701. static Zero(): Quaternion;
  2702. /**
  2703. * Inverse a given quaternion
  2704. * @param q defines the source quaternion
  2705. * @returns a new quaternion as the inverted current quaternion
  2706. */
  2707. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  2708. /**
  2709. * Inverse a given quaternion
  2710. * @param q defines the source quaternion
  2711. * @param result the quaternion the result will be stored in
  2712. * @returns the result quaternion
  2713. */
  2714. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  2715. /**
  2716. * Creates an identity quaternion
  2717. * @returns the identity quaternion
  2718. */
  2719. static Identity(): Quaternion;
  2720. /**
  2721. * Gets a boolean indicating if the given quaternion is identity
  2722. * @param quaternion defines the quaternion to check
  2723. * @returns true if the quaternion is identity
  2724. */
  2725. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  2726. /**
  2727. * Creates a quaternion from a rotation around an axis
  2728. * @param axis defines the axis to use
  2729. * @param angle defines the angle to use
  2730. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  2731. */
  2732. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  2733. /**
  2734. * Creates a rotation around an axis and stores it into the given quaternion
  2735. * @param axis defines the axis to use
  2736. * @param angle defines the angle to use
  2737. * @param result defines the target quaternion
  2738. * @returns the target quaternion
  2739. */
  2740. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  2741. /**
  2742. * Creates a new quaternion from data stored into an array
  2743. * @param array defines the data source
  2744. * @param offset defines the offset in the source array where the data starts
  2745. * @returns a new quaternion
  2746. */
  2747. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  2748. /**
  2749. * Create a quaternion from Euler rotation angles
  2750. * @param x Pitch
  2751. * @param y Yaw
  2752. * @param z Roll
  2753. * @returns the new Quaternion
  2754. */
  2755. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  2756. /**
  2757. * Updates a quaternion from Euler rotation angles
  2758. * @param x Pitch
  2759. * @param y Yaw
  2760. * @param z Roll
  2761. * @param result the quaternion to store the result
  2762. * @returns the updated quaternion
  2763. */
  2764. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  2765. /**
  2766. * Create a quaternion from Euler rotation vector
  2767. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  2768. * @returns the new Quaternion
  2769. */
  2770. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  2771. /**
  2772. * Updates a quaternion from Euler rotation vector
  2773. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  2774. * @param result the quaternion to store the result
  2775. * @returns the updated quaternion
  2776. */
  2777. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  2778. /**
  2779. * Creates a new quaternion from the given Euler float angles (y, x, z)
  2780. * @param yaw defines the rotation around Y axis
  2781. * @param pitch defines the rotation around X axis
  2782. * @param roll defines the rotation around Z axis
  2783. * @returns the new quaternion
  2784. */
  2785. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  2786. /**
  2787. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  2788. * @param yaw defines the rotation around Y axis
  2789. * @param pitch defines the rotation around X axis
  2790. * @param roll defines the rotation around Z axis
  2791. * @param result defines the target quaternion
  2792. */
  2793. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  2794. /**
  2795. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  2796. * @param alpha defines the rotation around first axis
  2797. * @param beta defines the rotation around second axis
  2798. * @param gamma defines the rotation around third axis
  2799. * @returns the new quaternion
  2800. */
  2801. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  2802. /**
  2803. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  2804. * @param alpha defines the rotation around first axis
  2805. * @param beta defines the rotation around second axis
  2806. * @param gamma defines the rotation around third axis
  2807. * @param result defines the target quaternion
  2808. */
  2809. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  2810. /**
  2811. * Creates a new quaternion containing the rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation)
  2812. * @param axis1 defines the first axis
  2813. * @param axis2 defines the second axis
  2814. * @param axis3 defines the third axis
  2815. * @returns the new quaternion
  2816. */
  2817. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  2818. /**
  2819. * Creates a rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation) and stores it in the target quaternion
  2820. * @param axis1 defines the first axis
  2821. * @param axis2 defines the second axis
  2822. * @param axis3 defines the third axis
  2823. * @param ref defines the target quaternion
  2824. */
  2825. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  2826. /**
  2827. * Interpolates between two quaternions
  2828. * @param left defines first quaternion
  2829. * @param right defines second quaternion
  2830. * @param amount defines the gradient to use
  2831. * @returns the new interpolated quaternion
  2832. */
  2833. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  2834. /**
  2835. * Interpolates between two quaternions and stores it into a target quaternion
  2836. * @param left defines first quaternion
  2837. * @param right defines second quaternion
  2838. * @param amount defines the gradient to use
  2839. * @param result defines the target quaternion
  2840. */
  2841. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  2842. /**
  2843. * Interpolate between two quaternions using Hermite interpolation
  2844. * @param value1 defines first quaternion
  2845. * @param tangent1 defines the incoming tangent
  2846. * @param value2 defines second quaternion
  2847. * @param tangent2 defines the outgoing tangent
  2848. * @param amount defines the target quaternion
  2849. * @returns the new interpolated quaternion
  2850. */
  2851. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  2852. }
  2853. /**
  2854. * Class used to store matrix data (4x4)
  2855. */
  2856. export class Matrix {
  2857. private static _updateFlagSeed;
  2858. private static _identityReadOnly;
  2859. private _isIdentity;
  2860. private _isIdentityDirty;
  2861. private _isIdentity3x2;
  2862. private _isIdentity3x2Dirty;
  2863. /**
  2864. * Gets the update flag of the matrix which is an unique number for the matrix.
  2865. * It will be incremented every time the matrix data change.
  2866. * You can use it to speed the comparison between two versions of the same matrix.
  2867. */
  2868. updateFlag: number;
  2869. private readonly _m;
  2870. /**
  2871. * Gets the internal data of the matrix
  2872. */
  2873. readonly m: DeepImmutable<Float32Array>;
  2874. /** @hidden */
  2875. _markAsUpdated(): void;
  2876. /** @hidden */
  2877. private _updateIdentityStatus;
  2878. /**
  2879. * Creates an empty matrix (filled with zeros)
  2880. */
  2881. constructor();
  2882. /**
  2883. * Check if the current matrix is identity
  2884. * @returns true is the matrix is the identity matrix
  2885. */
  2886. isIdentity(): boolean;
  2887. /**
  2888. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  2889. * @returns true is the matrix is the identity matrix
  2890. */
  2891. isIdentityAs3x2(): boolean;
  2892. /**
  2893. * Gets the determinant of the matrix
  2894. * @returns the matrix determinant
  2895. */
  2896. determinant(): number;
  2897. /**
  2898. * Returns the matrix as a Float32Array
  2899. * @returns the matrix underlying array
  2900. */
  2901. toArray(): DeepImmutable<Float32Array>;
  2902. /**
  2903. * Returns the matrix as a Float32Array
  2904. * @returns the matrix underlying array.
  2905. */
  2906. asArray(): DeepImmutable<Float32Array>;
  2907. /**
  2908. * Inverts the current matrix in place
  2909. * @returns the current inverted matrix
  2910. */
  2911. invert(): Matrix;
  2912. /**
  2913. * Sets all the matrix elements to zero
  2914. * @returns the current matrix
  2915. */
  2916. reset(): Matrix;
  2917. /**
  2918. * Adds the current matrix with a second one
  2919. * @param other defines the matrix to add
  2920. * @returns a new matrix as the addition of the current matrix and the given one
  2921. */
  2922. add(other: DeepImmutable<Matrix>): Matrix;
  2923. /**
  2924. * Sets the given matrix "result" to the addition of the current matrix and the given one
  2925. * @param other defines the matrix to add
  2926. * @param result defines the target matrix
  2927. * @returns the current matrix
  2928. */
  2929. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  2930. /**
  2931. * Adds in place the given matrix to the current matrix
  2932. * @param other defines the second operand
  2933. * @returns the current updated matrix
  2934. */
  2935. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  2936. /**
  2937. * Sets the given matrix to the current inverted Matrix
  2938. * @param other defines the target matrix
  2939. * @returns the unmodified current matrix
  2940. */
  2941. invertToRef(other: Matrix): Matrix;
  2942. /**
  2943. * add a value at the specified position in the current Matrix
  2944. * @param index the index of the value within the matrix. between 0 and 15.
  2945. * @param value the value to be added
  2946. * @returns the current updated matrix
  2947. */
  2948. addAtIndex(index: number, value: number): Matrix;
  2949. /**
  2950. * mutiply the specified position in the current Matrix by a value
  2951. * @param index the index of the value within the matrix. between 0 and 15.
  2952. * @param value the value to be added
  2953. * @returns the current updated matrix
  2954. */
  2955. multiplyAtIndex(index: number, value: number): Matrix;
  2956. /**
  2957. * Inserts the translation vector (using 3 floats) in the current matrix
  2958. * @param x defines the 1st component of the translation
  2959. * @param y defines the 2nd component of the translation
  2960. * @param z defines the 3rd component of the translation
  2961. * @returns the current updated matrix
  2962. */
  2963. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  2964. /**
  2965. * Adds the translation vector (using 3 floats) in the current matrix
  2966. * @param x defines the 1st component of the translation
  2967. * @param y defines the 2nd component of the translation
  2968. * @param z defines the 3rd component of the translation
  2969. * @returns the current updated matrix
  2970. */
  2971. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  2972. /**
  2973. * Inserts the translation vector in the current matrix
  2974. * @param vector3 defines the translation to insert
  2975. * @returns the current updated matrix
  2976. */
  2977. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  2978. /**
  2979. * Gets the translation value of the current matrix
  2980. * @returns a new Vector3 as the extracted translation from the matrix
  2981. */
  2982. getTranslation(): Vector3;
  2983. /**
  2984. * Fill a Vector3 with the extracted translation from the matrix
  2985. * @param result defines the Vector3 where to store the translation
  2986. * @returns the current matrix
  2987. */
  2988. getTranslationToRef(result: Vector3): Matrix;
  2989. /**
  2990. * Remove rotation and scaling part from the matrix
  2991. * @returns the updated matrix
  2992. */
  2993. removeRotationAndScaling(): Matrix;
  2994. /**
  2995. * Multiply two matrices
  2996. * @param other defines the second operand
  2997. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  2998. */
  2999. multiply(other: DeepImmutable<Matrix>): Matrix;
  3000. /**
  3001. * Copy the current matrix from the given one
  3002. * @param other defines the source matrix
  3003. * @returns the current updated matrix
  3004. */
  3005. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  3006. /**
  3007. * Populates the given array from the starting index with the current matrix values
  3008. * @param array defines the target array
  3009. * @param offset defines the offset in the target array where to start storing values
  3010. * @returns the current matrix
  3011. */
  3012. copyToArray(array: Float32Array, offset?: number): Matrix;
  3013. /**
  3014. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  3015. * @param other defines the second operand
  3016. * @param result defines the matrix where to store the multiplication
  3017. * @returns the current matrix
  3018. */
  3019. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3020. /**
  3021. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  3022. * @param other defines the second operand
  3023. * @param result defines the array where to store the multiplication
  3024. * @param offset defines the offset in the target array where to start storing values
  3025. * @returns the current matrix
  3026. */
  3027. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  3028. /**
  3029. * Check equality between this matrix and a second one
  3030. * @param value defines the second matrix to compare
  3031. * @returns true is the current matrix and the given one values are strictly equal
  3032. */
  3033. equals(value: DeepImmutable<Matrix>): boolean;
  3034. /**
  3035. * Clone the current matrix
  3036. * @returns a new matrix from the current matrix
  3037. */
  3038. clone(): Matrix;
  3039. /**
  3040. * Returns the name of the current matrix class
  3041. * @returns the string "Matrix"
  3042. */
  3043. getClassName(): string;
  3044. /**
  3045. * Gets the hash code of the current matrix
  3046. * @returns the hash code
  3047. */
  3048. getHashCode(): number;
  3049. /**
  3050. * Decomposes the current Matrix into a translation, rotation and scaling components
  3051. * @param scale defines the scale vector3 given as a reference to update
  3052. * @param rotation defines the rotation quaternion given as a reference to update
  3053. * @param translation defines the translation vector3 given as a reference to update
  3054. * @returns true if operation was successful
  3055. */
  3056. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  3057. /**
  3058. * Gets specific row of the matrix
  3059. * @param index defines the number of the row to get
  3060. * @returns the index-th row of the current matrix as a new Vector4
  3061. */
  3062. getRow(index: number): Nullable<Vector4>;
  3063. /**
  3064. * Sets the index-th row of the current matrix to the vector4 values
  3065. * @param index defines the number of the row to set
  3066. * @param row defines the target vector4
  3067. * @returns the updated current matrix
  3068. */
  3069. setRow(index: number, row: Vector4): Matrix;
  3070. /**
  3071. * Compute the transpose of the matrix
  3072. * @returns the new transposed matrix
  3073. */
  3074. transpose(): Matrix;
  3075. /**
  3076. * Compute the transpose of the matrix and store it in a given matrix
  3077. * @param result defines the target matrix
  3078. * @returns the current matrix
  3079. */
  3080. transposeToRef(result: Matrix): Matrix;
  3081. /**
  3082. * Sets the index-th row of the current matrix with the given 4 x float values
  3083. * @param index defines the row index
  3084. * @param x defines the x component to set
  3085. * @param y defines the y component to set
  3086. * @param z defines the z component to set
  3087. * @param w defines the w component to set
  3088. * @returns the updated current matrix
  3089. */
  3090. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  3091. /**
  3092. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  3093. * @param scale defines the scale factor
  3094. * @returns a new matrix
  3095. */
  3096. scale(scale: number): Matrix;
  3097. /**
  3098. * Scale the current matrix values by a factor to a given result matrix
  3099. * @param scale defines the scale factor
  3100. * @param result defines the matrix to store the result
  3101. * @returns the current matrix
  3102. */
  3103. scaleToRef(scale: number, result: Matrix): Matrix;
  3104. /**
  3105. * Scale the current matrix values by a factor and add the result to a given matrix
  3106. * @param scale defines the scale factor
  3107. * @param result defines the Matrix to store the result
  3108. * @returns the current matrix
  3109. */
  3110. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  3111. /**
  3112. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  3113. * @param ref matrix to store the result
  3114. */
  3115. toNormalMatrix(ref: Matrix): void;
  3116. /**
  3117. * Gets only rotation part of the current matrix
  3118. * @returns a new matrix sets to the extracted rotation matrix from the current one
  3119. */
  3120. getRotationMatrix(): Matrix;
  3121. /**
  3122. * Extracts the rotation matrix from the current one and sets it as the given "result"
  3123. * @param result defines the target matrix to store data to
  3124. * @returns the current matrix
  3125. */
  3126. getRotationMatrixToRef(result: Matrix): Matrix;
  3127. /**
  3128. * Toggles model matrix from being right handed to left handed in place and vice versa
  3129. */
  3130. toggleModelMatrixHandInPlace(): void;
  3131. /**
  3132. * Toggles projection matrix from being right handed to left handed in place and vice versa
  3133. */
  3134. toggleProjectionMatrixHandInPlace(): void;
  3135. /**
  3136. * Creates a matrix from an array
  3137. * @param array defines the source array
  3138. * @param offset defines an offset in the source array
  3139. * @returns a new Matrix set from the starting index of the given array
  3140. */
  3141. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  3142. /**
  3143. * Copy the content of an array into a given matrix
  3144. * @param array defines the source array
  3145. * @param offset defines an offset in the source array
  3146. * @param result defines the target matrix
  3147. */
  3148. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  3149. /**
  3150. * Stores an array into a matrix after having multiplied each component by a given factor
  3151. * @param array defines the source array
  3152. * @param offset defines the offset in the source array
  3153. * @param scale defines the scaling factor
  3154. * @param result defines the target matrix
  3155. */
  3156. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  3157. /**
  3158. * Gets an identity matrix that must not be updated
  3159. */
  3160. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  3161. /**
  3162. * Stores a list of values (16) inside a given matrix
  3163. * @param initialM11 defines 1st value of 1st row
  3164. * @param initialM12 defines 2nd value of 1st row
  3165. * @param initialM13 defines 3rd value of 1st row
  3166. * @param initialM14 defines 4th value of 1st row
  3167. * @param initialM21 defines 1st value of 2nd row
  3168. * @param initialM22 defines 2nd value of 2nd row
  3169. * @param initialM23 defines 3rd value of 2nd row
  3170. * @param initialM24 defines 4th value of 2nd row
  3171. * @param initialM31 defines 1st value of 3rd row
  3172. * @param initialM32 defines 2nd value of 3rd row
  3173. * @param initialM33 defines 3rd value of 3rd row
  3174. * @param initialM34 defines 4th value of 3rd row
  3175. * @param initialM41 defines 1st value of 4th row
  3176. * @param initialM42 defines 2nd value of 4th row
  3177. * @param initialM43 defines 3rd value of 4th row
  3178. * @param initialM44 defines 4th value of 4th row
  3179. * @param result defines the target matrix
  3180. */
  3181. static FromValuesToRef(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number, result: Matrix): void;
  3182. /**
  3183. * Creates new matrix from a list of values (16)
  3184. * @param initialM11 defines 1st value of 1st row
  3185. * @param initialM12 defines 2nd value of 1st row
  3186. * @param initialM13 defines 3rd value of 1st row
  3187. * @param initialM14 defines 4th value of 1st row
  3188. * @param initialM21 defines 1st value of 2nd row
  3189. * @param initialM22 defines 2nd value of 2nd row
  3190. * @param initialM23 defines 3rd value of 2nd row
  3191. * @param initialM24 defines 4th value of 2nd row
  3192. * @param initialM31 defines 1st value of 3rd row
  3193. * @param initialM32 defines 2nd value of 3rd row
  3194. * @param initialM33 defines 3rd value of 3rd row
  3195. * @param initialM34 defines 4th value of 3rd row
  3196. * @param initialM41 defines 1st value of 4th row
  3197. * @param initialM42 defines 2nd value of 4th row
  3198. * @param initialM43 defines 3rd value of 4th row
  3199. * @param initialM44 defines 4th value of 4th row
  3200. * @returns the new matrix
  3201. */
  3202. static FromValues(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number): Matrix;
  3203. /**
  3204. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3205. * @param scale defines the scale vector3
  3206. * @param rotation defines the rotation quaternion
  3207. * @param translation defines the translation vector3
  3208. * @returns a new matrix
  3209. */
  3210. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  3211. /**
  3212. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3213. * @param scale defines the scale vector3
  3214. * @param rotation defines the rotation quaternion
  3215. * @param translation defines the translation vector3
  3216. * @param result defines the target matrix
  3217. */
  3218. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  3219. /**
  3220. * Creates a new identity matrix
  3221. * @returns a new identity matrix
  3222. */
  3223. static Identity(): Matrix;
  3224. /**
  3225. * Creates a new identity matrix and stores the result in a given matrix
  3226. * @param result defines the target matrix
  3227. */
  3228. static IdentityToRef(result: Matrix): void;
  3229. /**
  3230. * Creates a new zero matrix
  3231. * @returns a new zero matrix
  3232. */
  3233. static Zero(): Matrix;
  3234. /**
  3235. * Creates a new rotation matrix for "angle" radians around the X axis
  3236. * @param angle defines the angle (in radians) to use
  3237. * @return the new matrix
  3238. */
  3239. static RotationX(angle: number): Matrix;
  3240. /**
  3241. * Creates a new matrix as the invert of a given matrix
  3242. * @param source defines the source matrix
  3243. * @returns the new matrix
  3244. */
  3245. static Invert(source: DeepImmutable<Matrix>): Matrix;
  3246. /**
  3247. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  3248. * @param angle defines the angle (in radians) to use
  3249. * @param result defines the target matrix
  3250. */
  3251. static RotationXToRef(angle: number, result: Matrix): void;
  3252. /**
  3253. * Creates a new rotation matrix for "angle" radians around the Y axis
  3254. * @param angle defines the angle (in radians) to use
  3255. * @return the new matrix
  3256. */
  3257. static RotationY(angle: number): Matrix;
  3258. /**
  3259. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  3260. * @param angle defines the angle (in radians) to use
  3261. * @param result defines the target matrix
  3262. */
  3263. static RotationYToRef(angle: number, result: Matrix): void;
  3264. /**
  3265. * Creates a new rotation matrix for "angle" radians around the Z axis
  3266. * @param angle defines the angle (in radians) to use
  3267. * @return the new matrix
  3268. */
  3269. static RotationZ(angle: number): Matrix;
  3270. /**
  3271. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  3272. * @param angle defines the angle (in radians) to use
  3273. * @param result defines the target matrix
  3274. */
  3275. static RotationZToRef(angle: number, result: Matrix): void;
  3276. /**
  3277. * Creates a new rotation matrix for "angle" radians around the given axis
  3278. * @param axis defines the axis to use
  3279. * @param angle defines the angle (in radians) to use
  3280. * @return the new matrix
  3281. */
  3282. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  3283. /**
  3284. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  3285. * @param axis defines the axis to use
  3286. * @param angle defines the angle (in radians) to use
  3287. * @param result defines the target matrix
  3288. */
  3289. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  3290. /**
  3291. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  3292. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  3293. * @param from defines the vector to align
  3294. * @param to defines the vector to align to
  3295. * @param result defines the target matrix
  3296. */
  3297. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  3298. /**
  3299. * Creates a rotation matrix
  3300. * @param yaw defines the yaw angle in radians (Y axis)
  3301. * @param pitch defines the pitch angle in radians (X axis)
  3302. * @param roll defines the roll angle in radians (X axis)
  3303. * @returns the new rotation matrix
  3304. */
  3305. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  3306. /**
  3307. * Creates a rotation matrix and stores it in a given matrix
  3308. * @param yaw defines the yaw angle in radians (Y axis)
  3309. * @param pitch defines the pitch angle in radians (X axis)
  3310. * @param roll defines the roll angle in radians (X axis)
  3311. * @param result defines the target matrix
  3312. */
  3313. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  3314. /**
  3315. * Creates a scaling matrix
  3316. * @param x defines the scale factor on X axis
  3317. * @param y defines the scale factor on Y axis
  3318. * @param z defines the scale factor on Z axis
  3319. * @returns the new matrix
  3320. */
  3321. static Scaling(x: number, y: number, z: number): Matrix;
  3322. /**
  3323. * Creates a scaling matrix and stores it in a given matrix
  3324. * @param x defines the scale factor on X axis
  3325. * @param y defines the scale factor on Y axis
  3326. * @param z defines the scale factor on Z axis
  3327. * @param result defines the target matrix
  3328. */
  3329. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  3330. /**
  3331. * Creates a translation matrix
  3332. * @param x defines the translation on X axis
  3333. * @param y defines the translation on Y axis
  3334. * @param z defines the translationon Z axis
  3335. * @returns the new matrix
  3336. */
  3337. static Translation(x: number, y: number, z: number): Matrix;
  3338. /**
  3339. * Creates a translation matrix and stores it in a given matrix
  3340. * @param x defines the translation on X axis
  3341. * @param y defines the translation on Y axis
  3342. * @param z defines the translationon Z axis
  3343. * @param result defines the target matrix
  3344. */
  3345. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  3346. /**
  3347. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3348. * @param startValue defines the start value
  3349. * @param endValue defines the end value
  3350. * @param gradient defines the gradient factor
  3351. * @returns the new matrix
  3352. */
  3353. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3354. /**
  3355. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3356. * @param startValue defines the start value
  3357. * @param endValue defines the end value
  3358. * @param gradient defines the gradient factor
  3359. * @param result defines the Matrix object where to store data
  3360. */
  3361. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3362. /**
  3363. * Builds a new matrix whose values are computed by:
  3364. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3365. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3366. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3367. * @param startValue defines the first matrix
  3368. * @param endValue defines the second matrix
  3369. * @param gradient defines the gradient between the two matrices
  3370. * @returns the new matrix
  3371. */
  3372. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3373. /**
  3374. * Update a matrix to values which are computed by:
  3375. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3376. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3377. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3378. * @param startValue defines the first matrix
  3379. * @param endValue defines the second matrix
  3380. * @param gradient defines the gradient between the two matrices
  3381. * @param result defines the target matrix
  3382. */
  3383. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3384. /**
  3385. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  3386. * This function works in left handed mode
  3387. * @param eye defines the final position of the entity
  3388. * @param target defines where the entity should look at
  3389. * @param up defines the up vector for the entity
  3390. * @returns the new matrix
  3391. */
  3392. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3393. /**
  3394. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  3395. * This function works in left handed mode
  3396. * @param eye defines the final position of the entity
  3397. * @param target defines where the entity should look at
  3398. * @param up defines the up vector for the entity
  3399. * @param result defines the target matrix
  3400. */
  3401. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3402. /**
  3403. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  3404. * This function works in right handed mode
  3405. * @param eye defines the final position of the entity
  3406. * @param target defines where the entity should look at
  3407. * @param up defines the up vector for the entity
  3408. * @returns the new matrix
  3409. */
  3410. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3411. /**
  3412. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  3413. * This function works in right handed mode
  3414. * @param eye defines the final position of the entity
  3415. * @param target defines where the entity should look at
  3416. * @param up defines the up vector for the entity
  3417. * @param result defines the target matrix
  3418. */
  3419. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3420. /**
  3421. * Create a left-handed orthographic projection matrix
  3422. * @param width defines the viewport width
  3423. * @param height defines the viewport height
  3424. * @param znear defines the near clip plane
  3425. * @param zfar defines the far clip plane
  3426. * @returns a new matrix as a left-handed orthographic projection matrix
  3427. */
  3428. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3429. /**
  3430. * Store a left-handed orthographic projection to a given matrix
  3431. * @param width defines the viewport width
  3432. * @param height defines the viewport height
  3433. * @param znear defines the near clip plane
  3434. * @param zfar defines the far clip plane
  3435. * @param result defines the target matrix
  3436. */
  3437. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  3438. /**
  3439. * Create a left-handed orthographic projection matrix
  3440. * @param left defines the viewport left coordinate
  3441. * @param right defines the viewport right coordinate
  3442. * @param bottom defines the viewport bottom coordinate
  3443. * @param top defines the viewport top coordinate
  3444. * @param znear defines the near clip plane
  3445. * @param zfar defines the far clip plane
  3446. * @returns a new matrix as a left-handed orthographic projection matrix
  3447. */
  3448. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3449. /**
  3450. * Stores a left-handed orthographic projection into a given matrix
  3451. * @param left defines the viewport left coordinate
  3452. * @param right defines the viewport right coordinate
  3453. * @param bottom defines the viewport bottom coordinate
  3454. * @param top defines the viewport top coordinate
  3455. * @param znear defines the near clip plane
  3456. * @param zfar defines the far clip plane
  3457. * @param result defines the target matrix
  3458. */
  3459. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3460. /**
  3461. * Creates a right-handed orthographic projection matrix
  3462. * @param left defines the viewport left coordinate
  3463. * @param right defines the viewport right coordinate
  3464. * @param bottom defines the viewport bottom coordinate
  3465. * @param top defines the viewport top coordinate
  3466. * @param znear defines the near clip plane
  3467. * @param zfar defines the far clip plane
  3468. * @returns a new matrix as a right-handed orthographic projection matrix
  3469. */
  3470. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3471. /**
  3472. * Stores a right-handed orthographic projection into a given matrix
  3473. * @param left defines the viewport left coordinate
  3474. * @param right defines the viewport right coordinate
  3475. * @param bottom defines the viewport bottom coordinate
  3476. * @param top defines the viewport top coordinate
  3477. * @param znear defines the near clip plane
  3478. * @param zfar defines the far clip plane
  3479. * @param result defines the target matrix
  3480. */
  3481. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3482. /**
  3483. * Creates a left-handed perspective projection matrix
  3484. * @param width defines the viewport width
  3485. * @param height defines the viewport height
  3486. * @param znear defines the near clip plane
  3487. * @param zfar defines the far clip plane
  3488. * @returns a new matrix as a left-handed perspective projection matrix
  3489. */
  3490. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3491. /**
  3492. * Creates a left-handed perspective projection matrix
  3493. * @param fov defines the horizontal field of view
  3494. * @param aspect defines the aspect ratio
  3495. * @param znear defines the near clip plane
  3496. * @param zfar defines the far clip plane
  3497. * @returns a new matrix as a left-handed perspective projection matrix
  3498. */
  3499. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3500. /**
  3501. * Stores a left-handed perspective projection into a given matrix
  3502. * @param fov defines the horizontal field of view
  3503. * @param aspect defines the aspect ratio
  3504. * @param znear defines the near clip plane
  3505. * @param zfar defines the far clip plane
  3506. * @param result defines the target matrix
  3507. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3508. */
  3509. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3510. /**
  3511. * Creates a right-handed perspective projection matrix
  3512. * @param fov defines the horizontal field of view
  3513. * @param aspect defines the aspect ratio
  3514. * @param znear defines the near clip plane
  3515. * @param zfar defines the far clip plane
  3516. * @returns a new matrix as a right-handed perspective projection matrix
  3517. */
  3518. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3519. /**
  3520. * Stores a right-handed perspective projection into a given matrix
  3521. * @param fov defines the horizontal field of view
  3522. * @param aspect defines the aspect ratio
  3523. * @param znear defines the near clip plane
  3524. * @param zfar defines the far clip plane
  3525. * @param result defines the target matrix
  3526. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3527. */
  3528. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3529. /**
  3530. * Stores a perspective projection for WebVR info a given matrix
  3531. * @param fov defines the field of view
  3532. * @param znear defines the near clip plane
  3533. * @param zfar defines the far clip plane
  3534. * @param result defines the target matrix
  3535. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  3536. */
  3537. static PerspectiveFovWebVRToRef(fov: {
  3538. upDegrees: number;
  3539. downDegrees: number;
  3540. leftDegrees: number;
  3541. rightDegrees: number;
  3542. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  3543. /**
  3544. * Computes a complete transformation matrix
  3545. * @param viewport defines the viewport to use
  3546. * @param world defines the world matrix
  3547. * @param view defines the view matrix
  3548. * @param projection defines the projection matrix
  3549. * @param zmin defines the near clip plane
  3550. * @param zmax defines the far clip plane
  3551. * @returns the transformation matrix
  3552. */
  3553. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  3554. /**
  3555. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  3556. * @param matrix defines the matrix to use
  3557. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  3558. */
  3559. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  3560. /**
  3561. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  3562. * @param matrix defines the matrix to use
  3563. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  3564. */
  3565. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  3566. /**
  3567. * Compute the transpose of a given matrix
  3568. * @param matrix defines the matrix to transpose
  3569. * @returns the new matrix
  3570. */
  3571. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  3572. /**
  3573. * Compute the transpose of a matrix and store it in a target matrix
  3574. * @param matrix defines the matrix to transpose
  3575. * @param result defines the target matrix
  3576. */
  3577. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  3578. /**
  3579. * Computes a reflection matrix from a plane
  3580. * @param plane defines the reflection plane
  3581. * @returns a new matrix
  3582. */
  3583. static Reflection(plane: DeepImmutable<Plane>): Matrix;
  3584. /**
  3585. * Computes a reflection matrix from a plane
  3586. * @param plane defines the reflection plane
  3587. * @param result defines the target matrix
  3588. */
  3589. static ReflectionToRef(plane: DeepImmutable<Plane>, result: Matrix): void;
  3590. /**
  3591. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  3592. * @param xaxis defines the value of the 1st axis
  3593. * @param yaxis defines the value of the 2nd axis
  3594. * @param zaxis defines the value of the 3rd axis
  3595. * @param result defines the target matrix
  3596. */
  3597. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  3598. /**
  3599. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  3600. * @param quat defines the quaternion to use
  3601. * @param result defines the target matrix
  3602. */
  3603. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  3604. }
  3605. /**
  3606. * Represens a plane by the equation ax + by + cz + d = 0
  3607. */
  3608. export class Plane {
  3609. /**
  3610. * Normal of the plane (a,b,c)
  3611. */
  3612. normal: Vector3;
  3613. /**
  3614. * d component of the plane
  3615. */
  3616. d: number;
  3617. /**
  3618. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  3619. * @param a a component of the plane
  3620. * @param b b component of the plane
  3621. * @param c c component of the plane
  3622. * @param d d component of the plane
  3623. */
  3624. constructor(a: number, b: number, c: number, d: number);
  3625. /**
  3626. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  3627. */
  3628. asArray(): number[];
  3629. /**
  3630. * @returns a new plane copied from the current Plane.
  3631. */
  3632. clone(): Plane;
  3633. /**
  3634. * @returns the string "Plane".
  3635. */
  3636. getClassName(): string;
  3637. /**
  3638. * @returns the Plane hash code.
  3639. */
  3640. getHashCode(): number;
  3641. /**
  3642. * Normalize the current Plane in place.
  3643. * @returns the updated Plane.
  3644. */
  3645. normalize(): Plane;
  3646. /**
  3647. * Applies a transformation the plane and returns the result
  3648. * @param transformation the transformation matrix to be applied to the plane
  3649. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  3650. */
  3651. transform(transformation: DeepImmutable<Matrix>): Plane;
  3652. /**
  3653. * Calcualtte the dot product between the point and the plane normal
  3654. * @param point point to calculate the dot product with
  3655. * @returns the dot product (float) of the point coordinates and the plane normal.
  3656. */
  3657. dotCoordinate(point: DeepImmutable<Vector3>): number;
  3658. /**
  3659. * Updates the current Plane from the plane defined by the three given points.
  3660. * @param point1 one of the points used to contruct the plane
  3661. * @param point2 one of the points used to contruct the plane
  3662. * @param point3 one of the points used to contruct the plane
  3663. * @returns the updated Plane.
  3664. */
  3665. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  3666. /**
  3667. * Checks if the plane is facing a given direction
  3668. * @param direction the direction to check if the plane is facing
  3669. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  3670. * @returns True is the vector "direction" is the same side than the plane normal.
  3671. */
  3672. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  3673. /**
  3674. * Calculates the distance to a point
  3675. * @param point point to calculate distance to
  3676. * @returns the signed distance (float) from the given point to the Plane.
  3677. */
  3678. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  3679. /**
  3680. * Creates a plane from an array
  3681. * @param array the array to create a plane from
  3682. * @returns a new Plane from the given array.
  3683. */
  3684. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  3685. /**
  3686. * Creates a plane from three points
  3687. * @param point1 point used to create the plane
  3688. * @param point2 point used to create the plane
  3689. * @param point3 point used to create the plane
  3690. * @returns a new Plane defined by the three given points.
  3691. */
  3692. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  3693. /**
  3694. * Creates a plane from an origin point and a normal
  3695. * @param origin origin of the plane to be constructed
  3696. * @param normal normal of the plane to be constructed
  3697. * @returns a new Plane the normal vector to this plane at the given origin point.
  3698. * Note : the vector "normal" is updated because normalized.
  3699. */
  3700. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  3701. /**
  3702. * Calculates the distance from a plane and a point
  3703. * @param origin origin of the plane to be constructed
  3704. * @param normal normal of the plane to be constructed
  3705. * @param point point to calculate distance to
  3706. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  3707. */
  3708. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  3709. }
  3710. /**
  3711. * Class used to represent a viewport on screen
  3712. */
  3713. export class Viewport {
  3714. /** viewport left coordinate */
  3715. x: number;
  3716. /** viewport top coordinate */
  3717. y: number;
  3718. /**viewport width */
  3719. width: number;
  3720. /** viewport height */
  3721. height: number;
  3722. /**
  3723. * Creates a Viewport object located at (x, y) and sized (width, height)
  3724. * @param x defines viewport left coordinate
  3725. * @param y defines viewport top coordinate
  3726. * @param width defines the viewport width
  3727. * @param height defines the viewport height
  3728. */
  3729. constructor(
  3730. /** viewport left coordinate */
  3731. x: number,
  3732. /** viewport top coordinate */
  3733. y: number,
  3734. /**viewport width */
  3735. width: number,
  3736. /** viewport height */
  3737. height: number);
  3738. /**
  3739. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  3740. * @param renderWidth defines the rendering width
  3741. * @param renderHeight defines the rendering height
  3742. * @returns a new Viewport
  3743. */
  3744. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  3745. /**
  3746. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  3747. * @param renderWidth defines the rendering width
  3748. * @param renderHeight defines the rendering height
  3749. * @param ref defines the target viewport
  3750. * @returns the current viewport
  3751. */
  3752. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  3753. /**
  3754. * Returns a new Viewport copied from the current one
  3755. * @returns a new Viewport
  3756. */
  3757. clone(): Viewport;
  3758. }
  3759. /**
  3760. * Reprasents a camera frustum
  3761. */
  3762. export class Frustum {
  3763. /**
  3764. * Gets the planes representing the frustum
  3765. * @param transform matrix to be applied to the returned planes
  3766. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  3767. */
  3768. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  3769. /**
  3770. * Gets the near frustum plane transformed by the transform matrix
  3771. * @param transform transformation matrix to be applied to the resulting frustum plane
  3772. * @param frustumPlane the resuling frustum plane
  3773. */
  3774. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3775. /**
  3776. * Gets the far frustum plane transformed by the transform matrix
  3777. * @param transform transformation matrix to be applied to the resulting frustum plane
  3778. * @param frustumPlane the resuling frustum plane
  3779. */
  3780. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3781. /**
  3782. * Gets the left frustum plane transformed by the transform matrix
  3783. * @param transform transformation matrix to be applied to the resulting frustum plane
  3784. * @param frustumPlane the resuling frustum plane
  3785. */
  3786. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3787. /**
  3788. * Gets the right frustum plane transformed by the transform matrix
  3789. * @param transform transformation matrix to be applied to the resulting frustum plane
  3790. * @param frustumPlane the resuling frustum plane
  3791. */
  3792. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3793. /**
  3794. * Gets the top frustum plane transformed by the transform matrix
  3795. * @param transform transformation matrix to be applied to the resulting frustum plane
  3796. * @param frustumPlane the resuling frustum plane
  3797. */
  3798. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3799. /**
  3800. * Gets the bottom frustum plane transformed by the transform matrix
  3801. * @param transform transformation matrix to be applied to the resulting frustum plane
  3802. * @param frustumPlane the resuling frustum plane
  3803. */
  3804. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3805. /**
  3806. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  3807. * @param transform transformation matrix to be applied to the resulting frustum planes
  3808. * @param frustumPlanes the resuling frustum planes
  3809. */
  3810. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  3811. }
  3812. /** Defines supported spaces */
  3813. export enum Space {
  3814. /** Local (object) space */
  3815. LOCAL = 0,
  3816. /** World space */
  3817. WORLD = 1,
  3818. /** Bone space */
  3819. BONE = 2
  3820. }
  3821. /** Defines the 3 main axes */
  3822. export class Axis {
  3823. /** X axis */
  3824. static X: Vector3;
  3825. /** Y axis */
  3826. static Y: Vector3;
  3827. /** Z axis */
  3828. static Z: Vector3;
  3829. }
  3830. /** Class used to represent a Bezier curve */
  3831. export class BezierCurve {
  3832. /**
  3833. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  3834. * @param t defines the time
  3835. * @param x1 defines the left coordinate on X axis
  3836. * @param y1 defines the left coordinate on Y axis
  3837. * @param x2 defines the right coordinate on X axis
  3838. * @param y2 defines the right coordinate on Y axis
  3839. * @returns the interpolated value
  3840. */
  3841. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  3842. }
  3843. /**
  3844. * Defines potential orientation for back face culling
  3845. */
  3846. export enum Orientation {
  3847. /**
  3848. * Clockwise
  3849. */
  3850. CW = 0,
  3851. /** Counter clockwise */
  3852. CCW = 1
  3853. }
  3854. /**
  3855. * Defines angle representation
  3856. */
  3857. export class Angle {
  3858. private _radians;
  3859. /**
  3860. * Creates an Angle object of "radians" radians (float).
  3861. * @param radians the angle in radians
  3862. */
  3863. constructor(radians: number);
  3864. /**
  3865. * Get value in degrees
  3866. * @returns the Angle value in degrees (float)
  3867. */
  3868. degrees(): number;
  3869. /**
  3870. * Get value in radians
  3871. * @returns the Angle value in radians (float)
  3872. */
  3873. radians(): number;
  3874. /**
  3875. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  3876. * @param a defines first vector
  3877. * @param b defines second vector
  3878. * @returns a new Angle
  3879. */
  3880. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  3881. /**
  3882. * Gets a new Angle object from the given float in radians
  3883. * @param radians defines the angle value in radians
  3884. * @returns a new Angle
  3885. */
  3886. static FromRadians(radians: number): Angle;
  3887. /**
  3888. * Gets a new Angle object from the given float in degrees
  3889. * @param degrees defines the angle value in degrees
  3890. * @returns a new Angle
  3891. */
  3892. static FromDegrees(degrees: number): Angle;
  3893. }
  3894. /**
  3895. * This represents an arc in a 2d space.
  3896. */
  3897. export class Arc2 {
  3898. /** Defines the start point of the arc */
  3899. startPoint: Vector2;
  3900. /** Defines the mid point of the arc */
  3901. midPoint: Vector2;
  3902. /** Defines the end point of the arc */
  3903. endPoint: Vector2;
  3904. /**
  3905. * Defines the center point of the arc.
  3906. */
  3907. centerPoint: Vector2;
  3908. /**
  3909. * Defines the radius of the arc.
  3910. */
  3911. radius: number;
  3912. /**
  3913. * Defines the angle of the arc (from mid point to end point).
  3914. */
  3915. angle: Angle;
  3916. /**
  3917. * Defines the start angle of the arc (from start point to middle point).
  3918. */
  3919. startAngle: Angle;
  3920. /**
  3921. * Defines the orientation of the arc (clock wise/counter clock wise).
  3922. */
  3923. orientation: Orientation;
  3924. /**
  3925. * Creates an Arc object from the three given points : start, middle and end.
  3926. * @param startPoint Defines the start point of the arc
  3927. * @param midPoint Defines the midlle point of the arc
  3928. * @param endPoint Defines the end point of the arc
  3929. */
  3930. constructor(
  3931. /** Defines the start point of the arc */
  3932. startPoint: Vector2,
  3933. /** Defines the mid point of the arc */
  3934. midPoint: Vector2,
  3935. /** Defines the end point of the arc */
  3936. endPoint: Vector2);
  3937. }
  3938. /**
  3939. * Represents a 2D path made up of multiple 2D points
  3940. */
  3941. export class Path2 {
  3942. private _points;
  3943. private _length;
  3944. /**
  3945. * If the path start and end point are the same
  3946. */
  3947. closed: boolean;
  3948. /**
  3949. * Creates a Path2 object from the starting 2D coordinates x and y.
  3950. * @param x the starting points x value
  3951. * @param y the starting points y value
  3952. */
  3953. constructor(x: number, y: number);
  3954. /**
  3955. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  3956. * @param x the added points x value
  3957. * @param y the added points y value
  3958. * @returns the updated Path2.
  3959. */
  3960. addLineTo(x: number, y: number): Path2;
  3961. /**
  3962. * Adds _numberOfSegments_ segments according to the arc definition (middle point coordinates, end point coordinates, the arc start point being the current Path2 last point) to the current Path2.
  3963. * @param midX middle point x value
  3964. * @param midY middle point y value
  3965. * @param endX end point x value
  3966. * @param endY end point y value
  3967. * @param numberOfSegments (default: 36)
  3968. * @returns the updated Path2.
  3969. */
  3970. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  3971. /**
  3972. * Closes the Path2.
  3973. * @returns the Path2.
  3974. */
  3975. close(): Path2;
  3976. /**
  3977. * Gets the sum of the distance between each sequential point in the path
  3978. * @returns the Path2 total length (float).
  3979. */
  3980. length(): number;
  3981. /**
  3982. * Gets the points which construct the path
  3983. * @returns the Path2 internal array of points.
  3984. */
  3985. getPoints(): Vector2[];
  3986. /**
  3987. * Retreives the point at the distance aways from the starting point
  3988. * @param normalizedLengthPosition the length along the path to retreive the point from
  3989. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  3990. */
  3991. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  3992. /**
  3993. * Creates a new path starting from an x and y position
  3994. * @param x starting x value
  3995. * @param y starting y value
  3996. * @returns a new Path2 starting at the coordinates (x, y).
  3997. */
  3998. static StartingAt(x: number, y: number): Path2;
  3999. }
  4000. /**
  4001. * Represents a 3D path made up of multiple 3D points
  4002. */
  4003. export class Path3D {
  4004. /**
  4005. * an array of Vector3, the curve axis of the Path3D
  4006. */
  4007. path: Vector3[];
  4008. private _curve;
  4009. private _distances;
  4010. private _tangents;
  4011. private _normals;
  4012. private _binormals;
  4013. private _raw;
  4014. /**
  4015. * new Path3D(path, normal, raw)
  4016. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  4017. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  4018. * @param path an array of Vector3, the curve axis of the Path3D
  4019. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  4020. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  4021. */
  4022. constructor(
  4023. /**
  4024. * an array of Vector3, the curve axis of the Path3D
  4025. */
  4026. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  4027. /**
  4028. * Returns the Path3D array of successive Vector3 designing its curve.
  4029. * @returns the Path3D array of successive Vector3 designing its curve.
  4030. */
  4031. getCurve(): Vector3[];
  4032. /**
  4033. * Returns an array populated with tangent vectors on each Path3D curve point.
  4034. * @returns an array populated with tangent vectors on each Path3D curve point.
  4035. */
  4036. getTangents(): Vector3[];
  4037. /**
  4038. * Returns an array populated with normal vectors on each Path3D curve point.
  4039. * @returns an array populated with normal vectors on each Path3D curve point.
  4040. */
  4041. getNormals(): Vector3[];
  4042. /**
  4043. * Returns an array populated with binormal vectors on each Path3D curve point.
  4044. * @returns an array populated with binormal vectors on each Path3D curve point.
  4045. */
  4046. getBinormals(): Vector3[];
  4047. /**
  4048. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  4049. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  4050. */
  4051. getDistances(): number[];
  4052. /**
  4053. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  4054. * @param path path which all values are copied into the curves points
  4055. * @param firstNormal which should be projected onto the curve
  4056. * @returns the same object updated.
  4057. */
  4058. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  4059. private _compute;
  4060. private _getFirstNonNullVector;
  4061. private _getLastNonNullVector;
  4062. private _normalVector;
  4063. }
  4064. /**
  4065. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4066. * A Curve3 is designed from a series of successive Vector3.
  4067. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  4068. */
  4069. export class Curve3 {
  4070. private _points;
  4071. private _length;
  4072. /**
  4073. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  4074. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  4075. * @param v1 (Vector3) the control point
  4076. * @param v2 (Vector3) the end point of the Quadratic Bezier
  4077. * @param nbPoints (integer) the wanted number of points in the curve
  4078. * @returns the created Curve3
  4079. */
  4080. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4081. /**
  4082. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  4083. * @param v0 (Vector3) the origin point of the Cubic Bezier
  4084. * @param v1 (Vector3) the first control point
  4085. * @param v2 (Vector3) the second control point
  4086. * @param v3 (Vector3) the end point of the Cubic Bezier
  4087. * @param nbPoints (integer) the wanted number of points in the curve
  4088. * @returns the created Curve3
  4089. */
  4090. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4091. /**
  4092. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  4093. * @param p1 (Vector3) the origin point of the Hermite Spline
  4094. * @param t1 (Vector3) the tangent vector at the origin point
  4095. * @param p2 (Vector3) the end point of the Hermite Spline
  4096. * @param t2 (Vector3) the tangent vector at the end point
  4097. * @param nbPoints (integer) the wanted number of points in the curve
  4098. * @returns the created Curve3
  4099. */
  4100. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4101. /**
  4102. * Returns a Curve3 object along a CatmullRom Spline curve :
  4103. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  4104. * @param nbPoints (integer) the wanted number of points between each curve control points
  4105. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  4106. * @returns the created Curve3
  4107. */
  4108. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  4109. /**
  4110. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4111. * A Curve3 is designed from a series of successive Vector3.
  4112. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  4113. * @param points points which make up the curve
  4114. */
  4115. constructor(points: Vector3[]);
  4116. /**
  4117. * @returns the Curve3 stored array of successive Vector3
  4118. */
  4119. getPoints(): Vector3[];
  4120. /**
  4121. * @returns the computed length (float) of the curve.
  4122. */
  4123. length(): number;
  4124. /**
  4125. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  4126. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  4127. * curveA and curveB keep unchanged.
  4128. * @param curve the curve to continue from this curve
  4129. * @returns the newly constructed curve
  4130. */
  4131. continue(curve: DeepImmutable<Curve3>): Curve3;
  4132. private _computeLength;
  4133. }
  4134. /**
  4135. * Contains position and normal vectors for a vertex
  4136. */
  4137. export class PositionNormalVertex {
  4138. /** the position of the vertex (defaut: 0,0,0) */
  4139. position: Vector3;
  4140. /** the normal of the vertex (defaut: 0,1,0) */
  4141. normal: Vector3;
  4142. /**
  4143. * Creates a PositionNormalVertex
  4144. * @param position the position of the vertex (defaut: 0,0,0)
  4145. * @param normal the normal of the vertex (defaut: 0,1,0)
  4146. */
  4147. constructor(
  4148. /** the position of the vertex (defaut: 0,0,0) */
  4149. position?: Vector3,
  4150. /** the normal of the vertex (defaut: 0,1,0) */
  4151. normal?: Vector3);
  4152. /**
  4153. * Clones the PositionNormalVertex
  4154. * @returns the cloned PositionNormalVertex
  4155. */
  4156. clone(): PositionNormalVertex;
  4157. }
  4158. /**
  4159. * Contains position, normal and uv vectors for a vertex
  4160. */
  4161. export class PositionNormalTextureVertex {
  4162. /** the position of the vertex (defaut: 0,0,0) */
  4163. position: Vector3;
  4164. /** the normal of the vertex (defaut: 0,1,0) */
  4165. normal: Vector3;
  4166. /** the uv of the vertex (default: 0,0) */
  4167. uv: Vector2;
  4168. /**
  4169. * Creates a PositionNormalTextureVertex
  4170. * @param position the position of the vertex (defaut: 0,0,0)
  4171. * @param normal the normal of the vertex (defaut: 0,1,0)
  4172. * @param uv the uv of the vertex (default: 0,0)
  4173. */
  4174. constructor(
  4175. /** the position of the vertex (defaut: 0,0,0) */
  4176. position?: Vector3,
  4177. /** the normal of the vertex (defaut: 0,1,0) */
  4178. normal?: Vector3,
  4179. /** the uv of the vertex (default: 0,0) */
  4180. uv?: Vector2);
  4181. /**
  4182. * Clones the PositionNormalTextureVertex
  4183. * @returns the cloned PositionNormalTextureVertex
  4184. */
  4185. clone(): PositionNormalTextureVertex;
  4186. }
  4187. /**
  4188. * @hidden
  4189. */
  4190. export class Tmp {
  4191. static Color3: Color3[];
  4192. static Color4: Color4[];
  4193. static Vector2: Vector2[];
  4194. static Vector3: Vector3[];
  4195. static Vector4: Vector4[];
  4196. static Quaternion: Quaternion[];
  4197. static Matrix: Matrix[];
  4198. }
  4199. }
  4200. declare module BABYLON {
  4201. /**
  4202. * Class used to enable access to offline support
  4203. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  4204. */
  4205. export interface IOfflineProvider {
  4206. /**
  4207. * Gets a boolean indicating if scene must be saved in the database
  4208. */
  4209. enableSceneOffline: boolean;
  4210. /**
  4211. * Gets a boolean indicating if textures must be saved in the database
  4212. */
  4213. enableTexturesOffline: boolean;
  4214. /**
  4215. * Open the offline support and make it available
  4216. * @param successCallback defines the callback to call on success
  4217. * @param errorCallback defines the callback to call on error
  4218. */
  4219. open(successCallback: () => void, errorCallback: () => void): void;
  4220. /**
  4221. * Loads an image from the offline support
  4222. * @param url defines the url to load from
  4223. * @param image defines the target DOM image
  4224. */
  4225. loadImage(url: string, image: HTMLImageElement): void;
  4226. /**
  4227. * Loads a file from offline support
  4228. * @param url defines the URL to load from
  4229. * @param sceneLoaded defines a callback to call on success
  4230. * @param progressCallBack defines a callback to call when progress changed
  4231. * @param errorCallback defines a callback to call on error
  4232. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  4233. */
  4234. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  4235. }
  4236. }
  4237. declare module BABYLON {
  4238. /**
  4239. * A class serves as a medium between the observable and its observers
  4240. */
  4241. export class EventState {
  4242. /**
  4243. * Create a new EventState
  4244. * @param mask defines the mask associated with this state
  4245. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  4246. * @param target defines the original target of the state
  4247. * @param currentTarget defines the current target of the state
  4248. */
  4249. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  4250. /**
  4251. * Initialize the current event state
  4252. * @param mask defines the mask associated with this state
  4253. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  4254. * @param target defines the original target of the state
  4255. * @param currentTarget defines the current target of the state
  4256. * @returns the current event state
  4257. */
  4258. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  4259. /**
  4260. * An Observer can set this property to true to prevent subsequent observers of being notified
  4261. */
  4262. skipNextObservers: boolean;
  4263. /**
  4264. * Get the mask value that were used to trigger the event corresponding to this EventState object
  4265. */
  4266. mask: number;
  4267. /**
  4268. * The object that originally notified the event
  4269. */
  4270. target?: any;
  4271. /**
  4272. * The current object in the bubbling phase
  4273. */
  4274. currentTarget?: any;
  4275. /**
  4276. * This will be populated with the return value of the last function that was executed.
  4277. * If it is the first function in the callback chain it will be the event data.
  4278. */
  4279. lastReturnValue?: any;
  4280. }
  4281. /**
  4282. * Represent an Observer registered to a given Observable object.
  4283. */
  4284. export class Observer<T> {
  4285. /**
  4286. * Defines the callback to call when the observer is notified
  4287. */
  4288. callback: (eventData: T, eventState: EventState) => void;
  4289. /**
  4290. * Defines the mask of the observer (used to filter notifications)
  4291. */
  4292. mask: number;
  4293. /**
  4294. * Defines the current scope used to restore the JS context
  4295. */
  4296. scope: any;
  4297. /** @hidden */
  4298. _willBeUnregistered: boolean;
  4299. /**
  4300. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  4301. */
  4302. unregisterOnNextCall: boolean;
  4303. /**
  4304. * Creates a new observer
  4305. * @param callback defines the callback to call when the observer is notified
  4306. * @param mask defines the mask of the observer (used to filter notifications)
  4307. * @param scope defines the current scope used to restore the JS context
  4308. */
  4309. constructor(
  4310. /**
  4311. * Defines the callback to call when the observer is notified
  4312. */
  4313. callback: (eventData: T, eventState: EventState) => void,
  4314. /**
  4315. * Defines the mask of the observer (used to filter notifications)
  4316. */
  4317. mask: number,
  4318. /**
  4319. * Defines the current scope used to restore the JS context
  4320. */
  4321. scope?: any);
  4322. }
  4323. /**
  4324. * Represent a list of observers registered to multiple Observables object.
  4325. */
  4326. export class MultiObserver<T> {
  4327. private _observers;
  4328. private _observables;
  4329. /**
  4330. * Release associated resources
  4331. */
  4332. dispose(): void;
  4333. /**
  4334. * Raise a callback when one of the observable will notify
  4335. * @param observables defines a list of observables to watch
  4336. * @param callback defines the callback to call on notification
  4337. * @param mask defines the mask used to filter notifications
  4338. * @param scope defines the current scope used to restore the JS context
  4339. * @returns the new MultiObserver
  4340. */
  4341. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  4342. }
  4343. /**
  4344. * The Observable class is a simple implementation of the Observable pattern.
  4345. *
  4346. * There's one slight particularity though: a given Observable can notify its observer using a particular mask value, only the Observers registered with this mask value will be notified.
  4347. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  4348. * For instance you may have a given Observable that have four different types of notifications: Move (mask = 0x01), Stop (mask = 0x02), Turn Right (mask = 0X04), Turn Left (mask = 0X08).
  4349. * A given observer can register itself with only Move and Stop (mask = 0x03), then it will only be notified when one of these two occurs and will never be for Turn Left/Right.
  4350. */
  4351. export class Observable<T> {
  4352. private _observers;
  4353. private _eventState;
  4354. private _onObserverAdded;
  4355. /**
  4356. * Creates a new observable
  4357. * @param onObserverAdded defines a callback to call when a new observer is added
  4358. */
  4359. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  4360. /**
  4361. * Create a new Observer with the specified callback
  4362. * @param callback the callback that will be executed for that Observer
  4363. * @param mask the mask used to filter observers
  4364. * @param insertFirst if true the callback will be inserted at the first position, hence executed before the others ones. If false (default behavior) the callback will be inserted at the last position, executed after all the others already present.
  4365. * @param scope optional scope for the callback to be called from
  4366. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  4367. * @returns the new observer created for the callback
  4368. */
  4369. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  4370. /**
  4371. * Create a new Observer with the specified callback and unregisters after the next notification
  4372. * @param callback the callback that will be executed for that Observer
  4373. * @returns the new observer created for the callback
  4374. */
  4375. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  4376. /**
  4377. * Remove an Observer from the Observable object
  4378. * @param observer the instance of the Observer to remove
  4379. * @returns false if it doesn't belong to this Observable
  4380. */
  4381. remove(observer: Nullable<Observer<T>>): boolean;
  4382. /**
  4383. * Remove a callback from the Observable object
  4384. * @param callback the callback to remove
  4385. * @param scope optional scope. If used only the callbacks with this scope will be removed
  4386. * @returns false if it doesn't belong to this Observable
  4387. */
  4388. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  4389. private _deferUnregister;
  4390. private _remove;
  4391. /**
  4392. * Moves the observable to the top of the observer list making it get called first when notified
  4393. * @param observer the observer to move
  4394. */
  4395. makeObserverTopPriority(observer: Observer<T>): void;
  4396. /**
  4397. * Moves the observable to the bottom of the observer list making it get called last when notified
  4398. * @param observer the observer to move
  4399. */
  4400. makeObserverBottomPriority(observer: Observer<T>): void;
  4401. /**
  4402. * Notify all Observers by calling their respective callback with the given data
  4403. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  4404. * @param eventData defines the data to send to all observers
  4405. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  4406. * @param target defines the original target of the state
  4407. * @param currentTarget defines the current target of the state
  4408. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  4409. */
  4410. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  4411. /**
  4412. * Calling this will execute each callback, expecting it to be a promise or return a value.
  4413. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  4414. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  4415. * and it is crucial that all callbacks will be executed.
  4416. * The order of the callbacks is kept, callbacks are not executed parallel.
  4417. *
  4418. * @param eventData The data to be sent to each callback
  4419. * @param mask is used to filter observers defaults to -1
  4420. * @param target defines the callback target (see EventState)
  4421. * @param currentTarget defines he current object in the bubbling phase
  4422. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  4423. */
  4424. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  4425. /**
  4426. * Notify a specific observer
  4427. * @param observer defines the observer to notify
  4428. * @param eventData defines the data to be sent to each callback
  4429. * @param mask is used to filter observers defaults to -1
  4430. */
  4431. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  4432. /**
  4433. * Gets a boolean indicating if the observable has at least one observer
  4434. * @returns true is the Observable has at least one Observer registered
  4435. */
  4436. hasObservers(): boolean;
  4437. /**
  4438. * Clear the list of observers
  4439. */
  4440. clear(): void;
  4441. /**
  4442. * Clone the current observable
  4443. * @returns a new observable
  4444. */
  4445. clone(): Observable<T>;
  4446. /**
  4447. * Does this observable handles observer registered with a given mask
  4448. * @param mask defines the mask to be tested
  4449. * @return whether or not one observer registered with the given mask is handeled
  4450. **/
  4451. hasSpecificMask(mask?: number): boolean;
  4452. }
  4453. }
  4454. declare module BABYLON {
  4455. /**
  4456. * Class used to help managing file picking and drag'n'drop
  4457. * File Storage
  4458. */
  4459. export class FilesInputStore {
  4460. /**
  4461. * List of files ready to be loaded
  4462. */
  4463. static FilesToLoad: {
  4464. [key: string]: File;
  4465. };
  4466. }
  4467. }
  4468. declare module BABYLON {
  4469. /** Defines the cross module used constants to avoid circular dependncies */
  4470. export class Constants {
  4471. /** Defines that alpha blending is disabled */
  4472. static readonly ALPHA_DISABLE: number;
  4473. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  4474. static readonly ALPHA_ADD: number;
  4475. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  4476. static readonly ALPHA_COMBINE: number;
  4477. /** Defines that alpha blending to DEST - SRC * DEST */
  4478. static readonly ALPHA_SUBTRACT: number;
  4479. /** Defines that alpha blending to SRC * DEST */
  4480. static readonly ALPHA_MULTIPLY: number;
  4481. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  4482. static readonly ALPHA_MAXIMIZED: number;
  4483. /** Defines that alpha blending to SRC + DEST */
  4484. static readonly ALPHA_ONEONE: number;
  4485. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  4486. static readonly ALPHA_PREMULTIPLIED: number;
  4487. /**
  4488. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  4489. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  4490. */
  4491. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  4492. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  4493. static readonly ALPHA_INTERPOLATE: number;
  4494. /**
  4495. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  4496. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  4497. */
  4498. static readonly ALPHA_SCREENMODE: number;
  4499. /** Defines that the ressource is not delayed*/
  4500. static readonly DELAYLOADSTATE_NONE: number;
  4501. /** Defines that the ressource was successfully delay loaded */
  4502. static readonly DELAYLOADSTATE_LOADED: number;
  4503. /** Defines that the ressource is currently delay loading */
  4504. static readonly DELAYLOADSTATE_LOADING: number;
  4505. /** Defines that the ressource is delayed and has not started loading */
  4506. static readonly DELAYLOADSTATE_NOTLOADED: number;
  4507. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  4508. static readonly NEVER: number;
  4509. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will always pass. i.e. Pixels will be drawn in the order they are drawn */
  4510. static readonly ALWAYS: number;
  4511. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  4512. static readonly LESS: number;
  4513. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  4514. static readonly EQUAL: number;
  4515. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than or equal to the stored value */
  4516. static readonly LEQUAL: number;
  4517. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  4518. static readonly GREATER: number;
  4519. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than or equal to the stored value */
  4520. static readonly GEQUAL: number;
  4521. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is not equal to the stored value */
  4522. static readonly NOTEQUAL: number;
  4523. /** Passed to stencilOperation to specify that stencil value must be kept */
  4524. static readonly KEEP: number;
  4525. /** Passed to stencilOperation to specify that stencil value must be replaced */
  4526. static readonly REPLACE: number;
  4527. /** Passed to stencilOperation to specify that stencil value must be incremented */
  4528. static readonly INCR: number;
  4529. /** Passed to stencilOperation to specify that stencil value must be decremented */
  4530. static readonly DECR: number;
  4531. /** Passed to stencilOperation to specify that stencil value must be inverted */
  4532. static readonly INVERT: number;
  4533. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  4534. static readonly INCR_WRAP: number;
  4535. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  4536. static readonly DECR_WRAP: number;
  4537. /** Texture is not repeating outside of 0..1 UVs */
  4538. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  4539. /** Texture is repeating outside of 0..1 UVs */
  4540. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  4541. /** Texture is repeating and mirrored */
  4542. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  4543. /** ALPHA */
  4544. static readonly TEXTUREFORMAT_ALPHA: number;
  4545. /** LUMINANCE */
  4546. static readonly TEXTUREFORMAT_LUMINANCE: number;
  4547. /** LUMINANCE_ALPHA */
  4548. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  4549. /** RGB */
  4550. static readonly TEXTUREFORMAT_RGB: number;
  4551. /** RGBA */
  4552. static readonly TEXTUREFORMAT_RGBA: number;
  4553. /** RED */
  4554. static readonly TEXTUREFORMAT_RED: number;
  4555. /** RED (2nd reference) */
  4556. static readonly TEXTUREFORMAT_R: number;
  4557. /** RG */
  4558. static readonly TEXTUREFORMAT_RG: number;
  4559. /** RED_INTEGER */
  4560. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  4561. /** RED_INTEGER (2nd reference) */
  4562. static readonly TEXTUREFORMAT_R_INTEGER: number;
  4563. /** RG_INTEGER */
  4564. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  4565. /** RGB_INTEGER */
  4566. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  4567. /** RGBA_INTEGER */
  4568. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  4569. /** UNSIGNED_BYTE */
  4570. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  4571. /** UNSIGNED_BYTE (2nd reference) */
  4572. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  4573. /** FLOAT */
  4574. static readonly TEXTURETYPE_FLOAT: number;
  4575. /** HALF_FLOAT */
  4576. static readonly TEXTURETYPE_HALF_FLOAT: number;
  4577. /** BYTE */
  4578. static readonly TEXTURETYPE_BYTE: number;
  4579. /** SHORT */
  4580. static readonly TEXTURETYPE_SHORT: number;
  4581. /** UNSIGNED_SHORT */
  4582. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  4583. /** INT */
  4584. static readonly TEXTURETYPE_INT: number;
  4585. /** UNSIGNED_INT */
  4586. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  4587. /** UNSIGNED_SHORT_4_4_4_4 */
  4588. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  4589. /** UNSIGNED_SHORT_5_5_5_1 */
  4590. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  4591. /** UNSIGNED_SHORT_5_6_5 */
  4592. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  4593. /** UNSIGNED_INT_2_10_10_10_REV */
  4594. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  4595. /** UNSIGNED_INT_24_8 */
  4596. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  4597. /** UNSIGNED_INT_10F_11F_11F_REV */
  4598. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  4599. /** UNSIGNED_INT_5_9_9_9_REV */
  4600. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  4601. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  4602. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  4603. /** nearest is mag = nearest and min = nearest and mip = linear */
  4604. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  4605. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4606. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  4607. /** Trilinear is mag = linear and min = linear and mip = linear */
  4608. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  4609. /** nearest is mag = nearest and min = nearest and mip = linear */
  4610. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  4611. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4612. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  4613. /** Trilinear is mag = linear and min = linear and mip = linear */
  4614. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  4615. /** mag = nearest and min = nearest and mip = nearest */
  4616. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  4617. /** mag = nearest and min = linear and mip = nearest */
  4618. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  4619. /** mag = nearest and min = linear and mip = linear */
  4620. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  4621. /** mag = nearest and min = linear and mip = none */
  4622. static readonly TEXTURE_NEAREST_LINEAR: number;
  4623. /** mag = nearest and min = nearest and mip = none */
  4624. static readonly TEXTURE_NEAREST_NEAREST: number;
  4625. /** mag = linear and min = nearest and mip = nearest */
  4626. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  4627. /** mag = linear and min = nearest and mip = linear */
  4628. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  4629. /** mag = linear and min = linear and mip = none */
  4630. static readonly TEXTURE_LINEAR_LINEAR: number;
  4631. /** mag = linear and min = nearest and mip = none */
  4632. static readonly TEXTURE_LINEAR_NEAREST: number;
  4633. /** Explicit coordinates mode */
  4634. static readonly TEXTURE_EXPLICIT_MODE: number;
  4635. /** Spherical coordinates mode */
  4636. static readonly TEXTURE_SPHERICAL_MODE: number;
  4637. /** Planar coordinates mode */
  4638. static readonly TEXTURE_PLANAR_MODE: number;
  4639. /** Cubic coordinates mode */
  4640. static readonly TEXTURE_CUBIC_MODE: number;
  4641. /** Projection coordinates mode */
  4642. static readonly TEXTURE_PROJECTION_MODE: number;
  4643. /** Skybox coordinates mode */
  4644. static readonly TEXTURE_SKYBOX_MODE: number;
  4645. /** Inverse Cubic coordinates mode */
  4646. static readonly TEXTURE_INVCUBIC_MODE: number;
  4647. /** Equirectangular coordinates mode */
  4648. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  4649. /** Equirectangular Fixed coordinates mode */
  4650. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  4651. /** Equirectangular Fixed Mirrored coordinates mode */
  4652. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  4653. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  4654. static readonly SCALEMODE_FLOOR: number;
  4655. /** Defines that texture rescaling will look for the nearest power of 2 size */
  4656. static readonly SCALEMODE_NEAREST: number;
  4657. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  4658. static readonly SCALEMODE_CEILING: number;
  4659. /**
  4660. * The dirty texture flag value
  4661. */
  4662. static readonly MATERIAL_TextureDirtyFlag: number;
  4663. /**
  4664. * The dirty light flag value
  4665. */
  4666. static readonly MATERIAL_LightDirtyFlag: number;
  4667. /**
  4668. * The dirty fresnel flag value
  4669. */
  4670. static readonly MATERIAL_FresnelDirtyFlag: number;
  4671. /**
  4672. * The dirty attribute flag value
  4673. */
  4674. static readonly MATERIAL_AttributesDirtyFlag: number;
  4675. /**
  4676. * The dirty misc flag value
  4677. */
  4678. static readonly MATERIAL_MiscDirtyFlag: number;
  4679. /**
  4680. * The all dirty flag value
  4681. */
  4682. static readonly MATERIAL_AllDirtyFlag: number;
  4683. /**
  4684. * Returns the triangle fill mode
  4685. */
  4686. static readonly MATERIAL_TriangleFillMode: number;
  4687. /**
  4688. * Returns the wireframe mode
  4689. */
  4690. static readonly MATERIAL_WireFrameFillMode: number;
  4691. /**
  4692. * Returns the point fill mode
  4693. */
  4694. static readonly MATERIAL_PointFillMode: number;
  4695. /**
  4696. * Returns the point list draw mode
  4697. */
  4698. static readonly MATERIAL_PointListDrawMode: number;
  4699. /**
  4700. * Returns the line list draw mode
  4701. */
  4702. static readonly MATERIAL_LineListDrawMode: number;
  4703. /**
  4704. * Returns the line loop draw mode
  4705. */
  4706. static readonly MATERIAL_LineLoopDrawMode: number;
  4707. /**
  4708. * Returns the line strip draw mode
  4709. */
  4710. static readonly MATERIAL_LineStripDrawMode: number;
  4711. /**
  4712. * Returns the triangle strip draw mode
  4713. */
  4714. static readonly MATERIAL_TriangleStripDrawMode: number;
  4715. /**
  4716. * Returns the triangle fan draw mode
  4717. */
  4718. static readonly MATERIAL_TriangleFanDrawMode: number;
  4719. /**
  4720. * Stores the clock-wise side orientation
  4721. */
  4722. static readonly MATERIAL_ClockWiseSideOrientation: number;
  4723. /**
  4724. * Stores the counter clock-wise side orientation
  4725. */
  4726. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  4727. /**
  4728. * Nothing
  4729. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4730. */
  4731. static readonly ACTION_NothingTrigger: number;
  4732. /**
  4733. * On pick
  4734. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4735. */
  4736. static readonly ACTION_OnPickTrigger: number;
  4737. /**
  4738. * On left pick
  4739. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4740. */
  4741. static readonly ACTION_OnLeftPickTrigger: number;
  4742. /**
  4743. * On right pick
  4744. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4745. */
  4746. static readonly ACTION_OnRightPickTrigger: number;
  4747. /**
  4748. * On center pick
  4749. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4750. */
  4751. static readonly ACTION_OnCenterPickTrigger: number;
  4752. /**
  4753. * On pick down
  4754. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4755. */
  4756. static readonly ACTION_OnPickDownTrigger: number;
  4757. /**
  4758. * On double pick
  4759. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4760. */
  4761. static readonly ACTION_OnDoublePickTrigger: number;
  4762. /**
  4763. * On pick up
  4764. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4765. */
  4766. static readonly ACTION_OnPickUpTrigger: number;
  4767. /**
  4768. * On pick out.
  4769. * This trigger will only be raised if you also declared a OnPickDown
  4770. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4771. */
  4772. static readonly ACTION_OnPickOutTrigger: number;
  4773. /**
  4774. * On long press
  4775. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4776. */
  4777. static readonly ACTION_OnLongPressTrigger: number;
  4778. /**
  4779. * On pointer over
  4780. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4781. */
  4782. static readonly ACTION_OnPointerOverTrigger: number;
  4783. /**
  4784. * On pointer out
  4785. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4786. */
  4787. static readonly ACTION_OnPointerOutTrigger: number;
  4788. /**
  4789. * On every frame
  4790. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4791. */
  4792. static readonly ACTION_OnEveryFrameTrigger: number;
  4793. /**
  4794. * On intersection enter
  4795. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4796. */
  4797. static readonly ACTION_OnIntersectionEnterTrigger: number;
  4798. /**
  4799. * On intersection exit
  4800. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4801. */
  4802. static readonly ACTION_OnIntersectionExitTrigger: number;
  4803. /**
  4804. * On key down
  4805. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4806. */
  4807. static readonly ACTION_OnKeyDownTrigger: number;
  4808. /**
  4809. * On key up
  4810. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4811. */
  4812. static readonly ACTION_OnKeyUpTrigger: number;
  4813. /**
  4814. * Billboard mode will only apply to Y axis
  4815. */
  4816. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  4817. /**
  4818. * Billboard mode will apply to all axes
  4819. */
  4820. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  4821. /**
  4822. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  4823. */
  4824. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  4825. /**
  4826. * Gets or sets base Assets URL
  4827. */
  4828. static PARTICLES_BaseAssetsUrl: string;
  4829. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  4830. * Test order :
  4831. * Is the bounding sphere outside the frustum ?
  4832. * If not, are the bounding box vertices outside the frustum ?
  4833. * It not, then the cullable object is in the frustum.
  4834. */
  4835. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  4836. /** Culling strategy : Bounding Sphere Only.
  4837. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  4838. * It's also less accurate than the standard because some not visible objects can still be selected.
  4839. * Test : is the bounding sphere outside the frustum ?
  4840. * If not, then the cullable object is in the frustum.
  4841. */
  4842. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  4843. /** Culling strategy : Optimistic Inclusion.
  4844. * This in an inclusion test first, then the standard exclusion test.
  4845. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  4846. * This could also be a little slower than the standard test when the tested object center is not the frustum but one of its bounding box vertex is still inside.
  4847. * Anyway, it's as accurate as the standard strategy.
  4848. * Test :
  4849. * Is the cullable object bounding sphere center in the frustum ?
  4850. * If not, apply the default culling strategy.
  4851. */
  4852. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  4853. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  4854. * This in an inclusion test first, then the bounding sphere only exclusion test.
  4855. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  4856. * This could also be a little slower than the BoundingSphereOnly strategy when the tested object center is not in the frustum but its bounding sphere still intersects it.
  4857. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  4858. * Test :
  4859. * Is the cullable object bounding sphere center in the frustum ?
  4860. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  4861. */
  4862. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  4863. /**
  4864. * No logging while loading
  4865. */
  4866. static readonly SCENELOADER_NO_LOGGING: number;
  4867. /**
  4868. * Minimal logging while loading
  4869. */
  4870. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  4871. /**
  4872. * Summary logging while loading
  4873. */
  4874. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  4875. /**
  4876. * Detailled logging while loading
  4877. */
  4878. static readonly SCENELOADER_DETAILED_LOGGING: number;
  4879. }
  4880. }
  4881. declare module BABYLON {
  4882. /**
  4883. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  4884. * Babylon.js
  4885. */
  4886. export class DomManagement {
  4887. /**
  4888. * Checks if the window object exists
  4889. * @returns true if the window object exists
  4890. */
  4891. static IsWindowObjectExist(): boolean;
  4892. /**
  4893. * Extracts text content from a DOM element hierarchy
  4894. * @param element defines the root element
  4895. * @returns a string
  4896. */
  4897. static GetDOMTextContent(element: HTMLElement): string;
  4898. }
  4899. }
  4900. declare module BABYLON {
  4901. /**
  4902. * Logger used througouht the application to allow configuration of
  4903. * the log level required for the messages.
  4904. */
  4905. export class Logger {
  4906. /**
  4907. * No log
  4908. */
  4909. static readonly NoneLogLevel: number;
  4910. /**
  4911. * Only message logs
  4912. */
  4913. static readonly MessageLogLevel: number;
  4914. /**
  4915. * Only warning logs
  4916. */
  4917. static readonly WarningLogLevel: number;
  4918. /**
  4919. * Only error logs
  4920. */
  4921. static readonly ErrorLogLevel: number;
  4922. /**
  4923. * All logs
  4924. */
  4925. static readonly AllLogLevel: number;
  4926. private static _LogCache;
  4927. /**
  4928. * Gets a value indicating the number of loading errors
  4929. * @ignorenaming
  4930. */
  4931. static errorsCount: number;
  4932. /**
  4933. * Callback called when a new log is added
  4934. */
  4935. static OnNewCacheEntry: (entry: string) => void;
  4936. private static _AddLogEntry;
  4937. private static _FormatMessage;
  4938. private static _LogDisabled;
  4939. private static _LogEnabled;
  4940. private static _WarnDisabled;
  4941. private static _WarnEnabled;
  4942. private static _ErrorDisabled;
  4943. private static _ErrorEnabled;
  4944. /**
  4945. * Log a message to the console
  4946. */
  4947. static Log: (message: string) => void;
  4948. /**
  4949. * Write a warning message to the console
  4950. */
  4951. static Warn: (message: string) => void;
  4952. /**
  4953. * Write an error message to the console
  4954. */
  4955. static Error: (message: string) => void;
  4956. /**
  4957. * Gets current log cache (list of logs)
  4958. */
  4959. static readonly LogCache: string;
  4960. /**
  4961. * Clears the log cache
  4962. */
  4963. static ClearLogCache(): void;
  4964. /**
  4965. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  4966. */
  4967. static LogLevels: number;
  4968. }
  4969. }
  4970. declare module BABYLON {
  4971. /** @hidden */
  4972. export class _TypeStore {
  4973. /** @hidden */
  4974. static RegisteredTypes: {
  4975. [key: string]: Object;
  4976. };
  4977. /** @hidden */
  4978. static GetClass(fqdn: string): any;
  4979. }
  4980. }
  4981. declare module BABYLON {
  4982. /**
  4983. * Class containing a set of static utilities functions for deep copy.
  4984. */
  4985. export class DeepCopier {
  4986. /**
  4987. * Tries to copy an object by duplicating every property
  4988. * @param source defines the source object
  4989. * @param destination defines the target object
  4990. * @param doNotCopyList defines a list of properties to avoid
  4991. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  4992. */
  4993. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  4994. }
  4995. }
  4996. declare module BABYLON {
  4997. /**
  4998. * Class containing a set of static utilities functions for precision date
  4999. */
  5000. export class PrecisionDate {
  5001. /**
  5002. * Gets either window.performance.now() if supported or Date.now() else
  5003. */
  5004. static readonly Now: number;
  5005. }
  5006. }
  5007. declare module BABYLON {
  5008. /** @hidden */
  5009. export class _DevTools {
  5010. static WarnImport(name: string): string;
  5011. }
  5012. }
  5013. declare module BABYLON {
  5014. /**
  5015. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  5016. */
  5017. export class WebRequest {
  5018. private _xhr;
  5019. /**
  5020. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  5021. * i.e. when loading files, where the server/service expects an Authorization header
  5022. */
  5023. static CustomRequestHeaders: {
  5024. [key: string]: string;
  5025. };
  5026. /**
  5027. * Add callback functions in this array to update all the requests before they get sent to the network
  5028. */
  5029. static CustomRequestModifiers: ((request: XMLHttpRequest) => void)[];
  5030. private _injectCustomRequestHeaders;
  5031. /**
  5032. * Gets or sets a function to be called when loading progress changes
  5033. */
  5034. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  5035. /**
  5036. * Returns client's state
  5037. */
  5038. readonly readyState: number;
  5039. /**
  5040. * Returns client's status
  5041. */
  5042. readonly status: number;
  5043. /**
  5044. * Returns client's status as a text
  5045. */
  5046. readonly statusText: string;
  5047. /**
  5048. * Returns client's response
  5049. */
  5050. readonly response: any;
  5051. /**
  5052. * Returns client's response url
  5053. */
  5054. readonly responseURL: string;
  5055. /**
  5056. * Returns client's response as text
  5057. */
  5058. readonly responseText: string;
  5059. /**
  5060. * Gets or sets the expected response type
  5061. */
  5062. responseType: XMLHttpRequestResponseType;
  5063. /** @hidden */
  5064. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  5065. /** @hidden */
  5066. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  5067. /**
  5068. * Cancels any network activity
  5069. */
  5070. abort(): void;
  5071. /**
  5072. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  5073. * @param body defines an optional request body
  5074. */
  5075. send(body?: Document | BodyInit | null): void;
  5076. /**
  5077. * Sets the request method, request URL
  5078. * @param method defines the method to use (GET, POST, etc..)
  5079. * @param url defines the url to connect with
  5080. */
  5081. open(method: string, url: string): void;
  5082. }
  5083. }
  5084. declare module BABYLON {
  5085. /**
  5086. * Class used to evalaute queries containing `and` and `or` operators
  5087. */
  5088. export class AndOrNotEvaluator {
  5089. /**
  5090. * Evaluate a query
  5091. * @param query defines the query to evaluate
  5092. * @param evaluateCallback defines the callback used to filter result
  5093. * @returns true if the query matches
  5094. */
  5095. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  5096. private static _HandleParenthesisContent;
  5097. private static _SimplifyNegation;
  5098. }
  5099. }
  5100. declare module BABYLON {
  5101. /**
  5102. * Class used to store custom tags
  5103. */
  5104. export class Tags {
  5105. /**
  5106. * Adds support for tags on the given object
  5107. * @param obj defines the object to use
  5108. */
  5109. static EnableFor(obj: any): void;
  5110. /**
  5111. * Removes tags support
  5112. * @param obj defines the object to use
  5113. */
  5114. static DisableFor(obj: any): void;
  5115. /**
  5116. * Gets a boolean indicating if the given object has tags
  5117. * @param obj defines the object to use
  5118. * @returns a boolean
  5119. */
  5120. static HasTags(obj: any): boolean;
  5121. /**
  5122. * Gets the tags available on a given object
  5123. * @param obj defines the object to use
  5124. * @param asString defines if the tags must be returned as a string instead of an array of strings
  5125. * @returns the tags
  5126. */
  5127. static GetTags(obj: any, asString?: boolean): any;
  5128. /**
  5129. * Adds tags to an object
  5130. * @param obj defines the object to use
  5131. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  5132. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  5133. */
  5134. static AddTagsTo(obj: any, tagsString: string): void;
  5135. /**
  5136. * @hidden
  5137. */
  5138. static _AddTagTo(obj: any, tag: string): void;
  5139. /**
  5140. * Removes specific tags from a specific object
  5141. * @param obj defines the object to use
  5142. * @param tagsString defines the tags to remove
  5143. */
  5144. static RemoveTagsFrom(obj: any, tagsString: string): void;
  5145. /**
  5146. * @hidden
  5147. */
  5148. static _RemoveTagFrom(obj: any, tag: string): void;
  5149. /**
  5150. * Defines if tags hosted on an object match a given query
  5151. * @param obj defines the object to use
  5152. * @param tagsQuery defines the tag query
  5153. * @returns a boolean
  5154. */
  5155. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  5156. }
  5157. }
  5158. declare module BABYLON {
  5159. /**
  5160. * Manages the defines for the Material
  5161. */
  5162. export class MaterialDefines {
  5163. /** @hidden */
  5164. protected _keys: string[];
  5165. private _isDirty;
  5166. /** @hidden */
  5167. _renderId: number;
  5168. /** @hidden */
  5169. _areLightsDirty: boolean;
  5170. /** @hidden */
  5171. _areAttributesDirty: boolean;
  5172. /** @hidden */
  5173. _areTexturesDirty: boolean;
  5174. /** @hidden */
  5175. _areFresnelDirty: boolean;
  5176. /** @hidden */
  5177. _areMiscDirty: boolean;
  5178. /** @hidden */
  5179. _areImageProcessingDirty: boolean;
  5180. /** @hidden */
  5181. _normals: boolean;
  5182. /** @hidden */
  5183. _uvs: boolean;
  5184. /** @hidden */
  5185. _needNormals: boolean;
  5186. /** @hidden */
  5187. _needUVs: boolean;
  5188. [id: string]: any;
  5189. /**
  5190. * Specifies if the material needs to be re-calculated
  5191. */
  5192. readonly isDirty: boolean;
  5193. /**
  5194. * Marks the material to indicate that it has been re-calculated
  5195. */
  5196. markAsProcessed(): void;
  5197. /**
  5198. * Marks the material to indicate that it needs to be re-calculated
  5199. */
  5200. markAsUnprocessed(): void;
  5201. /**
  5202. * Marks the material to indicate all of its defines need to be re-calculated
  5203. */
  5204. markAllAsDirty(): void;
  5205. /**
  5206. * Marks the material to indicate that image processing needs to be re-calculated
  5207. */
  5208. markAsImageProcessingDirty(): void;
  5209. /**
  5210. * Marks the material to indicate the lights need to be re-calculated
  5211. */
  5212. markAsLightDirty(): void;
  5213. /**
  5214. * Marks the attribute state as changed
  5215. */
  5216. markAsAttributesDirty(): void;
  5217. /**
  5218. * Marks the texture state as changed
  5219. */
  5220. markAsTexturesDirty(): void;
  5221. /**
  5222. * Marks the fresnel state as changed
  5223. */
  5224. markAsFresnelDirty(): void;
  5225. /**
  5226. * Marks the misc state as changed
  5227. */
  5228. markAsMiscDirty(): void;
  5229. /**
  5230. * Rebuilds the material defines
  5231. */
  5232. rebuild(): void;
  5233. /**
  5234. * Specifies if two material defines are equal
  5235. * @param other - A material define instance to compare to
  5236. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  5237. */
  5238. isEqual(other: MaterialDefines): boolean;
  5239. /**
  5240. * Clones this instance's defines to another instance
  5241. * @param other - material defines to clone values to
  5242. */
  5243. cloneTo(other: MaterialDefines): void;
  5244. /**
  5245. * Resets the material define values
  5246. */
  5247. reset(): void;
  5248. /**
  5249. * Converts the material define values to a string
  5250. * @returns - String of material define information
  5251. */
  5252. toString(): string;
  5253. }
  5254. }
  5255. declare module BABYLON {
  5256. /**
  5257. * Class used to store and describe the pipeline context associated with an effect
  5258. */
  5259. export interface IPipelineContext {
  5260. /**
  5261. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  5262. */
  5263. isAsync: boolean;
  5264. /**
  5265. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  5266. */
  5267. isReady: boolean;
  5268. /** @hidden */
  5269. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  5270. }
  5271. }
  5272. declare module BABYLON {
  5273. /**
  5274. * Class used to store gfx data (like WebGLBuffer)
  5275. */
  5276. export class DataBuffer {
  5277. /**
  5278. * Gets or sets the number of objects referencing this buffer
  5279. */
  5280. references: number;
  5281. /** Gets or sets the size of the underlying buffer */
  5282. capacity: number;
  5283. /**
  5284. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  5285. */
  5286. is32Bits: boolean;
  5287. /**
  5288. * Gets the underlying buffer
  5289. */
  5290. readonly underlyingResource: any;
  5291. }
  5292. }
  5293. declare module BABYLON {
  5294. /** @hidden */
  5295. export interface IShaderProcessor {
  5296. attributeProcessor?: (attribute: string) => string;
  5297. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  5298. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  5299. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  5300. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  5301. lineProcessor?: (line: string, isFragment: boolean) => string;
  5302. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  5303. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  5304. }
  5305. }
  5306. declare module BABYLON {
  5307. /** @hidden */
  5308. export interface ProcessingOptions {
  5309. defines: string[];
  5310. indexParameters: any;
  5311. isFragment: boolean;
  5312. shouldUseHighPrecisionShader: boolean;
  5313. supportsUniformBuffers: boolean;
  5314. shadersRepository: string;
  5315. includesShadersStore: {
  5316. [key: string]: string;
  5317. };
  5318. processor?: IShaderProcessor;
  5319. version: string;
  5320. platformName: string;
  5321. lookForClosingBracketForUniformBuffer?: boolean;
  5322. }
  5323. }
  5324. declare module BABYLON {
  5325. /** @hidden */
  5326. export class ShaderCodeNode {
  5327. line: string;
  5328. children: ShaderCodeNode[];
  5329. additionalDefineKey?: string;
  5330. additionalDefineValue?: string;
  5331. isValid(preprocessors: {
  5332. [key: string]: string;
  5333. }): boolean;
  5334. process(preprocessors: {
  5335. [key: string]: string;
  5336. }, options: ProcessingOptions): string;
  5337. }
  5338. }
  5339. declare module BABYLON {
  5340. /** @hidden */
  5341. export class ShaderCodeCursor {
  5342. private _lines;
  5343. lineIndex: number;
  5344. readonly currentLine: string;
  5345. readonly canRead: boolean;
  5346. lines: string[];
  5347. }
  5348. }
  5349. declare module BABYLON {
  5350. /** @hidden */
  5351. export class ShaderCodeConditionNode extends ShaderCodeNode {
  5352. process(preprocessors: {
  5353. [key: string]: string;
  5354. }, options: ProcessingOptions): string;
  5355. }
  5356. }
  5357. declare module BABYLON {
  5358. /** @hidden */
  5359. export class ShaderDefineExpression {
  5360. isTrue(preprocessors: {
  5361. [key: string]: string;
  5362. }): boolean;
  5363. }
  5364. }
  5365. declare module BABYLON {
  5366. /** @hidden */
  5367. export class ShaderCodeTestNode extends ShaderCodeNode {
  5368. testExpression: ShaderDefineExpression;
  5369. isValid(preprocessors: {
  5370. [key: string]: string;
  5371. }): boolean;
  5372. }
  5373. }
  5374. declare module BABYLON {
  5375. /** @hidden */
  5376. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  5377. define: string;
  5378. not: boolean;
  5379. constructor(define: string, not?: boolean);
  5380. isTrue(preprocessors: {
  5381. [key: string]: string;
  5382. }): boolean;
  5383. }
  5384. }
  5385. declare module BABYLON {
  5386. /** @hidden */
  5387. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  5388. leftOperand: ShaderDefineExpression;
  5389. rightOperand: ShaderDefineExpression;
  5390. isTrue(preprocessors: {
  5391. [key: string]: string;
  5392. }): boolean;
  5393. }
  5394. }
  5395. declare module BABYLON {
  5396. /** @hidden */
  5397. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  5398. leftOperand: ShaderDefineExpression;
  5399. rightOperand: ShaderDefineExpression;
  5400. isTrue(preprocessors: {
  5401. [key: string]: string;
  5402. }): boolean;
  5403. }
  5404. }
  5405. declare module BABYLON {
  5406. /** @hidden */
  5407. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  5408. define: string;
  5409. operand: string;
  5410. testValue: string;
  5411. constructor(define: string, operand: string, testValue: string);
  5412. isTrue(preprocessors: {
  5413. [key: string]: string;
  5414. }): boolean;
  5415. }
  5416. }
  5417. declare module BABYLON {
  5418. /** @hidden */
  5419. export class ShaderProcessor {
  5420. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  5421. private static _ProcessPrecision;
  5422. private static _ExtractOperation;
  5423. private static _BuildSubExpression;
  5424. private static _BuildExpression;
  5425. private static _MoveCursorWithinIf;
  5426. private static _MoveCursor;
  5427. private static _EvaluatePreProcessors;
  5428. private static _PreparePreProcessors;
  5429. private static _ProcessShaderConversion;
  5430. private static _ProcessIncludes;
  5431. }
  5432. }
  5433. declare module BABYLON {
  5434. /**
  5435. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  5436. */
  5437. export class PerformanceMonitor {
  5438. private _enabled;
  5439. private _rollingFrameTime;
  5440. private _lastFrameTimeMs;
  5441. /**
  5442. * constructor
  5443. * @param frameSampleSize The number of samples required to saturate the sliding window
  5444. */
  5445. constructor(frameSampleSize?: number);
  5446. /**
  5447. * Samples current frame
  5448. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  5449. */
  5450. sampleFrame(timeMs?: number): void;
  5451. /**
  5452. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  5453. */
  5454. readonly averageFrameTime: number;
  5455. /**
  5456. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  5457. */
  5458. readonly averageFrameTimeVariance: number;
  5459. /**
  5460. * Returns the frame time of the most recent frame
  5461. */
  5462. readonly instantaneousFrameTime: number;
  5463. /**
  5464. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  5465. */
  5466. readonly averageFPS: number;
  5467. /**
  5468. * Returns the average framerate in frames per second using the most recent frame time
  5469. */
  5470. readonly instantaneousFPS: number;
  5471. /**
  5472. * Returns true if enough samples have been taken to completely fill the sliding window
  5473. */
  5474. readonly isSaturated: boolean;
  5475. /**
  5476. * Enables contributions to the sliding window sample set
  5477. */
  5478. enable(): void;
  5479. /**
  5480. * Disables contributions to the sliding window sample set
  5481. * Samples will not be interpolated over the disabled period
  5482. */
  5483. disable(): void;
  5484. /**
  5485. * Returns true if sampling is enabled
  5486. */
  5487. readonly isEnabled: boolean;
  5488. /**
  5489. * Resets performance monitor
  5490. */
  5491. reset(): void;
  5492. }
  5493. /**
  5494. * RollingAverage
  5495. *
  5496. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  5497. */
  5498. export class RollingAverage {
  5499. /**
  5500. * Current average
  5501. */
  5502. average: number;
  5503. /**
  5504. * Current variance
  5505. */
  5506. variance: number;
  5507. protected _samples: Array<number>;
  5508. protected _sampleCount: number;
  5509. protected _pos: number;
  5510. protected _m2: number;
  5511. /**
  5512. * constructor
  5513. * @param length The number of samples required to saturate the sliding window
  5514. */
  5515. constructor(length: number);
  5516. /**
  5517. * Adds a sample to the sample set
  5518. * @param v The sample value
  5519. */
  5520. add(v: number): void;
  5521. /**
  5522. * Returns previously added values or null if outside of history or outside the sliding window domain
  5523. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  5524. * @return Value previously recorded with add() or null if outside of range
  5525. */
  5526. history(i: number): number;
  5527. /**
  5528. * Returns true if enough samples have been taken to completely fill the sliding window
  5529. * @return true if sample-set saturated
  5530. */
  5531. isSaturated(): boolean;
  5532. /**
  5533. * Resets the rolling average (equivalent to 0 samples taken so far)
  5534. */
  5535. reset(): void;
  5536. /**
  5537. * Wraps a value around the sample range boundaries
  5538. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  5539. * @return Wrapped position in sample range
  5540. */
  5541. protected _wrapPosition(i: number): number;
  5542. }
  5543. }
  5544. declare module BABYLON {
  5545. /**
  5546. * This class implement a typical dictionary using a string as key and the generic type T as value.
  5547. * The underlying implementation relies on an associative array to ensure the best performances.
  5548. * The value can be anything including 'null' but except 'undefined'
  5549. */
  5550. export class StringDictionary<T> {
  5551. /**
  5552. * This will clear this dictionary and copy the content from the 'source' one.
  5553. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  5554. * @param source the dictionary to take the content from and copy to this dictionary
  5555. */
  5556. copyFrom(source: StringDictionary<T>): void;
  5557. /**
  5558. * Get a value based from its key
  5559. * @param key the given key to get the matching value from
  5560. * @return the value if found, otherwise undefined is returned
  5561. */
  5562. get(key: string): T | undefined;
  5563. /**
  5564. * Get a value from its key or add it if it doesn't exist.
  5565. * This method will ensure you that a given key/data will be present in the dictionary.
  5566. * @param key the given key to get the matching value from
  5567. * @param factory the factory that will create the value if the key is not present in the dictionary.
  5568. * The factory will only be invoked if there's no data for the given key.
  5569. * @return the value corresponding to the key.
  5570. */
  5571. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  5572. /**
  5573. * Get a value from its key if present in the dictionary otherwise add it
  5574. * @param key the key to get the value from
  5575. * @param val if there's no such key/value pair in the dictionary add it with this value
  5576. * @return the value corresponding to the key
  5577. */
  5578. getOrAdd(key: string, val: T): T;
  5579. /**
  5580. * Check if there's a given key in the dictionary
  5581. * @param key the key to check for
  5582. * @return true if the key is present, false otherwise
  5583. */
  5584. contains(key: string): boolean;
  5585. /**
  5586. * Add a new key and its corresponding value
  5587. * @param key the key to add
  5588. * @param value the value corresponding to the key
  5589. * @return true if the operation completed successfully, false if we couldn't insert the key/value because there was already this key in the dictionary
  5590. */
  5591. add(key: string, value: T): boolean;
  5592. /**
  5593. * Update a specific value associated to a key
  5594. * @param key defines the key to use
  5595. * @param value defines the value to store
  5596. * @returns true if the value was updated (or false if the key was not found)
  5597. */
  5598. set(key: string, value: T): boolean;
  5599. /**
  5600. * Get the element of the given key and remove it from the dictionary
  5601. * @param key defines the key to search
  5602. * @returns the value associated with the key or null if not found
  5603. */
  5604. getAndRemove(key: string): Nullable<T>;
  5605. /**
  5606. * Remove a key/value from the dictionary.
  5607. * @param key the key to remove
  5608. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  5609. */
  5610. remove(key: string): boolean;
  5611. /**
  5612. * Clear the whole content of the dictionary
  5613. */
  5614. clear(): void;
  5615. /**
  5616. * Gets the current count
  5617. */
  5618. readonly count: number;
  5619. /**
  5620. * Execute a callback on each key/val of the dictionary.
  5621. * Note that you can remove any element in this dictionary in the callback implementation
  5622. * @param callback the callback to execute on a given key/value pair
  5623. */
  5624. forEach(callback: (key: string, val: T) => void): void;
  5625. /**
  5626. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  5627. * If the callback returns null or undefined the method will iterate to the next key/value pair
  5628. * Note that you can remove any element in this dictionary in the callback implementation
  5629. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  5630. * @returns the first item
  5631. */
  5632. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  5633. private _count;
  5634. private _data;
  5635. }
  5636. }
  5637. declare module BABYLON {
  5638. /**
  5639. * Helper class that provides a small promise polyfill
  5640. */
  5641. export class PromisePolyfill {
  5642. /**
  5643. * Static function used to check if the polyfill is required
  5644. * If this is the case then the function will inject the polyfill to window.Promise
  5645. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  5646. */
  5647. static Apply(force?: boolean): void;
  5648. }
  5649. }
  5650. declare module BABYLON {
  5651. /**
  5652. * Class used to store data that will be store in GPU memory
  5653. */
  5654. export class Buffer {
  5655. private _engine;
  5656. private _buffer;
  5657. /** @hidden */
  5658. _data: Nullable<DataArray>;
  5659. private _updatable;
  5660. private _instanced;
  5661. /**
  5662. * Gets the byte stride.
  5663. */
  5664. readonly byteStride: number;
  5665. /**
  5666. * Constructor
  5667. * @param engine the engine
  5668. * @param data the data to use for this buffer
  5669. * @param updatable whether the data is updatable
  5670. * @param stride the stride (optional)
  5671. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  5672. * @param instanced whether the buffer is instanced (optional)
  5673. * @param useBytes set to true if the stride in in bytes (optional)
  5674. */
  5675. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  5676. /**
  5677. * Create a new VertexBuffer based on the current buffer
  5678. * @param kind defines the vertex buffer kind (position, normal, etc.)
  5679. * @param offset defines offset in the buffer (0 by default)
  5680. * @param size defines the size in floats of attributes (position is 3 for instance)
  5681. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  5682. * @param instanced defines if the vertex buffer contains indexed data
  5683. * @param useBytes defines if the offset and stride are in bytes
  5684. * @returns the new vertex buffer
  5685. */
  5686. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  5687. /**
  5688. * Gets a boolean indicating if the Buffer is updatable?
  5689. * @returns true if the buffer is updatable
  5690. */
  5691. isUpdatable(): boolean;
  5692. /**
  5693. * Gets current buffer's data
  5694. * @returns a DataArray or null
  5695. */
  5696. getData(): Nullable<DataArray>;
  5697. /**
  5698. * Gets underlying native buffer
  5699. * @returns underlying native buffer
  5700. */
  5701. getBuffer(): Nullable<DataBuffer>;
  5702. /**
  5703. * Gets the stride in float32 units (i.e. byte stride / 4).
  5704. * May not be an integer if the byte stride is not divisible by 4.
  5705. * DEPRECATED. Use byteStride instead.
  5706. * @returns the stride in float32 units
  5707. */
  5708. getStrideSize(): number;
  5709. /**
  5710. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  5711. * @param data defines the data to store
  5712. */
  5713. create(data?: Nullable<DataArray>): void;
  5714. /** @hidden */
  5715. _rebuild(): void;
  5716. /**
  5717. * Update current buffer data
  5718. * @param data defines the data to store
  5719. */
  5720. update(data: DataArray): void;
  5721. /**
  5722. * Updates the data directly.
  5723. * @param data the new data
  5724. * @param offset the new offset
  5725. * @param vertexCount the vertex count (optional)
  5726. * @param useBytes set to true if the offset is in bytes
  5727. */
  5728. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  5729. /**
  5730. * Release all resources
  5731. */
  5732. dispose(): void;
  5733. }
  5734. /**
  5735. * Specialized buffer used to store vertex data
  5736. */
  5737. export class VertexBuffer {
  5738. /** @hidden */
  5739. _buffer: Buffer;
  5740. private _kind;
  5741. private _size;
  5742. private _ownsBuffer;
  5743. private _instanced;
  5744. private _instanceDivisor;
  5745. /**
  5746. * The byte type.
  5747. */
  5748. static readonly BYTE: number;
  5749. /**
  5750. * The unsigned byte type.
  5751. */
  5752. static readonly UNSIGNED_BYTE: number;
  5753. /**
  5754. * The short type.
  5755. */
  5756. static readonly SHORT: number;
  5757. /**
  5758. * The unsigned short type.
  5759. */
  5760. static readonly UNSIGNED_SHORT: number;
  5761. /**
  5762. * The integer type.
  5763. */
  5764. static readonly INT: number;
  5765. /**
  5766. * The unsigned integer type.
  5767. */
  5768. static readonly UNSIGNED_INT: number;
  5769. /**
  5770. * The float type.
  5771. */
  5772. static readonly FLOAT: number;
  5773. /**
  5774. * Gets or sets the instance divisor when in instanced mode
  5775. */
  5776. instanceDivisor: number;
  5777. /**
  5778. * Gets the byte stride.
  5779. */
  5780. readonly byteStride: number;
  5781. /**
  5782. * Gets the byte offset.
  5783. */
  5784. readonly byteOffset: number;
  5785. /**
  5786. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  5787. */
  5788. readonly normalized: boolean;
  5789. /**
  5790. * Gets the data type of each component in the array.
  5791. */
  5792. readonly type: number;
  5793. /**
  5794. * Constructor
  5795. * @param engine the engine
  5796. * @param data the data to use for this vertex buffer
  5797. * @param kind the vertex buffer kind
  5798. * @param updatable whether the data is updatable
  5799. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  5800. * @param stride the stride (optional)
  5801. * @param instanced whether the buffer is instanced (optional)
  5802. * @param offset the offset of the data (optional)
  5803. * @param size the number of components (optional)
  5804. * @param type the type of the component (optional)
  5805. * @param normalized whether the data contains normalized data (optional)
  5806. * @param useBytes set to true if stride and offset are in bytes (optional)
  5807. */
  5808. constructor(engine: any, data: DataArray | Buffer, kind: string, updatable: boolean, postponeInternalCreation?: boolean, stride?: number, instanced?: boolean, offset?: number, size?: number, type?: number, normalized?: boolean, useBytes?: boolean);
  5809. /** @hidden */
  5810. _rebuild(): void;
  5811. /**
  5812. * Returns the kind of the VertexBuffer (string)
  5813. * @returns a string
  5814. */
  5815. getKind(): string;
  5816. /**
  5817. * Gets a boolean indicating if the VertexBuffer is updatable?
  5818. * @returns true if the buffer is updatable
  5819. */
  5820. isUpdatable(): boolean;
  5821. /**
  5822. * Gets current buffer's data
  5823. * @returns a DataArray or null
  5824. */
  5825. getData(): Nullable<DataArray>;
  5826. /**
  5827. * Gets underlying native buffer
  5828. * @returns underlying native buffer
  5829. */
  5830. getBuffer(): Nullable<DataBuffer>;
  5831. /**
  5832. * Gets the stride in float32 units (i.e. byte stride / 4).
  5833. * May not be an integer if the byte stride is not divisible by 4.
  5834. * DEPRECATED. Use byteStride instead.
  5835. * @returns the stride in float32 units
  5836. */
  5837. getStrideSize(): number;
  5838. /**
  5839. * Returns the offset as a multiple of the type byte length.
  5840. * DEPRECATED. Use byteOffset instead.
  5841. * @returns the offset in bytes
  5842. */
  5843. getOffset(): number;
  5844. /**
  5845. * Returns the number of components per vertex attribute (integer)
  5846. * @returns the size in float
  5847. */
  5848. getSize(): number;
  5849. /**
  5850. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  5851. * @returns true if this buffer is instanced
  5852. */
  5853. getIsInstanced(): boolean;
  5854. /**
  5855. * Returns the instancing divisor, zero for non-instanced (integer).
  5856. * @returns a number
  5857. */
  5858. getInstanceDivisor(): number;
  5859. /**
  5860. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  5861. * @param data defines the data to store
  5862. */
  5863. create(data?: DataArray): void;
  5864. /**
  5865. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  5866. * This function will create a new buffer if the current one is not updatable
  5867. * @param data defines the data to store
  5868. */
  5869. update(data: DataArray): void;
  5870. /**
  5871. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  5872. * Returns the directly updated WebGLBuffer.
  5873. * @param data the new data
  5874. * @param offset the new offset
  5875. * @param useBytes set to true if the offset is in bytes
  5876. */
  5877. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  5878. /**
  5879. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  5880. */
  5881. dispose(): void;
  5882. /**
  5883. * Enumerates each value of this vertex buffer as numbers.
  5884. * @param count the number of values to enumerate
  5885. * @param callback the callback function called for each value
  5886. */
  5887. forEach(count: number, callback: (value: number, index: number) => void): void;
  5888. /**
  5889. * Positions
  5890. */
  5891. static readonly PositionKind: string;
  5892. /**
  5893. * Normals
  5894. */
  5895. static readonly NormalKind: string;
  5896. /**
  5897. * Tangents
  5898. */
  5899. static readonly TangentKind: string;
  5900. /**
  5901. * Texture coordinates
  5902. */
  5903. static readonly UVKind: string;
  5904. /**
  5905. * Texture coordinates 2
  5906. */
  5907. static readonly UV2Kind: string;
  5908. /**
  5909. * Texture coordinates 3
  5910. */
  5911. static readonly UV3Kind: string;
  5912. /**
  5913. * Texture coordinates 4
  5914. */
  5915. static readonly UV4Kind: string;
  5916. /**
  5917. * Texture coordinates 5
  5918. */
  5919. static readonly UV5Kind: string;
  5920. /**
  5921. * Texture coordinates 6
  5922. */
  5923. static readonly UV6Kind: string;
  5924. /**
  5925. * Colors
  5926. */
  5927. static readonly ColorKind: string;
  5928. /**
  5929. * Matrix indices (for bones)
  5930. */
  5931. static readonly MatricesIndicesKind: string;
  5932. /**
  5933. * Matrix weights (for bones)
  5934. */
  5935. static readonly MatricesWeightsKind: string;
  5936. /**
  5937. * Additional matrix indices (for bones)
  5938. */
  5939. static readonly MatricesIndicesExtraKind: string;
  5940. /**
  5941. * Additional matrix weights (for bones)
  5942. */
  5943. static readonly MatricesWeightsExtraKind: string;
  5944. /**
  5945. * Deduces the stride given a kind.
  5946. * @param kind The kind string to deduce
  5947. * @returns The deduced stride
  5948. */
  5949. static DeduceStride(kind: string): number;
  5950. /**
  5951. * Gets the byte length of the given type.
  5952. * @param type the type
  5953. * @returns the number of bytes
  5954. */
  5955. static GetTypeByteLength(type: number): number;
  5956. /**
  5957. * Enumerates each value of the given parameters as numbers.
  5958. * @param data the data to enumerate
  5959. * @param byteOffset the byte offset of the data
  5960. * @param byteStride the byte stride of the data
  5961. * @param componentCount the number of components per element
  5962. * @param componentType the type of the component
  5963. * @param count the total number of components
  5964. * @param normalized whether the data is normalized
  5965. * @param callback the callback function called for each value
  5966. */
  5967. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  5968. private static _GetFloatValue;
  5969. }
  5970. }
  5971. declare module BABYLON {
  5972. /**
  5973. * Class representing spherical harmonics coefficients to the 3rd degree
  5974. */
  5975. export class SphericalHarmonics {
  5976. /**
  5977. * Defines whether or not the harmonics have been prescaled for rendering.
  5978. */
  5979. preScaled: boolean;
  5980. /**
  5981. * The l0,0 coefficients of the spherical harmonics
  5982. */
  5983. l00: Vector3;
  5984. /**
  5985. * The l1,-1 coefficients of the spherical harmonics
  5986. */
  5987. l1_1: Vector3;
  5988. /**
  5989. * The l1,0 coefficients of the spherical harmonics
  5990. */
  5991. l10: Vector3;
  5992. /**
  5993. * The l1,1 coefficients of the spherical harmonics
  5994. */
  5995. l11: Vector3;
  5996. /**
  5997. * The l2,-2 coefficients of the spherical harmonics
  5998. */
  5999. l2_2: Vector3;
  6000. /**
  6001. * The l2,-1 coefficients of the spherical harmonics
  6002. */
  6003. l2_1: Vector3;
  6004. /**
  6005. * The l2,0 coefficients of the spherical harmonics
  6006. */
  6007. l20: Vector3;
  6008. /**
  6009. * The l2,1 coefficients of the spherical harmonics
  6010. */
  6011. l21: Vector3;
  6012. /**
  6013. * The l2,2 coefficients of the spherical harmonics
  6014. */
  6015. l22: Vector3;
  6016. /**
  6017. * Adds a light to the spherical harmonics
  6018. * @param direction the direction of the light
  6019. * @param color the color of the light
  6020. * @param deltaSolidAngle the delta solid angle of the light
  6021. */
  6022. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  6023. /**
  6024. * Scales the spherical harmonics by the given amount
  6025. * @param scale the amount to scale
  6026. */
  6027. scaleInPlace(scale: number): void;
  6028. /**
  6029. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  6030. *
  6031. * ```
  6032. * E_lm = A_l * L_lm
  6033. * ```
  6034. *
  6035. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  6036. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  6037. * the scaling factors are given in equation 9.
  6038. */
  6039. convertIncidentRadianceToIrradiance(): void;
  6040. /**
  6041. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  6042. *
  6043. * ```
  6044. * L = (1/pi) * E * rho
  6045. * ```
  6046. *
  6047. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  6048. */
  6049. convertIrradianceToLambertianRadiance(): void;
  6050. /**
  6051. * Integrates the reconstruction coefficients directly in to the SH preventing further
  6052. * required operations at run time.
  6053. *
  6054. * This is simply done by scaling back the SH with Ylm constants parameter.
  6055. * The trigonometric part being applied by the shader at run time.
  6056. */
  6057. preScaleForRendering(): void;
  6058. /**
  6059. * Constructs a spherical harmonics from an array.
  6060. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  6061. * @returns the spherical harmonics
  6062. */
  6063. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  6064. /**
  6065. * Gets the spherical harmonics from polynomial
  6066. * @param polynomial the spherical polynomial
  6067. * @returns the spherical harmonics
  6068. */
  6069. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  6070. }
  6071. /**
  6072. * Class representing spherical polynomial coefficients to the 3rd degree
  6073. */
  6074. export class SphericalPolynomial {
  6075. private _harmonics;
  6076. /**
  6077. * The spherical harmonics used to create the polynomials.
  6078. */
  6079. readonly preScaledHarmonics: SphericalHarmonics;
  6080. /**
  6081. * The x coefficients of the spherical polynomial
  6082. */
  6083. x: Vector3;
  6084. /**
  6085. * The y coefficients of the spherical polynomial
  6086. */
  6087. y: Vector3;
  6088. /**
  6089. * The z coefficients of the spherical polynomial
  6090. */
  6091. z: Vector3;
  6092. /**
  6093. * The xx coefficients of the spherical polynomial
  6094. */
  6095. xx: Vector3;
  6096. /**
  6097. * The yy coefficients of the spherical polynomial
  6098. */
  6099. yy: Vector3;
  6100. /**
  6101. * The zz coefficients of the spherical polynomial
  6102. */
  6103. zz: Vector3;
  6104. /**
  6105. * The xy coefficients of the spherical polynomial
  6106. */
  6107. xy: Vector3;
  6108. /**
  6109. * The yz coefficients of the spherical polynomial
  6110. */
  6111. yz: Vector3;
  6112. /**
  6113. * The zx coefficients of the spherical polynomial
  6114. */
  6115. zx: Vector3;
  6116. /**
  6117. * Adds an ambient color to the spherical polynomial
  6118. * @param color the color to add
  6119. */
  6120. addAmbient(color: Color3): void;
  6121. /**
  6122. * Scales the spherical polynomial by the given amount
  6123. * @param scale the amount to scale
  6124. */
  6125. scaleInPlace(scale: number): void;
  6126. /**
  6127. * Gets the spherical polynomial from harmonics
  6128. * @param harmonics the spherical harmonics
  6129. * @returns the spherical polynomial
  6130. */
  6131. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  6132. /**
  6133. * Constructs a spherical polynomial from an array.
  6134. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  6135. * @returns the spherical polynomial
  6136. */
  6137. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  6138. }
  6139. }
  6140. declare module BABYLON {
  6141. /**
  6142. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  6143. */
  6144. export interface CubeMapInfo {
  6145. /**
  6146. * The pixel array for the front face.
  6147. * This is stored in format, left to right, up to down format.
  6148. */
  6149. front: Nullable<ArrayBufferView>;
  6150. /**
  6151. * The pixel array for the back face.
  6152. * This is stored in format, left to right, up to down format.
  6153. */
  6154. back: Nullable<ArrayBufferView>;
  6155. /**
  6156. * The pixel array for the left face.
  6157. * This is stored in format, left to right, up to down format.
  6158. */
  6159. left: Nullable<ArrayBufferView>;
  6160. /**
  6161. * The pixel array for the right face.
  6162. * This is stored in format, left to right, up to down format.
  6163. */
  6164. right: Nullable<ArrayBufferView>;
  6165. /**
  6166. * The pixel array for the up face.
  6167. * This is stored in format, left to right, up to down format.
  6168. */
  6169. up: Nullable<ArrayBufferView>;
  6170. /**
  6171. * The pixel array for the down face.
  6172. * This is stored in format, left to right, up to down format.
  6173. */
  6174. down: Nullable<ArrayBufferView>;
  6175. /**
  6176. * The size of the cubemap stored.
  6177. *
  6178. * Each faces will be size * size pixels.
  6179. */
  6180. size: number;
  6181. /**
  6182. * The format of the texture.
  6183. *
  6184. * RGBA, RGB.
  6185. */
  6186. format: number;
  6187. /**
  6188. * The type of the texture data.
  6189. *
  6190. * UNSIGNED_INT, FLOAT.
  6191. */
  6192. type: number;
  6193. /**
  6194. * Specifies whether the texture is in gamma space.
  6195. */
  6196. gammaSpace: boolean;
  6197. }
  6198. /**
  6199. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  6200. */
  6201. export class PanoramaToCubeMapTools {
  6202. private static FACE_FRONT;
  6203. private static FACE_BACK;
  6204. private static FACE_RIGHT;
  6205. private static FACE_LEFT;
  6206. private static FACE_DOWN;
  6207. private static FACE_UP;
  6208. /**
  6209. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  6210. *
  6211. * @param float32Array The source data.
  6212. * @param inputWidth The width of the input panorama.
  6213. * @param inputHeight The height of the input panorama.
  6214. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  6215. * @return The cubemap data
  6216. */
  6217. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  6218. private static CreateCubemapTexture;
  6219. private static CalcProjectionSpherical;
  6220. }
  6221. }
  6222. declare module BABYLON {
  6223. /**
  6224. * Helper class dealing with the extraction of spherical polynomial dataArray
  6225. * from a cube map.
  6226. */
  6227. export class CubeMapToSphericalPolynomialTools {
  6228. private static FileFaces;
  6229. /**
  6230. * Converts a texture to the according Spherical Polynomial data.
  6231. * This extracts the first 3 orders only as they are the only one used in the lighting.
  6232. *
  6233. * @param texture The texture to extract the information from.
  6234. * @return The Spherical Polynomial data.
  6235. */
  6236. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): SphericalPolynomial | null;
  6237. /**
  6238. * Converts a cubemap to the according Spherical Polynomial data.
  6239. * This extracts the first 3 orders only as they are the only one used in the lighting.
  6240. *
  6241. * @param cubeInfo The Cube map to extract the information from.
  6242. * @return The Spherical Polynomial data.
  6243. */
  6244. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  6245. }
  6246. }
  6247. declare module BABYLON {
  6248. /**
  6249. * The engine store class is responsible to hold all the instances of Engine and Scene created
  6250. * during the life time of the application.
  6251. */
  6252. export class EngineStore {
  6253. /** Gets the list of created engines */
  6254. static Instances: Engine[];
  6255. /** @hidden */
  6256. static _LastCreatedScene: Nullable<Scene>;
  6257. /**
  6258. * Gets the latest created engine
  6259. */
  6260. static readonly LastCreatedEngine: Nullable<Engine>;
  6261. /**
  6262. * Gets the latest created scene
  6263. */
  6264. static readonly LastCreatedScene: Nullable<Scene>;
  6265. }
  6266. }
  6267. declare module BABYLON {
  6268. /**
  6269. * Define options used to create a render target texture
  6270. */
  6271. export class RenderTargetCreationOptions {
  6272. /**
  6273. * Specifies is mipmaps must be generated
  6274. */
  6275. generateMipMaps?: boolean;
  6276. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  6277. generateDepthBuffer?: boolean;
  6278. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  6279. generateStencilBuffer?: boolean;
  6280. /** Defines texture type (int by default) */
  6281. type?: number;
  6282. /** Defines sampling mode (trilinear by default) */
  6283. samplingMode?: number;
  6284. /** Defines format (RGBA by default) */
  6285. format?: number;
  6286. }
  6287. }
  6288. declare module BABYLON {
  6289. /**
  6290. * @hidden
  6291. **/
  6292. export class _AlphaState {
  6293. private _isAlphaBlendDirty;
  6294. private _isBlendFunctionParametersDirty;
  6295. private _isBlendEquationParametersDirty;
  6296. private _isBlendConstantsDirty;
  6297. private _alphaBlend;
  6298. private _blendFunctionParameters;
  6299. private _blendEquationParameters;
  6300. private _blendConstants;
  6301. /**
  6302. * Initializes the state.
  6303. */
  6304. constructor();
  6305. readonly isDirty: boolean;
  6306. alphaBlend: boolean;
  6307. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  6308. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  6309. setAlphaEquationParameters(rgb: number, alpha: number): void;
  6310. reset(): void;
  6311. apply(gl: WebGLRenderingContext): void;
  6312. }
  6313. }
  6314. declare module BABYLON {
  6315. /**
  6316. * @hidden
  6317. **/
  6318. export class _DepthCullingState {
  6319. private _isDepthTestDirty;
  6320. private _isDepthMaskDirty;
  6321. private _isDepthFuncDirty;
  6322. private _isCullFaceDirty;
  6323. private _isCullDirty;
  6324. private _isZOffsetDirty;
  6325. private _isFrontFaceDirty;
  6326. private _depthTest;
  6327. private _depthMask;
  6328. private _depthFunc;
  6329. private _cull;
  6330. private _cullFace;
  6331. private _zOffset;
  6332. private _frontFace;
  6333. /**
  6334. * Initializes the state.
  6335. */
  6336. constructor();
  6337. readonly isDirty: boolean;
  6338. zOffset: number;
  6339. cullFace: Nullable<number>;
  6340. cull: Nullable<boolean>;
  6341. depthFunc: Nullable<number>;
  6342. depthMask: boolean;
  6343. depthTest: boolean;
  6344. frontFace: Nullable<number>;
  6345. reset(): void;
  6346. apply(gl: WebGLRenderingContext): void;
  6347. }
  6348. }
  6349. declare module BABYLON {
  6350. /**
  6351. * @hidden
  6352. **/
  6353. export class _StencilState {
  6354. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will always pass. i.e. Pixels will be drawn in the order they are drawn */
  6355. static readonly ALWAYS: number;
  6356. /** Passed to stencilOperation to specify that stencil value must be kept */
  6357. static readonly KEEP: number;
  6358. /** Passed to stencilOperation to specify that stencil value must be replaced */
  6359. static readonly REPLACE: number;
  6360. private _isStencilTestDirty;
  6361. private _isStencilMaskDirty;
  6362. private _isStencilFuncDirty;
  6363. private _isStencilOpDirty;
  6364. private _stencilTest;
  6365. private _stencilMask;
  6366. private _stencilFunc;
  6367. private _stencilFuncRef;
  6368. private _stencilFuncMask;
  6369. private _stencilOpStencilFail;
  6370. private _stencilOpDepthFail;
  6371. private _stencilOpStencilDepthPass;
  6372. readonly isDirty: boolean;
  6373. stencilFunc: number;
  6374. stencilFuncRef: number;
  6375. stencilFuncMask: number;
  6376. stencilOpStencilFail: number;
  6377. stencilOpDepthFail: number;
  6378. stencilOpStencilDepthPass: number;
  6379. stencilMask: number;
  6380. stencilTest: boolean;
  6381. constructor();
  6382. reset(): void;
  6383. apply(gl: WebGLRenderingContext): void;
  6384. }
  6385. }
  6386. declare module BABYLON {
  6387. /**
  6388. * @hidden
  6389. **/
  6390. export class _TimeToken {
  6391. _startTimeQuery: Nullable<WebGLQuery>;
  6392. _endTimeQuery: Nullable<WebGLQuery>;
  6393. _timeElapsedQuery: Nullable<WebGLQuery>;
  6394. _timeElapsedQueryEnded: boolean;
  6395. }
  6396. }
  6397. declare module BABYLON {
  6398. /**
  6399. * Class used to store data associated with WebGL texture data for the engine
  6400. * This class should not be used directly
  6401. */
  6402. export class InternalTexture {
  6403. /** @hidden */
  6404. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: SphericalPolynomial | null, lodScale: number, lodOffset: number) => Promise<void>;
  6405. /**
  6406. * The source of the texture data is unknown
  6407. */
  6408. static DATASOURCE_UNKNOWN: number;
  6409. /**
  6410. * Texture data comes from an URL
  6411. */
  6412. static DATASOURCE_URL: number;
  6413. /**
  6414. * Texture data is only used for temporary storage
  6415. */
  6416. static DATASOURCE_TEMP: number;
  6417. /**
  6418. * Texture data comes from raw data (ArrayBuffer)
  6419. */
  6420. static DATASOURCE_RAW: number;
  6421. /**
  6422. * Texture content is dynamic (video or dynamic texture)
  6423. */
  6424. static DATASOURCE_DYNAMIC: number;
  6425. /**
  6426. * Texture content is generated by rendering to it
  6427. */
  6428. static DATASOURCE_RENDERTARGET: number;
  6429. /**
  6430. * Texture content is part of a multi render target process
  6431. */
  6432. static DATASOURCE_MULTIRENDERTARGET: number;
  6433. /**
  6434. * Texture data comes from a cube data file
  6435. */
  6436. static DATASOURCE_CUBE: number;
  6437. /**
  6438. * Texture data comes from a raw cube data
  6439. */
  6440. static DATASOURCE_CUBERAW: number;
  6441. /**
  6442. * Texture data come from a prefiltered cube data file
  6443. */
  6444. static DATASOURCE_CUBEPREFILTERED: number;
  6445. /**
  6446. * Texture content is raw 3D data
  6447. */
  6448. static DATASOURCE_RAW3D: number;
  6449. /**
  6450. * Texture content is a depth texture
  6451. */
  6452. static DATASOURCE_DEPTHTEXTURE: number;
  6453. /**
  6454. * Texture data comes from a raw cube data encoded with RGBD
  6455. */
  6456. static DATASOURCE_CUBERAW_RGBD: number;
  6457. /**
  6458. * Defines if the texture is ready
  6459. */
  6460. isReady: boolean;
  6461. /**
  6462. * Defines if the texture is a cube texture
  6463. */
  6464. isCube: boolean;
  6465. /**
  6466. * Defines if the texture contains 3D data
  6467. */
  6468. is3D: boolean;
  6469. /**
  6470. * Defines if the texture contains multiview data
  6471. */
  6472. isMultiview: boolean;
  6473. /**
  6474. * Gets the URL used to load this texture
  6475. */
  6476. url: string;
  6477. /**
  6478. * Gets the sampling mode of the texture
  6479. */
  6480. samplingMode: number;
  6481. /**
  6482. * Gets a boolean indicating if the texture needs mipmaps generation
  6483. */
  6484. generateMipMaps: boolean;
  6485. /**
  6486. * Gets the number of samples used by the texture (WebGL2+ only)
  6487. */
  6488. samples: number;
  6489. /**
  6490. * Gets the type of the texture (int, float...)
  6491. */
  6492. type: number;
  6493. /**
  6494. * Gets the format of the texture (RGB, RGBA...)
  6495. */
  6496. format: number;
  6497. /**
  6498. * Observable called when the texture is loaded
  6499. */
  6500. onLoadedObservable: Observable<InternalTexture>;
  6501. /**
  6502. * Gets the width of the texture
  6503. */
  6504. width: number;
  6505. /**
  6506. * Gets the height of the texture
  6507. */
  6508. height: number;
  6509. /**
  6510. * Gets the depth of the texture
  6511. */
  6512. depth: number;
  6513. /**
  6514. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  6515. */
  6516. baseWidth: number;
  6517. /**
  6518. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  6519. */
  6520. baseHeight: number;
  6521. /**
  6522. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  6523. */
  6524. baseDepth: number;
  6525. /**
  6526. * Gets a boolean indicating if the texture is inverted on Y axis
  6527. */
  6528. invertY: boolean;
  6529. /** @hidden */
  6530. _invertVScale: boolean;
  6531. /** @hidden */
  6532. _associatedChannel: number;
  6533. /** @hidden */
  6534. _dataSource: number;
  6535. /** @hidden */
  6536. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  6537. /** @hidden */
  6538. _bufferView: Nullable<ArrayBufferView>;
  6539. /** @hidden */
  6540. _bufferViewArray: Nullable<ArrayBufferView[]>;
  6541. /** @hidden */
  6542. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  6543. /** @hidden */
  6544. _size: number;
  6545. /** @hidden */
  6546. _extension: string;
  6547. /** @hidden */
  6548. _files: Nullable<string[]>;
  6549. /** @hidden */
  6550. _workingCanvas: Nullable<HTMLCanvasElement>;
  6551. /** @hidden */
  6552. _workingContext: Nullable<CanvasRenderingContext2D>;
  6553. /** @hidden */
  6554. _framebuffer: Nullable<WebGLFramebuffer>;
  6555. /** @hidden */
  6556. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  6557. /** @hidden */
  6558. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  6559. /** @hidden */
  6560. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  6561. /** @hidden */
  6562. _attachments: Nullable<number[]>;
  6563. /** @hidden */
  6564. _cachedCoordinatesMode: Nullable<number>;
  6565. /** @hidden */
  6566. _cachedWrapU: Nullable<number>;
  6567. /** @hidden */
  6568. _cachedWrapV: Nullable<number>;
  6569. /** @hidden */
  6570. _cachedWrapR: Nullable<number>;
  6571. /** @hidden */
  6572. _cachedAnisotropicFilteringLevel: Nullable<number>;
  6573. /** @hidden */
  6574. _isDisabled: boolean;
  6575. /** @hidden */
  6576. _compression: Nullable<string>;
  6577. /** @hidden */
  6578. _generateStencilBuffer: boolean;
  6579. /** @hidden */
  6580. _generateDepthBuffer: boolean;
  6581. /** @hidden */
  6582. _comparisonFunction: number;
  6583. /** @hidden */
  6584. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  6585. /** @hidden */
  6586. _lodGenerationScale: number;
  6587. /** @hidden */
  6588. _lodGenerationOffset: number;
  6589. /** @hidden */
  6590. _colorTextureArray: Nullable<WebGLTexture>;
  6591. /** @hidden */
  6592. _depthStencilTextureArray: Nullable<WebGLTexture>;
  6593. /** @hidden */
  6594. _lodTextureHigh: Nullable<BaseTexture>;
  6595. /** @hidden */
  6596. _lodTextureMid: Nullable<BaseTexture>;
  6597. /** @hidden */
  6598. _lodTextureLow: Nullable<BaseTexture>;
  6599. /** @hidden */
  6600. _isRGBD: boolean;
  6601. /** @hidden */
  6602. _linearSpecularLOD: boolean;
  6603. /** @hidden */
  6604. _irradianceTexture: Nullable<BaseTexture>;
  6605. /** @hidden */
  6606. _webGLTexture: Nullable<WebGLTexture>;
  6607. /** @hidden */
  6608. _references: number;
  6609. private _engine;
  6610. /**
  6611. * Gets the Engine the texture belongs to.
  6612. * @returns The babylon engine
  6613. */
  6614. getEngine(): Engine;
  6615. /**
  6616. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  6617. */
  6618. readonly dataSource: number;
  6619. /**
  6620. * Creates a new InternalTexture
  6621. * @param engine defines the engine to use
  6622. * @param dataSource defines the type of data that will be used
  6623. * @param delayAllocation if the texture allocation should be delayed (default: false)
  6624. */
  6625. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  6626. /**
  6627. * Increments the number of references (ie. the number of Texture that point to it)
  6628. */
  6629. incrementReferences(): void;
  6630. /**
  6631. * Change the size of the texture (not the size of the content)
  6632. * @param width defines the new width
  6633. * @param height defines the new height
  6634. * @param depth defines the new depth (1 by default)
  6635. */
  6636. updateSize(width: int, height: int, depth?: int): void;
  6637. /** @hidden */
  6638. _rebuild(): void;
  6639. /** @hidden */
  6640. _swapAndDie(target: InternalTexture): void;
  6641. /**
  6642. * Dispose the current allocated resources
  6643. */
  6644. dispose(): void;
  6645. }
  6646. }
  6647. declare module BABYLON {
  6648. /**
  6649. * This represents the main contract an easing function should follow.
  6650. * Easing functions are used throughout the animation system.
  6651. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6652. */
  6653. export interface IEasingFunction {
  6654. /**
  6655. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6656. * of the easing function.
  6657. * The link below provides some of the most common examples of easing functions.
  6658. * @see https://easings.net/
  6659. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6660. * @returns the corresponding value on the curve defined by the easing function
  6661. */
  6662. ease(gradient: number): number;
  6663. }
  6664. /**
  6665. * Base class used for every default easing function.
  6666. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6667. */
  6668. export class EasingFunction implements IEasingFunction {
  6669. /**
  6670. * Interpolation follows the mathematical formula associated with the easing function.
  6671. */
  6672. static readonly EASINGMODE_EASEIN: number;
  6673. /**
  6674. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  6675. */
  6676. static readonly EASINGMODE_EASEOUT: number;
  6677. /**
  6678. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  6679. */
  6680. static readonly EASINGMODE_EASEINOUT: number;
  6681. private _easingMode;
  6682. /**
  6683. * Sets the easing mode of the current function.
  6684. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  6685. */
  6686. setEasingMode(easingMode: number): void;
  6687. /**
  6688. * Gets the current easing mode.
  6689. * @returns the easing mode
  6690. */
  6691. getEasingMode(): number;
  6692. /**
  6693. * @hidden
  6694. */
  6695. easeInCore(gradient: number): number;
  6696. /**
  6697. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6698. * of the easing function.
  6699. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6700. * @returns the corresponding value on the curve defined by the easing function
  6701. */
  6702. ease(gradient: number): number;
  6703. }
  6704. /**
  6705. * Easing function with a circle shape (see link below).
  6706. * @see https://easings.net/#easeInCirc
  6707. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6708. */
  6709. export class CircleEase extends EasingFunction implements IEasingFunction {
  6710. /** @hidden */
  6711. easeInCore(gradient: number): number;
  6712. }
  6713. /**
  6714. * Easing function with a ease back shape (see link below).
  6715. * @see https://easings.net/#easeInBack
  6716. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6717. */
  6718. export class BackEase extends EasingFunction implements IEasingFunction {
  6719. /** Defines the amplitude of the function */
  6720. amplitude: number;
  6721. /**
  6722. * Instantiates a back ease easing
  6723. * @see https://easings.net/#easeInBack
  6724. * @param amplitude Defines the amplitude of the function
  6725. */
  6726. constructor(
  6727. /** Defines the amplitude of the function */
  6728. amplitude?: number);
  6729. /** @hidden */
  6730. easeInCore(gradient: number): number;
  6731. }
  6732. /**
  6733. * Easing function with a bouncing shape (see link below).
  6734. * @see https://easings.net/#easeInBounce
  6735. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6736. */
  6737. export class BounceEase extends EasingFunction implements IEasingFunction {
  6738. /** Defines the number of bounces */
  6739. bounces: number;
  6740. /** Defines the amplitude of the bounce */
  6741. bounciness: number;
  6742. /**
  6743. * Instantiates a bounce easing
  6744. * @see https://easings.net/#easeInBounce
  6745. * @param bounces Defines the number of bounces
  6746. * @param bounciness Defines the amplitude of the bounce
  6747. */
  6748. constructor(
  6749. /** Defines the number of bounces */
  6750. bounces?: number,
  6751. /** Defines the amplitude of the bounce */
  6752. bounciness?: number);
  6753. /** @hidden */
  6754. easeInCore(gradient: number): number;
  6755. }
  6756. /**
  6757. * Easing function with a power of 3 shape (see link below).
  6758. * @see https://easings.net/#easeInCubic
  6759. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6760. */
  6761. export class CubicEase extends EasingFunction implements IEasingFunction {
  6762. /** @hidden */
  6763. easeInCore(gradient: number): number;
  6764. }
  6765. /**
  6766. * Easing function with an elastic shape (see link below).
  6767. * @see https://easings.net/#easeInElastic
  6768. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6769. */
  6770. export class ElasticEase extends EasingFunction implements IEasingFunction {
  6771. /** Defines the number of oscillations*/
  6772. oscillations: number;
  6773. /** Defines the amplitude of the oscillations*/
  6774. springiness: number;
  6775. /**
  6776. * Instantiates an elastic easing function
  6777. * @see https://easings.net/#easeInElastic
  6778. * @param oscillations Defines the number of oscillations
  6779. * @param springiness Defines the amplitude of the oscillations
  6780. */
  6781. constructor(
  6782. /** Defines the number of oscillations*/
  6783. oscillations?: number,
  6784. /** Defines the amplitude of the oscillations*/
  6785. springiness?: number);
  6786. /** @hidden */
  6787. easeInCore(gradient: number): number;
  6788. }
  6789. /**
  6790. * Easing function with an exponential shape (see link below).
  6791. * @see https://easings.net/#easeInExpo
  6792. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6793. */
  6794. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  6795. /** Defines the exponent of the function */
  6796. exponent: number;
  6797. /**
  6798. * Instantiates an exponential easing function
  6799. * @see https://easings.net/#easeInExpo
  6800. * @param exponent Defines the exponent of the function
  6801. */
  6802. constructor(
  6803. /** Defines the exponent of the function */
  6804. exponent?: number);
  6805. /** @hidden */
  6806. easeInCore(gradient: number): number;
  6807. }
  6808. /**
  6809. * Easing function with a power shape (see link below).
  6810. * @see https://easings.net/#easeInQuad
  6811. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6812. */
  6813. export class PowerEase extends EasingFunction implements IEasingFunction {
  6814. /** Defines the power of the function */
  6815. power: number;
  6816. /**
  6817. * Instantiates an power base easing function
  6818. * @see https://easings.net/#easeInQuad
  6819. * @param power Defines the power of the function
  6820. */
  6821. constructor(
  6822. /** Defines the power of the function */
  6823. power?: number);
  6824. /** @hidden */
  6825. easeInCore(gradient: number): number;
  6826. }
  6827. /**
  6828. * Easing function with a power of 2 shape (see link below).
  6829. * @see https://easings.net/#easeInQuad
  6830. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6831. */
  6832. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  6833. /** @hidden */
  6834. easeInCore(gradient: number): number;
  6835. }
  6836. /**
  6837. * Easing function with a power of 4 shape (see link below).
  6838. * @see https://easings.net/#easeInQuart
  6839. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6840. */
  6841. export class QuarticEase extends EasingFunction implements IEasingFunction {
  6842. /** @hidden */
  6843. easeInCore(gradient: number): number;
  6844. }
  6845. /**
  6846. * Easing function with a power of 5 shape (see link below).
  6847. * @see https://easings.net/#easeInQuint
  6848. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6849. */
  6850. export class QuinticEase extends EasingFunction implements IEasingFunction {
  6851. /** @hidden */
  6852. easeInCore(gradient: number): number;
  6853. }
  6854. /**
  6855. * Easing function with a sin shape (see link below).
  6856. * @see https://easings.net/#easeInSine
  6857. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6858. */
  6859. export class SineEase extends EasingFunction implements IEasingFunction {
  6860. /** @hidden */
  6861. easeInCore(gradient: number): number;
  6862. }
  6863. /**
  6864. * Easing function with a bezier shape (see link below).
  6865. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6866. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6867. */
  6868. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  6869. /** Defines the x component of the start tangent in the bezier curve */
  6870. x1: number;
  6871. /** Defines the y component of the start tangent in the bezier curve */
  6872. y1: number;
  6873. /** Defines the x component of the end tangent in the bezier curve */
  6874. x2: number;
  6875. /** Defines the y component of the end tangent in the bezier curve */
  6876. y2: number;
  6877. /**
  6878. * Instantiates a bezier function
  6879. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6880. * @param x1 Defines the x component of the start tangent in the bezier curve
  6881. * @param y1 Defines the y component of the start tangent in the bezier curve
  6882. * @param x2 Defines the x component of the end tangent in the bezier curve
  6883. * @param y2 Defines the y component of the end tangent in the bezier curve
  6884. */
  6885. constructor(
  6886. /** Defines the x component of the start tangent in the bezier curve */
  6887. x1?: number,
  6888. /** Defines the y component of the start tangent in the bezier curve */
  6889. y1?: number,
  6890. /** Defines the x component of the end tangent in the bezier curve */
  6891. x2?: number,
  6892. /** Defines the y component of the end tangent in the bezier curve */
  6893. y2?: number);
  6894. /** @hidden */
  6895. easeInCore(gradient: number): number;
  6896. }
  6897. }
  6898. declare module BABYLON {
  6899. /**
  6900. * Defines an interface which represents an animation key frame
  6901. */
  6902. export interface IAnimationKey {
  6903. /**
  6904. * Frame of the key frame
  6905. */
  6906. frame: number;
  6907. /**
  6908. * Value at the specifies key frame
  6909. */
  6910. value: any;
  6911. /**
  6912. * The input tangent for the cubic hermite spline
  6913. */
  6914. inTangent?: any;
  6915. /**
  6916. * The output tangent for the cubic hermite spline
  6917. */
  6918. outTangent?: any;
  6919. /**
  6920. * The animation interpolation type
  6921. */
  6922. interpolation?: AnimationKeyInterpolation;
  6923. }
  6924. /**
  6925. * Enum for the animation key frame interpolation type
  6926. */
  6927. export enum AnimationKeyInterpolation {
  6928. /**
  6929. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6930. */
  6931. STEP = 1
  6932. }
  6933. }
  6934. declare module BABYLON {
  6935. /**
  6936. * Represents the range of an animation
  6937. */
  6938. export class AnimationRange {
  6939. /**The name of the animation range**/
  6940. name: string;
  6941. /**The starting frame of the animation */
  6942. from: number;
  6943. /**The ending frame of the animation*/
  6944. to: number;
  6945. /**
  6946. * Initializes the range of an animation
  6947. * @param name The name of the animation range
  6948. * @param from The starting frame of the animation
  6949. * @param to The ending frame of the animation
  6950. */
  6951. constructor(
  6952. /**The name of the animation range**/
  6953. name: string,
  6954. /**The starting frame of the animation */
  6955. from: number,
  6956. /**The ending frame of the animation*/
  6957. to: number);
  6958. /**
  6959. * Makes a copy of the animation range
  6960. * @returns A copy of the animation range
  6961. */
  6962. clone(): AnimationRange;
  6963. }
  6964. }
  6965. declare module BABYLON {
  6966. /**
  6967. * Composed of a frame, and an action function
  6968. */
  6969. export class AnimationEvent {
  6970. /** The frame for which the event is triggered **/
  6971. frame: number;
  6972. /** The event to perform when triggered **/
  6973. action: (currentFrame: number) => void;
  6974. /** Specifies if the event should be triggered only once**/
  6975. onlyOnce?: boolean | undefined;
  6976. /**
  6977. * Specifies if the animation event is done
  6978. */
  6979. isDone: boolean;
  6980. /**
  6981. * Initializes the animation event
  6982. * @param frame The frame for which the event is triggered
  6983. * @param action The event to perform when triggered
  6984. * @param onlyOnce Specifies if the event should be triggered only once
  6985. */
  6986. constructor(
  6987. /** The frame for which the event is triggered **/
  6988. frame: number,
  6989. /** The event to perform when triggered **/
  6990. action: (currentFrame: number) => void,
  6991. /** Specifies if the event should be triggered only once**/
  6992. onlyOnce?: boolean | undefined);
  6993. /** @hidden */
  6994. _clone(): AnimationEvent;
  6995. }
  6996. }
  6997. declare module BABYLON {
  6998. /**
  6999. * Interface used to define a behavior
  7000. */
  7001. export interface Behavior<T> {
  7002. /** gets or sets behavior's name */
  7003. name: string;
  7004. /**
  7005. * Function called when the behavior needs to be initialized (after attaching it to a target)
  7006. */
  7007. init(): void;
  7008. /**
  7009. * Called when the behavior is attached to a target
  7010. * @param target defines the target where the behavior is attached to
  7011. */
  7012. attach(target: T): void;
  7013. /**
  7014. * Called when the behavior is detached from its target
  7015. */
  7016. detach(): void;
  7017. }
  7018. /**
  7019. * Interface implemented by classes supporting behaviors
  7020. */
  7021. export interface IBehaviorAware<T> {
  7022. /**
  7023. * Attach a behavior
  7024. * @param behavior defines the behavior to attach
  7025. * @returns the current host
  7026. */
  7027. addBehavior(behavior: Behavior<T>): T;
  7028. /**
  7029. * Remove a behavior from the current object
  7030. * @param behavior defines the behavior to detach
  7031. * @returns the current host
  7032. */
  7033. removeBehavior(behavior: Behavior<T>): T;
  7034. /**
  7035. * Gets a behavior using its name to search
  7036. * @param name defines the name to search
  7037. * @returns the behavior or null if not found
  7038. */
  7039. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  7040. }
  7041. }
  7042. declare module BABYLON {
  7043. /**
  7044. * @hidden
  7045. */
  7046. export class IntersectionInfo {
  7047. bu: Nullable<number>;
  7048. bv: Nullable<number>;
  7049. distance: number;
  7050. faceId: number;
  7051. subMeshId: number;
  7052. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  7053. }
  7054. }
  7055. declare module BABYLON {
  7056. /**
  7057. * Class used to store bounding sphere information
  7058. */
  7059. export class BoundingSphere {
  7060. /**
  7061. * Gets the center of the bounding sphere in local space
  7062. */
  7063. readonly center: Vector3;
  7064. /**
  7065. * Radius of the bounding sphere in local space
  7066. */
  7067. radius: number;
  7068. /**
  7069. * Gets the center of the bounding sphere in world space
  7070. */
  7071. readonly centerWorld: Vector3;
  7072. /**
  7073. * Radius of the bounding sphere in world space
  7074. */
  7075. radiusWorld: number;
  7076. /**
  7077. * Gets the minimum vector in local space
  7078. */
  7079. readonly minimum: Vector3;
  7080. /**
  7081. * Gets the maximum vector in local space
  7082. */
  7083. readonly maximum: Vector3;
  7084. private _worldMatrix;
  7085. private static readonly TmpVector3;
  7086. /**
  7087. * Creates a new bounding sphere
  7088. * @param min defines the minimum vector (in local space)
  7089. * @param max defines the maximum vector (in local space)
  7090. * @param worldMatrix defines the new world matrix
  7091. */
  7092. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7093. /**
  7094. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  7095. * @param min defines the new minimum vector (in local space)
  7096. * @param max defines the new maximum vector (in local space)
  7097. * @param worldMatrix defines the new world matrix
  7098. */
  7099. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7100. /**
  7101. * Scale the current bounding sphere by applying a scale factor
  7102. * @param factor defines the scale factor to apply
  7103. * @returns the current bounding box
  7104. */
  7105. scale(factor: number): BoundingSphere;
  7106. /**
  7107. * Gets the world matrix of the bounding box
  7108. * @returns a matrix
  7109. */
  7110. getWorldMatrix(): DeepImmutable<Matrix>;
  7111. /** @hidden */
  7112. _update(worldMatrix: DeepImmutable<Matrix>): void;
  7113. /**
  7114. * Tests if the bounding sphere is intersecting the frustum planes
  7115. * @param frustumPlanes defines the frustum planes to test
  7116. * @returns true if there is an intersection
  7117. */
  7118. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7119. /**
  7120. * Tests if the bounding sphere center is in between the frustum planes.
  7121. * Used for optimistic fast inclusion.
  7122. * @param frustumPlanes defines the frustum planes to test
  7123. * @returns true if the sphere center is in between the frustum planes
  7124. */
  7125. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7126. /**
  7127. * Tests if a point is inside the bounding sphere
  7128. * @param point defines the point to test
  7129. * @returns true if the point is inside the bounding sphere
  7130. */
  7131. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7132. /**
  7133. * Checks if two sphere intersct
  7134. * @param sphere0 sphere 0
  7135. * @param sphere1 sphere 1
  7136. * @returns true if the speres intersect
  7137. */
  7138. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  7139. }
  7140. }
  7141. declare module BABYLON {
  7142. /**
  7143. * Class used to store bounding box information
  7144. */
  7145. export class BoundingBox implements ICullable {
  7146. /**
  7147. * Gets the 8 vectors representing the bounding box in local space
  7148. */
  7149. readonly vectors: Vector3[];
  7150. /**
  7151. * Gets the center of the bounding box in local space
  7152. */
  7153. readonly center: Vector3;
  7154. /**
  7155. * Gets the center of the bounding box in world space
  7156. */
  7157. readonly centerWorld: Vector3;
  7158. /**
  7159. * Gets the extend size in local space
  7160. */
  7161. readonly extendSize: Vector3;
  7162. /**
  7163. * Gets the extend size in world space
  7164. */
  7165. readonly extendSizeWorld: Vector3;
  7166. /**
  7167. * Gets the OBB (object bounding box) directions
  7168. */
  7169. readonly directions: Vector3[];
  7170. /**
  7171. * Gets the 8 vectors representing the bounding box in world space
  7172. */
  7173. readonly vectorsWorld: Vector3[];
  7174. /**
  7175. * Gets the minimum vector in world space
  7176. */
  7177. readonly minimumWorld: Vector3;
  7178. /**
  7179. * Gets the maximum vector in world space
  7180. */
  7181. readonly maximumWorld: Vector3;
  7182. /**
  7183. * Gets the minimum vector in local space
  7184. */
  7185. readonly minimum: Vector3;
  7186. /**
  7187. * Gets the maximum vector in local space
  7188. */
  7189. readonly maximum: Vector3;
  7190. private _worldMatrix;
  7191. private static readonly TmpVector3;
  7192. /**
  7193. * @hidden
  7194. */
  7195. _tag: number;
  7196. /**
  7197. * Creates a new bounding box
  7198. * @param min defines the minimum vector (in local space)
  7199. * @param max defines the maximum vector (in local space)
  7200. * @param worldMatrix defines the new world matrix
  7201. */
  7202. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7203. /**
  7204. * Recreates the entire bounding box from scratch as if we call the constructor in place
  7205. * @param min defines the new minimum vector (in local space)
  7206. * @param max defines the new maximum vector (in local space)
  7207. * @param worldMatrix defines the new world matrix
  7208. */
  7209. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7210. /**
  7211. * Scale the current bounding box by applying a scale factor
  7212. * @param factor defines the scale factor to apply
  7213. * @returns the current bounding box
  7214. */
  7215. scale(factor: number): BoundingBox;
  7216. /**
  7217. * Gets the world matrix of the bounding box
  7218. * @returns a matrix
  7219. */
  7220. getWorldMatrix(): DeepImmutable<Matrix>;
  7221. /** @hidden */
  7222. _update(world: DeepImmutable<Matrix>): void;
  7223. /**
  7224. * Tests if the bounding box is intersecting the frustum planes
  7225. * @param frustumPlanes defines the frustum planes to test
  7226. * @returns true if there is an intersection
  7227. */
  7228. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7229. /**
  7230. * Tests if the bounding box is entirely inside the frustum planes
  7231. * @param frustumPlanes defines the frustum planes to test
  7232. * @returns true if there is an inclusion
  7233. */
  7234. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7235. /**
  7236. * Tests if a point is inside the bounding box
  7237. * @param point defines the point to test
  7238. * @returns true if the point is inside the bounding box
  7239. */
  7240. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7241. /**
  7242. * Tests if the bounding box intersects with a bounding sphere
  7243. * @param sphere defines the sphere to test
  7244. * @returns true if there is an intersection
  7245. */
  7246. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7247. /**
  7248. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7249. * @param min defines the min vector to use
  7250. * @param max defines the max vector to use
  7251. * @returns true if there is an intersection
  7252. */
  7253. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7254. /**
  7255. * Tests if two bounding boxes are intersections
  7256. * @param box0 defines the first box to test
  7257. * @param box1 defines the second box to test
  7258. * @returns true if there is an intersection
  7259. */
  7260. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7261. /**
  7262. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7263. * @param minPoint defines the minimum vector of the bounding box
  7264. * @param maxPoint defines the maximum vector of the bounding box
  7265. * @param sphereCenter defines the sphere center
  7266. * @param sphereRadius defines the sphere radius
  7267. * @returns true if there is an intersection
  7268. */
  7269. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7270. /**
  7271. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7272. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7273. * @param frustumPlanes defines the frustum planes to test
  7274. * @return true if there is an inclusion
  7275. */
  7276. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7277. /**
  7278. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7279. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7280. * @param frustumPlanes defines the frustum planes to test
  7281. * @return true if there is an intersection
  7282. */
  7283. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7284. }
  7285. }
  7286. declare module BABYLON {
  7287. /** @hidden */
  7288. export class Collider {
  7289. /** Define if a collision was found */
  7290. collisionFound: boolean;
  7291. /**
  7292. * Define last intersection point in local space
  7293. */
  7294. intersectionPoint: Vector3;
  7295. /**
  7296. * Define last collided mesh
  7297. */
  7298. collidedMesh: Nullable<AbstractMesh>;
  7299. private _collisionPoint;
  7300. private _planeIntersectionPoint;
  7301. private _tempVector;
  7302. private _tempVector2;
  7303. private _tempVector3;
  7304. private _tempVector4;
  7305. private _edge;
  7306. private _baseToVertex;
  7307. private _destinationPoint;
  7308. private _slidePlaneNormal;
  7309. private _displacementVector;
  7310. /** @hidden */
  7311. _radius: Vector3;
  7312. /** @hidden */
  7313. _retry: number;
  7314. private _velocity;
  7315. private _basePoint;
  7316. private _epsilon;
  7317. /** @hidden */
  7318. _velocityWorldLength: number;
  7319. /** @hidden */
  7320. _basePointWorld: Vector3;
  7321. private _velocityWorld;
  7322. private _normalizedVelocity;
  7323. /** @hidden */
  7324. _initialVelocity: Vector3;
  7325. /** @hidden */
  7326. _initialPosition: Vector3;
  7327. private _nearestDistance;
  7328. private _collisionMask;
  7329. collisionMask: number;
  7330. /**
  7331. * Gets the plane normal used to compute the sliding response (in local space)
  7332. */
  7333. readonly slidePlaneNormal: Vector3;
  7334. /** @hidden */
  7335. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7336. /** @hidden */
  7337. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7338. /** @hidden */
  7339. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7340. /** @hidden */
  7341. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  7342. /** @hidden */
  7343. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  7344. /** @hidden */
  7345. _getResponse(pos: Vector3, vel: Vector3): void;
  7346. }
  7347. }
  7348. declare module BABYLON {
  7349. /**
  7350. * Interface for cullable objects
  7351. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7352. */
  7353. export interface ICullable {
  7354. /**
  7355. * Checks if the object or part of the object is in the frustum
  7356. * @param frustumPlanes Camera near/planes
  7357. * @returns true if the object is in frustum otherwise false
  7358. */
  7359. isInFrustum(frustumPlanes: Plane[]): boolean;
  7360. /**
  7361. * Checks if a cullable object (mesh...) is in the camera frustum
  7362. * Unlike isInFrustum this cheks the full bounding box
  7363. * @param frustumPlanes Camera near/planes
  7364. * @returns true if the object is in frustum otherwise false
  7365. */
  7366. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7367. }
  7368. /**
  7369. * Info for a bounding data of a mesh
  7370. */
  7371. export class BoundingInfo implements ICullable {
  7372. /**
  7373. * Bounding box for the mesh
  7374. */
  7375. readonly boundingBox: BoundingBox;
  7376. /**
  7377. * Bounding sphere for the mesh
  7378. */
  7379. readonly boundingSphere: BoundingSphere;
  7380. private _isLocked;
  7381. private static readonly TmpVector3;
  7382. /**
  7383. * Constructs bounding info
  7384. * @param minimum min vector of the bounding box/sphere
  7385. * @param maximum max vector of the bounding box/sphere
  7386. * @param worldMatrix defines the new world matrix
  7387. */
  7388. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7389. /**
  7390. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7391. * @param min defines the new minimum vector (in local space)
  7392. * @param max defines the new maximum vector (in local space)
  7393. * @param worldMatrix defines the new world matrix
  7394. */
  7395. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7396. /**
  7397. * min vector of the bounding box/sphere
  7398. */
  7399. readonly minimum: Vector3;
  7400. /**
  7401. * max vector of the bounding box/sphere
  7402. */
  7403. readonly maximum: Vector3;
  7404. /**
  7405. * If the info is locked and won't be updated to avoid perf overhead
  7406. */
  7407. isLocked: boolean;
  7408. /**
  7409. * Updates the bounding sphere and box
  7410. * @param world world matrix to be used to update
  7411. */
  7412. update(world: DeepImmutable<Matrix>): void;
  7413. /**
  7414. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7415. * @param center New center of the bounding info
  7416. * @param extend New extend of the bounding info
  7417. * @returns the current bounding info
  7418. */
  7419. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7420. /**
  7421. * Scale the current bounding info by applying a scale factor
  7422. * @param factor defines the scale factor to apply
  7423. * @returns the current bounding info
  7424. */
  7425. scale(factor: number): BoundingInfo;
  7426. /**
  7427. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7428. * @param frustumPlanes defines the frustum to test
  7429. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7430. * @returns true if the bounding info is in the frustum planes
  7431. */
  7432. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7433. /**
  7434. * Gets the world distance between the min and max points of the bounding box
  7435. */
  7436. readonly diagonalLength: number;
  7437. /**
  7438. * Checks if a cullable object (mesh...) is in the camera frustum
  7439. * Unlike isInFrustum this cheks the full bounding box
  7440. * @param frustumPlanes Camera near/planes
  7441. * @returns true if the object is in frustum otherwise false
  7442. */
  7443. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7444. /** @hidden */
  7445. _checkCollision(collider: Collider): boolean;
  7446. /**
  7447. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7448. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7449. * @param point the point to check intersection with
  7450. * @returns if the point intersects
  7451. */
  7452. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7453. /**
  7454. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7455. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7456. * @param boundingInfo the bounding info to check intersection with
  7457. * @param precise if the intersection should be done using OBB
  7458. * @returns if the bounding info intersects
  7459. */
  7460. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7461. }
  7462. }
  7463. declare module BABYLON {
  7464. /**
  7465. * Defines an array and its length.
  7466. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  7467. */
  7468. export interface ISmartArrayLike<T> {
  7469. /**
  7470. * The data of the array.
  7471. */
  7472. data: Array<T>;
  7473. /**
  7474. * The active length of the array.
  7475. */
  7476. length: number;
  7477. }
  7478. /**
  7479. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  7480. */
  7481. export class SmartArray<T> implements ISmartArrayLike<T> {
  7482. /**
  7483. * The full set of data from the array.
  7484. */
  7485. data: Array<T>;
  7486. /**
  7487. * The active length of the array.
  7488. */
  7489. length: number;
  7490. protected _id: number;
  7491. /**
  7492. * Instantiates a Smart Array.
  7493. * @param capacity defines the default capacity of the array.
  7494. */
  7495. constructor(capacity: number);
  7496. /**
  7497. * Pushes a value at the end of the active data.
  7498. * @param value defines the object to push in the array.
  7499. */
  7500. push(value: T): void;
  7501. /**
  7502. * Iterates over the active data and apply the lambda to them.
  7503. * @param func defines the action to apply on each value.
  7504. */
  7505. forEach(func: (content: T) => void): void;
  7506. /**
  7507. * Sorts the full sets of data.
  7508. * @param compareFn defines the comparison function to apply.
  7509. */
  7510. sort(compareFn: (a: T, b: T) => number): void;
  7511. /**
  7512. * Resets the active data to an empty array.
  7513. */
  7514. reset(): void;
  7515. /**
  7516. * Releases all the data from the array as well as the array.
  7517. */
  7518. dispose(): void;
  7519. /**
  7520. * Concats the active data with a given array.
  7521. * @param array defines the data to concatenate with.
  7522. */
  7523. concat(array: any): void;
  7524. /**
  7525. * Returns the position of a value in the active data.
  7526. * @param value defines the value to find the index for
  7527. * @returns the index if found in the active data otherwise -1
  7528. */
  7529. indexOf(value: T): number;
  7530. /**
  7531. * Returns whether an element is part of the active data.
  7532. * @param value defines the value to look for
  7533. * @returns true if found in the active data otherwise false
  7534. */
  7535. contains(value: T): boolean;
  7536. private static _GlobalId;
  7537. }
  7538. /**
  7539. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  7540. * The data in this array can only be present once
  7541. */
  7542. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  7543. private _duplicateId;
  7544. /**
  7545. * Pushes a value at the end of the active data.
  7546. * THIS DOES NOT PREVENT DUPPLICATE DATA
  7547. * @param value defines the object to push in the array.
  7548. */
  7549. push(value: T): void;
  7550. /**
  7551. * Pushes a value at the end of the active data.
  7552. * If the data is already present, it won t be added again
  7553. * @param value defines the object to push in the array.
  7554. * @returns true if added false if it was already present
  7555. */
  7556. pushNoDuplicate(value: T): boolean;
  7557. /**
  7558. * Resets the active data to an empty array.
  7559. */
  7560. reset(): void;
  7561. /**
  7562. * Concats the active data with a given array.
  7563. * This ensures no dupplicate will be present in the result.
  7564. * @param array defines the data to concatenate with.
  7565. */
  7566. concatWithNoDuplicate(array: any): void;
  7567. }
  7568. }
  7569. declare module BABYLON {
  7570. /**
  7571. * Enum that determines the text-wrapping mode to use.
  7572. */
  7573. export enum InspectableType {
  7574. /**
  7575. * Checkbox for booleans
  7576. */
  7577. Checkbox = 0,
  7578. /**
  7579. * Sliders for numbers
  7580. */
  7581. Slider = 1,
  7582. /**
  7583. * Vector3
  7584. */
  7585. Vector3 = 2,
  7586. /**
  7587. * Quaternions
  7588. */
  7589. Quaternion = 3,
  7590. /**
  7591. * Color3
  7592. */
  7593. Color3 = 4
  7594. }
  7595. /**
  7596. * Interface used to define custom inspectable properties.
  7597. * This interface is used by the inspector to display custom property grids
  7598. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7599. */
  7600. export interface IInspectable {
  7601. /**
  7602. * Gets the label to display
  7603. */
  7604. label: string;
  7605. /**
  7606. * Gets the name of the property to edit
  7607. */
  7608. propertyName: string;
  7609. /**
  7610. * Gets the type of the editor to use
  7611. */
  7612. type: InspectableType;
  7613. /**
  7614. * Gets the minimum value of the property when using in "slider" mode
  7615. */
  7616. min?: number;
  7617. /**
  7618. * Gets the maximum value of the property when using in "slider" mode
  7619. */
  7620. max?: number;
  7621. /**
  7622. * Gets the setp to use when using in "slider" mode
  7623. */
  7624. step?: number;
  7625. }
  7626. }
  7627. declare module BABYLON {
  7628. /**
  7629. * This represents the required contract to create a new type of texture loader.
  7630. */
  7631. export interface IInternalTextureLoader {
  7632. /**
  7633. * Defines wether the loader supports cascade loading the different faces.
  7634. */
  7635. supportCascades: boolean;
  7636. /**
  7637. * This returns if the loader support the current file information.
  7638. * @param extension defines the file extension of the file being loaded
  7639. * @param textureFormatInUse defines the current compressed format in use iun the engine
  7640. * @param fallback defines the fallback internal texture if any
  7641. * @param isBase64 defines whether the texture is encoded as a base64
  7642. * @param isBuffer defines whether the texture data are stored as a buffer
  7643. * @returns true if the loader can load the specified file
  7644. */
  7645. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  7646. /**
  7647. * Transform the url before loading if required.
  7648. * @param rootUrl the url of the texture
  7649. * @param textureFormatInUse defines the current compressed format in use iun the engine
  7650. * @returns the transformed texture
  7651. */
  7652. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  7653. /**
  7654. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  7655. * @param rootUrl the url of the texture
  7656. * @param textureFormatInUse defines the current compressed format in use iun the engine
  7657. * @returns the fallback texture
  7658. */
  7659. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  7660. /**
  7661. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  7662. * @param data contains the texture data
  7663. * @param texture defines the BabylonJS internal texture
  7664. * @param createPolynomials will be true if polynomials have been requested
  7665. * @param onLoad defines the callback to trigger once the texture is ready
  7666. * @param onError defines the callback to trigger in case of error
  7667. */
  7668. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  7669. /**
  7670. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  7671. * @param data contains the texture data
  7672. * @param texture defines the BabylonJS internal texture
  7673. * @param callback defines the method to call once ready to upload
  7674. */
  7675. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  7676. }
  7677. }
  7678. declare module BABYLON {
  7679. interface Engine {
  7680. /**
  7681. * Creates a depth stencil cube texture.
  7682. * This is only available in WebGL 2.
  7683. * @param size The size of face edge in the cube texture.
  7684. * @param options The options defining the cube texture.
  7685. * @returns The cube texture
  7686. */
  7687. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7688. /**
  7689. * Creates a cube texture
  7690. * @param rootUrl defines the url where the files to load is located
  7691. * @param scene defines the current scene
  7692. * @param files defines the list of files to load (1 per face)
  7693. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7694. * @param onLoad defines an optional callback raised when the texture is loaded
  7695. * @param onError defines an optional callback raised if there is an issue to load the texture
  7696. * @param format defines the format of the data
  7697. * @param forcedExtension defines the extension to use to pick the right loader
  7698. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7699. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7700. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7701. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7702. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  7703. * @returns the cube texture as an InternalTexture
  7704. */
  7705. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean | undefined, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number, fallback: Nullable<InternalTexture>, excludeLoaders: Array<IInternalTextureLoader>): InternalTexture;
  7706. /**
  7707. * Creates a cube texture
  7708. * @param rootUrl defines the url where the files to load is located
  7709. * @param scene defines the current scene
  7710. * @param files defines the list of files to load (1 per face)
  7711. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7712. * @param onLoad defines an optional callback raised when the texture is loaded
  7713. * @param onError defines an optional callback raised if there is an issue to load the texture
  7714. * @param format defines the format of the data
  7715. * @param forcedExtension defines the extension to use to pick the right loader
  7716. * @returns the cube texture as an InternalTexture
  7717. */
  7718. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any): InternalTexture;
  7719. /**
  7720. * Creates a cube texture
  7721. * @param rootUrl defines the url where the files to load is located
  7722. * @param scene defines the current scene
  7723. * @param files defines the list of files to load (1 per face)
  7724. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7725. * @param onLoad defines an optional callback raised when the texture is loaded
  7726. * @param onError defines an optional callback raised if there is an issue to load the texture
  7727. * @param format defines the format of the data
  7728. * @param forcedExtension defines the extension to use to pick the right loader
  7729. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7730. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7731. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7732. * @returns the cube texture as an InternalTexture
  7733. */
  7734. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number): InternalTexture;
  7735. /** @hidden */
  7736. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7737. /** @hidden */
  7738. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7739. /** @hidden */
  7740. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7741. /** @hidden */
  7742. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7743. }
  7744. }
  7745. declare module BABYLON {
  7746. /**
  7747. * Class for creating a cube texture
  7748. */
  7749. export class CubeTexture extends BaseTexture {
  7750. private _delayedOnLoad;
  7751. /**
  7752. * The url of the texture
  7753. */
  7754. url: string;
  7755. /**
  7756. * Gets or sets the center of the bounding box associated with the cube texture.
  7757. * It must define where the camera used to render the texture was set
  7758. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7759. */
  7760. boundingBoxPosition: Vector3;
  7761. private _boundingBoxSize;
  7762. /**
  7763. * Gets or sets the size of the bounding box associated with the cube texture
  7764. * When defined, the cubemap will switch to local mode
  7765. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7766. * @example https://www.babylonjs-playground.com/#RNASML
  7767. */
  7768. /**
  7769. * Returns the bounding box size
  7770. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7771. */
  7772. boundingBoxSize: Vector3;
  7773. protected _rotationY: number;
  7774. /**
  7775. * Sets texture matrix rotation angle around Y axis in radians.
  7776. */
  7777. /**
  7778. * Gets texture matrix rotation angle around Y axis radians.
  7779. */
  7780. rotationY: number;
  7781. /**
  7782. * Are mip maps generated for this texture or not.
  7783. */
  7784. readonly noMipmap: boolean;
  7785. private _noMipmap;
  7786. private _files;
  7787. private _extensions;
  7788. private _textureMatrix;
  7789. private _format;
  7790. private _createPolynomials;
  7791. /** @hidden */
  7792. _prefiltered: boolean;
  7793. /**
  7794. * Creates a cube texture from an array of image urls
  7795. * @param files defines an array of image urls
  7796. * @param scene defines the hosting scene
  7797. * @param noMipmap specifies if mip maps are not used
  7798. * @returns a cube texture
  7799. */
  7800. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7801. /**
  7802. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7803. * @param url defines the url of the prefiltered texture
  7804. * @param scene defines the scene the texture is attached to
  7805. * @param forcedExtension defines the extension of the file if different from the url
  7806. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7807. * @return the prefiltered texture
  7808. */
  7809. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7810. /**
  7811. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7812. * as prefiltered data.
  7813. * @param rootUrl defines the url of the texture or the root name of the six images
  7814. * @param scene defines the scene the texture is attached to
  7815. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7816. * @param noMipmap defines if mipmaps should be created or not
  7817. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7818. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7819. * @param onError defines a callback triggered in case of error during load
  7820. * @param format defines the internal format to use for the texture once loaded
  7821. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7822. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7823. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7824. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7825. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7826. * @return the cube texture
  7827. */
  7828. constructor(rootUrl: string, scene: Scene, extensions?: Nullable<string[]>, noMipmap?: boolean, files?: Nullable<string[]>, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, prefiltered?: boolean, forcedExtension?: any, createPolynomials?: boolean, lodScale?: number, lodOffset?: number);
  7829. /**
  7830. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  7831. */
  7832. readonly isPrefiltered: boolean;
  7833. /**
  7834. * Get the current class name of the texture useful for serialization or dynamic coding.
  7835. * @returns "CubeTexture"
  7836. */
  7837. getClassName(): string;
  7838. /**
  7839. * Update the url (and optional buffer) of this texture if url was null during construction.
  7840. * @param url the url of the texture
  7841. * @param forcedExtension defines the extension to use
  7842. * @param onLoad callback called when the texture is loaded (defaults to null)
  7843. */
  7844. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  7845. /**
  7846. * Delays loading of the cube texture
  7847. * @param forcedExtension defines the extension to use
  7848. */
  7849. delayLoad(forcedExtension?: string): void;
  7850. /**
  7851. * Returns the reflection texture matrix
  7852. * @returns the reflection texture matrix
  7853. */
  7854. getReflectionTextureMatrix(): Matrix;
  7855. /**
  7856. * Sets the reflection texture matrix
  7857. * @param value Reflection texture matrix
  7858. */
  7859. setReflectionTextureMatrix(value: Matrix): void;
  7860. /**
  7861. * Parses text to create a cube texture
  7862. * @param parsedTexture define the serialized text to read from
  7863. * @param scene defines the hosting scene
  7864. * @param rootUrl defines the root url of the cube texture
  7865. * @returns a cube texture
  7866. */
  7867. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7868. /**
  7869. * Makes a clone, or deep copy, of the cube texture
  7870. * @returns a new cube texture
  7871. */
  7872. clone(): CubeTexture;
  7873. }
  7874. }
  7875. declare module BABYLON {
  7876. /** @hidden */
  7877. export var postprocessVertexShader: {
  7878. name: string;
  7879. shader: string;
  7880. };
  7881. }
  7882. declare module BABYLON {
  7883. /**
  7884. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  7885. * This is the base of the follow, arc rotate cameras and Free camera
  7886. * @see http://doc.babylonjs.com/features/cameras
  7887. */
  7888. export class TargetCamera extends Camera {
  7889. private static _RigCamTransformMatrix;
  7890. private static _TargetTransformMatrix;
  7891. private static _TargetFocalPoint;
  7892. /**
  7893. * Define the current direction the camera is moving to
  7894. */
  7895. cameraDirection: Vector3;
  7896. /**
  7897. * Define the current rotation the camera is rotating to
  7898. */
  7899. cameraRotation: Vector2;
  7900. /**
  7901. * When set, the up vector of the camera will be updated by the rotation of the camera
  7902. */
  7903. updateUpVectorFromRotation: boolean;
  7904. private _tmpQuaternion;
  7905. /**
  7906. * Define the current rotation of the camera
  7907. */
  7908. rotation: Vector3;
  7909. /**
  7910. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  7911. */
  7912. rotationQuaternion: Quaternion;
  7913. /**
  7914. * Define the current speed of the camera
  7915. */
  7916. speed: number;
  7917. /**
  7918. * Add cconstraint to the camera to prevent it to move freely in all directions and
  7919. * around all axis.
  7920. */
  7921. noRotationConstraint: boolean;
  7922. /**
  7923. * Define the current target of the camera as an object or a position.
  7924. */
  7925. lockedTarget: any;
  7926. /** @hidden */
  7927. _currentTarget: Vector3;
  7928. /** @hidden */
  7929. _initialFocalDistance: number;
  7930. /** @hidden */
  7931. _viewMatrix: Matrix;
  7932. /** @hidden */
  7933. _camMatrix: Matrix;
  7934. /** @hidden */
  7935. _cameraTransformMatrix: Matrix;
  7936. /** @hidden */
  7937. _cameraRotationMatrix: Matrix;
  7938. /** @hidden */
  7939. _referencePoint: Vector3;
  7940. /** @hidden */
  7941. _transformedReferencePoint: Vector3;
  7942. protected _globalCurrentTarget: Vector3;
  7943. protected _globalCurrentUpVector: Vector3;
  7944. /** @hidden */
  7945. _reset: () => void;
  7946. private _defaultUp;
  7947. /**
  7948. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  7949. * This is the base of the follow, arc rotate cameras and Free camera
  7950. * @see http://doc.babylonjs.com/features/cameras
  7951. * @param name Defines the name of the camera in the scene
  7952. * @param position Defines the start position of the camera in the scene
  7953. * @param scene Defines the scene the camera belongs to
  7954. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  7955. */
  7956. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  7957. /**
  7958. * Gets the position in front of the camera at a given distance.
  7959. * @param distance The distance from the camera we want the position to be
  7960. * @returns the position
  7961. */
  7962. getFrontPosition(distance: number): Vector3;
  7963. /** @hidden */
  7964. _getLockedTargetPosition(): Nullable<Vector3>;
  7965. private _storedPosition;
  7966. private _storedRotation;
  7967. private _storedRotationQuaternion;
  7968. /**
  7969. * Store current camera state of the camera (fov, position, rotation, etc..)
  7970. * @returns the camera
  7971. */
  7972. storeState(): Camera;
  7973. /**
  7974. * Restored camera state. You must call storeState() first
  7975. * @returns whether it was successful or not
  7976. * @hidden
  7977. */
  7978. _restoreStateValues(): boolean;
  7979. /** @hidden */
  7980. _initCache(): void;
  7981. /** @hidden */
  7982. _updateCache(ignoreParentClass?: boolean): void;
  7983. /** @hidden */
  7984. _isSynchronizedViewMatrix(): boolean;
  7985. /** @hidden */
  7986. _computeLocalCameraSpeed(): number;
  7987. /**
  7988. * Defines the target the camera should look at.
  7989. * This will automatically adapt alpha beta and radius to fit within the new target.
  7990. * @param target Defines the new target as a Vector or a mesh
  7991. */
  7992. setTarget(target: Vector3): void;
  7993. /**
  7994. * Return the current target position of the camera. This value is expressed in local space.
  7995. * @returns the target position
  7996. */
  7997. getTarget(): Vector3;
  7998. /** @hidden */
  7999. _decideIfNeedsToMove(): boolean;
  8000. /** @hidden */
  8001. _updatePosition(): void;
  8002. /** @hidden */
  8003. _checkInputs(): void;
  8004. protected _updateCameraRotationMatrix(): void;
  8005. /**
  8006. * Update the up vector to apply the rotation of the camera (So if you changed the camera rotation.z this will let you update the up vector as well)
  8007. * @returns the current camera
  8008. */
  8009. private _rotateUpVectorWithCameraRotationMatrix;
  8010. private _cachedRotationZ;
  8011. private _cachedQuaternionRotationZ;
  8012. /** @hidden */
  8013. _getViewMatrix(): Matrix;
  8014. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8015. /**
  8016. * @hidden
  8017. */
  8018. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8019. /**
  8020. * @hidden
  8021. */
  8022. _updateRigCameras(): void;
  8023. private _getRigCamPositionAndTarget;
  8024. /**
  8025. * Gets the current object class name.
  8026. * @return the class name
  8027. */
  8028. getClassName(): string;
  8029. }
  8030. }
  8031. declare module BABYLON {
  8032. /**
  8033. * @ignore
  8034. * This is a list of all the different input types that are available in the application.
  8035. * Fo instance: ArcRotateCameraGamepadInput...
  8036. */
  8037. export var CameraInputTypes: {};
  8038. /**
  8039. * This is the contract to implement in order to create a new input class.
  8040. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  8041. */
  8042. export interface ICameraInput<TCamera extends Camera> {
  8043. /**
  8044. * Defines the camera the input is attached to.
  8045. */
  8046. camera: Nullable<TCamera>;
  8047. /**
  8048. * Gets the class name of the current intput.
  8049. * @returns the class name
  8050. */
  8051. getClassName(): string;
  8052. /**
  8053. * Get the friendly name associated with the input class.
  8054. * @returns the input friendly name
  8055. */
  8056. getSimpleName(): string;
  8057. /**
  8058. * Attach the input controls to a specific dom element to get the input from.
  8059. * @param element Defines the element the controls should be listened from
  8060. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8061. */
  8062. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8063. /**
  8064. * Detach the current controls from the specified dom element.
  8065. * @param element Defines the element to stop listening the inputs from
  8066. */
  8067. detachControl(element: Nullable<HTMLElement>): void;
  8068. /**
  8069. * Update the current camera state depending on the inputs that have been used this frame.
  8070. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8071. */
  8072. checkInputs?: () => void;
  8073. }
  8074. /**
  8075. * Represents a map of input types to input instance or input index to input instance.
  8076. */
  8077. export interface CameraInputsMap<TCamera extends Camera> {
  8078. /**
  8079. * Accessor to the input by input type.
  8080. */
  8081. [name: string]: ICameraInput<TCamera>;
  8082. /**
  8083. * Accessor to the input by input index.
  8084. */
  8085. [idx: number]: ICameraInput<TCamera>;
  8086. }
  8087. /**
  8088. * This represents the input manager used within a camera.
  8089. * It helps dealing with all the different kind of input attached to a camera.
  8090. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8091. */
  8092. export class CameraInputsManager<TCamera extends Camera> {
  8093. /**
  8094. * Defines the list of inputs attahed to the camera.
  8095. */
  8096. attached: CameraInputsMap<TCamera>;
  8097. /**
  8098. * Defines the dom element the camera is collecting inputs from.
  8099. * This is null if the controls have not been attached.
  8100. */
  8101. attachedElement: Nullable<HTMLElement>;
  8102. /**
  8103. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8104. */
  8105. noPreventDefault: boolean;
  8106. /**
  8107. * Defined the camera the input manager belongs to.
  8108. */
  8109. camera: TCamera;
  8110. /**
  8111. * Update the current camera state depending on the inputs that have been used this frame.
  8112. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8113. */
  8114. checkInputs: () => void;
  8115. /**
  8116. * Instantiate a new Camera Input Manager.
  8117. * @param camera Defines the camera the input manager blongs to
  8118. */
  8119. constructor(camera: TCamera);
  8120. /**
  8121. * Add an input method to a camera
  8122. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8123. * @param input camera input method
  8124. */
  8125. add(input: ICameraInput<TCamera>): void;
  8126. /**
  8127. * Remove a specific input method from a camera
  8128. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  8129. * @param inputToRemove camera input method
  8130. */
  8131. remove(inputToRemove: ICameraInput<TCamera>): void;
  8132. /**
  8133. * Remove a specific input type from a camera
  8134. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  8135. * @param inputType the type of the input to remove
  8136. */
  8137. removeByType(inputType: string): void;
  8138. private _addCheckInputs;
  8139. /**
  8140. * Attach the input controls to the currently attached dom element to listen the events from.
  8141. * @param input Defines the input to attach
  8142. */
  8143. attachInput(input: ICameraInput<TCamera>): void;
  8144. /**
  8145. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  8146. * @param element Defines the dom element to collect the events from
  8147. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8148. */
  8149. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  8150. /**
  8151. * Detach the current manager inputs controls from a specific dom element.
  8152. * @param element Defines the dom element to collect the events from
  8153. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  8154. */
  8155. detachElement(element: HTMLElement, disconnect?: boolean): void;
  8156. /**
  8157. * Rebuild the dynamic inputCheck function from the current list of
  8158. * defined inputs in the manager.
  8159. */
  8160. rebuildInputCheck(): void;
  8161. /**
  8162. * Remove all attached input methods from a camera
  8163. */
  8164. clear(): void;
  8165. /**
  8166. * Serialize the current input manager attached to a camera.
  8167. * This ensures than once parsed,
  8168. * the input associated to the camera will be identical to the current ones
  8169. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  8170. */
  8171. serialize(serializedCamera: any): void;
  8172. /**
  8173. * Parses an input manager serialized JSON to restore the previous list of inputs
  8174. * and states associated to a camera.
  8175. * @param parsedCamera Defines the JSON to parse
  8176. */
  8177. parse(parsedCamera: any): void;
  8178. }
  8179. }
  8180. declare module BABYLON {
  8181. /**
  8182. * Gather the list of keyboard event types as constants.
  8183. */
  8184. export class KeyboardEventTypes {
  8185. /**
  8186. * The keydown event is fired when a key becomes active (pressed).
  8187. */
  8188. static readonly KEYDOWN: number;
  8189. /**
  8190. * The keyup event is fired when a key has been released.
  8191. */
  8192. static readonly KEYUP: number;
  8193. }
  8194. /**
  8195. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8196. */
  8197. export class KeyboardInfo {
  8198. /**
  8199. * Defines the type of event (KeyboardEventTypes)
  8200. */
  8201. type: number;
  8202. /**
  8203. * Defines the related dom event
  8204. */
  8205. event: KeyboardEvent;
  8206. /**
  8207. * Instantiates a new keyboard info.
  8208. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8209. * @param type Defines the type of event (KeyboardEventTypes)
  8210. * @param event Defines the related dom event
  8211. */
  8212. constructor(
  8213. /**
  8214. * Defines the type of event (KeyboardEventTypes)
  8215. */
  8216. type: number,
  8217. /**
  8218. * Defines the related dom event
  8219. */
  8220. event: KeyboardEvent);
  8221. }
  8222. /**
  8223. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8224. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8225. */
  8226. export class KeyboardInfoPre extends KeyboardInfo {
  8227. /**
  8228. * Defines the type of event (KeyboardEventTypes)
  8229. */
  8230. type: number;
  8231. /**
  8232. * Defines the related dom event
  8233. */
  8234. event: KeyboardEvent;
  8235. /**
  8236. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8237. */
  8238. skipOnPointerObservable: boolean;
  8239. /**
  8240. * Instantiates a new keyboard pre info.
  8241. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8242. * @param type Defines the type of event (KeyboardEventTypes)
  8243. * @param event Defines the related dom event
  8244. */
  8245. constructor(
  8246. /**
  8247. * Defines the type of event (KeyboardEventTypes)
  8248. */
  8249. type: number,
  8250. /**
  8251. * Defines the related dom event
  8252. */
  8253. event: KeyboardEvent);
  8254. }
  8255. }
  8256. declare module BABYLON {
  8257. /**
  8258. * Manage the keyboard inputs to control the movement of a free camera.
  8259. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8260. */
  8261. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8262. /**
  8263. * Defines the camera the input is attached to.
  8264. */
  8265. camera: FreeCamera;
  8266. /**
  8267. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8268. */
  8269. keysUp: number[];
  8270. /**
  8271. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8272. */
  8273. keysDown: number[];
  8274. /**
  8275. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8276. */
  8277. keysLeft: number[];
  8278. /**
  8279. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8280. */
  8281. keysRight: number[];
  8282. private _keys;
  8283. private _onCanvasBlurObserver;
  8284. private _onKeyboardObserver;
  8285. private _engine;
  8286. private _scene;
  8287. /**
  8288. * Attach the input controls to a specific dom element to get the input from.
  8289. * @param element Defines the element the controls should be listened from
  8290. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8291. */
  8292. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8293. /**
  8294. * Detach the current controls from the specified dom element.
  8295. * @param element Defines the element to stop listening the inputs from
  8296. */
  8297. detachControl(element: Nullable<HTMLElement>): void;
  8298. /**
  8299. * Update the current camera state depending on the inputs that have been used this frame.
  8300. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8301. */
  8302. checkInputs(): void;
  8303. /**
  8304. * Gets the class name of the current intput.
  8305. * @returns the class name
  8306. */
  8307. getClassName(): string;
  8308. /** @hidden */
  8309. _onLostFocus(): void;
  8310. /**
  8311. * Get the friendly name associated with the input class.
  8312. * @returns the input friendly name
  8313. */
  8314. getSimpleName(): string;
  8315. }
  8316. }
  8317. declare module BABYLON {
  8318. /**
  8319. * A multi-material is used to apply different materials to different parts of the same object without the need of
  8320. * separate meshes. This can be use to improve performances.
  8321. * @see http://doc.babylonjs.com/how_to/multi_materials
  8322. */
  8323. export class MultiMaterial extends Material {
  8324. private _subMaterials;
  8325. /**
  8326. * Gets or Sets the list of Materials used within the multi material.
  8327. * They need to be ordered according to the submeshes order in the associated mesh
  8328. */
  8329. subMaterials: Nullable<Material>[];
  8330. /**
  8331. * Function used to align with Node.getChildren()
  8332. * @returns the list of Materials used within the multi material
  8333. */
  8334. getChildren(): Nullable<Material>[];
  8335. /**
  8336. * Instantiates a new Multi Material
  8337. * A multi-material is used to apply different materials to different parts of the same object without the need of
  8338. * separate meshes. This can be use to improve performances.
  8339. * @see http://doc.babylonjs.com/how_to/multi_materials
  8340. * @param name Define the name in the scene
  8341. * @param scene Define the scene the material belongs to
  8342. */
  8343. constructor(name: string, scene: Scene);
  8344. private _hookArray;
  8345. /**
  8346. * Get one of the submaterial by its index in the submaterials array
  8347. * @param index The index to look the sub material at
  8348. * @returns The Material if the index has been defined
  8349. */
  8350. getSubMaterial(index: number): Nullable<Material>;
  8351. /**
  8352. * Get the list of active textures for the whole sub materials list.
  8353. * @returns All the textures that will be used during the rendering
  8354. */
  8355. getActiveTextures(): BaseTexture[];
  8356. /**
  8357. * Gets the current class name of the material e.g. "MultiMaterial"
  8358. * Mainly use in serialization.
  8359. * @returns the class name
  8360. */
  8361. getClassName(): string;
  8362. /**
  8363. * Checks if the material is ready to render the requested sub mesh
  8364. * @param mesh Define the mesh the submesh belongs to
  8365. * @param subMesh Define the sub mesh to look readyness for
  8366. * @param useInstances Define whether or not the material is used with instances
  8367. * @returns true if ready, otherwise false
  8368. */
  8369. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  8370. /**
  8371. * Clones the current material and its related sub materials
  8372. * @param name Define the name of the newly cloned material
  8373. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  8374. * @returns the cloned material
  8375. */
  8376. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  8377. /**
  8378. * Serializes the materials into a JSON representation.
  8379. * @returns the JSON representation
  8380. */
  8381. serialize(): any;
  8382. /**
  8383. * Dispose the material and release its associated resources
  8384. * @param forceDisposeEffect Define if we want to force disposing the associated effect (if false the shader is not released and could be reuse later on)
  8385. * @param forceDisposeTextures Define if we want to force disposing the associated textures (if false, they will not be disposed and can still be use elsewhere in the app)
  8386. * @param forceDisposeChildren Define if we want to force disposing the associated submaterials (if false, they will not be disposed and can still be use elsewhere in the app)
  8387. */
  8388. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  8389. /**
  8390. * Creates a MultiMaterial from parsed MultiMaterial data.
  8391. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  8392. * @param scene defines the hosting scene
  8393. * @returns a new MultiMaterial
  8394. */
  8395. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  8396. }
  8397. }
  8398. declare module BABYLON {
  8399. /**
  8400. * Class used to represent data loading progression
  8401. */
  8402. export class SceneLoaderFlags {
  8403. private static _ForceFullSceneLoadingForIncremental;
  8404. private static _ShowLoadingScreen;
  8405. private static _CleanBoneMatrixWeights;
  8406. private static _loggingLevel;
  8407. /**
  8408. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  8409. */
  8410. static ForceFullSceneLoadingForIncremental: boolean;
  8411. /**
  8412. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  8413. */
  8414. static ShowLoadingScreen: boolean;
  8415. /**
  8416. * Defines the current logging level (while loading the scene)
  8417. * @ignorenaming
  8418. */
  8419. static loggingLevel: number;
  8420. /**
  8421. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  8422. */
  8423. static CleanBoneMatrixWeights: boolean;
  8424. }
  8425. }
  8426. declare module BABYLON {
  8427. /**
  8428. * A TransformNode is an object that is not rendered but can be used as a center of transformation. This can decrease memory usage and increase rendering speed compared to using an empty mesh as a parent and is less complicated than using a pivot matrix.
  8429. * @see https://doc.babylonjs.com/how_to/transformnode
  8430. */
  8431. export class TransformNode extends Node {
  8432. /**
  8433. * Object will not rotate to face the camera
  8434. */
  8435. static BILLBOARDMODE_NONE: number;
  8436. /**
  8437. * Object will rotate to face the camera but only on the x axis
  8438. */
  8439. static BILLBOARDMODE_X: number;
  8440. /**
  8441. * Object will rotate to face the camera but only on the y axis
  8442. */
  8443. static BILLBOARDMODE_Y: number;
  8444. /**
  8445. * Object will rotate to face the camera but only on the z axis
  8446. */
  8447. static BILLBOARDMODE_Z: number;
  8448. /**
  8449. * Object will rotate to face the camera
  8450. */
  8451. static BILLBOARDMODE_ALL: number;
  8452. private _forward;
  8453. private _forwardInverted;
  8454. private _up;
  8455. private _right;
  8456. private _rightInverted;
  8457. private _position;
  8458. private _rotation;
  8459. private _rotationQuaternion;
  8460. protected _scaling: Vector3;
  8461. protected _isDirty: boolean;
  8462. private _transformToBoneReferal;
  8463. private _billboardMode;
  8464. /**
  8465. * Gets or sets the billboard mode. Default is 0.
  8466. *
  8467. * | Value | Type | Description |
  8468. * | --- | --- | --- |
  8469. * | 0 | BILLBOARDMODE_NONE | |
  8470. * | 1 | BILLBOARDMODE_X | |
  8471. * | 2 | BILLBOARDMODE_Y | |
  8472. * | 4 | BILLBOARDMODE_Z | |
  8473. * | 7 | BILLBOARDMODE_ALL | |
  8474. *
  8475. */
  8476. billboardMode: number;
  8477. private _preserveParentRotationForBillboard;
  8478. /**
  8479. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  8480. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  8481. */
  8482. preserveParentRotationForBillboard: boolean;
  8483. /**
  8484. * Multiplication factor on scale x/y/z when computing the world matrix. Eg. for a 1x1x1 cube setting this to 2 will make it a 2x2x2 cube
  8485. */
  8486. scalingDeterminant: number;
  8487. private _infiniteDistance;
  8488. /**
  8489. * Gets or sets the distance of the object to max, often used by skybox
  8490. */
  8491. infiniteDistance: boolean;
  8492. /**
  8493. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  8494. * By default the system will update normals to compensate
  8495. */
  8496. ignoreNonUniformScaling: boolean;
  8497. /**
  8498. * Gets or sets a boolean indicating that even if rotationQuaternion is defined, you can keep updating rotation property and Babylon.js will just mix both
  8499. */
  8500. reIntegrateRotationIntoRotationQuaternion: boolean;
  8501. /** @hidden */
  8502. _poseMatrix: Nullable<Matrix>;
  8503. /** @hidden */
  8504. _localMatrix: Matrix;
  8505. private _usePivotMatrix;
  8506. private _absolutePosition;
  8507. private _pivotMatrix;
  8508. private _pivotMatrixInverse;
  8509. protected _postMultiplyPivotMatrix: boolean;
  8510. protected _isWorldMatrixFrozen: boolean;
  8511. /** @hidden */
  8512. _indexInSceneTransformNodesArray: number;
  8513. /**
  8514. * An event triggered after the world matrix is updated
  8515. */
  8516. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  8517. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  8518. /**
  8519. * Gets a string identifying the name of the class
  8520. * @returns "TransformNode" string
  8521. */
  8522. getClassName(): string;
  8523. /**
  8524. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  8525. */
  8526. position: Vector3;
  8527. /**
  8528. * Gets or sets the rotation property : a Vector3 defining the rotation value in radians around each local axis X, Y, Z (default is (0.0, 0.0, 0.0)).
  8529. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  8530. */
  8531. rotation: Vector3;
  8532. /**
  8533. * Gets or sets the scaling property : a Vector3 defining the node scaling along each local axis X, Y, Z (default is (0.0, 0.0, 0.0)).
  8534. */
  8535. scaling: Vector3;
  8536. /**
  8537. * Gets or sets the rotation Quaternion property : this a Quaternion object defining the node rotation by using a unit quaternion (undefined by default, but can be null).
  8538. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  8539. */
  8540. rotationQuaternion: Nullable<Quaternion>;
  8541. /**
  8542. * The forward direction of that transform in world space.
  8543. */
  8544. readonly forward: Vector3;
  8545. /**
  8546. * The up direction of that transform in world space.
  8547. */
  8548. readonly up: Vector3;
  8549. /**
  8550. * The right direction of that transform in world space.
  8551. */
  8552. readonly right: Vector3;
  8553. /**
  8554. * Copies the parameter passed Matrix into the mesh Pose matrix.
  8555. * @param matrix the matrix to copy the pose from
  8556. * @returns this TransformNode.
  8557. */
  8558. updatePoseMatrix(matrix: Matrix): TransformNode;
  8559. /**
  8560. * Returns the mesh Pose matrix.
  8561. * @returns the pose matrix
  8562. */
  8563. getPoseMatrix(): Matrix;
  8564. /** @hidden */
  8565. _isSynchronized(): boolean;
  8566. /** @hidden */
  8567. _initCache(): void;
  8568. /**
  8569. * Flag the transform node as dirty (Forcing it to update everything)
  8570. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  8571. * @returns this transform node
  8572. */
  8573. markAsDirty(property: string): TransformNode;
  8574. /**
  8575. * Returns the current mesh absolute position.
  8576. * Returns a Vector3.
  8577. */
  8578. readonly absolutePosition: Vector3;
  8579. /**
  8580. * Sets a new matrix to apply before all other transformation
  8581. * @param matrix defines the transform matrix
  8582. * @returns the current TransformNode
  8583. */
  8584. setPreTransformMatrix(matrix: Matrix): TransformNode;
  8585. /**
  8586. * Sets a new pivot matrix to the current node
  8587. * @param matrix defines the new pivot matrix to use
  8588. * @param postMultiplyPivotMatrix defines if the pivot matrix must be cancelled in the world matrix. When this parameter is set to true (default), the inverse of the pivot matrix is also applied at the end to cancel the transformation effect
  8589. * @returns the current TransformNode
  8590. */
  8591. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  8592. /**
  8593. * Returns the mesh pivot matrix.
  8594. * Default : Identity.
  8595. * @returns the matrix
  8596. */
  8597. getPivotMatrix(): Matrix;
  8598. /**
  8599. * Prevents the World matrix to be computed any longer.
  8600. * @returns the TransformNode.
  8601. */
  8602. freezeWorldMatrix(): TransformNode;
  8603. /**
  8604. * Allows back the World matrix computation.
  8605. * @returns the TransformNode.
  8606. */
  8607. unfreezeWorldMatrix(): this;
  8608. /**
  8609. * True if the World matrix has been frozen.
  8610. */
  8611. readonly isWorldMatrixFrozen: boolean;
  8612. /**
  8613. * Retuns the mesh absolute position in the World.
  8614. * @returns a Vector3.
  8615. */
  8616. getAbsolutePosition(): Vector3;
  8617. /**
  8618. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  8619. * @param absolutePosition the absolute position to set
  8620. * @returns the TransformNode.
  8621. */
  8622. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  8623. /**
  8624. * Sets the mesh position in its local space.
  8625. * @param vector3 the position to set in localspace
  8626. * @returns the TransformNode.
  8627. */
  8628. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  8629. /**
  8630. * Returns the mesh position in the local space from the current World matrix values.
  8631. * @returns a new Vector3.
  8632. */
  8633. getPositionExpressedInLocalSpace(): Vector3;
  8634. /**
  8635. * Translates the mesh along the passed Vector3 in its local space.
  8636. * @param vector3 the distance to translate in localspace
  8637. * @returns the TransformNode.
  8638. */
  8639. locallyTranslate(vector3: Vector3): TransformNode;
  8640. private static _lookAtVectorCache;
  8641. /**
  8642. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  8643. * @param targetPoint the position (must be in same space as current mesh) to look at
  8644. * @param yawCor optional yaw (y-axis) correction in radians
  8645. * @param pitchCor optional pitch (x-axis) correction in radians
  8646. * @param rollCor optional roll (z-axis) correction in radians
  8647. * @param space the choosen space of the target
  8648. * @returns the TransformNode.
  8649. */
  8650. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  8651. /**
  8652. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  8653. * This Vector3 is expressed in the World space.
  8654. * @param localAxis axis to rotate
  8655. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  8656. */
  8657. getDirection(localAxis: Vector3): Vector3;
  8658. /**
  8659. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  8660. * localAxis is expressed in the mesh local space.
  8661. * result is computed in the Wordl space from the mesh World matrix.
  8662. * @param localAxis axis to rotate
  8663. * @param result the resulting transformnode
  8664. * @returns this TransformNode.
  8665. */
  8666. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  8667. /**
  8668. * Sets this transform node rotation to the given local axis.
  8669. * @param localAxis the axis in local space
  8670. * @param yawCor optional yaw (y-axis) correction in radians
  8671. * @param pitchCor optional pitch (x-axis) correction in radians
  8672. * @param rollCor optional roll (z-axis) correction in radians
  8673. * @returns this TransformNode
  8674. */
  8675. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  8676. /**
  8677. * Sets a new pivot point to the current node
  8678. * @param point defines the new pivot point to use
  8679. * @param space defines if the point is in world or local space (local by default)
  8680. * @returns the current TransformNode
  8681. */
  8682. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  8683. /**
  8684. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  8685. * @returns the pivot point
  8686. */
  8687. getPivotPoint(): Vector3;
  8688. /**
  8689. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  8690. * @param result the vector3 to store the result
  8691. * @returns this TransformNode.
  8692. */
  8693. getPivotPointToRef(result: Vector3): TransformNode;
  8694. /**
  8695. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  8696. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  8697. */
  8698. getAbsolutePivotPoint(): Vector3;
  8699. /**
  8700. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  8701. * @param result vector3 to store the result
  8702. * @returns this TransformNode.
  8703. */
  8704. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  8705. /**
  8706. * Defines the passed node as the parent of the current node.
  8707. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  8708. * @see https://doc.babylonjs.com/how_to/parenting
  8709. * @param node the node ot set as the parent
  8710. * @returns this TransformNode.
  8711. */
  8712. setParent(node: Nullable<Node>): TransformNode;
  8713. private _nonUniformScaling;
  8714. /**
  8715. * True if the scaling property of this object is non uniform eg. (1,2,1)
  8716. */
  8717. readonly nonUniformScaling: boolean;
  8718. /** @hidden */
  8719. _updateNonUniformScalingState(value: boolean): boolean;
  8720. /**
  8721. * Attach the current TransformNode to another TransformNode associated with a bone
  8722. * @param bone Bone affecting the TransformNode
  8723. * @param affectedTransformNode TransformNode associated with the bone
  8724. * @returns this object
  8725. */
  8726. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  8727. /**
  8728. * Detach the transform node if its associated with a bone
  8729. * @returns this object
  8730. */
  8731. detachFromBone(): TransformNode;
  8732. private static _rotationAxisCache;
  8733. /**
  8734. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  8735. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  8736. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  8737. * The passed axis is also normalized.
  8738. * @param axis the axis to rotate around
  8739. * @param amount the amount to rotate in radians
  8740. * @param space Space to rotate in (Default: local)
  8741. * @returns the TransformNode.
  8742. */
  8743. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  8744. /**
  8745. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  8746. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  8747. * The passed axis is also normalized. .
  8748. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  8749. * @param point the point to rotate around
  8750. * @param axis the axis to rotate around
  8751. * @param amount the amount to rotate in radians
  8752. * @returns the TransformNode
  8753. */
  8754. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  8755. /**
  8756. * Translates the mesh along the axis vector for the passed distance in the given space.
  8757. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  8758. * @param axis the axis to translate in
  8759. * @param distance the distance to translate
  8760. * @param space Space to rotate in (Default: local)
  8761. * @returns the TransformNode.
  8762. */
  8763. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  8764. /**
  8765. * Adds a rotation step to the mesh current rotation.
  8766. * x, y, z are Euler angles expressed in radians.
  8767. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  8768. * This means this rotation is made in the mesh local space only.
  8769. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  8770. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  8771. * ```javascript
  8772. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  8773. * ```
  8774. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  8775. * Under the hood, only quaternions are used. So it's a little faster is you use .rotationQuaternion because it doesn't need to translate them back to Euler angles.
  8776. * @param x Rotation to add
  8777. * @param y Rotation to add
  8778. * @param z Rotation to add
  8779. * @returns the TransformNode.
  8780. */
  8781. addRotation(x: number, y: number, z: number): TransformNode;
  8782. /**
  8783. * @hidden
  8784. */
  8785. protected _getEffectiveParent(): Nullable<Node>;
  8786. /**
  8787. * Computes the world matrix of the node
  8788. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  8789. * @returns the world matrix
  8790. */
  8791. computeWorldMatrix(force?: boolean): Matrix;
  8792. protected _afterComputeWorldMatrix(): void;
  8793. /**
  8794. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  8795. * @param func callback function to add
  8796. *
  8797. * @returns the TransformNode.
  8798. */
  8799. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  8800. /**
  8801. * Removes a registered callback function.
  8802. * @param func callback function to remove
  8803. * @returns the TransformNode.
  8804. */
  8805. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  8806. /**
  8807. * Gets the position of the current mesh in camera space
  8808. * @param camera defines the camera to use
  8809. * @returns a position
  8810. */
  8811. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  8812. /**
  8813. * Returns the distance from the mesh to the active camera
  8814. * @param camera defines the camera to use
  8815. * @returns the distance
  8816. */
  8817. getDistanceToCamera(camera?: Nullable<Camera>): number;
  8818. /**
  8819. * Clone the current transform node
  8820. * @param name Name of the new clone
  8821. * @param newParent New parent for the clone
  8822. * @param doNotCloneChildren Do not clone children hierarchy
  8823. * @returns the new transform node
  8824. */
  8825. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  8826. /**
  8827. * Serializes the objects information.
  8828. * @param currentSerializationObject defines the object to serialize in
  8829. * @returns the serialized object
  8830. */
  8831. serialize(currentSerializationObject?: any): any;
  8832. /**
  8833. * Returns a new TransformNode object parsed from the source provided.
  8834. * @param parsedTransformNode is the source.
  8835. * @param scene the scne the object belongs to
  8836. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  8837. * @returns a new TransformNode object parsed from the source provided.
  8838. */
  8839. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  8840. /**
  8841. * Get all child-transformNodes of this node
  8842. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered
  8843. * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
  8844. * @returns an array of TransformNode
  8845. */
  8846. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  8847. /**
  8848. * Releases resources associated with this transform node.
  8849. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  8850. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  8851. */
  8852. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  8853. }
  8854. }
  8855. declare module BABYLON {
  8856. /**
  8857. * Class used to override all child animations of a given target
  8858. */
  8859. export class AnimationPropertiesOverride {
  8860. /**
  8861. * Gets or sets a value indicating if animation blending must be used
  8862. */
  8863. enableBlending: boolean;
  8864. /**
  8865. * Gets or sets the blending speed to use when enableBlending is true
  8866. */
  8867. blendingSpeed: number;
  8868. /**
  8869. * Gets or sets the default loop mode to use
  8870. */
  8871. loopMode: number;
  8872. }
  8873. }
  8874. declare module BABYLON {
  8875. /**
  8876. * Class used to store bone information
  8877. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  8878. */
  8879. export class Bone extends Node {
  8880. /**
  8881. * defines the bone name
  8882. */
  8883. name: string;
  8884. private static _tmpVecs;
  8885. private static _tmpQuat;
  8886. private static _tmpMats;
  8887. /**
  8888. * Gets the list of child bones
  8889. */
  8890. children: Bone[];
  8891. /** Gets the animations associated with this bone */
  8892. animations: Animation[];
  8893. /**
  8894. * Gets or sets bone length
  8895. */
  8896. length: number;
  8897. /**
  8898. * @hidden Internal only
  8899. * Set this value to map this bone to a different index in the transform matrices
  8900. * Set this value to -1 to exclude the bone from the transform matrices
  8901. */
  8902. _index: Nullable<number>;
  8903. private _skeleton;
  8904. private _localMatrix;
  8905. private _restPose;
  8906. private _baseMatrix;
  8907. private _absoluteTransform;
  8908. private _invertedAbsoluteTransform;
  8909. private _parent;
  8910. private _scalingDeterminant;
  8911. private _worldTransform;
  8912. private _localScaling;
  8913. private _localRotation;
  8914. private _localPosition;
  8915. private _needToDecompose;
  8916. private _needToCompose;
  8917. /** @hidden */
  8918. _linkedTransformNode: Nullable<TransformNode>;
  8919. /** @hidden */
  8920. _waitingTransformNodeId: Nullable<string>;
  8921. /** @hidden */
  8922. /** @hidden */
  8923. _matrix: Matrix;
  8924. /**
  8925. * Create a new bone
  8926. * @param name defines the bone name
  8927. * @param skeleton defines the parent skeleton
  8928. * @param parentBone defines the parent (can be null if the bone is the root)
  8929. * @param localMatrix defines the local matrix
  8930. * @param restPose defines the rest pose matrix
  8931. * @param baseMatrix defines the base matrix
  8932. * @param index defines index of the bone in the hiearchy
  8933. */
  8934. constructor(
  8935. /**
  8936. * defines the bone name
  8937. */
  8938. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  8939. /**
  8940. * Gets the current object class name.
  8941. * @return the class name
  8942. */
  8943. getClassName(): string;
  8944. /**
  8945. * Gets the parent skeleton
  8946. * @returns a skeleton
  8947. */
  8948. getSkeleton(): Skeleton;
  8949. /**
  8950. * Gets parent bone
  8951. * @returns a bone or null if the bone is the root of the bone hierarchy
  8952. */
  8953. getParent(): Nullable<Bone>;
  8954. /**
  8955. * Returns an array containing the root bones
  8956. * @returns an array containing the root bones
  8957. */
  8958. getChildren(): Array<Bone>;
  8959. /**
  8960. * Sets the parent bone
  8961. * @param parent defines the parent (can be null if the bone is the root)
  8962. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  8963. */
  8964. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  8965. /**
  8966. * Gets the local matrix
  8967. * @returns a matrix
  8968. */
  8969. getLocalMatrix(): Matrix;
  8970. /**
  8971. * Gets the base matrix (initial matrix which remains unchanged)
  8972. * @returns a matrix
  8973. */
  8974. getBaseMatrix(): Matrix;
  8975. /**
  8976. * Gets the rest pose matrix
  8977. * @returns a matrix
  8978. */
  8979. getRestPose(): Matrix;
  8980. /**
  8981. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  8982. */
  8983. getWorldMatrix(): Matrix;
  8984. /**
  8985. * Sets the local matrix to rest pose matrix
  8986. */
  8987. returnToRest(): void;
  8988. /**
  8989. * Gets the inverse of the absolute transform matrix.
  8990. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  8991. * @returns a matrix
  8992. */
  8993. getInvertedAbsoluteTransform(): Matrix;
  8994. /**
  8995. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  8996. * @returns a matrix
  8997. */
  8998. getAbsoluteTransform(): Matrix;
  8999. /**
  9000. * Links with the given transform node.
  9001. * The local matrix of this bone is copied from the transform node every frame.
  9002. * @param transformNode defines the transform node to link to
  9003. */
  9004. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  9005. /** Gets or sets current position (in local space) */
  9006. position: Vector3;
  9007. /** Gets or sets current rotation (in local space) */
  9008. rotation: Vector3;
  9009. /** Gets or sets current rotation quaternion (in local space) */
  9010. rotationQuaternion: Quaternion;
  9011. /** Gets or sets current scaling (in local space) */
  9012. scaling: Vector3;
  9013. /**
  9014. * Gets the animation properties override
  9015. */
  9016. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  9017. private _decompose;
  9018. private _compose;
  9019. /**
  9020. * Update the base and local matrices
  9021. * @param matrix defines the new base or local matrix
  9022. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  9023. * @param updateLocalMatrix defines if the local matrix should be updated
  9024. */
  9025. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  9026. /** @hidden */
  9027. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  9028. /**
  9029. * Flag the bone as dirty (Forcing it to update everything)
  9030. */
  9031. markAsDirty(): void;
  9032. /** @hidden */
  9033. _markAsDirtyAndCompose(): void;
  9034. private _markAsDirtyAndDecompose;
  9035. /**
  9036. * Translate the bone in local or world space
  9037. * @param vec The amount to translate the bone
  9038. * @param space The space that the translation is in
  9039. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9040. */
  9041. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  9042. /**
  9043. * Set the postion of the bone in local or world space
  9044. * @param position The position to set the bone
  9045. * @param space The space that the position is in
  9046. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9047. */
  9048. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  9049. /**
  9050. * Set the absolute position of the bone (world space)
  9051. * @param position The position to set the bone
  9052. * @param mesh The mesh that this bone is attached to
  9053. */
  9054. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  9055. /**
  9056. * Scale the bone on the x, y and z axes (in local space)
  9057. * @param x The amount to scale the bone on the x axis
  9058. * @param y The amount to scale the bone on the y axis
  9059. * @param z The amount to scale the bone on the z axis
  9060. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  9061. */
  9062. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  9063. /**
  9064. * Set the bone scaling in local space
  9065. * @param scale defines the scaling vector
  9066. */
  9067. setScale(scale: Vector3): void;
  9068. /**
  9069. * Gets the current scaling in local space
  9070. * @returns the current scaling vector
  9071. */
  9072. getScale(): Vector3;
  9073. /**
  9074. * Gets the current scaling in local space and stores it in a target vector
  9075. * @param result defines the target vector
  9076. */
  9077. getScaleToRef(result: Vector3): void;
  9078. /**
  9079. * Set the yaw, pitch, and roll of the bone in local or world space
  9080. * @param yaw The rotation of the bone on the y axis
  9081. * @param pitch The rotation of the bone on the x axis
  9082. * @param roll The rotation of the bone on the z axis
  9083. * @param space The space that the axes of rotation are in
  9084. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9085. */
  9086. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  9087. /**
  9088. * Add a rotation to the bone on an axis in local or world space
  9089. * @param axis The axis to rotate the bone on
  9090. * @param amount The amount to rotate the bone
  9091. * @param space The space that the axis is in
  9092. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9093. */
  9094. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  9095. /**
  9096. * Set the rotation of the bone to a particular axis angle in local or world space
  9097. * @param axis The axis to rotate the bone on
  9098. * @param angle The angle that the bone should be rotated to
  9099. * @param space The space that the axis is in
  9100. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9101. */
  9102. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  9103. /**
  9104. * Set the euler rotation of the bone in local of world space
  9105. * @param rotation The euler rotation that the bone should be set to
  9106. * @param space The space that the rotation is in
  9107. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9108. */
  9109. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  9110. /**
  9111. * Set the quaternion rotation of the bone in local of world space
  9112. * @param quat The quaternion rotation that the bone should be set to
  9113. * @param space The space that the rotation is in
  9114. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9115. */
  9116. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  9117. /**
  9118. * Set the rotation matrix of the bone in local of world space
  9119. * @param rotMat The rotation matrix that the bone should be set to
  9120. * @param space The space that the rotation is in
  9121. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9122. */
  9123. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  9124. private _rotateWithMatrix;
  9125. private _getNegativeRotationToRef;
  9126. /**
  9127. * Get the position of the bone in local or world space
  9128. * @param space The space that the returned position is in
  9129. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9130. * @returns The position of the bone
  9131. */
  9132. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  9133. /**
  9134. * Copy the position of the bone to a vector3 in local or world space
  9135. * @param space The space that the returned position is in
  9136. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9137. * @param result The vector3 to copy the position to
  9138. */
  9139. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  9140. /**
  9141. * Get the absolute position of the bone (world space)
  9142. * @param mesh The mesh that this bone is attached to
  9143. * @returns The absolute position of the bone
  9144. */
  9145. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  9146. /**
  9147. * Copy the absolute position of the bone (world space) to the result param
  9148. * @param mesh The mesh that this bone is attached to
  9149. * @param result The vector3 to copy the absolute position to
  9150. */
  9151. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  9152. /**
  9153. * Compute the absolute transforms of this bone and its children
  9154. */
  9155. computeAbsoluteTransforms(): void;
  9156. /**
  9157. * Get the world direction from an axis that is in the local space of the bone
  9158. * @param localAxis The local direction that is used to compute the world direction
  9159. * @param mesh The mesh that this bone is attached to
  9160. * @returns The world direction
  9161. */
  9162. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  9163. /**
  9164. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  9165. * @param localAxis The local direction that is used to compute the world direction
  9166. * @param mesh The mesh that this bone is attached to
  9167. * @param result The vector3 that the world direction will be copied to
  9168. */
  9169. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  9170. /**
  9171. * Get the euler rotation of the bone in local or world space
  9172. * @param space The space that the rotation should be in
  9173. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9174. * @returns The euler rotation
  9175. */
  9176. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  9177. /**
  9178. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  9179. * @param space The space that the rotation should be in
  9180. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9181. * @param result The vector3 that the rotation should be copied to
  9182. */
  9183. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  9184. /**
  9185. * Get the quaternion rotation of the bone in either local or world space
  9186. * @param space The space that the rotation should be in
  9187. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9188. * @returns The quaternion rotation
  9189. */
  9190. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  9191. /**
  9192. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  9193. * @param space The space that the rotation should be in
  9194. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9195. * @param result The quaternion that the rotation should be copied to
  9196. */
  9197. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  9198. /**
  9199. * Get the rotation matrix of the bone in local or world space
  9200. * @param space The space that the rotation should be in
  9201. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9202. * @returns The rotation matrix
  9203. */
  9204. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  9205. /**
  9206. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  9207. * @param space The space that the rotation should be in
  9208. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9209. * @param result The quaternion that the rotation should be copied to
  9210. */
  9211. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  9212. /**
  9213. * Get the world position of a point that is in the local space of the bone
  9214. * @param position The local position
  9215. * @param mesh The mesh that this bone is attached to
  9216. * @returns The world position
  9217. */
  9218. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  9219. /**
  9220. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  9221. * @param position The local position
  9222. * @param mesh The mesh that this bone is attached to
  9223. * @param result The vector3 that the world position should be copied to
  9224. */
  9225. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  9226. /**
  9227. * Get the local position of a point that is in world space
  9228. * @param position The world position
  9229. * @param mesh The mesh that this bone is attached to
  9230. * @returns The local position
  9231. */
  9232. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  9233. /**
  9234. * Get the local position of a point that is in world space and copy it to the result param
  9235. * @param position The world position
  9236. * @param mesh The mesh that this bone is attached to
  9237. * @param result The vector3 that the local position should be copied to
  9238. */
  9239. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  9240. }
  9241. }
  9242. declare module BABYLON {
  9243. interface Engine {
  9244. /**
  9245. * Creates a raw texture
  9246. * @param data defines the data to store in the texture
  9247. * @param width defines the width of the texture
  9248. * @param height defines the height of the texture
  9249. * @param format defines the format of the data
  9250. * @param generateMipMaps defines if the engine should generate the mip levels
  9251. * @param invertY defines if data must be stored with Y axis inverted
  9252. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  9253. * @param compression defines the compression used (null by default)
  9254. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  9255. * @returns the raw texture inside an InternalTexture
  9256. */
  9257. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  9258. /**
  9259. * Update a raw texture
  9260. * @param texture defines the texture to update
  9261. * @param data defines the data to store in the texture
  9262. * @param format defines the format of the data
  9263. * @param invertY defines if data must be stored with Y axis inverted
  9264. */
  9265. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  9266. /**
  9267. * Update a raw texture
  9268. * @param texture defines the texture to update
  9269. * @param data defines the data to store in the texture
  9270. * @param format defines the format of the data
  9271. * @param invertY defines if data must be stored with Y axis inverted
  9272. * @param compression defines the compression used (null by default)
  9273. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  9274. */
  9275. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  9276. /**
  9277. * Creates a new raw cube texture
  9278. * @param data defines the array of data to use to create each face
  9279. * @param size defines the size of the textures
  9280. * @param format defines the format of the data
  9281. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  9282. * @param generateMipMaps defines if the engine should generate the mip levels
  9283. * @param invertY defines if data must be stored with Y axis inverted
  9284. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  9285. * @param compression defines the compression used (null by default)
  9286. * @returns the cube texture as an InternalTexture
  9287. */
  9288. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  9289. /**
  9290. * Update a raw cube texture
  9291. * @param texture defines the texture to udpdate
  9292. * @param data defines the data to store
  9293. * @param format defines the data format
  9294. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  9295. * @param invertY defines if data must be stored with Y axis inverted
  9296. */
  9297. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  9298. /**
  9299. * Update a raw cube texture
  9300. * @param texture defines the texture to udpdate
  9301. * @param data defines the data to store
  9302. * @param format defines the data format
  9303. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  9304. * @param invertY defines if data must be stored with Y axis inverted
  9305. * @param compression defines the compression used (null by default)
  9306. */
  9307. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  9308. /**
  9309. * Update a raw cube texture
  9310. * @param texture defines the texture to udpdate
  9311. * @param data defines the data to store
  9312. * @param format defines the data format
  9313. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  9314. * @param invertY defines if data must be stored with Y axis inverted
  9315. * @param compression defines the compression used (null by default)
  9316. * @param level defines which level of the texture to update
  9317. */
  9318. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  9319. /**
  9320. * Creates a new raw cube texture from a specified url
  9321. * @param url defines the url where the data is located
  9322. * @param scene defines the current scene
  9323. * @param size defines the size of the textures
  9324. * @param format defines the format of the data
  9325. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  9326. * @param noMipmap defines if the engine should avoid generating the mip levels
  9327. * @param callback defines a callback used to extract texture data from loaded data
  9328. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  9329. * @param onLoad defines a callback called when texture is loaded
  9330. * @param onError defines a callback called if there is an error
  9331. * @returns the cube texture as an InternalTexture
  9332. */
  9333. 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;
  9334. /**
  9335. * Creates a new raw cube texture from a specified url
  9336. * @param url defines the url where the data is located
  9337. * @param scene defines the current scene
  9338. * @param size defines the size of the textures
  9339. * @param format defines the format of the data
  9340. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  9341. * @param noMipmap defines if the engine should avoid generating the mip levels
  9342. * @param callback defines a callback used to extract texture data from loaded data
  9343. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  9344. * @param onLoad defines a callback called when texture is loaded
  9345. * @param onError defines a callback called if there is an error
  9346. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  9347. * @param invertY defines if data must be stored with Y axis inverted
  9348. * @returns the cube texture as an InternalTexture
  9349. */
  9350. 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;
  9351. /**
  9352. * Creates a new raw 3D texture
  9353. * @param data defines the data used to create the texture
  9354. * @param width defines the width of the texture
  9355. * @param height defines the height of the texture
  9356. * @param depth defines the depth of the texture
  9357. * @param format defines the format of the texture
  9358. * @param generateMipMaps defines if the engine must generate mip levels
  9359. * @param invertY defines if data must be stored with Y axis inverted
  9360. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  9361. * @param compression defines the compressed used (can be null)
  9362. * @param textureType defines the compressed used (can be null)
  9363. * @returns a new raw 3D texture (stored in an InternalTexture)
  9364. */
  9365. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  9366. /**
  9367. * Update a raw 3D texture
  9368. * @param texture defines the texture to update
  9369. * @param data defines the data to store
  9370. * @param format defines the data format
  9371. * @param invertY defines if data must be stored with Y axis inverted
  9372. */
  9373. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  9374. /**
  9375. * Update a raw 3D texture
  9376. * @param texture defines the texture to update
  9377. * @param data defines the data to store
  9378. * @param format defines the data format
  9379. * @param invertY defines if data must be stored with Y axis inverted
  9380. * @param compression defines the used compression (can be null)
  9381. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  9382. */
  9383. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  9384. }
  9385. }
  9386. declare module BABYLON {
  9387. /**
  9388. * Raw texture can help creating a texture directly from an array of data.
  9389. * This can be super useful if you either get the data from an uncompressed source or
  9390. * if you wish to create your texture pixel by pixel.
  9391. */
  9392. export class RawTexture extends Texture {
  9393. /**
  9394. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  9395. */
  9396. format: number;
  9397. private _engine;
  9398. /**
  9399. * Instantiates a new RawTexture.
  9400. * Raw texture can help creating a texture directly from an array of data.
  9401. * This can be super useful if you either get the data from an uncompressed source or
  9402. * if you wish to create your texture pixel by pixel.
  9403. * @param data define the array of data to use to create the texture
  9404. * @param width define the width of the texture
  9405. * @param height define the height of the texture
  9406. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  9407. * @param scene define the scene the texture belongs to
  9408. * @param generateMipMaps define whether mip maps should be generated or not
  9409. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  9410. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  9411. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  9412. */
  9413. constructor(data: ArrayBufferView, width: number, height: number,
  9414. /**
  9415. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  9416. */
  9417. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  9418. /**
  9419. * Updates the texture underlying data.
  9420. * @param data Define the new data of the texture
  9421. */
  9422. update(data: ArrayBufferView): void;
  9423. /**
  9424. * Creates a luminance texture from some data.
  9425. * @param data Define the texture data
  9426. * @param width Define the width of the texture
  9427. * @param height Define the height of the texture
  9428. * @param scene Define the scene the texture belongs to
  9429. * @param generateMipMaps Define whether or not to create mip maps for the texture
  9430. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  9431. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  9432. * @returns the luminance texture
  9433. */
  9434. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  9435. /**
  9436. * Creates a luminance alpha texture from some data.
  9437. * @param data Define the texture data
  9438. * @param width Define the width of the texture
  9439. * @param height Define the height of the texture
  9440. * @param scene Define the scene the texture belongs to
  9441. * @param generateMipMaps Define whether or not to create mip maps for the texture
  9442. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  9443. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  9444. * @returns the luminance alpha texture
  9445. */
  9446. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  9447. /**
  9448. * Creates an alpha texture from some data.
  9449. * @param data Define the texture data
  9450. * @param width Define the width of the texture
  9451. * @param height Define the height of the texture
  9452. * @param scene Define the scene the texture belongs to
  9453. * @param generateMipMaps Define whether or not to create mip maps for the texture
  9454. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  9455. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  9456. * @returns the alpha texture
  9457. */
  9458. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  9459. /**
  9460. * Creates a RGB texture from some data.
  9461. * @param data Define the texture data
  9462. * @param width Define the width of the texture
  9463. * @param height Define the height of the texture
  9464. * @param scene Define the scene the texture belongs to
  9465. * @param generateMipMaps Define whether or not to create mip maps for the texture
  9466. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  9467. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  9468. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  9469. * @returns the RGB alpha texture
  9470. */
  9471. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  9472. /**
  9473. * Creates a RGBA texture from some data.
  9474. * @param data Define the texture data
  9475. * @param width Define the width of the texture
  9476. * @param height Define the height of the texture
  9477. * @param scene Define the scene the texture belongs to
  9478. * @param generateMipMaps Define whether or not to create mip maps for the texture
  9479. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  9480. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  9481. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  9482. * @returns the RGBA texture
  9483. */
  9484. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  9485. /**
  9486. * Creates a R texture from some data.
  9487. * @param data Define the texture data
  9488. * @param width Define the width of the texture
  9489. * @param height Define the height of the texture
  9490. * @param scene Define the scene the texture belongs to
  9491. * @param generateMipMaps Define whether or not to create mip maps for the texture
  9492. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  9493. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  9494. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  9495. * @returns the R texture
  9496. */
  9497. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  9498. }
  9499. }
  9500. declare module BABYLON {
  9501. /**
  9502. * Defines a runtime animation
  9503. */
  9504. export class RuntimeAnimation {
  9505. private _events;
  9506. /**
  9507. * The current frame of the runtime animation
  9508. */
  9509. private _currentFrame;
  9510. /**
  9511. * The animation used by the runtime animation
  9512. */
  9513. private _animation;
  9514. /**
  9515. * The target of the runtime animation
  9516. */
  9517. private _target;
  9518. /**
  9519. * The initiating animatable
  9520. */
  9521. private _host;
  9522. /**
  9523. * The original value of the runtime animation
  9524. */
  9525. private _originalValue;
  9526. /**
  9527. * The original blend value of the runtime animation
  9528. */
  9529. private _originalBlendValue;
  9530. /**
  9531. * The offsets cache of the runtime animation
  9532. */
  9533. private _offsetsCache;
  9534. /**
  9535. * The high limits cache of the runtime animation
  9536. */
  9537. private _highLimitsCache;
  9538. /**
  9539. * Specifies if the runtime animation has been stopped
  9540. */
  9541. private _stopped;
  9542. /**
  9543. * The blending factor of the runtime animation
  9544. */
  9545. private _blendingFactor;
  9546. /**
  9547. * The BabylonJS scene
  9548. */
  9549. private _scene;
  9550. /**
  9551. * The current value of the runtime animation
  9552. */
  9553. private _currentValue;
  9554. /** @hidden */
  9555. _animationState: _IAnimationState;
  9556. /**
  9557. * The active target of the runtime animation
  9558. */
  9559. private _activeTargets;
  9560. private _currentActiveTarget;
  9561. private _directTarget;
  9562. /**
  9563. * The target path of the runtime animation
  9564. */
  9565. private _targetPath;
  9566. /**
  9567. * The weight of the runtime animation
  9568. */
  9569. private _weight;
  9570. /**
  9571. * The ratio offset of the runtime animation
  9572. */
  9573. private _ratioOffset;
  9574. /**
  9575. * The previous delay of the runtime animation
  9576. */
  9577. private _previousDelay;
  9578. /**
  9579. * The previous ratio of the runtime animation
  9580. */
  9581. private _previousRatio;
  9582. private _enableBlending;
  9583. private _keys;
  9584. private _minFrame;
  9585. private _maxFrame;
  9586. private _minValue;
  9587. private _maxValue;
  9588. private _targetIsArray;
  9589. /**
  9590. * Gets the current frame of the runtime animation
  9591. */
  9592. readonly currentFrame: number;
  9593. /**
  9594. * Gets the weight of the runtime animation
  9595. */
  9596. readonly weight: number;
  9597. /**
  9598. * Gets the current value of the runtime animation
  9599. */
  9600. readonly currentValue: any;
  9601. /**
  9602. * Gets the target path of the runtime animation
  9603. */
  9604. readonly targetPath: string;
  9605. /**
  9606. * Gets the actual target of the runtime animation
  9607. */
  9608. readonly target: any;
  9609. /** @hidden */
  9610. _onLoop: () => void;
  9611. /**
  9612. * Create a new RuntimeAnimation object
  9613. * @param target defines the target of the animation
  9614. * @param animation defines the source animation object
  9615. * @param scene defines the hosting scene
  9616. * @param host defines the initiating Animatable
  9617. */
  9618. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  9619. private _preparePath;
  9620. /**
  9621. * Gets the animation from the runtime animation
  9622. */
  9623. readonly animation: Animation;
  9624. /**
  9625. * Resets the runtime animation to the beginning
  9626. * @param restoreOriginal defines whether to restore the target property to the original value
  9627. */
  9628. reset(restoreOriginal?: boolean): void;
  9629. /**
  9630. * Specifies if the runtime animation is stopped
  9631. * @returns Boolean specifying if the runtime animation is stopped
  9632. */
  9633. isStopped(): boolean;
  9634. /**
  9635. * Disposes of the runtime animation
  9636. */
  9637. dispose(): void;
  9638. /**
  9639. * Apply the interpolated value to the target
  9640. * @param currentValue defines the value computed by the animation
  9641. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  9642. */
  9643. setValue(currentValue: any, weight: number): void;
  9644. private _getOriginalValues;
  9645. private _setValue;
  9646. /**
  9647. * Gets the loop pmode of the runtime animation
  9648. * @returns Loop Mode
  9649. */
  9650. private _getCorrectLoopMode;
  9651. /**
  9652. * Move the current animation to a given frame
  9653. * @param frame defines the frame to move to
  9654. */
  9655. goToFrame(frame: number): void;
  9656. /**
  9657. * @hidden Internal use only
  9658. */
  9659. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  9660. /**
  9661. * Execute the current animation
  9662. * @param delay defines the delay to add to the current frame
  9663. * @param from defines the lower bound of the animation range
  9664. * @param to defines the upper bound of the animation range
  9665. * @param loop defines if the current animation must loop
  9666. * @param speedRatio defines the current speed ratio
  9667. * @param weight defines the weight of the animation (default is -1 so no weight)
  9668. * @param onLoop optional callback called when animation loops
  9669. * @returns a boolean indicating if the animation is running
  9670. */
  9671. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  9672. }
  9673. }
  9674. declare module BABYLON {
  9675. /**
  9676. * Class used to store an actual running animation
  9677. */
  9678. export class Animatable {
  9679. /** defines the target object */
  9680. target: any;
  9681. /** defines the starting frame number (default is 0) */
  9682. fromFrame: number;
  9683. /** defines the ending frame number (default is 100) */
  9684. toFrame: number;
  9685. /** defines if the animation must loop (default is false) */
  9686. loopAnimation: boolean;
  9687. /** defines a callback to call when animation ends if it is not looping */
  9688. onAnimationEnd?: (() => void) | null | undefined;
  9689. /** defines a callback to call when animation loops */
  9690. onAnimationLoop?: (() => void) | null | undefined;
  9691. private _localDelayOffset;
  9692. private _pausedDelay;
  9693. private _runtimeAnimations;
  9694. private _paused;
  9695. private _scene;
  9696. private _speedRatio;
  9697. private _weight;
  9698. private _syncRoot;
  9699. /**
  9700. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  9701. * This will only apply for non looping animation (default is true)
  9702. */
  9703. disposeOnEnd: boolean;
  9704. /**
  9705. * Gets a boolean indicating if the animation has started
  9706. */
  9707. animationStarted: boolean;
  9708. /**
  9709. * Observer raised when the animation ends
  9710. */
  9711. onAnimationEndObservable: Observable<Animatable>;
  9712. /**
  9713. * Observer raised when the animation loops
  9714. */
  9715. onAnimationLoopObservable: Observable<Animatable>;
  9716. /**
  9717. * Gets the root Animatable used to synchronize and normalize animations
  9718. */
  9719. readonly syncRoot: Nullable<Animatable>;
  9720. /**
  9721. * Gets the current frame of the first RuntimeAnimation
  9722. * Used to synchronize Animatables
  9723. */
  9724. readonly masterFrame: number;
  9725. /**
  9726. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  9727. */
  9728. weight: number;
  9729. /**
  9730. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  9731. */
  9732. speedRatio: number;
  9733. /**
  9734. * Creates a new Animatable
  9735. * @param scene defines the hosting scene
  9736. * @param target defines the target object
  9737. * @param fromFrame defines the starting frame number (default is 0)
  9738. * @param toFrame defines the ending frame number (default is 100)
  9739. * @param loopAnimation defines if the animation must loop (default is false)
  9740. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  9741. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  9742. * @param animations defines a group of animation to add to the new Animatable
  9743. * @param onAnimationLoop defines a callback to call when animation loops
  9744. */
  9745. constructor(scene: Scene,
  9746. /** defines the target object */
  9747. target: any,
  9748. /** defines the starting frame number (default is 0) */
  9749. fromFrame?: number,
  9750. /** defines the ending frame number (default is 100) */
  9751. toFrame?: number,
  9752. /** defines if the animation must loop (default is false) */
  9753. loopAnimation?: boolean, speedRatio?: number,
  9754. /** defines a callback to call when animation ends if it is not looping */
  9755. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  9756. /** defines a callback to call when animation loops */
  9757. onAnimationLoop?: (() => void) | null | undefined);
  9758. /**
  9759. * Synchronize and normalize current Animatable with a source Animatable
  9760. * This is useful when using animation weights and when animations are not of the same length
  9761. * @param root defines the root Animatable to synchronize with
  9762. * @returns the current Animatable
  9763. */
  9764. syncWith(root: Animatable): Animatable;
  9765. /**
  9766. * Gets the list of runtime animations
  9767. * @returns an array of RuntimeAnimation
  9768. */
  9769. getAnimations(): RuntimeAnimation[];
  9770. /**
  9771. * Adds more animations to the current animatable
  9772. * @param target defines the target of the animations
  9773. * @param animations defines the new animations to add
  9774. */
  9775. appendAnimations(target: any, animations: Animation[]): void;
  9776. /**
  9777. * Gets the source animation for a specific property
  9778. * @param property defines the propertyu to look for
  9779. * @returns null or the source animation for the given property
  9780. */
  9781. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  9782. /**
  9783. * Gets the runtime animation for a specific property
  9784. * @param property defines the propertyu to look for
  9785. * @returns null or the runtime animation for the given property
  9786. */
  9787. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  9788. /**
  9789. * Resets the animatable to its original state
  9790. */
  9791. reset(): void;
  9792. /**
  9793. * Allows the animatable to blend with current running animations
  9794. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  9795. * @param blendingSpeed defines the blending speed to use
  9796. */
  9797. enableBlending(blendingSpeed: number): void;
  9798. /**
  9799. * Disable animation blending
  9800. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  9801. */
  9802. disableBlending(): void;
  9803. /**
  9804. * Jump directly to a given frame
  9805. * @param frame defines the frame to jump to
  9806. */
  9807. goToFrame(frame: number): void;
  9808. /**
  9809. * Pause the animation
  9810. */
  9811. pause(): void;
  9812. /**
  9813. * Restart the animation
  9814. */
  9815. restart(): void;
  9816. private _raiseOnAnimationEnd;
  9817. /**
  9818. * Stop and delete the current animation
  9819. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  9820. * @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)
  9821. */
  9822. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  9823. /**
  9824. * Wait asynchronously for the animation to end
  9825. * @returns a promise which will be fullfilled when the animation ends
  9826. */
  9827. waitAsync(): Promise<Animatable>;
  9828. /** @hidden */
  9829. _animate(delay: number): boolean;
  9830. }
  9831. interface Scene {
  9832. /** @hidden */
  9833. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  9834. /** @hidden */
  9835. _processLateAnimationBindingsForMatrices(holder: {
  9836. totalWeight: number;
  9837. animations: RuntimeAnimation[];
  9838. originalValue: Matrix;
  9839. }): any;
  9840. /** @hidden */
  9841. _processLateAnimationBindingsForQuaternions(holder: {
  9842. totalWeight: number;
  9843. animations: RuntimeAnimation[];
  9844. originalValue: Quaternion;
  9845. }, refQuaternion: Quaternion): Quaternion;
  9846. /** @hidden */
  9847. _processLateAnimationBindings(): void;
  9848. /**
  9849. * Will start the animation sequence of a given target
  9850. * @param target defines the target
  9851. * @param from defines from which frame should animation start
  9852. * @param to defines until which frame should animation run.
  9853. * @param weight defines the weight to apply to the animation (1.0 by default)
  9854. * @param loop defines if the animation loops
  9855. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  9856. * @param onAnimationEnd defines the function to be executed when the animation ends
  9857. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  9858. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  9859. * @param onAnimationLoop defines the callback to call when an animation loops
  9860. * @returns the animatable object created for this animation
  9861. */
  9862. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  9863. /**
  9864. * Will start the animation sequence of a given target
  9865. * @param target defines the target
  9866. * @param from defines from which frame should animation start
  9867. * @param to defines until which frame should animation run.
  9868. * @param loop defines if the animation loops
  9869. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  9870. * @param onAnimationEnd defines the function to be executed when the animation ends
  9871. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  9872. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  9873. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  9874. * @param onAnimationLoop defines the callback to call when an animation loops
  9875. * @returns the animatable object created for this animation
  9876. */
  9877. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  9878. /**
  9879. * Will start the animation sequence of a given target and its hierarchy
  9880. * @param target defines the target
  9881. * @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.
  9882. * @param from defines from which frame should animation start
  9883. * @param to defines until which frame should animation run.
  9884. * @param loop defines if the animation loops
  9885. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  9886. * @param onAnimationEnd defines the function to be executed when the animation ends
  9887. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  9888. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  9889. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  9890. * @param onAnimationLoop defines the callback to call when an animation loops
  9891. * @returns the list of created animatables
  9892. */
  9893. 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[];
  9894. /**
  9895. * Begin a new animation on a given node
  9896. * @param target defines the target where the animation will take place
  9897. * @param animations defines the list of animations to start
  9898. * @param from defines the initial value
  9899. * @param to defines the final value
  9900. * @param loop defines if you want animation to loop (off by default)
  9901. * @param speedRatio defines the speed ratio to apply to all animations
  9902. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  9903. * @param onAnimationLoop defines the callback to call when an animation loops
  9904. * @returns the list of created animatables
  9905. */
  9906. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  9907. /**
  9908. * Begin a new animation on a given node and its hierarchy
  9909. * @param target defines the root node where the animation will take place
  9910. * @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.
  9911. * @param animations defines the list of animations to start
  9912. * @param from defines the initial value
  9913. * @param to defines the final value
  9914. * @param loop defines if you want animation to loop (off by default)
  9915. * @param speedRatio defines the speed ratio to apply to all animations
  9916. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  9917. * @param onAnimationLoop defines the callback to call when an animation loops
  9918. * @returns the list of animatables created for all nodes
  9919. */
  9920. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  9921. /**
  9922. * Gets the animatable associated with a specific target
  9923. * @param target defines the target of the animatable
  9924. * @returns the required animatable if found
  9925. */
  9926. getAnimatableByTarget(target: any): Nullable<Animatable>;
  9927. /**
  9928. * Gets all animatables associated with a given target
  9929. * @param target defines the target to look animatables for
  9930. * @returns an array of Animatables
  9931. */
  9932. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  9933. /**
  9934. * Stops and removes all animations that have been applied to the scene
  9935. */
  9936. stopAllAnimations(): void;
  9937. }
  9938. interface Bone {
  9939. /**
  9940. * Copy an animation range from another bone
  9941. * @param source defines the source bone
  9942. * @param rangeName defines the range name to copy
  9943. * @param frameOffset defines the frame offset
  9944. * @param rescaleAsRequired defines if rescaling must be applied if required
  9945. * @param skelDimensionsRatio defines the scaling ratio
  9946. * @returns true if operation was successful
  9947. */
  9948. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  9949. }
  9950. }
  9951. declare module BABYLON {
  9952. /**
  9953. * Class used to handle skinning animations
  9954. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  9955. */
  9956. export class Skeleton implements IAnimatable {
  9957. /** defines the skeleton name */
  9958. name: string;
  9959. /** defines the skeleton Id */
  9960. id: string;
  9961. /**
  9962. * Defines the list of child bones
  9963. */
  9964. bones: Bone[];
  9965. /**
  9966. * Defines an estimate of the dimension of the skeleton at rest
  9967. */
  9968. dimensionsAtRest: Vector3;
  9969. /**
  9970. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  9971. */
  9972. needInitialSkinMatrix: boolean;
  9973. /**
  9974. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  9975. */
  9976. overrideMesh: Nullable<AbstractMesh>;
  9977. /**
  9978. * Gets the list of animations attached to this skeleton
  9979. */
  9980. animations: Array<Animation>;
  9981. private _scene;
  9982. private _isDirty;
  9983. private _transformMatrices;
  9984. private _transformMatrixTexture;
  9985. private _meshesWithPoseMatrix;
  9986. private _animatables;
  9987. private _identity;
  9988. private _synchronizedWithMesh;
  9989. private _ranges;
  9990. private _lastAbsoluteTransformsUpdateId;
  9991. private _canUseTextureForBones;
  9992. private _uniqueId;
  9993. /** @hidden */
  9994. _numBonesWithLinkedTransformNode: number;
  9995. /** @hidden */
  9996. _hasWaitingData: Nullable<boolean>;
  9997. /**
  9998. * Specifies if the skeleton should be serialized
  9999. */
  10000. doNotSerialize: boolean;
  10001. private _useTextureToStoreBoneMatrices;
  10002. /**
  10003. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  10004. * Please note that this option is not available when needInitialSkinMatrix === true or if the hardware does not support it
  10005. */
  10006. useTextureToStoreBoneMatrices: boolean;
  10007. private _animationPropertiesOverride;
  10008. /**
  10009. * Gets or sets the animation properties override
  10010. */
  10011. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  10012. /**
  10013. * List of inspectable custom properties (used by the Inspector)
  10014. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  10015. */
  10016. inspectableCustomProperties: IInspectable[];
  10017. /**
  10018. * An observable triggered before computing the skeleton's matrices
  10019. */
  10020. onBeforeComputeObservable: Observable<Skeleton>;
  10021. /**
  10022. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  10023. */
  10024. readonly isUsingTextureForMatrices: boolean;
  10025. /**
  10026. * Gets the unique ID of this skeleton
  10027. */
  10028. readonly uniqueId: number;
  10029. /**
  10030. * Creates a new skeleton
  10031. * @param name defines the skeleton name
  10032. * @param id defines the skeleton Id
  10033. * @param scene defines the hosting scene
  10034. */
  10035. constructor(
  10036. /** defines the skeleton name */
  10037. name: string,
  10038. /** defines the skeleton Id */
  10039. id: string, scene: Scene);
  10040. /**
  10041. * Gets the current object class name.
  10042. * @return the class name
  10043. */
  10044. getClassName(): string;
  10045. /**
  10046. * Returns an array containing the root bones
  10047. * @returns an array containing the root bones
  10048. */
  10049. getChildren(): Array<Bone>;
  10050. /**
  10051. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  10052. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  10053. * @returns a Float32Array containing matrices data
  10054. */
  10055. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  10056. /**
  10057. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  10058. * @returns a raw texture containing the data
  10059. */
  10060. getTransformMatrixTexture(): Nullable<RawTexture>;
  10061. /**
  10062. * Gets the current hosting scene
  10063. * @returns a scene object
  10064. */
  10065. getScene(): Scene;
  10066. /**
  10067. * Gets a string representing the current skeleton data
  10068. * @param fullDetails defines a boolean indicating if we want a verbose version
  10069. * @returns a string representing the current skeleton data
  10070. */
  10071. toString(fullDetails?: boolean): string;
  10072. /**
  10073. * Get bone's index searching by name
  10074. * @param name defines bone's name to search for
  10075. * @return the indice of the bone. Returns -1 if not found
  10076. */
  10077. getBoneIndexByName(name: string): number;
  10078. /**
  10079. * Creater a new animation range
  10080. * @param name defines the name of the range
  10081. * @param from defines the start key
  10082. * @param to defines the end key
  10083. */
  10084. createAnimationRange(name: string, from: number, to: number): void;
  10085. /**
  10086. * Delete a specific animation range
  10087. * @param name defines the name of the range
  10088. * @param deleteFrames defines if frames must be removed as well
  10089. */
  10090. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  10091. /**
  10092. * Gets a specific animation range
  10093. * @param name defines the name of the range to look for
  10094. * @returns the requested animation range or null if not found
  10095. */
  10096. getAnimationRange(name: string): Nullable<AnimationRange>;
  10097. /**
  10098. * Gets the list of all animation ranges defined on this skeleton
  10099. * @returns an array
  10100. */
  10101. getAnimationRanges(): Nullable<AnimationRange>[];
  10102. /**
  10103. * Copy animation range from a source skeleton.
  10104. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  10105. * @param source defines the source skeleton
  10106. * @param name defines the name of the range to copy
  10107. * @param rescaleAsRequired defines if rescaling must be applied if required
  10108. * @returns true if operation was successful
  10109. */
  10110. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  10111. /**
  10112. * Forces the skeleton to go to rest pose
  10113. */
  10114. returnToRest(): void;
  10115. private _getHighestAnimationFrame;
  10116. /**
  10117. * Begin a specific animation range
  10118. * @param name defines the name of the range to start
  10119. * @param loop defines if looping must be turned on (false by default)
  10120. * @param speedRatio defines the speed ratio to apply (1 by default)
  10121. * @param onAnimationEnd defines a callback which will be called when animation will end
  10122. * @returns a new animatable
  10123. */
  10124. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  10125. /** @hidden */
  10126. _markAsDirty(): void;
  10127. /** @hidden */
  10128. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  10129. /** @hidden */
  10130. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  10131. private _computeTransformMatrices;
  10132. /**
  10133. * Build all resources required to render a skeleton
  10134. */
  10135. prepare(): void;
  10136. /**
  10137. * Gets the list of animatables currently running for this skeleton
  10138. * @returns an array of animatables
  10139. */
  10140. getAnimatables(): IAnimatable[];
  10141. /**
  10142. * Clone the current skeleton
  10143. * @param name defines the name of the new skeleton
  10144. * @param id defines the id of the new skeleton
  10145. * @returns the new skeleton
  10146. */
  10147. clone(name: string, id: string): Skeleton;
  10148. /**
  10149. * Enable animation blending for this skeleton
  10150. * @param blendingSpeed defines the blending speed to apply
  10151. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  10152. */
  10153. enableBlending(blendingSpeed?: number): void;
  10154. /**
  10155. * Releases all resources associated with the current skeleton
  10156. */
  10157. dispose(): void;
  10158. /**
  10159. * Serialize the skeleton in a JSON object
  10160. * @returns a JSON object
  10161. */
  10162. serialize(): any;
  10163. /**
  10164. * Creates a new skeleton from serialized data
  10165. * @param parsedSkeleton defines the serialized data
  10166. * @param scene defines the hosting scene
  10167. * @returns a new skeleton
  10168. */
  10169. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  10170. /**
  10171. * Compute all node absolute transforms
  10172. * @param forceUpdate defines if computation must be done even if cache is up to date
  10173. */
  10174. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  10175. /**
  10176. * Gets the root pose matrix
  10177. * @returns a matrix
  10178. */
  10179. getPoseMatrix(): Nullable<Matrix>;
  10180. /**
  10181. * Sorts bones per internal index
  10182. */
  10183. sortBones(): void;
  10184. private _sortBones;
  10185. }
  10186. }
  10187. declare module BABYLON {
  10188. /**
  10189. * Defines a target to use with MorphTargetManager
  10190. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  10191. */
  10192. export class MorphTarget implements IAnimatable {
  10193. /** defines the name of the target */
  10194. name: string;
  10195. /**
  10196. * Gets or sets the list of animations
  10197. */
  10198. animations: Animation[];
  10199. private _scene;
  10200. private _positions;
  10201. private _normals;
  10202. private _tangents;
  10203. private _influence;
  10204. /**
  10205. * Observable raised when the influence changes
  10206. */
  10207. onInfluenceChanged: Observable<boolean>;
  10208. /** @hidden */
  10209. _onDataLayoutChanged: Observable<void>;
  10210. /**
  10211. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  10212. */
  10213. influence: number;
  10214. /**
  10215. * Gets or sets the id of the morph Target
  10216. */
  10217. id: string;
  10218. private _animationPropertiesOverride;
  10219. /**
  10220. * Gets or sets the animation properties override
  10221. */
  10222. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  10223. /**
  10224. * Creates a new MorphTarget
  10225. * @param name defines the name of the target
  10226. * @param influence defines the influence to use
  10227. * @param scene defines the scene the morphtarget belongs to
  10228. */
  10229. constructor(
  10230. /** defines the name of the target */
  10231. name: string, influence?: number, scene?: Nullable<Scene>);
  10232. /**
  10233. * Gets a boolean defining if the target contains position data
  10234. */
  10235. readonly hasPositions: boolean;
  10236. /**
  10237. * Gets a boolean defining if the target contains normal data
  10238. */
  10239. readonly hasNormals: boolean;
  10240. /**
  10241. * Gets a boolean defining if the target contains tangent data
  10242. */
  10243. readonly hasTangents: boolean;
  10244. /**
  10245. * Affects position data to this target
  10246. * @param data defines the position data to use
  10247. */
  10248. setPositions(data: Nullable<FloatArray>): void;
  10249. /**
  10250. * Gets the position data stored in this target
  10251. * @returns a FloatArray containing the position data (or null if not present)
  10252. */
  10253. getPositions(): Nullable<FloatArray>;
  10254. /**
  10255. * Affects normal data to this target
  10256. * @param data defines the normal data to use
  10257. */
  10258. setNormals(data: Nullable<FloatArray>): void;
  10259. /**
  10260. * Gets the normal data stored in this target
  10261. * @returns a FloatArray containing the normal data (or null if not present)
  10262. */
  10263. getNormals(): Nullable<FloatArray>;
  10264. /**
  10265. * Affects tangent data to this target
  10266. * @param data defines the tangent data to use
  10267. */
  10268. setTangents(data: Nullable<FloatArray>): void;
  10269. /**
  10270. * Gets the tangent data stored in this target
  10271. * @returns a FloatArray containing the tangent data (or null if not present)
  10272. */
  10273. getTangents(): Nullable<FloatArray>;
  10274. /**
  10275. * Serializes the current target into a Serialization object
  10276. * @returns the serialized object
  10277. */
  10278. serialize(): any;
  10279. /**
  10280. * Returns the string "MorphTarget"
  10281. * @returns "MorphTarget"
  10282. */
  10283. getClassName(): string;
  10284. /**
  10285. * Creates a new target from serialized data
  10286. * @param serializationObject defines the serialized data to use
  10287. * @returns a new MorphTarget
  10288. */
  10289. static Parse(serializationObject: any): MorphTarget;
  10290. /**
  10291. * Creates a MorphTarget from mesh data
  10292. * @param mesh defines the source mesh
  10293. * @param name defines the name to use for the new target
  10294. * @param influence defines the influence to attach to the target
  10295. * @returns a new MorphTarget
  10296. */
  10297. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  10298. }
  10299. }
  10300. declare module BABYLON {
  10301. /**
  10302. * This class is used to deform meshes using morphing between different targets
  10303. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  10304. */
  10305. export class MorphTargetManager {
  10306. private _targets;
  10307. private _targetInfluenceChangedObservers;
  10308. private _targetDataLayoutChangedObservers;
  10309. private _activeTargets;
  10310. private _scene;
  10311. private _influences;
  10312. private _supportsNormals;
  10313. private _supportsTangents;
  10314. private _vertexCount;
  10315. private _uniqueId;
  10316. private _tempInfluences;
  10317. /**
  10318. * Creates a new MorphTargetManager
  10319. * @param scene defines the current scene
  10320. */
  10321. constructor(scene?: Nullable<Scene>);
  10322. /**
  10323. * Gets the unique ID of this manager
  10324. */
  10325. readonly uniqueId: number;
  10326. /**
  10327. * Gets the number of vertices handled by this manager
  10328. */
  10329. readonly vertexCount: number;
  10330. /**
  10331. * Gets a boolean indicating if this manager supports morphing of normals
  10332. */
  10333. readonly supportsNormals: boolean;
  10334. /**
  10335. * Gets a boolean indicating if this manager supports morphing of tangents
  10336. */
  10337. readonly supportsTangents: boolean;
  10338. /**
  10339. * Gets the number of targets stored in this manager
  10340. */
  10341. readonly numTargets: number;
  10342. /**
  10343. * Gets the number of influencers (ie. the number of targets with influences > 0)
  10344. */
  10345. readonly numInfluencers: number;
  10346. /**
  10347. * Gets the list of influences (one per target)
  10348. */
  10349. readonly influences: Float32Array;
  10350. /**
  10351. * Gets the active target at specified index. An active target is a target with an influence > 0
  10352. * @param index defines the index to check
  10353. * @returns the requested target
  10354. */
  10355. getActiveTarget(index: number): MorphTarget;
  10356. /**
  10357. * Gets the target at specified index
  10358. * @param index defines the index to check
  10359. * @returns the requested target
  10360. */
  10361. getTarget(index: number): MorphTarget;
  10362. /**
  10363. * Add a new target to this manager
  10364. * @param target defines the target to add
  10365. */
  10366. addTarget(target: MorphTarget): void;
  10367. /**
  10368. * Removes a target from the manager
  10369. * @param target defines the target to remove
  10370. */
  10371. removeTarget(target: MorphTarget): void;
  10372. /**
  10373. * Serializes the current manager into a Serialization object
  10374. * @returns the serialized object
  10375. */
  10376. serialize(): any;
  10377. private _syncActiveTargets;
  10378. /**
  10379. * Syncrhonize the targets with all the meshes using this morph target manager
  10380. */
  10381. synchronize(): void;
  10382. /**
  10383. * Creates a new MorphTargetManager from serialized data
  10384. * @param serializationObject defines the serialized data
  10385. * @param scene defines the hosting scene
  10386. * @returns the new MorphTargetManager
  10387. */
  10388. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  10389. }
  10390. }
  10391. declare module BABYLON {
  10392. /**
  10393. * Groups all the scene component constants in one place to ease maintenance.
  10394. * @hidden
  10395. */
  10396. export class SceneComponentConstants {
  10397. static readonly NAME_EFFECTLAYER: string;
  10398. static readonly NAME_LAYER: string;
  10399. static readonly NAME_LENSFLARESYSTEM: string;
  10400. static readonly NAME_BOUNDINGBOXRENDERER: string;
  10401. static readonly NAME_PARTICLESYSTEM: string;
  10402. static readonly NAME_GAMEPAD: string;
  10403. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  10404. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  10405. static readonly NAME_DEPTHRENDERER: string;
  10406. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  10407. static readonly NAME_SPRITE: string;
  10408. static readonly NAME_OUTLINERENDERER: string;
  10409. static readonly NAME_PROCEDURALTEXTURE: string;
  10410. static readonly NAME_SHADOWGENERATOR: string;
  10411. static readonly NAME_OCTREE: string;
  10412. static readonly NAME_PHYSICSENGINE: string;
  10413. static readonly NAME_AUDIO: string;
  10414. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  10415. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10416. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  10417. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10418. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  10419. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  10420. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  10421. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  10422. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  10423. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  10424. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  10425. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  10426. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  10427. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  10428. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  10429. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  10430. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  10431. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  10432. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  10433. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  10434. static readonly STEP_AFTERRENDER_AUDIO: number;
  10435. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  10436. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  10437. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  10438. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  10439. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  10440. static readonly STEP_POINTERMOVE_SPRITE: number;
  10441. static readonly STEP_POINTERDOWN_SPRITE: number;
  10442. static readonly STEP_POINTERUP_SPRITE: number;
  10443. }
  10444. /**
  10445. * This represents a scene component.
  10446. *
  10447. * This is used to decouple the dependency the scene is having on the different workloads like
  10448. * layers, post processes...
  10449. */
  10450. export interface ISceneComponent {
  10451. /**
  10452. * The name of the component. Each component must have a unique name.
  10453. */
  10454. name: string;
  10455. /**
  10456. * The scene the component belongs to.
  10457. */
  10458. scene: Scene;
  10459. /**
  10460. * Register the component to one instance of a scene.
  10461. */
  10462. register(): void;
  10463. /**
  10464. * Rebuilds the elements related to this component in case of
  10465. * context lost for instance.
  10466. */
  10467. rebuild(): void;
  10468. /**
  10469. * Disposes the component and the associated ressources.
  10470. */
  10471. dispose(): void;
  10472. }
  10473. /**
  10474. * This represents a SERIALIZABLE scene component.
  10475. *
  10476. * This extends Scene Component to add Serialization methods on top.
  10477. */
  10478. export interface ISceneSerializableComponent extends ISceneComponent {
  10479. /**
  10480. * Adds all the elements from the container to the scene
  10481. * @param container the container holding the elements
  10482. */
  10483. addFromContainer(container: AbstractScene): void;
  10484. /**
  10485. * Removes all the elements in the container from the scene
  10486. * @param container contains the elements to remove
  10487. * @param dispose if the removed element should be disposed (default: false)
  10488. */
  10489. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  10490. /**
  10491. * Serializes the component data to the specified json object
  10492. * @param serializationObject The object to serialize to
  10493. */
  10494. serialize(serializationObject: any): void;
  10495. }
  10496. /**
  10497. * Strong typing of a Mesh related stage step action
  10498. */
  10499. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  10500. /**
  10501. * Strong typing of a Evaluate Sub Mesh related stage step action
  10502. */
  10503. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  10504. /**
  10505. * Strong typing of a Active Mesh related stage step action
  10506. */
  10507. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  10508. /**
  10509. * Strong typing of a Camera related stage step action
  10510. */
  10511. export type CameraStageAction = (camera: Camera) => void;
  10512. /**
  10513. * Strong typing of a Camera Frame buffer related stage step action
  10514. */
  10515. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  10516. /**
  10517. * Strong typing of a Render Target related stage step action
  10518. */
  10519. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  10520. /**
  10521. * Strong typing of a RenderingGroup related stage step action
  10522. */
  10523. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  10524. /**
  10525. * Strong typing of a Mesh Render related stage step action
  10526. */
  10527. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  10528. /**
  10529. * Strong typing of a simple stage step action
  10530. */
  10531. export type SimpleStageAction = () => void;
  10532. /**
  10533. * Strong typing of a render target action.
  10534. */
  10535. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  10536. /**
  10537. * Strong typing of a pointer move action.
  10538. */
  10539. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  10540. /**
  10541. * Strong typing of a pointer up/down action.
  10542. */
  10543. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  10544. /**
  10545. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  10546. * @hidden
  10547. */
  10548. export class Stage<T extends Function> extends Array<{
  10549. index: number;
  10550. component: ISceneComponent;
  10551. action: T;
  10552. }> {
  10553. /**
  10554. * Hide ctor from the rest of the world.
  10555. * @param items The items to add.
  10556. */
  10557. private constructor();
  10558. /**
  10559. * Creates a new Stage.
  10560. * @returns A new instance of a Stage
  10561. */
  10562. static Create<T extends Function>(): Stage<T>;
  10563. /**
  10564. * Registers a step in an ordered way in the targeted stage.
  10565. * @param index Defines the position to register the step in
  10566. * @param component Defines the component attached to the step
  10567. * @param action Defines the action to launch during the step
  10568. */
  10569. registerStep(index: number, component: ISceneComponent, action: T): void;
  10570. /**
  10571. * Clears all the steps from the stage.
  10572. */
  10573. clear(): void;
  10574. }
  10575. }
  10576. declare module BABYLON {
  10577. /**
  10578. * Class used to represent a specific level of detail of a mesh
  10579. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  10580. */
  10581. export class MeshLODLevel {
  10582. /** Defines the distance where this level should star being displayed */
  10583. distance: number;
  10584. /** Defines the mesh to use to render this level */
  10585. mesh: Nullable<Mesh>;
  10586. /**
  10587. * Creates a new LOD level
  10588. * @param distance defines the distance where this level should star being displayed
  10589. * @param mesh defines the mesh to use to render this level
  10590. */
  10591. constructor(
  10592. /** Defines the distance where this level should star being displayed */
  10593. distance: number,
  10594. /** Defines the mesh to use to render this level */
  10595. mesh: Nullable<Mesh>);
  10596. }
  10597. }
  10598. declare module BABYLON {
  10599. /**
  10600. * Interface describing all the common properties and methods a shadow light needs to implement.
  10601. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  10602. * as well as binding the different shadow properties to the effects.
  10603. */
  10604. export interface IShadowLight extends Light {
  10605. /**
  10606. * The light id in the scene (used in scene.findLighById for instance)
  10607. */
  10608. id: string;
  10609. /**
  10610. * The position the shdow will be casted from.
  10611. */
  10612. position: Vector3;
  10613. /**
  10614. * In 2d mode (needCube being false), the direction used to cast the shadow.
  10615. */
  10616. direction: Vector3;
  10617. /**
  10618. * The transformed position. Position of the light in world space taking parenting in account.
  10619. */
  10620. transformedPosition: Vector3;
  10621. /**
  10622. * The transformed direction. Direction of the light in world space taking parenting in account.
  10623. */
  10624. transformedDirection: Vector3;
  10625. /**
  10626. * The friendly name of the light in the scene.
  10627. */
  10628. name: string;
  10629. /**
  10630. * Defines the shadow projection clipping minimum z value.
  10631. */
  10632. shadowMinZ: number;
  10633. /**
  10634. * Defines the shadow projection clipping maximum z value.
  10635. */
  10636. shadowMaxZ: number;
  10637. /**
  10638. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  10639. * @returns true if the information has been computed, false if it does not need to (no parenting)
  10640. */
  10641. computeTransformedInformation(): boolean;
  10642. /**
  10643. * Gets the scene the light belongs to.
  10644. * @returns The scene
  10645. */
  10646. getScene(): Scene;
  10647. /**
  10648. * Callback defining a custom Projection Matrix Builder.
  10649. * This can be used to override the default projection matrix computation.
  10650. */
  10651. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  10652. /**
  10653. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  10654. * @param matrix The materix to updated with the projection information
  10655. * @param viewMatrix The transform matrix of the light
  10656. * @param renderList The list of mesh to render in the map
  10657. * @returns The current light
  10658. */
  10659. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  10660. /**
  10661. * Gets the current depth scale used in ESM.
  10662. * @returns The scale
  10663. */
  10664. getDepthScale(): number;
  10665. /**
  10666. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  10667. * @returns true if a cube texture needs to be use
  10668. */
  10669. needCube(): boolean;
  10670. /**
  10671. * Detects if the projection matrix requires to be recomputed this frame.
  10672. * @returns true if it requires to be recomputed otherwise, false.
  10673. */
  10674. needProjectionMatrixCompute(): boolean;
  10675. /**
  10676. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  10677. */
  10678. forceProjectionMatrixCompute(): void;
  10679. /**
  10680. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  10681. * @param faceIndex The index of the face we are computed the direction to generate shadow
  10682. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  10683. */
  10684. getShadowDirection(faceIndex?: number): Vector3;
  10685. /**
  10686. * Gets the minZ used for shadow according to both the scene and the light.
  10687. * @param activeCamera The camera we are returning the min for
  10688. * @returns the depth min z
  10689. */
  10690. getDepthMinZ(activeCamera: Camera): number;
  10691. /**
  10692. * Gets the maxZ used for shadow according to both the scene and the light.
  10693. * @param activeCamera The camera we are returning the max for
  10694. * @returns the depth max z
  10695. */
  10696. getDepthMaxZ(activeCamera: Camera): number;
  10697. }
  10698. /**
  10699. * Base implementation IShadowLight
  10700. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  10701. */
  10702. export abstract class ShadowLight extends Light implements IShadowLight {
  10703. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  10704. protected _position: Vector3;
  10705. protected _setPosition(value: Vector3): void;
  10706. /**
  10707. * Sets the position the shadow will be casted from. Also use as the light position for both
  10708. * point and spot lights.
  10709. */
  10710. /**
  10711. * Sets the position the shadow will be casted from. Also use as the light position for both
  10712. * point and spot lights.
  10713. */
  10714. position: Vector3;
  10715. protected _direction: Vector3;
  10716. protected _setDirection(value: Vector3): void;
  10717. /**
  10718. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  10719. * Also use as the light direction on spot and directional lights.
  10720. */
  10721. /**
  10722. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  10723. * Also use as the light direction on spot and directional lights.
  10724. */
  10725. direction: Vector3;
  10726. private _shadowMinZ;
  10727. /**
  10728. * Gets the shadow projection clipping minimum z value.
  10729. */
  10730. /**
  10731. * Sets the shadow projection clipping minimum z value.
  10732. */
  10733. shadowMinZ: number;
  10734. private _shadowMaxZ;
  10735. /**
  10736. * Sets the shadow projection clipping maximum z value.
  10737. */
  10738. /**
  10739. * Gets the shadow projection clipping maximum z value.
  10740. */
  10741. shadowMaxZ: number;
  10742. /**
  10743. * Callback defining a custom Projection Matrix Builder.
  10744. * This can be used to override the default projection matrix computation.
  10745. */
  10746. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  10747. /**
  10748. * The transformed position. Position of the light in world space taking parenting in account.
  10749. */
  10750. transformedPosition: Vector3;
  10751. /**
  10752. * The transformed direction. Direction of the light in world space taking parenting in account.
  10753. */
  10754. transformedDirection: Vector3;
  10755. private _needProjectionMatrixCompute;
  10756. /**
  10757. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  10758. * @returns true if the information has been computed, false if it does not need to (no parenting)
  10759. */
  10760. computeTransformedInformation(): boolean;
  10761. /**
  10762. * Return the depth scale used for the shadow map.
  10763. * @returns the depth scale.
  10764. */
  10765. getDepthScale(): number;
  10766. /**
  10767. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  10768. * @param faceIndex The index of the face we are computed the direction to generate shadow
  10769. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  10770. */
  10771. getShadowDirection(faceIndex?: number): Vector3;
  10772. /**
  10773. * Returns the ShadowLight absolute position in the World.
  10774. * @returns the position vector in world space
  10775. */
  10776. getAbsolutePosition(): Vector3;
  10777. /**
  10778. * Sets the ShadowLight direction toward the passed target.
  10779. * @param target The point to target in local space
  10780. * @returns the updated ShadowLight direction
  10781. */
  10782. setDirectionToTarget(target: Vector3): Vector3;
  10783. /**
  10784. * Returns the light rotation in euler definition.
  10785. * @returns the x y z rotation in local space.
  10786. */
  10787. getRotation(): Vector3;
  10788. /**
  10789. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  10790. * @returns true if a cube texture needs to be use
  10791. */
  10792. needCube(): boolean;
  10793. /**
  10794. * Detects if the projection matrix requires to be recomputed this frame.
  10795. * @returns true if it requires to be recomputed otherwise, false.
  10796. */
  10797. needProjectionMatrixCompute(): boolean;
  10798. /**
  10799. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  10800. */
  10801. forceProjectionMatrixCompute(): void;
  10802. /** @hidden */
  10803. _initCache(): void;
  10804. /** @hidden */
  10805. _isSynchronized(): boolean;
  10806. /**
  10807. * Computes the world matrix of the node
  10808. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  10809. * @returns the world matrix
  10810. */
  10811. computeWorldMatrix(force?: boolean): Matrix;
  10812. /**
  10813. * Gets the minZ used for shadow according to both the scene and the light.
  10814. * @param activeCamera The camera we are returning the min for
  10815. * @returns the depth min z
  10816. */
  10817. getDepthMinZ(activeCamera: Camera): number;
  10818. /**
  10819. * Gets the maxZ used for shadow according to both the scene and the light.
  10820. * @param activeCamera The camera we are returning the max for
  10821. * @returns the depth max z
  10822. */
  10823. getDepthMaxZ(activeCamera: Camera): number;
  10824. /**
  10825. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  10826. * @param matrix The materix to updated with the projection information
  10827. * @param viewMatrix The transform matrix of the light
  10828. * @param renderList The list of mesh to render in the map
  10829. * @returns The current light
  10830. */
  10831. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  10832. }
  10833. }
  10834. declare module BABYLON {
  10835. /**
  10836. * "Static Class" containing the most commonly used helper while dealing with material for
  10837. * rendering purpose.
  10838. *
  10839. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  10840. *
  10841. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  10842. */
  10843. export class MaterialHelper {
  10844. /**
  10845. * Bind the current view position to an effect.
  10846. * @param effect The effect to be bound
  10847. * @param scene The scene the eyes position is used from
  10848. */
  10849. static BindEyePosition(effect: Effect, scene: Scene): void;
  10850. /**
  10851. * Helps preparing the defines values about the UVs in used in the effect.
  10852. * UVs are shared as much as we can accross channels in the shaders.
  10853. * @param texture The texture we are preparing the UVs for
  10854. * @param defines The defines to update
  10855. * @param key The channel key "diffuse", "specular"... used in the shader
  10856. */
  10857. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  10858. /**
  10859. * Binds a texture matrix value to its corrsponding uniform
  10860. * @param texture The texture to bind the matrix for
  10861. * @param uniformBuffer The uniform buffer receivin the data
  10862. * @param key The channel key "diffuse", "specular"... used in the shader
  10863. */
  10864. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  10865. /**
  10866. * Gets the current status of the fog (should it be enabled?)
  10867. * @param mesh defines the mesh to evaluate for fog support
  10868. * @param scene defines the hosting scene
  10869. * @returns true if fog must be enabled
  10870. */
  10871. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  10872. /**
  10873. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  10874. * @param mesh defines the current mesh
  10875. * @param scene defines the current scene
  10876. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  10877. * @param pointsCloud defines if point cloud rendering has to be turned on
  10878. * @param fogEnabled defines if fog has to be turned on
  10879. * @param alphaTest defines if alpha testing has to be turned on
  10880. * @param defines defines the current list of defines
  10881. */
  10882. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  10883. /**
  10884. * Helper used to prepare the list of defines associated with frame values for shader compilation
  10885. * @param scene defines the current scene
  10886. * @param engine defines the current engine
  10887. * @param defines specifies the list of active defines
  10888. * @param useInstances defines if instances have to be turned on
  10889. * @param useClipPlane defines if clip plane have to be turned on
  10890. */
  10891. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  10892. /**
  10893. * Prepares the defines for bones
  10894. * @param mesh The mesh containing the geometry data we will draw
  10895. * @param defines The defines to update
  10896. */
  10897. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  10898. /**
  10899. * Prepares the defines for morph targets
  10900. * @param mesh The mesh containing the geometry data we will draw
  10901. * @param defines The defines to update
  10902. */
  10903. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  10904. /**
  10905. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  10906. * @param mesh The mesh containing the geometry data we will draw
  10907. * @param defines The defines to update
  10908. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  10909. * @param useBones Precise whether bones should be used or not (override mesh info)
  10910. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  10911. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  10912. * @returns false if defines are considered not dirty and have not been checked
  10913. */
  10914. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  10915. /**
  10916. * Prepares the defines related to multiview
  10917. * @param scene The scene we are intending to draw
  10918. * @param defines The defines to update
  10919. */
  10920. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  10921. /**
  10922. * Prepares the defines related to the light information passed in parameter
  10923. * @param scene The scene we are intending to draw
  10924. * @param mesh The mesh the effect is compiling for
  10925. * @param defines The defines to update
  10926. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  10927. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  10928. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  10929. * @returns true if normals will be required for the rest of the effect
  10930. */
  10931. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  10932. /**
  10933. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  10934. * that won t be acctive due to defines being turned off.
  10935. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  10936. * @param samplersList The samplers list
  10937. * @param defines The defines helping in the list generation
  10938. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  10939. */
  10940. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  10941. /**
  10942. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  10943. * @param defines The defines to update while falling back
  10944. * @param fallbacks The authorized effect fallbacks
  10945. * @param maxSimultaneousLights The maximum number of lights allowed
  10946. * @param rank the current rank of the Effect
  10947. * @returns The newly affected rank
  10948. */
  10949. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  10950. /**
  10951. * Prepares the list of attributes required for morph targets according to the effect defines.
  10952. * @param attribs The current list of supported attribs
  10953. * @param mesh The mesh to prepare the morph targets attributes for
  10954. * @param defines The current Defines of the effect
  10955. */
  10956. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  10957. /**
  10958. * Prepares the list of attributes required for bones according to the effect defines.
  10959. * @param attribs The current list of supported attribs
  10960. * @param mesh The mesh to prepare the bones attributes for
  10961. * @param defines The current Defines of the effect
  10962. * @param fallbacks The current efffect fallback strategy
  10963. */
  10964. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  10965. /**
  10966. * Check and prepare the list of attributes required for instances according to the effect defines.
  10967. * @param attribs The current list of supported attribs
  10968. * @param defines The current MaterialDefines of the effect
  10969. */
  10970. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  10971. /**
  10972. * Add the list of attributes required for instances to the attribs array.
  10973. * @param attribs The current list of supported attribs
  10974. */
  10975. static PushAttributesForInstances(attribs: string[]): void;
  10976. /**
  10977. * Binds the light shadow information to the effect for the given mesh.
  10978. * @param light The light containing the generator
  10979. * @param scene The scene the lights belongs to
  10980. * @param mesh The mesh we are binding the information to render
  10981. * @param lightIndex The light index in the effect used to render the mesh
  10982. * @param effect The effect we are binding the data to
  10983. */
  10984. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  10985. /**
  10986. * Binds the light information to the effect.
  10987. * @param light The light containing the generator
  10988. * @param effect The effect we are binding the data to
  10989. * @param lightIndex The light index in the effect used to render
  10990. */
  10991. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  10992. /**
  10993. * Binds the lights information from the scene to the effect for the given mesh.
  10994. * @param scene The scene the lights belongs to
  10995. * @param mesh The mesh we are binding the information to render
  10996. * @param effect The effect we are binding the data to
  10997. * @param defines The generated defines for the effect
  10998. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  10999. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  11000. */
  11001. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  11002. private static _tempFogColor;
  11003. /**
  11004. * Binds the fog information from the scene to the effect for the given mesh.
  11005. * @param scene The scene the lights belongs to
  11006. * @param mesh The mesh we are binding the information to render
  11007. * @param effect The effect we are binding the data to
  11008. * @param linearSpace Defines if the fog effect is applied in linear space
  11009. */
  11010. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  11011. /**
  11012. * Binds the bones information from the mesh to the effect.
  11013. * @param mesh The mesh we are binding the information to render
  11014. * @param effect The effect we are binding the data to
  11015. */
  11016. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  11017. /**
  11018. * Binds the morph targets information from the mesh to the effect.
  11019. * @param abstractMesh The mesh we are binding the information to render
  11020. * @param effect The effect we are binding the data to
  11021. */
  11022. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  11023. /**
  11024. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  11025. * @param defines The generated defines used in the effect
  11026. * @param effect The effect we are binding the data to
  11027. * @param scene The scene we are willing to render with logarithmic scale for
  11028. */
  11029. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  11030. /**
  11031. * Binds the clip plane information from the scene to the effect.
  11032. * @param scene The scene the clip plane information are extracted from
  11033. * @param effect The effect we are binding the data to
  11034. */
  11035. static BindClipPlane(effect: Effect, scene: Scene): void;
  11036. }
  11037. }
  11038. declare module BABYLON {
  11039. /** @hidden */
  11040. export var shadowMapPixelShader: {
  11041. name: string;
  11042. shader: string;
  11043. };
  11044. }
  11045. declare module BABYLON {
  11046. /** @hidden */
  11047. export var bonesDeclaration: {
  11048. name: string;
  11049. shader: string;
  11050. };
  11051. }
  11052. declare module BABYLON {
  11053. /** @hidden */
  11054. export var morphTargetsVertexGlobalDeclaration: {
  11055. name: string;
  11056. shader: string;
  11057. };
  11058. }
  11059. declare module BABYLON {
  11060. /** @hidden */
  11061. export var morphTargetsVertexDeclaration: {
  11062. name: string;
  11063. shader: string;
  11064. };
  11065. }
  11066. declare module BABYLON {
  11067. /** @hidden */
  11068. export var instancesDeclaration: {
  11069. name: string;
  11070. shader: string;
  11071. };
  11072. }
  11073. declare module BABYLON {
  11074. /** @hidden */
  11075. export var helperFunctions: {
  11076. name: string;
  11077. shader: string;
  11078. };
  11079. }
  11080. declare module BABYLON {
  11081. /** @hidden */
  11082. export var morphTargetsVertex: {
  11083. name: string;
  11084. shader: string;
  11085. };
  11086. }
  11087. declare module BABYLON {
  11088. /** @hidden */
  11089. export var instancesVertex: {
  11090. name: string;
  11091. shader: string;
  11092. };
  11093. }
  11094. declare module BABYLON {
  11095. /** @hidden */
  11096. export var bonesVertex: {
  11097. name: string;
  11098. shader: string;
  11099. };
  11100. }
  11101. declare module BABYLON {
  11102. /** @hidden */
  11103. export var shadowMapVertexShader: {
  11104. name: string;
  11105. shader: string;
  11106. };
  11107. }
  11108. declare module BABYLON {
  11109. /** @hidden */
  11110. export var depthBoxBlurPixelShader: {
  11111. name: string;
  11112. shader: string;
  11113. };
  11114. }
  11115. declare module BABYLON {
  11116. /**
  11117. * Defines the options associated with the creation of a custom shader for a shadow generator.
  11118. */
  11119. export interface ICustomShaderOptions {
  11120. /**
  11121. * Gets or sets the custom shader name to use
  11122. */
  11123. shaderName: string;
  11124. /**
  11125. * The list of attribute names used in the shader
  11126. */
  11127. attributes?: string[];
  11128. /**
  11129. * The list of unifrom names used in the shader
  11130. */
  11131. uniforms?: string[];
  11132. /**
  11133. * The list of sampler names used in the shader
  11134. */
  11135. samplers?: string[];
  11136. /**
  11137. * The list of defines used in the shader
  11138. */
  11139. defines?: string[];
  11140. }
  11141. /**
  11142. * Interface to implement to create a shadow generator compatible with BJS.
  11143. */
  11144. export interface IShadowGenerator {
  11145. /**
  11146. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  11147. * @returns The render target texture if present otherwise, null
  11148. */
  11149. getShadowMap(): Nullable<RenderTargetTexture>;
  11150. /**
  11151. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  11152. * @returns The render target texture if the shadow map is present otherwise, null
  11153. */
  11154. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  11155. /**
  11156. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  11157. * @param subMesh The submesh we want to render in the shadow map
  11158. * @param useInstances Defines wether will draw in the map using instances
  11159. * @returns true if ready otherwise, false
  11160. */
  11161. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  11162. /**
  11163. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  11164. * @param defines Defines of the material we want to update
  11165. * @param lightIndex Index of the light in the enabled light list of the material
  11166. */
  11167. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  11168. /**
  11169. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  11170. * defined in the generator but impacting the effect).
  11171. * It implies the unifroms available on the materials are the standard BJS ones.
  11172. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  11173. * @param effect The effect we are binfing the information for
  11174. */
  11175. bindShadowLight(lightIndex: string, effect: Effect): void;
  11176. /**
  11177. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  11178. * (eq to shadow prjection matrix * light transform matrix)
  11179. * @returns The transform matrix used to create the shadow map
  11180. */
  11181. getTransformMatrix(): Matrix;
  11182. /**
  11183. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  11184. * Cube and 2D textures for instance.
  11185. */
  11186. recreateShadowMap(): void;
  11187. /**
  11188. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  11189. * @param onCompiled Callback triggered at the and of the effects compilation
  11190. * @param options Sets of optional options forcing the compilation with different modes
  11191. */
  11192. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  11193. useInstances: boolean;
  11194. }>): void;
  11195. /**
  11196. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  11197. * @param options Sets of optional options forcing the compilation with different modes
  11198. * @returns A promise that resolves when the compilation completes
  11199. */
  11200. forceCompilationAsync(options?: Partial<{
  11201. useInstances: boolean;
  11202. }>): Promise<void>;
  11203. /**
  11204. * Serializes the shadow generator setup to a json object.
  11205. * @returns The serialized JSON object
  11206. */
  11207. serialize(): any;
  11208. /**
  11209. * Disposes the Shadow map and related Textures and effects.
  11210. */
  11211. dispose(): void;
  11212. }
  11213. /**
  11214. * Default implementation IShadowGenerator.
  11215. * This is the main object responsible of generating shadows in the framework.
  11216. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  11217. */
  11218. export class ShadowGenerator implements IShadowGenerator {
  11219. /**
  11220. * Shadow generator mode None: no filtering applied.
  11221. */
  11222. static readonly FILTER_NONE: number;
  11223. /**
  11224. * Shadow generator mode ESM: Exponential Shadow Mapping.
  11225. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  11226. */
  11227. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  11228. /**
  11229. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  11230. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  11231. */
  11232. static readonly FILTER_POISSONSAMPLING: number;
  11233. /**
  11234. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  11235. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  11236. */
  11237. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  11238. /**
  11239. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  11240. * edge artifacts on steep falloff.
  11241. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  11242. */
  11243. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  11244. /**
  11245. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  11246. * edge artifacts on steep falloff.
  11247. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  11248. */
  11249. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  11250. /**
  11251. * Shadow generator mode PCF: Percentage Closer Filtering
  11252. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  11253. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  11254. */
  11255. static readonly FILTER_PCF: number;
  11256. /**
  11257. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  11258. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  11259. * Contact Hardening
  11260. */
  11261. static readonly FILTER_PCSS: number;
  11262. /**
  11263. * Reserved for PCF and PCSS
  11264. * Highest Quality.
  11265. *
  11266. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  11267. *
  11268. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  11269. */
  11270. static readonly QUALITY_HIGH: number;
  11271. /**
  11272. * Reserved for PCF and PCSS
  11273. * Good tradeoff for quality/perf cross devices
  11274. *
  11275. * Execute PCF on a 3*3 kernel.
  11276. *
  11277. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  11278. */
  11279. static readonly QUALITY_MEDIUM: number;
  11280. /**
  11281. * Reserved for PCF and PCSS
  11282. * The lowest quality but the fastest.
  11283. *
  11284. * Execute PCF on a 1*1 kernel.
  11285. *
  11286. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  11287. */
  11288. static readonly QUALITY_LOW: number;
  11289. /** Gets or sets the custom shader name to use */
  11290. customShaderOptions: ICustomShaderOptions;
  11291. /**
  11292. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  11293. */
  11294. onBeforeShadowMapRenderObservable: Observable<Effect>;
  11295. /**
  11296. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  11297. */
  11298. onAfterShadowMapRenderObservable: Observable<Effect>;
  11299. /**
  11300. * Observable triggered before a mesh is rendered in the shadow map.
  11301. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  11302. */
  11303. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  11304. /**
  11305. * Observable triggered after a mesh is rendered in the shadow map.
  11306. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  11307. */
  11308. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  11309. private _bias;
  11310. /**
  11311. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  11312. */
  11313. /**
  11314. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  11315. */
  11316. bias: number;
  11317. private _normalBias;
  11318. /**
  11319. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  11320. */
  11321. /**
  11322. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  11323. */
  11324. normalBias: number;
  11325. private _blurBoxOffset;
  11326. /**
  11327. * Gets the blur box offset: offset applied during the blur pass.
  11328. * Only useful if useKernelBlur = false
  11329. */
  11330. /**
  11331. * Sets the blur box offset: offset applied during the blur pass.
  11332. * Only useful if useKernelBlur = false
  11333. */
  11334. blurBoxOffset: number;
  11335. private _blurScale;
  11336. /**
  11337. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  11338. * 2 means half of the size.
  11339. */
  11340. /**
  11341. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  11342. * 2 means half of the size.
  11343. */
  11344. blurScale: number;
  11345. private _blurKernel;
  11346. /**
  11347. * Gets the blur kernel: kernel size of the blur pass.
  11348. * Only useful if useKernelBlur = true
  11349. */
  11350. /**
  11351. * Sets the blur kernel: kernel size of the blur pass.
  11352. * Only useful if useKernelBlur = true
  11353. */
  11354. blurKernel: number;
  11355. private _useKernelBlur;
  11356. /**
  11357. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  11358. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  11359. */
  11360. /**
  11361. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  11362. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  11363. */
  11364. useKernelBlur: boolean;
  11365. private _depthScale;
  11366. /**
  11367. * Gets the depth scale used in ESM mode.
  11368. */
  11369. /**
  11370. * Sets the depth scale used in ESM mode.
  11371. * This can override the scale stored on the light.
  11372. */
  11373. depthScale: number;
  11374. private _filter;
  11375. /**
  11376. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  11377. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  11378. */
  11379. /**
  11380. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  11381. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  11382. */
  11383. filter: number;
  11384. /**
  11385. * Gets if the current filter is set to Poisson Sampling.
  11386. */
  11387. /**
  11388. * Sets the current filter to Poisson Sampling.
  11389. */
  11390. usePoissonSampling: boolean;
  11391. /**
  11392. * Gets if the current filter is set to ESM.
  11393. */
  11394. /**
  11395. * Sets the current filter is to ESM.
  11396. */
  11397. useExponentialShadowMap: boolean;
  11398. /**
  11399. * Gets if the current filter is set to filtered ESM.
  11400. */
  11401. /**
  11402. * Gets if the current filter is set to filtered ESM.
  11403. */
  11404. useBlurExponentialShadowMap: boolean;
  11405. /**
  11406. * Gets if the current filter is set to "close ESM" (using the inverse of the
  11407. * exponential to prevent steep falloff artifacts).
  11408. */
  11409. /**
  11410. * Sets the current filter to "close ESM" (using the inverse of the
  11411. * exponential to prevent steep falloff artifacts).
  11412. */
  11413. useCloseExponentialShadowMap: boolean;
  11414. /**
  11415. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  11416. * exponential to prevent steep falloff artifacts).
  11417. */
  11418. /**
  11419. * Sets the current filter to filtered "close ESM" (using the inverse of the
  11420. * exponential to prevent steep falloff artifacts).
  11421. */
  11422. useBlurCloseExponentialShadowMap: boolean;
  11423. /**
  11424. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  11425. */
  11426. /**
  11427. * Sets the current filter to "PCF" (percentage closer filtering).
  11428. */
  11429. usePercentageCloserFiltering: boolean;
  11430. private _filteringQuality;
  11431. /**
  11432. * Gets the PCF or PCSS Quality.
  11433. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  11434. */
  11435. /**
  11436. * Sets the PCF or PCSS Quality.
  11437. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  11438. */
  11439. filteringQuality: number;
  11440. /**
  11441. * Gets if the current filter is set to "PCSS" (contact hardening).
  11442. */
  11443. /**
  11444. * Sets the current filter to "PCSS" (contact hardening).
  11445. */
  11446. useContactHardeningShadow: boolean;
  11447. private _contactHardeningLightSizeUVRatio;
  11448. /**
  11449. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  11450. * Using a ratio helps keeping shape stability independently of the map size.
  11451. *
  11452. * It does not account for the light projection as it was having too much
  11453. * instability during the light setup or during light position changes.
  11454. *
  11455. * Only valid if useContactHardeningShadow is true.
  11456. */
  11457. /**
  11458. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  11459. * Using a ratio helps keeping shape stability independently of the map size.
  11460. *
  11461. * It does not account for the light projection as it was having too much
  11462. * instability during the light setup or during light position changes.
  11463. *
  11464. * Only valid if useContactHardeningShadow is true.
  11465. */
  11466. contactHardeningLightSizeUVRatio: number;
  11467. private _darkness;
  11468. /** Gets or sets the actual darkness of a shadow */
  11469. darkness: number;
  11470. /**
  11471. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  11472. * 0 means strongest and 1 would means no shadow.
  11473. * @returns the darkness.
  11474. */
  11475. getDarkness(): number;
  11476. /**
  11477. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  11478. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  11479. * @returns the shadow generator allowing fluent coding.
  11480. */
  11481. setDarkness(darkness: number): ShadowGenerator;
  11482. private _transparencyShadow;
  11483. /** Gets or sets the ability to have transparent shadow */
  11484. transparencyShadow: boolean;
  11485. /**
  11486. * Sets the ability to have transparent shadow (boolean).
  11487. * @param transparent True if transparent else False
  11488. * @returns the shadow generator allowing fluent coding
  11489. */
  11490. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  11491. private _shadowMap;
  11492. private _shadowMap2;
  11493. /**
  11494. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  11495. * @returns The render target texture if present otherwise, null
  11496. */
  11497. getShadowMap(): Nullable<RenderTargetTexture>;
  11498. /**
  11499. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  11500. * @returns The render target texture if the shadow map is present otherwise, null
  11501. */
  11502. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  11503. /**
  11504. * Gets the class name of that object
  11505. * @returns "ShadowGenerator"
  11506. */
  11507. getClassName(): string;
  11508. /**
  11509. * Helper function to add a mesh and its descendants to the list of shadow casters.
  11510. * @param mesh Mesh to add
  11511. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  11512. * @returns the Shadow Generator itself
  11513. */
  11514. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  11515. /**
  11516. * Helper function to remove a mesh and its descendants from the list of shadow casters
  11517. * @param mesh Mesh to remove
  11518. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  11519. * @returns the Shadow Generator itself
  11520. */
  11521. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  11522. /**
  11523. * Controls the extent to which the shadows fade out at the edge of the frustum
  11524. * Used only by directionals and spots
  11525. */
  11526. frustumEdgeFalloff: number;
  11527. private _light;
  11528. /**
  11529. * Returns the associated light object.
  11530. * @returns the light generating the shadow
  11531. */
  11532. getLight(): IShadowLight;
  11533. /**
  11534. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  11535. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  11536. * It might on the other hand introduce peter panning.
  11537. */
  11538. forceBackFacesOnly: boolean;
  11539. private _scene;
  11540. private _lightDirection;
  11541. private _effect;
  11542. private _viewMatrix;
  11543. private _projectionMatrix;
  11544. private _transformMatrix;
  11545. private _cachedPosition;
  11546. private _cachedDirection;
  11547. private _cachedDefines;
  11548. private _currentRenderID;
  11549. private _boxBlurPostprocess;
  11550. private _kernelBlurXPostprocess;
  11551. private _kernelBlurYPostprocess;
  11552. private _blurPostProcesses;
  11553. private _mapSize;
  11554. private _currentFaceIndex;
  11555. private _currentFaceIndexCache;
  11556. private _textureType;
  11557. private _defaultTextureMatrix;
  11558. /** @hidden */
  11559. static _SceneComponentInitialization: (scene: Scene) => void;
  11560. /**
  11561. * Creates a ShadowGenerator object.
  11562. * A ShadowGenerator is the required tool to use the shadows.
  11563. * Each light casting shadows needs to use its own ShadowGenerator.
  11564. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  11565. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  11566. * @param light The light object generating the shadows.
  11567. * @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.
  11568. */
  11569. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  11570. private _initializeGenerator;
  11571. private _initializeShadowMap;
  11572. private _initializeBlurRTTAndPostProcesses;
  11573. private _renderForShadowMap;
  11574. private _renderSubMeshForShadowMap;
  11575. private _applyFilterValues;
  11576. /**
  11577. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  11578. * @param onCompiled Callback triggered at the and of the effects compilation
  11579. * @param options Sets of optional options forcing the compilation with different modes
  11580. */
  11581. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  11582. useInstances: boolean;
  11583. }>): void;
  11584. /**
  11585. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  11586. * @param options Sets of optional options forcing the compilation with different modes
  11587. * @returns A promise that resolves when the compilation completes
  11588. */
  11589. forceCompilationAsync(options?: Partial<{
  11590. useInstances: boolean;
  11591. }>): Promise<void>;
  11592. /**
  11593. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  11594. * @param subMesh The submesh we want to render in the shadow map
  11595. * @param useInstances Defines wether will draw in the map using instances
  11596. * @returns true if ready otherwise, false
  11597. */
  11598. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  11599. /**
  11600. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  11601. * @param defines Defines of the material we want to update
  11602. * @param lightIndex Index of the light in the enabled light list of the material
  11603. */
  11604. prepareDefines(defines: any, lightIndex: number): void;
  11605. /**
  11606. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  11607. * defined in the generator but impacting the effect).
  11608. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  11609. * @param effect The effect we are binfing the information for
  11610. */
  11611. bindShadowLight(lightIndex: string, effect: Effect): void;
  11612. /**
  11613. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  11614. * (eq to shadow prjection matrix * light transform matrix)
  11615. * @returns The transform matrix used to create the shadow map
  11616. */
  11617. getTransformMatrix(): Matrix;
  11618. /**
  11619. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  11620. * Cube and 2D textures for instance.
  11621. */
  11622. recreateShadowMap(): void;
  11623. private _disposeBlurPostProcesses;
  11624. private _disposeRTTandPostProcesses;
  11625. /**
  11626. * Disposes the ShadowGenerator.
  11627. * Returns nothing.
  11628. */
  11629. dispose(): void;
  11630. /**
  11631. * Serializes the shadow generator setup to a json object.
  11632. * @returns The serialized JSON object
  11633. */
  11634. serialize(): any;
  11635. /**
  11636. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  11637. * @param parsedShadowGenerator The JSON object to parse
  11638. * @param scene The scene to create the shadow map for
  11639. * @returns The parsed shadow generator
  11640. */
  11641. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  11642. }
  11643. }
  11644. declare module BABYLON {
  11645. /**
  11646. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  11647. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  11648. * 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.
  11649. */
  11650. export abstract class Light extends Node {
  11651. /**
  11652. * Falloff Default: light is falling off following the material specification:
  11653. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  11654. */
  11655. static readonly FALLOFF_DEFAULT: number;
  11656. /**
  11657. * Falloff Physical: light is falling off following the inverse squared distance law.
  11658. */
  11659. static readonly FALLOFF_PHYSICAL: number;
  11660. /**
  11661. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  11662. * to enhance interoperability with other engines.
  11663. */
  11664. static readonly FALLOFF_GLTF: number;
  11665. /**
  11666. * Falloff Standard: light is falling off like in the standard material
  11667. * to enhance interoperability with other materials.
  11668. */
  11669. static readonly FALLOFF_STANDARD: number;
  11670. /**
  11671. * If every light affecting the material is in this lightmapMode,
  11672. * material.lightmapTexture adds or multiplies
  11673. * (depends on material.useLightmapAsShadowmap)
  11674. * after every other light calculations.
  11675. */
  11676. static readonly LIGHTMAP_DEFAULT: number;
  11677. /**
  11678. * material.lightmapTexture as only diffuse lighting from this light
  11679. * adds only specular lighting from this light
  11680. * adds dynamic shadows
  11681. */
  11682. static readonly LIGHTMAP_SPECULAR: number;
  11683. /**
  11684. * material.lightmapTexture as only lighting
  11685. * no light calculation from this light
  11686. * only adds dynamic shadows from this light
  11687. */
  11688. static readonly LIGHTMAP_SHADOWSONLY: number;
  11689. /**
  11690. * Each light type uses the default quantity according to its type:
  11691. * point/spot lights use luminous intensity
  11692. * directional lights use illuminance
  11693. */
  11694. static readonly INTENSITYMODE_AUTOMATIC: number;
  11695. /**
  11696. * lumen (lm)
  11697. */
  11698. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  11699. /**
  11700. * candela (lm/sr)
  11701. */
  11702. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  11703. /**
  11704. * lux (lm/m^2)
  11705. */
  11706. static readonly INTENSITYMODE_ILLUMINANCE: number;
  11707. /**
  11708. * nit (cd/m^2)
  11709. */
  11710. static readonly INTENSITYMODE_LUMINANCE: number;
  11711. /**
  11712. * Light type const id of the point light.
  11713. */
  11714. static readonly LIGHTTYPEID_POINTLIGHT: number;
  11715. /**
  11716. * Light type const id of the directional light.
  11717. */
  11718. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  11719. /**
  11720. * Light type const id of the spot light.
  11721. */
  11722. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  11723. /**
  11724. * Light type const id of the hemispheric light.
  11725. */
  11726. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  11727. /**
  11728. * Diffuse gives the basic color to an object.
  11729. */
  11730. diffuse: Color3;
  11731. /**
  11732. * Specular produces a highlight color on an object.
  11733. * Note: This is note affecting PBR materials.
  11734. */
  11735. specular: Color3;
  11736. /**
  11737. * Defines the falloff type for this light. This lets overrriding how punctual light are
  11738. * falling off base on range or angle.
  11739. * This can be set to any values in Light.FALLOFF_x.
  11740. *
  11741. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  11742. * other types of materials.
  11743. */
  11744. falloffType: number;
  11745. /**
  11746. * Strength of the light.
  11747. * Note: By default it is define in the framework own unit.
  11748. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  11749. */
  11750. intensity: number;
  11751. private _range;
  11752. protected _inverseSquaredRange: number;
  11753. /**
  11754. * Defines how far from the source the light is impacting in scene units.
  11755. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  11756. */
  11757. /**
  11758. * Defines how far from the source the light is impacting in scene units.
  11759. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  11760. */
  11761. range: number;
  11762. /**
  11763. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  11764. * of light.
  11765. */
  11766. private _photometricScale;
  11767. private _intensityMode;
  11768. /**
  11769. * Gets the photometric scale used to interpret the intensity.
  11770. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  11771. */
  11772. /**
  11773. * Sets the photometric scale used to interpret the intensity.
  11774. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  11775. */
  11776. intensityMode: number;
  11777. private _radius;
  11778. /**
  11779. * Gets the light radius used by PBR Materials to simulate soft area lights.
  11780. */
  11781. /**
  11782. * sets the light radius used by PBR Materials to simulate soft area lights.
  11783. */
  11784. radius: number;
  11785. private _renderPriority;
  11786. /**
  11787. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  11788. * exceeding the number allowed of the materials.
  11789. */
  11790. renderPriority: number;
  11791. private _shadowEnabled;
  11792. /**
  11793. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  11794. * the current shadow generator.
  11795. */
  11796. /**
  11797. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  11798. * the current shadow generator.
  11799. */
  11800. shadowEnabled: boolean;
  11801. private _includedOnlyMeshes;
  11802. /**
  11803. * Gets the only meshes impacted by this light.
  11804. */
  11805. /**
  11806. * Sets the only meshes impacted by this light.
  11807. */
  11808. includedOnlyMeshes: AbstractMesh[];
  11809. private _excludedMeshes;
  11810. /**
  11811. * Gets the meshes not impacted by this light.
  11812. */
  11813. /**
  11814. * Sets the meshes not impacted by this light.
  11815. */
  11816. excludedMeshes: AbstractMesh[];
  11817. private _excludeWithLayerMask;
  11818. /**
  11819. * Gets the layer id use to find what meshes are not impacted by the light.
  11820. * Inactive if 0
  11821. */
  11822. /**
  11823. * Sets the layer id use to find what meshes are not impacted by the light.
  11824. * Inactive if 0
  11825. */
  11826. excludeWithLayerMask: number;
  11827. private _includeOnlyWithLayerMask;
  11828. /**
  11829. * Gets the layer id use to find what meshes are impacted by the light.
  11830. * Inactive if 0
  11831. */
  11832. /**
  11833. * Sets the layer id use to find what meshes are impacted by the light.
  11834. * Inactive if 0
  11835. */
  11836. includeOnlyWithLayerMask: number;
  11837. private _lightmapMode;
  11838. /**
  11839. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  11840. */
  11841. /**
  11842. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  11843. */
  11844. lightmapMode: number;
  11845. /**
  11846. * Shadow generator associted to the light.
  11847. * @hidden Internal use only.
  11848. */
  11849. _shadowGenerator: Nullable<IShadowGenerator>;
  11850. /**
  11851. * @hidden Internal use only.
  11852. */
  11853. _excludedMeshesIds: string[];
  11854. /**
  11855. * @hidden Internal use only.
  11856. */
  11857. _includedOnlyMeshesIds: string[];
  11858. /**
  11859. * The current light unifom buffer.
  11860. * @hidden Internal use only.
  11861. */
  11862. _uniformBuffer: UniformBuffer;
  11863. /**
  11864. * Creates a Light object in the scene.
  11865. * Documentation : https://doc.babylonjs.com/babylon101/lights
  11866. * @param name The firendly name of the light
  11867. * @param scene The scene the light belongs too
  11868. */
  11869. constructor(name: string, scene: Scene);
  11870. protected abstract _buildUniformLayout(): void;
  11871. /**
  11872. * Sets the passed Effect "effect" with the Light information.
  11873. * @param effect The effect to update
  11874. * @param lightIndex The index of the light in the effect to update
  11875. * @returns The light
  11876. */
  11877. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  11878. /**
  11879. * Returns the string "Light".
  11880. * @returns the class name
  11881. */
  11882. getClassName(): string;
  11883. /** @hidden */
  11884. readonly _isLight: boolean;
  11885. /**
  11886. * Converts the light information to a readable string for debug purpose.
  11887. * @param fullDetails Supports for multiple levels of logging within scene loading
  11888. * @returns the human readable light info
  11889. */
  11890. toString(fullDetails?: boolean): string;
  11891. /** @hidden */
  11892. protected _syncParentEnabledState(): void;
  11893. /**
  11894. * Set the enabled state of this node.
  11895. * @param value - the new enabled state
  11896. */
  11897. setEnabled(value: boolean): void;
  11898. /**
  11899. * Returns the Light associated shadow generator if any.
  11900. * @return the associated shadow generator.
  11901. */
  11902. getShadowGenerator(): Nullable<IShadowGenerator>;
  11903. /**
  11904. * Returns a Vector3, the absolute light position in the World.
  11905. * @returns the world space position of the light
  11906. */
  11907. getAbsolutePosition(): Vector3;
  11908. /**
  11909. * Specifies if the light will affect the passed mesh.
  11910. * @param mesh The mesh to test against the light
  11911. * @return true the mesh is affected otherwise, false.
  11912. */
  11913. canAffectMesh(mesh: AbstractMesh): boolean;
  11914. /**
  11915. * Sort function to order lights for rendering.
  11916. * @param a First Light object to compare to second.
  11917. * @param b Second Light object to compare first.
  11918. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  11919. */
  11920. static CompareLightsPriority(a: Light, b: Light): number;
  11921. /**
  11922. * Releases resources associated with this node.
  11923. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  11924. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  11925. */
  11926. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  11927. /**
  11928. * Returns the light type ID (integer).
  11929. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  11930. */
  11931. getTypeID(): number;
  11932. /**
  11933. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  11934. * @returns the scaled intensity in intensity mode unit
  11935. */
  11936. getScaledIntensity(): number;
  11937. /**
  11938. * Returns a new Light object, named "name", from the current one.
  11939. * @param name The name of the cloned light
  11940. * @returns the new created light
  11941. */
  11942. clone(name: string): Nullable<Light>;
  11943. /**
  11944. * Serializes the current light into a Serialization object.
  11945. * @returns the serialized object.
  11946. */
  11947. serialize(): any;
  11948. /**
  11949. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  11950. * This new light is named "name" and added to the passed scene.
  11951. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  11952. * @param name The friendly name of the light
  11953. * @param scene The scene the new light will belong to
  11954. * @returns the constructor function
  11955. */
  11956. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  11957. /**
  11958. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  11959. * @param parsedLight The JSON representation of the light
  11960. * @param scene The scene to create the parsed light in
  11961. * @returns the created light after parsing
  11962. */
  11963. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  11964. private _hookArrayForExcluded;
  11965. private _hookArrayForIncludedOnly;
  11966. private _resyncMeshes;
  11967. /**
  11968. * Forces the meshes to update their light related information in their rendering used effects
  11969. * @hidden Internal Use Only
  11970. */
  11971. _markMeshesAsLightDirty(): void;
  11972. /**
  11973. * Recomputes the cached photometric scale if needed.
  11974. */
  11975. private _computePhotometricScale;
  11976. /**
  11977. * Returns the Photometric Scale according to the light type and intensity mode.
  11978. */
  11979. private _getPhotometricScale;
  11980. /**
  11981. * Reorder the light in the scene according to their defined priority.
  11982. * @hidden Internal Use Only
  11983. */
  11984. _reorderLightsInScene(): void;
  11985. /**
  11986. * Prepares the list of defines specific to the light type.
  11987. * @param defines the list of defines
  11988. * @param lightIndex defines the index of the light for the effect
  11989. */
  11990. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  11991. }
  11992. }
  11993. declare module BABYLON {
  11994. /**
  11995. * Creates an instance based on a source mesh.
  11996. */
  11997. export class InstancedMesh extends AbstractMesh {
  11998. private _sourceMesh;
  11999. private _currentLOD;
  12000. /** @hidden */
  12001. _indexInSourceMeshInstanceArray: number;
  12002. constructor(name: string, source: Mesh);
  12003. /**
  12004. * Returns the string "InstancedMesh".
  12005. */
  12006. getClassName(): string;
  12007. /** Gets the list of lights affecting that mesh */
  12008. readonly lightSources: Light[];
  12009. _resyncLightSources(): void;
  12010. _resyncLighSource(light: Light): void;
  12011. _removeLightSource(light: Light): void;
  12012. /**
  12013. * If the source mesh receives shadows
  12014. */
  12015. readonly receiveShadows: boolean;
  12016. /**
  12017. * The material of the source mesh
  12018. */
  12019. readonly material: Nullable<Material>;
  12020. /**
  12021. * Visibility of the source mesh
  12022. */
  12023. readonly visibility: number;
  12024. /**
  12025. * Skeleton of the source mesh
  12026. */
  12027. readonly skeleton: Nullable<Skeleton>;
  12028. /**
  12029. * Rendering ground id of the source mesh
  12030. */
  12031. renderingGroupId: number;
  12032. /**
  12033. * Returns the total number of vertices (integer).
  12034. */
  12035. getTotalVertices(): number;
  12036. /**
  12037. * Returns a positive integer : the total number of indices in this mesh geometry.
  12038. * @returns the numner of indices or zero if the mesh has no geometry.
  12039. */
  12040. getTotalIndices(): number;
  12041. /**
  12042. * The source mesh of the instance
  12043. */
  12044. readonly sourceMesh: Mesh;
  12045. /**
  12046. * Is this node ready to be used/rendered
  12047. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  12048. * @return {boolean} is it ready
  12049. */
  12050. isReady(completeCheck?: boolean): boolean;
  12051. /**
  12052. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  12053. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  12054. * @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.
  12055. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  12056. */
  12057. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  12058. /**
  12059. * Sets the vertex data of the mesh geometry for the requested `kind`.
  12060. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  12061. * The `data` are either a numeric array either a Float32Array.
  12062. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  12063. * 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).
  12064. * Note that a new underlying VertexBuffer object is created each call.
  12065. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  12066. *
  12067. * Possible `kind` values :
  12068. * - VertexBuffer.PositionKind
  12069. * - VertexBuffer.UVKind
  12070. * - VertexBuffer.UV2Kind
  12071. * - VertexBuffer.UV3Kind
  12072. * - VertexBuffer.UV4Kind
  12073. * - VertexBuffer.UV5Kind
  12074. * - VertexBuffer.UV6Kind
  12075. * - VertexBuffer.ColorKind
  12076. * - VertexBuffer.MatricesIndicesKind
  12077. * - VertexBuffer.MatricesIndicesExtraKind
  12078. * - VertexBuffer.MatricesWeightsKind
  12079. * - VertexBuffer.MatricesWeightsExtraKind
  12080. *
  12081. * Returns the Mesh.
  12082. */
  12083. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  12084. /**
  12085. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  12086. * If the mesh has no geometry, it is simply returned as it is.
  12087. * The `data` are either a numeric array either a Float32Array.
  12088. * No new underlying VertexBuffer object is created.
  12089. * 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.
  12090. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  12091. *
  12092. * Possible `kind` values :
  12093. * - VertexBuffer.PositionKind
  12094. * - VertexBuffer.UVKind
  12095. * - VertexBuffer.UV2Kind
  12096. * - VertexBuffer.UV3Kind
  12097. * - VertexBuffer.UV4Kind
  12098. * - VertexBuffer.UV5Kind
  12099. * - VertexBuffer.UV6Kind
  12100. * - VertexBuffer.ColorKind
  12101. * - VertexBuffer.MatricesIndicesKind
  12102. * - VertexBuffer.MatricesIndicesExtraKind
  12103. * - VertexBuffer.MatricesWeightsKind
  12104. * - VertexBuffer.MatricesWeightsExtraKind
  12105. *
  12106. * Returns the Mesh.
  12107. */
  12108. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  12109. /**
  12110. * Sets the mesh indices.
  12111. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  12112. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  12113. * This method creates a new index buffer each call.
  12114. * Returns the Mesh.
  12115. */
  12116. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  12117. /**
  12118. * Boolean : True if the mesh owns the requested kind of data.
  12119. */
  12120. isVerticesDataPresent(kind: string): boolean;
  12121. /**
  12122. * Returns an array of indices (IndicesArray).
  12123. */
  12124. getIndices(): Nullable<IndicesArray>;
  12125. readonly _positions: Nullable<Vector3[]>;
  12126. /**
  12127. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  12128. * This means the mesh underlying bounding box and sphere are recomputed.
  12129. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  12130. * @returns the current mesh
  12131. */
  12132. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  12133. /** @hidden */
  12134. _preActivate(): InstancedMesh;
  12135. /** @hidden */
  12136. _activate(renderId: number, intermediateRendering: boolean): boolean;
  12137. /** @hidden */
  12138. _postActivate(): void;
  12139. getWorldMatrix(): Matrix;
  12140. readonly isAnInstance: boolean;
  12141. /**
  12142. * Returns the current associated LOD AbstractMesh.
  12143. */
  12144. getLOD(camera: Camera): AbstractMesh;
  12145. /** @hidden */
  12146. _syncSubMeshes(): InstancedMesh;
  12147. /** @hidden */
  12148. _generatePointsArray(): boolean;
  12149. /**
  12150. * Creates a new InstancedMesh from the current mesh.
  12151. * - name (string) : the cloned mesh name
  12152. * - newParent (optional Node) : the optional Node to parent the clone to.
  12153. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  12154. *
  12155. * Returns the clone.
  12156. */
  12157. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  12158. /**
  12159. * Disposes the InstancedMesh.
  12160. * Returns nothing.
  12161. */
  12162. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  12163. }
  12164. }
  12165. declare module BABYLON {
  12166. /**
  12167. * Defines the options associated with the creation of a shader material.
  12168. */
  12169. export interface IShaderMaterialOptions {
  12170. /**
  12171. * Does the material work in alpha blend mode
  12172. */
  12173. needAlphaBlending: boolean;
  12174. /**
  12175. * Does the material work in alpha test mode
  12176. */
  12177. needAlphaTesting: boolean;
  12178. /**
  12179. * The list of attribute names used in the shader
  12180. */
  12181. attributes: string[];
  12182. /**
  12183. * The list of unifrom names used in the shader
  12184. */
  12185. uniforms: string[];
  12186. /**
  12187. * The list of UBO names used in the shader
  12188. */
  12189. uniformBuffers: string[];
  12190. /**
  12191. * The list of sampler names used in the shader
  12192. */
  12193. samplers: string[];
  12194. /**
  12195. * The list of defines used in the shader
  12196. */
  12197. defines: string[];
  12198. }
  12199. /**
  12200. * 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.
  12201. *
  12202. * This returned material effects how the mesh will look based on the code in the shaders.
  12203. *
  12204. * @see http://doc.babylonjs.com/how_to/shader_material
  12205. */
  12206. export class ShaderMaterial extends Material {
  12207. private _shaderPath;
  12208. private _options;
  12209. private _textures;
  12210. private _textureArrays;
  12211. private _floats;
  12212. private _ints;
  12213. private _floatsArrays;
  12214. private _colors3;
  12215. private _colors3Arrays;
  12216. private _colors4;
  12217. private _vectors2;
  12218. private _vectors3;
  12219. private _vectors4;
  12220. private _matrices;
  12221. private _matrices3x3;
  12222. private _matrices2x2;
  12223. private _vectors2Arrays;
  12224. private _vectors3Arrays;
  12225. private _cachedWorldViewMatrix;
  12226. private _cachedWorldViewProjectionMatrix;
  12227. private _renderId;
  12228. /**
  12229. * Instantiate a new shader material.
  12230. * 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.
  12231. * This returned material effects how the mesh will look based on the code in the shaders.
  12232. * @see http://doc.babylonjs.com/how_to/shader_material
  12233. * @param name Define the name of the material in the scene
  12234. * @param scene Define the scene the material belongs to
  12235. * @param shaderPath Defines the route to the shader code in one of three ways:
  12236. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  12237. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  12238. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  12239. * @param options Define the options used to create the shader
  12240. */
  12241. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  12242. /**
  12243. * Gets the options used to compile the shader.
  12244. * They can be modified to trigger a new compilation
  12245. */
  12246. readonly options: IShaderMaterialOptions;
  12247. /**
  12248. * Gets the current class name of the material e.g. "ShaderMaterial"
  12249. * Mainly use in serialization.
  12250. * @returns the class name
  12251. */
  12252. getClassName(): string;
  12253. /**
  12254. * Specifies if the material will require alpha blending
  12255. * @returns a boolean specifying if alpha blending is needed
  12256. */
  12257. needAlphaBlending(): boolean;
  12258. /**
  12259. * Specifies if this material should be rendered in alpha test mode
  12260. * @returns a boolean specifying if an alpha test is needed.
  12261. */
  12262. needAlphaTesting(): boolean;
  12263. private _checkUniform;
  12264. /**
  12265. * Set a texture in the shader.
  12266. * @param name Define the name of the uniform samplers as defined in the shader
  12267. * @param texture Define the texture to bind to this sampler
  12268. * @return the material itself allowing "fluent" like uniform updates
  12269. */
  12270. setTexture(name: string, texture: Texture): ShaderMaterial;
  12271. /**
  12272. * Set a texture array in the shader.
  12273. * @param name Define the name of the uniform sampler array as defined in the shader
  12274. * @param textures Define the list of textures to bind to this sampler
  12275. * @return the material itself allowing "fluent" like uniform updates
  12276. */
  12277. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  12278. /**
  12279. * Set a float in the shader.
  12280. * @param name Define the name of the uniform as defined in the shader
  12281. * @param value Define the value to give to the uniform
  12282. * @return the material itself allowing "fluent" like uniform updates
  12283. */
  12284. setFloat(name: string, value: number): ShaderMaterial;
  12285. /**
  12286. * Set a int in the shader.
  12287. * @param name Define the name of the uniform as defined in the shader
  12288. * @param value Define the value to give to the uniform
  12289. * @return the material itself allowing "fluent" like uniform updates
  12290. */
  12291. setInt(name: string, value: number): ShaderMaterial;
  12292. /**
  12293. * Set an array of floats in the shader.
  12294. * @param name Define the name of the uniform as defined in the shader
  12295. * @param value Define the value to give to the uniform
  12296. * @return the material itself allowing "fluent" like uniform updates
  12297. */
  12298. setFloats(name: string, value: number[]): ShaderMaterial;
  12299. /**
  12300. * Set a vec3 in the shader from a Color3.
  12301. * @param name Define the name of the uniform as defined in the shader
  12302. * @param value Define the value to give to the uniform
  12303. * @return the material itself allowing "fluent" like uniform updates
  12304. */
  12305. setColor3(name: string, value: Color3): ShaderMaterial;
  12306. /**
  12307. * Set a vec3 array in the shader from a Color3 array.
  12308. * @param name Define the name of the uniform as defined in the shader
  12309. * @param value Define the value to give to the uniform
  12310. * @return the material itself allowing "fluent" like uniform updates
  12311. */
  12312. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  12313. /**
  12314. * Set a vec4 in the shader from a Color4.
  12315. * @param name Define the name of the uniform as defined in the shader
  12316. * @param value Define the value to give to the uniform
  12317. * @return the material itself allowing "fluent" like uniform updates
  12318. */
  12319. setColor4(name: string, value: Color4): ShaderMaterial;
  12320. /**
  12321. * Set a vec2 in the shader from a Vector2.
  12322. * @param name Define the name of the uniform as defined in the shader
  12323. * @param value Define the value to give to the uniform
  12324. * @return the material itself allowing "fluent" like uniform updates
  12325. */
  12326. setVector2(name: string, value: Vector2): ShaderMaterial;
  12327. /**
  12328. * Set a vec3 in the shader from a Vector3.
  12329. * @param name Define the name of the uniform as defined in the shader
  12330. * @param value Define the value to give to the uniform
  12331. * @return the material itself allowing "fluent" like uniform updates
  12332. */
  12333. setVector3(name: string, value: Vector3): ShaderMaterial;
  12334. /**
  12335. * Set a vec4 in the shader from a Vector4.
  12336. * @param name Define the name of the uniform as defined in the shader
  12337. * @param value Define the value to give to the uniform
  12338. * @return the material itself allowing "fluent" like uniform updates
  12339. */
  12340. setVector4(name: string, value: Vector4): ShaderMaterial;
  12341. /**
  12342. * Set a mat4 in the shader from a Matrix.
  12343. * @param name Define the name of the uniform as defined in the shader
  12344. * @param value Define the value to give to the uniform
  12345. * @return the material itself allowing "fluent" like uniform updates
  12346. */
  12347. setMatrix(name: string, value: Matrix): ShaderMaterial;
  12348. /**
  12349. * Set a mat3 in the shader from a Float32Array.
  12350. * @param name Define the name of the uniform as defined in the shader
  12351. * @param value Define the value to give to the uniform
  12352. * @return the material itself allowing "fluent" like uniform updates
  12353. */
  12354. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  12355. /**
  12356. * Set a mat2 in the shader from a Float32Array.
  12357. * @param name Define the name of the uniform as defined in the shader
  12358. * @param value Define the value to give to the uniform
  12359. * @return the material itself allowing "fluent" like uniform updates
  12360. */
  12361. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  12362. /**
  12363. * Set a vec2 array in the shader from a number array.
  12364. * @param name Define the name of the uniform as defined in the shader
  12365. * @param value Define the value to give to the uniform
  12366. * @return the material itself allowing "fluent" like uniform updates
  12367. */
  12368. setArray2(name: string, value: number[]): ShaderMaterial;
  12369. /**
  12370. * Set a vec3 array in the shader from a number array.
  12371. * @param name Define the name of the uniform as defined in the shader
  12372. * @param value Define the value to give to the uniform
  12373. * @return the material itself allowing "fluent" like uniform updates
  12374. */
  12375. setArray3(name: string, value: number[]): ShaderMaterial;
  12376. private _checkCache;
  12377. /**
  12378. * Specifies that the submesh is ready to be used
  12379. * @param mesh defines the mesh to check
  12380. * @param subMesh defines which submesh to check
  12381. * @param useInstances specifies that instances should be used
  12382. * @returns a boolean indicating that the submesh is ready or not
  12383. */
  12384. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  12385. /**
  12386. * Checks if the material is ready to render the requested mesh
  12387. * @param mesh Define the mesh to render
  12388. * @param useInstances Define whether or not the material is used with instances
  12389. * @returns true if ready, otherwise false
  12390. */
  12391. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  12392. /**
  12393. * Binds the world matrix to the material
  12394. * @param world defines the world transformation matrix
  12395. */
  12396. bindOnlyWorldMatrix(world: Matrix): void;
  12397. /**
  12398. * Binds the material to the mesh
  12399. * @param world defines the world transformation matrix
  12400. * @param mesh defines the mesh to bind the material to
  12401. */
  12402. bind(world: Matrix, mesh?: Mesh): void;
  12403. /**
  12404. * Gets the active textures from the material
  12405. * @returns an array of textures
  12406. */
  12407. getActiveTextures(): BaseTexture[];
  12408. /**
  12409. * Specifies if the material uses a texture
  12410. * @param texture defines the texture to check against the material
  12411. * @returns a boolean specifying if the material uses the texture
  12412. */
  12413. hasTexture(texture: BaseTexture): boolean;
  12414. /**
  12415. * Makes a duplicate of the material, and gives it a new name
  12416. * @param name defines the new name for the duplicated material
  12417. * @returns the cloned material
  12418. */
  12419. clone(name: string): ShaderMaterial;
  12420. /**
  12421. * Disposes the material
  12422. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  12423. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  12424. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  12425. */
  12426. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  12427. /**
  12428. * Serializes this material in a JSON representation
  12429. * @returns the serialized material object
  12430. */
  12431. serialize(): any;
  12432. /**
  12433. * Creates a shader material from parsed shader material data
  12434. * @param source defines the JSON represnetation of the material
  12435. * @param scene defines the hosting scene
  12436. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  12437. * @returns a new material
  12438. */
  12439. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  12440. }
  12441. }
  12442. declare module BABYLON {
  12443. /** @hidden */
  12444. export var clipPlaneFragmentDeclaration: {
  12445. name: string;
  12446. shader: string;
  12447. };
  12448. }
  12449. declare module BABYLON {
  12450. /** @hidden */
  12451. export var clipPlaneFragment: {
  12452. name: string;
  12453. shader: string;
  12454. };
  12455. }
  12456. declare module BABYLON {
  12457. /** @hidden */
  12458. export var colorPixelShader: {
  12459. name: string;
  12460. shader: string;
  12461. };
  12462. }
  12463. declare module BABYLON {
  12464. /** @hidden */
  12465. export var clipPlaneVertexDeclaration: {
  12466. name: string;
  12467. shader: string;
  12468. };
  12469. }
  12470. declare module BABYLON {
  12471. /** @hidden */
  12472. export var clipPlaneVertex: {
  12473. name: string;
  12474. shader: string;
  12475. };
  12476. }
  12477. declare module BABYLON {
  12478. /** @hidden */
  12479. export var colorVertexShader: {
  12480. name: string;
  12481. shader: string;
  12482. };
  12483. }
  12484. declare module BABYLON {
  12485. /**
  12486. * Line mesh
  12487. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  12488. */
  12489. export class LinesMesh extends Mesh {
  12490. /**
  12491. * If vertex color should be applied to the mesh
  12492. */
  12493. readonly useVertexColor?: boolean | undefined;
  12494. /**
  12495. * If vertex alpha should be applied to the mesh
  12496. */
  12497. readonly useVertexAlpha?: boolean | undefined;
  12498. /**
  12499. * Color of the line (Default: White)
  12500. */
  12501. color: Color3;
  12502. /**
  12503. * Alpha of the line (Default: 1)
  12504. */
  12505. alpha: number;
  12506. /**
  12507. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  12508. * This margin is expressed in world space coordinates, so its value may vary.
  12509. * Default value is 0.1
  12510. */
  12511. intersectionThreshold: number;
  12512. private _colorShader;
  12513. private color4;
  12514. /**
  12515. * Creates a new LinesMesh
  12516. * @param name defines the name
  12517. * @param scene defines the hosting scene
  12518. * @param parent defines the parent mesh if any
  12519. * @param source defines the optional source LinesMesh used to clone data from
  12520. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  12521. * When false, achieved by calling a clone(), also passing False.
  12522. * This will make creation of children, recursive.
  12523. * @param useVertexColor defines if this LinesMesh supports vertex color
  12524. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  12525. */
  12526. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  12527. /**
  12528. * If vertex color should be applied to the mesh
  12529. */
  12530. useVertexColor?: boolean | undefined,
  12531. /**
  12532. * If vertex alpha should be applied to the mesh
  12533. */
  12534. useVertexAlpha?: boolean | undefined);
  12535. private _addClipPlaneDefine;
  12536. private _removeClipPlaneDefine;
  12537. isReady(): boolean;
  12538. /**
  12539. * Returns the string "LineMesh"
  12540. */
  12541. getClassName(): string;
  12542. /**
  12543. * @hidden
  12544. */
  12545. /**
  12546. * @hidden
  12547. */
  12548. material: Material;
  12549. /**
  12550. * @hidden
  12551. */
  12552. readonly checkCollisions: boolean;
  12553. /** @hidden */
  12554. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  12555. /** @hidden */
  12556. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  12557. /**
  12558. * Disposes of the line mesh
  12559. * @param doNotRecurse If children should be disposed
  12560. */
  12561. dispose(doNotRecurse?: boolean): void;
  12562. /**
  12563. * Returns a new LineMesh object cloned from the current one.
  12564. */
  12565. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  12566. /**
  12567. * Creates a new InstancedLinesMesh object from the mesh model.
  12568. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  12569. * @param name defines the name of the new instance
  12570. * @returns a new InstancedLinesMesh
  12571. */
  12572. createInstance(name: string): InstancedLinesMesh;
  12573. }
  12574. /**
  12575. * Creates an instance based on a source LinesMesh
  12576. */
  12577. export class InstancedLinesMesh extends InstancedMesh {
  12578. /**
  12579. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  12580. * This margin is expressed in world space coordinates, so its value may vary.
  12581. * Initilized with the intersectionThreshold value of the source LinesMesh
  12582. */
  12583. intersectionThreshold: number;
  12584. constructor(name: string, source: LinesMesh);
  12585. /**
  12586. * Returns the string "InstancedLinesMesh".
  12587. */
  12588. getClassName(): string;
  12589. }
  12590. }
  12591. declare module BABYLON {
  12592. /**
  12593. * Mesh representing the gorund
  12594. */
  12595. export class GroundMesh extends Mesh {
  12596. /** If octree should be generated */
  12597. generateOctree: boolean;
  12598. private _heightQuads;
  12599. /** @hidden */
  12600. _subdivisionsX: number;
  12601. /** @hidden */
  12602. _subdivisionsY: number;
  12603. /** @hidden */
  12604. _width: number;
  12605. /** @hidden */
  12606. _height: number;
  12607. /** @hidden */
  12608. _minX: number;
  12609. /** @hidden */
  12610. _maxX: number;
  12611. /** @hidden */
  12612. _minZ: number;
  12613. /** @hidden */
  12614. _maxZ: number;
  12615. constructor(name: string, scene: Scene);
  12616. /**
  12617. * "GroundMesh"
  12618. * @returns "GroundMesh"
  12619. */
  12620. getClassName(): string;
  12621. /**
  12622. * The minimum of x and y subdivisions
  12623. */
  12624. readonly subdivisions: number;
  12625. /**
  12626. * X subdivisions
  12627. */
  12628. readonly subdivisionsX: number;
  12629. /**
  12630. * Y subdivisions
  12631. */
  12632. readonly subdivisionsY: number;
  12633. /**
  12634. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  12635. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  12636. * @param chunksCount the number of subdivisions for x and y
  12637. * @param octreeBlocksSize (Default: 32)
  12638. */
  12639. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  12640. /**
  12641. * Returns a height (y) value in the Worl system :
  12642. * the ground altitude at the coordinates (x, z) expressed in the World system.
  12643. * @param x x coordinate
  12644. * @param z z coordinate
  12645. * @returns the ground y position if (x, z) are outside the ground surface.
  12646. */
  12647. getHeightAtCoordinates(x: number, z: number): number;
  12648. /**
  12649. * Returns a normalized vector (Vector3) orthogonal to the ground
  12650. * at the ground coordinates (x, z) expressed in the World system.
  12651. * @param x x coordinate
  12652. * @param z z coordinate
  12653. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  12654. */
  12655. getNormalAtCoordinates(x: number, z: number): Vector3;
  12656. /**
  12657. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  12658. * at the ground coordinates (x, z) expressed in the World system.
  12659. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  12660. * @param x x coordinate
  12661. * @param z z coordinate
  12662. * @param ref vector to store the result
  12663. * @returns the GroundMesh.
  12664. */
  12665. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  12666. /**
  12667. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  12668. * if the ground has been updated.
  12669. * This can be used in the render loop.
  12670. * @returns the GroundMesh.
  12671. */
  12672. updateCoordinateHeights(): GroundMesh;
  12673. private _getFacetAt;
  12674. private _initHeightQuads;
  12675. private _computeHeightQuads;
  12676. /**
  12677. * Serializes this ground mesh
  12678. * @param serializationObject object to write serialization to
  12679. */
  12680. serialize(serializationObject: any): void;
  12681. /**
  12682. * Parses a serialized ground mesh
  12683. * @param parsedMesh the serialized mesh
  12684. * @param scene the scene to create the ground mesh in
  12685. * @returns the created ground mesh
  12686. */
  12687. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  12688. }
  12689. }
  12690. declare module BABYLON {
  12691. /**
  12692. * Interface for Physics-Joint data
  12693. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  12694. */
  12695. export interface PhysicsJointData {
  12696. /**
  12697. * The main pivot of the joint
  12698. */
  12699. mainPivot?: Vector3;
  12700. /**
  12701. * The connected pivot of the joint
  12702. */
  12703. connectedPivot?: Vector3;
  12704. /**
  12705. * The main axis of the joint
  12706. */
  12707. mainAxis?: Vector3;
  12708. /**
  12709. * The connected axis of the joint
  12710. */
  12711. connectedAxis?: Vector3;
  12712. /**
  12713. * The collision of the joint
  12714. */
  12715. collision?: boolean;
  12716. /**
  12717. * Native Oimo/Cannon/Energy data
  12718. */
  12719. nativeParams?: any;
  12720. }
  12721. /**
  12722. * This is a holder class for the physics joint created by the physics plugin
  12723. * It holds a set of functions to control the underlying joint
  12724. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  12725. */
  12726. export class PhysicsJoint {
  12727. /**
  12728. * The type of the physics joint
  12729. */
  12730. type: number;
  12731. /**
  12732. * The data for the physics joint
  12733. */
  12734. jointData: PhysicsJointData;
  12735. private _physicsJoint;
  12736. protected _physicsPlugin: IPhysicsEnginePlugin;
  12737. /**
  12738. * Initializes the physics joint
  12739. * @param type The type of the physics joint
  12740. * @param jointData The data for the physics joint
  12741. */
  12742. constructor(
  12743. /**
  12744. * The type of the physics joint
  12745. */
  12746. type: number,
  12747. /**
  12748. * The data for the physics joint
  12749. */
  12750. jointData: PhysicsJointData);
  12751. /**
  12752. * Gets the physics joint
  12753. */
  12754. /**
  12755. * Sets the physics joint
  12756. */
  12757. physicsJoint: any;
  12758. /**
  12759. * Sets the physics plugin
  12760. */
  12761. physicsPlugin: IPhysicsEnginePlugin;
  12762. /**
  12763. * Execute a function that is physics-plugin specific.
  12764. * @param {Function} func the function that will be executed.
  12765. * It accepts two parameters: the physics world and the physics joint
  12766. */
  12767. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  12768. /**
  12769. * Distance-Joint type
  12770. */
  12771. static DistanceJoint: number;
  12772. /**
  12773. * Hinge-Joint type
  12774. */
  12775. static HingeJoint: number;
  12776. /**
  12777. * Ball-and-Socket joint type
  12778. */
  12779. static BallAndSocketJoint: number;
  12780. /**
  12781. * Wheel-Joint type
  12782. */
  12783. static WheelJoint: number;
  12784. /**
  12785. * Slider-Joint type
  12786. */
  12787. static SliderJoint: number;
  12788. /**
  12789. * Prismatic-Joint type
  12790. */
  12791. static PrismaticJoint: number;
  12792. /**
  12793. * Universal-Joint type
  12794. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  12795. */
  12796. static UniversalJoint: number;
  12797. /**
  12798. * Hinge-Joint 2 type
  12799. */
  12800. static Hinge2Joint: number;
  12801. /**
  12802. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  12803. */
  12804. static PointToPointJoint: number;
  12805. /**
  12806. * Spring-Joint type
  12807. */
  12808. static SpringJoint: number;
  12809. /**
  12810. * Lock-Joint type
  12811. */
  12812. static LockJoint: number;
  12813. }
  12814. /**
  12815. * A class representing a physics distance joint
  12816. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  12817. */
  12818. export class DistanceJoint extends PhysicsJoint {
  12819. /**
  12820. *
  12821. * @param jointData The data for the Distance-Joint
  12822. */
  12823. constructor(jointData: DistanceJointData);
  12824. /**
  12825. * Update the predefined distance.
  12826. * @param maxDistance The maximum preferred distance
  12827. * @param minDistance The minimum preferred distance
  12828. */
  12829. updateDistance(maxDistance: number, minDistance?: number): void;
  12830. }
  12831. /**
  12832. * Represents a Motor-Enabled Joint
  12833. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  12834. */
  12835. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  12836. /**
  12837. * Initializes the Motor-Enabled Joint
  12838. * @param type The type of the joint
  12839. * @param jointData The physica joint data for the joint
  12840. */
  12841. constructor(type: number, jointData: PhysicsJointData);
  12842. /**
  12843. * Set the motor values.
  12844. * Attention, this function is plugin specific. Engines won't react 100% the same.
  12845. * @param force the force to apply
  12846. * @param maxForce max force for this motor.
  12847. */
  12848. setMotor(force?: number, maxForce?: number): void;
  12849. /**
  12850. * Set the motor's limits.
  12851. * Attention, this function is plugin specific. Engines won't react 100% the same.
  12852. * @param upperLimit The upper limit of the motor
  12853. * @param lowerLimit The lower limit of the motor
  12854. */
  12855. setLimit(upperLimit: number, lowerLimit?: number): void;
  12856. }
  12857. /**
  12858. * This class represents a single physics Hinge-Joint
  12859. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  12860. */
  12861. export class HingeJoint extends MotorEnabledJoint {
  12862. /**
  12863. * Initializes the Hinge-Joint
  12864. * @param jointData The joint data for the Hinge-Joint
  12865. */
  12866. constructor(jointData: PhysicsJointData);
  12867. /**
  12868. * Set the motor values.
  12869. * Attention, this function is plugin specific. Engines won't react 100% the same.
  12870. * @param {number} force the force to apply
  12871. * @param {number} maxForce max force for this motor.
  12872. */
  12873. setMotor(force?: number, maxForce?: number): void;
  12874. /**
  12875. * Set the motor's limits.
  12876. * Attention, this function is plugin specific. Engines won't react 100% the same.
  12877. * @param upperLimit The upper limit of the motor
  12878. * @param lowerLimit The lower limit of the motor
  12879. */
  12880. setLimit(upperLimit: number, lowerLimit?: number): void;
  12881. }
  12882. /**
  12883. * This class represents a dual hinge physics joint (same as wheel joint)
  12884. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  12885. */
  12886. export class Hinge2Joint extends MotorEnabledJoint {
  12887. /**
  12888. * Initializes the Hinge2-Joint
  12889. * @param jointData The joint data for the Hinge2-Joint
  12890. */
  12891. constructor(jointData: PhysicsJointData);
  12892. /**
  12893. * Set the motor values.
  12894. * Attention, this function is plugin specific. Engines won't react 100% the same.
  12895. * @param {number} targetSpeed the speed the motor is to reach
  12896. * @param {number} maxForce max force for this motor.
  12897. * @param {motorIndex} the motor's index, 0 or 1.
  12898. */
  12899. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  12900. /**
  12901. * Set the motor limits.
  12902. * Attention, this function is plugin specific. Engines won't react 100% the same.
  12903. * @param {number} upperLimit the upper limit
  12904. * @param {number} lowerLimit lower limit
  12905. * @param {motorIndex} the motor's index, 0 or 1.
  12906. */
  12907. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  12908. }
  12909. /**
  12910. * Interface for a motor enabled joint
  12911. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  12912. */
  12913. export interface IMotorEnabledJoint {
  12914. /**
  12915. * Physics joint
  12916. */
  12917. physicsJoint: any;
  12918. /**
  12919. * Sets the motor of the motor-enabled joint
  12920. * @param force The force of the motor
  12921. * @param maxForce The maximum force of the motor
  12922. * @param motorIndex The index of the motor
  12923. */
  12924. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  12925. /**
  12926. * Sets the limit of the motor
  12927. * @param upperLimit The upper limit of the motor
  12928. * @param lowerLimit The lower limit of the motor
  12929. * @param motorIndex The index of the motor
  12930. */
  12931. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  12932. }
  12933. /**
  12934. * Joint data for a Distance-Joint
  12935. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  12936. */
  12937. export interface DistanceJointData extends PhysicsJointData {
  12938. /**
  12939. * Max distance the 2 joint objects can be apart
  12940. */
  12941. maxDistance: number;
  12942. }
  12943. /**
  12944. * Joint data from a spring joint
  12945. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  12946. */
  12947. export interface SpringJointData extends PhysicsJointData {
  12948. /**
  12949. * Length of the spring
  12950. */
  12951. length: number;
  12952. /**
  12953. * Stiffness of the spring
  12954. */
  12955. stiffness: number;
  12956. /**
  12957. * Damping of the spring
  12958. */
  12959. damping: number;
  12960. /** this callback will be called when applying the force to the impostors. */
  12961. forceApplicationCallback: () => void;
  12962. }
  12963. }
  12964. declare module BABYLON {
  12965. /**
  12966. * Holds the data for the raycast result
  12967. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  12968. */
  12969. export class PhysicsRaycastResult {
  12970. private _hasHit;
  12971. private _hitDistance;
  12972. private _hitNormalWorld;
  12973. private _hitPointWorld;
  12974. private _rayFromWorld;
  12975. private _rayToWorld;
  12976. /**
  12977. * Gets if there was a hit
  12978. */
  12979. readonly hasHit: boolean;
  12980. /**
  12981. * Gets the distance from the hit
  12982. */
  12983. readonly hitDistance: number;
  12984. /**
  12985. * Gets the hit normal/direction in the world
  12986. */
  12987. readonly hitNormalWorld: Vector3;
  12988. /**
  12989. * Gets the hit point in the world
  12990. */
  12991. readonly hitPointWorld: Vector3;
  12992. /**
  12993. * Gets the ray "start point" of the ray in the world
  12994. */
  12995. readonly rayFromWorld: Vector3;
  12996. /**
  12997. * Gets the ray "end point" of the ray in the world
  12998. */
  12999. readonly rayToWorld: Vector3;
  13000. /**
  13001. * Sets the hit data (normal & point in world space)
  13002. * @param hitNormalWorld defines the normal in world space
  13003. * @param hitPointWorld defines the point in world space
  13004. */
  13005. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  13006. /**
  13007. * Sets the distance from the start point to the hit point
  13008. * @param distance
  13009. */
  13010. setHitDistance(distance: number): void;
  13011. /**
  13012. * Calculates the distance manually
  13013. */
  13014. calculateHitDistance(): void;
  13015. /**
  13016. * Resets all the values to default
  13017. * @param from The from point on world space
  13018. * @param to The to point on world space
  13019. */
  13020. reset(from?: Vector3, to?: Vector3): void;
  13021. }
  13022. /**
  13023. * Interface for the size containing width and height
  13024. */
  13025. interface IXYZ {
  13026. /**
  13027. * X
  13028. */
  13029. x: number;
  13030. /**
  13031. * Y
  13032. */
  13033. y: number;
  13034. /**
  13035. * Z
  13036. */
  13037. z: number;
  13038. }
  13039. }
  13040. declare module BABYLON {
  13041. /**
  13042. * Interface used to describe a physics joint
  13043. */
  13044. export interface PhysicsImpostorJoint {
  13045. /** Defines the main impostor to which the joint is linked */
  13046. mainImpostor: PhysicsImpostor;
  13047. /** Defines the impostor that is connected to the main impostor using this joint */
  13048. connectedImpostor: PhysicsImpostor;
  13049. /** Defines the joint itself */
  13050. joint: PhysicsJoint;
  13051. }
  13052. /** @hidden */
  13053. export interface IPhysicsEnginePlugin {
  13054. world: any;
  13055. name: string;
  13056. setGravity(gravity: Vector3): void;
  13057. setTimeStep(timeStep: number): void;
  13058. getTimeStep(): number;
  13059. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  13060. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  13061. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  13062. generatePhysicsBody(impostor: PhysicsImpostor): void;
  13063. removePhysicsBody(impostor: PhysicsImpostor): void;
  13064. generateJoint(joint: PhysicsImpostorJoint): void;
  13065. removeJoint(joint: PhysicsImpostorJoint): void;
  13066. isSupported(): boolean;
  13067. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  13068. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  13069. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  13070. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  13071. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  13072. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  13073. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  13074. getBodyMass(impostor: PhysicsImpostor): number;
  13075. getBodyFriction(impostor: PhysicsImpostor): number;
  13076. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  13077. getBodyRestitution(impostor: PhysicsImpostor): number;
  13078. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  13079. getBodyPressure?(impostor: PhysicsImpostor): number;
  13080. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  13081. getBodyStiffness?(impostor: PhysicsImpostor): number;
  13082. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  13083. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  13084. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  13085. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  13086. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  13087. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  13088. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  13089. sleepBody(impostor: PhysicsImpostor): void;
  13090. wakeUpBody(impostor: PhysicsImpostor): void;
  13091. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  13092. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  13093. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  13094. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  13095. getRadius(impostor: PhysicsImpostor): number;
  13096. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  13097. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  13098. dispose(): void;
  13099. }
  13100. /**
  13101. * Interface used to define a physics engine
  13102. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  13103. */
  13104. export interface IPhysicsEngine {
  13105. /**
  13106. * Gets the gravity vector used by the simulation
  13107. */
  13108. gravity: Vector3;
  13109. /**
  13110. * Sets the gravity vector used by the simulation
  13111. * @param gravity defines the gravity vector to use
  13112. */
  13113. setGravity(gravity: Vector3): void;
  13114. /**
  13115. * Set the time step of the physics engine.
  13116. * Default is 1/60.
  13117. * To slow it down, enter 1/600 for example.
  13118. * To speed it up, 1/30
  13119. * @param newTimeStep the new timestep to apply to this world.
  13120. */
  13121. setTimeStep(newTimeStep: number): void;
  13122. /**
  13123. * Get the time step of the physics engine.
  13124. * @returns the current time step
  13125. */
  13126. getTimeStep(): number;
  13127. /**
  13128. * Release all resources
  13129. */
  13130. dispose(): void;
  13131. /**
  13132. * Gets the name of the current physics plugin
  13133. * @returns the name of the plugin
  13134. */
  13135. getPhysicsPluginName(): string;
  13136. /**
  13137. * Adding a new impostor for the impostor tracking.
  13138. * This will be done by the impostor itself.
  13139. * @param impostor the impostor to add
  13140. */
  13141. addImpostor(impostor: PhysicsImpostor): void;
  13142. /**
  13143. * Remove an impostor from the engine.
  13144. * This impostor and its mesh will not longer be updated by the physics engine.
  13145. * @param impostor the impostor to remove
  13146. */
  13147. removeImpostor(impostor: PhysicsImpostor): void;
  13148. /**
  13149. * Add a joint to the physics engine
  13150. * @param mainImpostor defines the main impostor to which the joint is added.
  13151. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  13152. * @param joint defines the joint that will connect both impostors.
  13153. */
  13154. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  13155. /**
  13156. * Removes a joint from the simulation
  13157. * @param mainImpostor defines the impostor used with the joint
  13158. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  13159. * @param joint defines the joint to remove
  13160. */
  13161. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  13162. /**
  13163. * Gets the current plugin used to run the simulation
  13164. * @returns current plugin
  13165. */
  13166. getPhysicsPlugin(): IPhysicsEnginePlugin;
  13167. /**
  13168. * Gets the list of physic impostors
  13169. * @returns an array of PhysicsImpostor
  13170. */
  13171. getImpostors(): Array<PhysicsImpostor>;
  13172. /**
  13173. * Gets the impostor for a physics enabled object
  13174. * @param object defines the object impersonated by the impostor
  13175. * @returns the PhysicsImpostor or null if not found
  13176. */
  13177. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  13178. /**
  13179. * Gets the impostor for a physics body object
  13180. * @param body defines physics body used by the impostor
  13181. * @returns the PhysicsImpostor or null if not found
  13182. */
  13183. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  13184. /**
  13185. * Does a raycast in the physics world
  13186. * @param from when should the ray start?
  13187. * @param to when should the ray end?
  13188. * @returns PhysicsRaycastResult
  13189. */
  13190. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  13191. /**
  13192. * Called by the scene. No need to call it.
  13193. * @param delta defines the timespam between frames
  13194. */
  13195. _step(delta: number): void;
  13196. }
  13197. }
  13198. declare module BABYLON {
  13199. /**
  13200. * The interface for the physics imposter parameters
  13201. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  13202. */
  13203. export interface PhysicsImpostorParameters {
  13204. /**
  13205. * The mass of the physics imposter
  13206. */
  13207. mass: number;
  13208. /**
  13209. * The friction of the physics imposter
  13210. */
  13211. friction?: number;
  13212. /**
  13213. * The coefficient of restitution of the physics imposter
  13214. */
  13215. restitution?: number;
  13216. /**
  13217. * The native options of the physics imposter
  13218. */
  13219. nativeOptions?: any;
  13220. /**
  13221. * Specifies if the parent should be ignored
  13222. */
  13223. ignoreParent?: boolean;
  13224. /**
  13225. * Specifies if bi-directional transformations should be disabled
  13226. */
  13227. disableBidirectionalTransformation?: boolean;
  13228. /**
  13229. * The pressure inside the physics imposter, soft object only
  13230. */
  13231. pressure?: number;
  13232. /**
  13233. * The stiffness the physics imposter, soft object only
  13234. */
  13235. stiffness?: number;
  13236. /**
  13237. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  13238. */
  13239. velocityIterations?: number;
  13240. /**
  13241. * The number of iterations used in maintaining consistent vertex positions, soft object only
  13242. */
  13243. positionIterations?: number;
  13244. /**
  13245. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  13246. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  13247. * Add to fix multiple points
  13248. */
  13249. fixedPoints?: number;
  13250. /**
  13251. * The collision margin around a soft object
  13252. */
  13253. margin?: number;
  13254. /**
  13255. * The collision margin around a soft object
  13256. */
  13257. damping?: number;
  13258. /**
  13259. * The path for a rope based on an extrusion
  13260. */
  13261. path?: any;
  13262. /**
  13263. * The shape of an extrusion used for a rope based on an extrusion
  13264. */
  13265. shape?: any;
  13266. }
  13267. /**
  13268. * Interface for a physics-enabled object
  13269. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  13270. */
  13271. export interface IPhysicsEnabledObject {
  13272. /**
  13273. * The position of the physics-enabled object
  13274. */
  13275. position: Vector3;
  13276. /**
  13277. * The rotation of the physics-enabled object
  13278. */
  13279. rotationQuaternion: Nullable<Quaternion>;
  13280. /**
  13281. * The scale of the physics-enabled object
  13282. */
  13283. scaling: Vector3;
  13284. /**
  13285. * The rotation of the physics-enabled object
  13286. */
  13287. rotation?: Vector3;
  13288. /**
  13289. * The parent of the physics-enabled object
  13290. */
  13291. parent?: any;
  13292. /**
  13293. * The bounding info of the physics-enabled object
  13294. * @returns The bounding info of the physics-enabled object
  13295. */
  13296. getBoundingInfo(): BoundingInfo;
  13297. /**
  13298. * Computes the world matrix
  13299. * @param force Specifies if the world matrix should be computed by force
  13300. * @returns A world matrix
  13301. */
  13302. computeWorldMatrix(force: boolean): Matrix;
  13303. /**
  13304. * Gets the world matrix
  13305. * @returns A world matrix
  13306. */
  13307. getWorldMatrix?(): Matrix;
  13308. /**
  13309. * Gets the child meshes
  13310. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  13311. * @returns An array of abstract meshes
  13312. */
  13313. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  13314. /**
  13315. * Gets the vertex data
  13316. * @param kind The type of vertex data
  13317. * @returns A nullable array of numbers, or a float32 array
  13318. */
  13319. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  13320. /**
  13321. * Gets the indices from the mesh
  13322. * @returns A nullable array of index arrays
  13323. */
  13324. getIndices?(): Nullable<IndicesArray>;
  13325. /**
  13326. * Gets the scene from the mesh
  13327. * @returns the indices array or null
  13328. */
  13329. getScene?(): Scene;
  13330. /**
  13331. * Gets the absolute position from the mesh
  13332. * @returns the absolute position
  13333. */
  13334. getAbsolutePosition(): Vector3;
  13335. /**
  13336. * Gets the absolute pivot point from the mesh
  13337. * @returns the absolute pivot point
  13338. */
  13339. getAbsolutePivotPoint(): Vector3;
  13340. /**
  13341. * Rotates the mesh
  13342. * @param axis The axis of rotation
  13343. * @param amount The amount of rotation
  13344. * @param space The space of the rotation
  13345. * @returns The rotation transform node
  13346. */
  13347. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  13348. /**
  13349. * Translates the mesh
  13350. * @param axis The axis of translation
  13351. * @param distance The distance of translation
  13352. * @param space The space of the translation
  13353. * @returns The transform node
  13354. */
  13355. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  13356. /**
  13357. * Sets the absolute position of the mesh
  13358. * @param absolutePosition The absolute position of the mesh
  13359. * @returns The transform node
  13360. */
  13361. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  13362. /**
  13363. * Gets the class name of the mesh
  13364. * @returns The class name
  13365. */
  13366. getClassName(): string;
  13367. }
  13368. /**
  13369. * Represents a physics imposter
  13370. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  13371. */
  13372. export class PhysicsImpostor {
  13373. /**
  13374. * The physics-enabled object used as the physics imposter
  13375. */
  13376. object: IPhysicsEnabledObject;
  13377. /**
  13378. * The type of the physics imposter
  13379. */
  13380. type: number;
  13381. private _options;
  13382. private _scene?;
  13383. /**
  13384. * The default object size of the imposter
  13385. */
  13386. static DEFAULT_OBJECT_SIZE: Vector3;
  13387. /**
  13388. * The identity quaternion of the imposter
  13389. */
  13390. static IDENTITY_QUATERNION: Quaternion;
  13391. /** @hidden */
  13392. _pluginData: any;
  13393. private _physicsEngine;
  13394. private _physicsBody;
  13395. private _bodyUpdateRequired;
  13396. private _onBeforePhysicsStepCallbacks;
  13397. private _onAfterPhysicsStepCallbacks;
  13398. /** @hidden */
  13399. _onPhysicsCollideCallbacks: Array<{
  13400. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  13401. otherImpostors: Array<PhysicsImpostor>;
  13402. }>;
  13403. private _deltaPosition;
  13404. private _deltaRotation;
  13405. private _deltaRotationConjugated;
  13406. /** @hidden */
  13407. _isFromLine: boolean;
  13408. private _parent;
  13409. private _isDisposed;
  13410. private static _tmpVecs;
  13411. private static _tmpQuat;
  13412. /**
  13413. * Specifies if the physics imposter is disposed
  13414. */
  13415. readonly isDisposed: boolean;
  13416. /**
  13417. * Gets the mass of the physics imposter
  13418. */
  13419. mass: number;
  13420. /**
  13421. * Gets the coefficient of friction
  13422. */
  13423. /**
  13424. * Sets the coefficient of friction
  13425. */
  13426. friction: number;
  13427. /**
  13428. * Gets the coefficient of restitution
  13429. */
  13430. /**
  13431. * Sets the coefficient of restitution
  13432. */
  13433. restitution: number;
  13434. /**
  13435. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  13436. */
  13437. /**
  13438. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  13439. */
  13440. pressure: number;
  13441. /**
  13442. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  13443. */
  13444. /**
  13445. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  13446. */
  13447. stiffness: number;
  13448. /**
  13449. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  13450. */
  13451. /**
  13452. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  13453. */
  13454. velocityIterations: number;
  13455. /**
  13456. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  13457. */
  13458. /**
  13459. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  13460. */
  13461. positionIterations: number;
  13462. /**
  13463. * The unique id of the physics imposter
  13464. * set by the physics engine when adding this impostor to the array
  13465. */
  13466. uniqueId: number;
  13467. /**
  13468. * @hidden
  13469. */
  13470. soft: boolean;
  13471. /**
  13472. * @hidden
  13473. */
  13474. segments: number;
  13475. private _joints;
  13476. /**
  13477. * Initializes the physics imposter
  13478. * @param object The physics-enabled object used as the physics imposter
  13479. * @param type The type of the physics imposter
  13480. * @param _options The options for the physics imposter
  13481. * @param _scene The Babylon scene
  13482. */
  13483. constructor(
  13484. /**
  13485. * The physics-enabled object used as the physics imposter
  13486. */
  13487. object: IPhysicsEnabledObject,
  13488. /**
  13489. * The type of the physics imposter
  13490. */
  13491. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  13492. /**
  13493. * This function will completly initialize this impostor.
  13494. * It will create a new body - but only if this mesh has no parent.
  13495. * If it has, this impostor will not be used other than to define the impostor
  13496. * of the child mesh.
  13497. * @hidden
  13498. */
  13499. _init(): void;
  13500. private _getPhysicsParent;
  13501. /**
  13502. * Should a new body be generated.
  13503. * @returns boolean specifying if body initialization is required
  13504. */
  13505. isBodyInitRequired(): boolean;
  13506. /**
  13507. * Sets the updated scaling
  13508. * @param updated Specifies if the scaling is updated
  13509. */
  13510. setScalingUpdated(): void;
  13511. /**
  13512. * Force a regeneration of this or the parent's impostor's body.
  13513. * Use under cautious - This will remove all joints already implemented.
  13514. */
  13515. forceUpdate(): void;
  13516. /**
  13517. * Gets the body that holds this impostor. Either its own, or its parent.
  13518. */
  13519. /**
  13520. * Set the physics body. Used mainly by the physics engine/plugin
  13521. */
  13522. physicsBody: any;
  13523. /**
  13524. * Get the parent of the physics imposter
  13525. * @returns Physics imposter or null
  13526. */
  13527. /**
  13528. * Sets the parent of the physics imposter
  13529. */
  13530. parent: Nullable<PhysicsImpostor>;
  13531. /**
  13532. * Resets the update flags
  13533. */
  13534. resetUpdateFlags(): void;
  13535. /**
  13536. * Gets the object extend size
  13537. * @returns the object extend size
  13538. */
  13539. getObjectExtendSize(): Vector3;
  13540. /**
  13541. * Gets the object center
  13542. * @returns The object center
  13543. */
  13544. getObjectCenter(): Vector3;
  13545. /**
  13546. * Get a specific parametes from the options parameter
  13547. * @param paramName The object parameter name
  13548. * @returns The object parameter
  13549. */
  13550. getParam(paramName: string): any;
  13551. /**
  13552. * Sets a specific parameter in the options given to the physics plugin
  13553. * @param paramName The parameter name
  13554. * @param value The value of the parameter
  13555. */
  13556. setParam(paramName: string, value: number): void;
  13557. /**
  13558. * Specifically change the body's mass option. Won't recreate the physics body object
  13559. * @param mass The mass of the physics imposter
  13560. */
  13561. setMass(mass: number): void;
  13562. /**
  13563. * Gets the linear velocity
  13564. * @returns linear velocity or null
  13565. */
  13566. getLinearVelocity(): Nullable<Vector3>;
  13567. /**
  13568. * Sets the linear velocity
  13569. * @param velocity linear velocity or null
  13570. */
  13571. setLinearVelocity(velocity: Nullable<Vector3>): void;
  13572. /**
  13573. * Gets the angular velocity
  13574. * @returns angular velocity or null
  13575. */
  13576. getAngularVelocity(): Nullable<Vector3>;
  13577. /**
  13578. * Sets the angular velocity
  13579. * @param velocity The velocity or null
  13580. */
  13581. setAngularVelocity(velocity: Nullable<Vector3>): void;
  13582. /**
  13583. * Execute a function with the physics plugin native code
  13584. * Provide a function the will have two variables - the world object and the physics body object
  13585. * @param func The function to execute with the physics plugin native code
  13586. */
  13587. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  13588. /**
  13589. * Register a function that will be executed before the physics world is stepping forward
  13590. * @param func The function to execute before the physics world is stepped forward
  13591. */
  13592. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  13593. /**
  13594. * Unregister a function that will be executed before the physics world is stepping forward
  13595. * @param func The function to execute before the physics world is stepped forward
  13596. */
  13597. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  13598. /**
  13599. * Register a function that will be executed after the physics step
  13600. * @param func The function to execute after physics step
  13601. */
  13602. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  13603. /**
  13604. * Unregisters a function that will be executed after the physics step
  13605. * @param func The function to execute after physics step
  13606. */
  13607. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  13608. /**
  13609. * register a function that will be executed when this impostor collides against a different body
  13610. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  13611. * @param func Callback that is executed on collision
  13612. */
  13613. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  13614. /**
  13615. * Unregisters the physics imposter on contact
  13616. * @param collideAgainst The physics object to collide against
  13617. * @param func Callback to execute on collision
  13618. */
  13619. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  13620. private _tmpQuat;
  13621. private _tmpQuat2;
  13622. /**
  13623. * Get the parent rotation
  13624. * @returns The parent rotation
  13625. */
  13626. getParentsRotation(): Quaternion;
  13627. /**
  13628. * this function is executed by the physics engine.
  13629. */
  13630. beforeStep: () => void;
  13631. /**
  13632. * this function is executed by the physics engine
  13633. */
  13634. afterStep: () => void;
  13635. /**
  13636. * Legacy collision detection event support
  13637. */
  13638. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  13639. /**
  13640. * event and body object due to cannon's event-based architecture.
  13641. */
  13642. onCollide: (e: {
  13643. body: any;
  13644. }) => void;
  13645. /**
  13646. * Apply a force
  13647. * @param force The force to apply
  13648. * @param contactPoint The contact point for the force
  13649. * @returns The physics imposter
  13650. */
  13651. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  13652. /**
  13653. * Apply an impulse
  13654. * @param force The impulse force
  13655. * @param contactPoint The contact point for the impulse force
  13656. * @returns The physics imposter
  13657. */
  13658. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  13659. /**
  13660. * A help function to create a joint
  13661. * @param otherImpostor A physics imposter used to create a joint
  13662. * @param jointType The type of joint
  13663. * @param jointData The data for the joint
  13664. * @returns The physics imposter
  13665. */
  13666. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  13667. /**
  13668. * Add a joint to this impostor with a different impostor
  13669. * @param otherImpostor A physics imposter used to add a joint
  13670. * @param joint The joint to add
  13671. * @returns The physics imposter
  13672. */
  13673. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  13674. /**
  13675. * Add an anchor to a cloth impostor
  13676. * @param otherImpostor rigid impostor to anchor to
  13677. * @param width ratio across width from 0 to 1
  13678. * @param height ratio up height from 0 to 1
  13679. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  13680. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  13681. * @returns impostor the soft imposter
  13682. */
  13683. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  13684. /**
  13685. * Add a hook to a rope impostor
  13686. * @param otherImpostor rigid impostor to anchor to
  13687. * @param length ratio across rope from 0 to 1
  13688. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  13689. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  13690. * @returns impostor the rope imposter
  13691. */
  13692. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  13693. /**
  13694. * Will keep this body still, in a sleep mode.
  13695. * @returns the physics imposter
  13696. */
  13697. sleep(): PhysicsImpostor;
  13698. /**
  13699. * Wake the body up.
  13700. * @returns The physics imposter
  13701. */
  13702. wakeUp(): PhysicsImpostor;
  13703. /**
  13704. * Clones the physics imposter
  13705. * @param newObject The physics imposter clones to this physics-enabled object
  13706. * @returns A nullable physics imposter
  13707. */
  13708. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  13709. /**
  13710. * Disposes the physics imposter
  13711. */
  13712. dispose(): void;
  13713. /**
  13714. * Sets the delta position
  13715. * @param position The delta position amount
  13716. */
  13717. setDeltaPosition(position: Vector3): void;
  13718. /**
  13719. * Sets the delta rotation
  13720. * @param rotation The delta rotation amount
  13721. */
  13722. setDeltaRotation(rotation: Quaternion): void;
  13723. /**
  13724. * Gets the box size of the physics imposter and stores the result in the input parameter
  13725. * @param result Stores the box size
  13726. * @returns The physics imposter
  13727. */
  13728. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  13729. /**
  13730. * Gets the radius of the physics imposter
  13731. * @returns Radius of the physics imposter
  13732. */
  13733. getRadius(): number;
  13734. /**
  13735. * Sync a bone with this impostor
  13736. * @param bone The bone to sync to the impostor.
  13737. * @param boneMesh The mesh that the bone is influencing.
  13738. * @param jointPivot The pivot of the joint / bone in local space.
  13739. * @param distToJoint Optional distance from the impostor to the joint.
  13740. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  13741. */
  13742. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  13743. /**
  13744. * Sync impostor to a bone
  13745. * @param bone The bone that the impostor will be synced to.
  13746. * @param boneMesh The mesh that the bone is influencing.
  13747. * @param jointPivot The pivot of the joint / bone in local space.
  13748. * @param distToJoint Optional distance from the impostor to the joint.
  13749. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  13750. * @param boneAxis Optional vector3 axis the bone is aligned with
  13751. */
  13752. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  13753. /**
  13754. * No-Imposter type
  13755. */
  13756. static NoImpostor: number;
  13757. /**
  13758. * Sphere-Imposter type
  13759. */
  13760. static SphereImpostor: number;
  13761. /**
  13762. * Box-Imposter type
  13763. */
  13764. static BoxImpostor: number;
  13765. /**
  13766. * Plane-Imposter type
  13767. */
  13768. static PlaneImpostor: number;
  13769. /**
  13770. * Mesh-imposter type
  13771. */
  13772. static MeshImpostor: number;
  13773. /**
  13774. * Cylinder-Imposter type
  13775. */
  13776. static CylinderImpostor: number;
  13777. /**
  13778. * Particle-Imposter type
  13779. */
  13780. static ParticleImpostor: number;
  13781. /**
  13782. * Heightmap-Imposter type
  13783. */
  13784. static HeightmapImpostor: number;
  13785. /**
  13786. * ConvexHull-Impostor type (Ammo.js plugin only)
  13787. */
  13788. static ConvexHullImpostor: number;
  13789. /**
  13790. * Rope-Imposter type
  13791. */
  13792. static RopeImpostor: number;
  13793. /**
  13794. * Cloth-Imposter type
  13795. */
  13796. static ClothImpostor: number;
  13797. /**
  13798. * Softbody-Imposter type
  13799. */
  13800. static SoftbodyImpostor: number;
  13801. }
  13802. }
  13803. declare module BABYLON {
  13804. /**
  13805. * @hidden
  13806. **/
  13807. export class _CreationDataStorage {
  13808. closePath?: boolean;
  13809. closeArray?: boolean;
  13810. idx: number[];
  13811. dashSize: number;
  13812. gapSize: number;
  13813. path3D: Path3D;
  13814. pathArray: Vector3[][];
  13815. arc: number;
  13816. radius: number;
  13817. cap: number;
  13818. tessellation: number;
  13819. }
  13820. /**
  13821. * @hidden
  13822. **/
  13823. class _InstanceDataStorage {
  13824. visibleInstances: any;
  13825. batchCache: _InstancesBatch;
  13826. instancesBufferSize: number;
  13827. instancesBuffer: Nullable<Buffer>;
  13828. instancesData: Float32Array;
  13829. overridenInstanceCount: number;
  13830. isFrozen: boolean;
  13831. previousBatch: _InstancesBatch;
  13832. hardwareInstancedRendering: boolean;
  13833. sideOrientation: number;
  13834. }
  13835. /**
  13836. * @hidden
  13837. **/
  13838. export class _InstancesBatch {
  13839. mustReturn: boolean;
  13840. visibleInstances: Nullable<InstancedMesh[]>[];
  13841. renderSelf: boolean[];
  13842. hardwareInstancedRendering: boolean[];
  13843. }
  13844. /**
  13845. * Class used to represent renderable models
  13846. */
  13847. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  13848. /**
  13849. * Mesh side orientation : usually the external or front surface
  13850. */
  13851. static readonly FRONTSIDE: number;
  13852. /**
  13853. * Mesh side orientation : usually the internal or back surface
  13854. */
  13855. static readonly BACKSIDE: number;
  13856. /**
  13857. * Mesh side orientation : both internal and external or front and back surfaces
  13858. */
  13859. static readonly DOUBLESIDE: number;
  13860. /**
  13861. * Mesh side orientation : by default, `FRONTSIDE`
  13862. */
  13863. static readonly DEFAULTSIDE: number;
  13864. /**
  13865. * Mesh cap setting : no cap
  13866. */
  13867. static readonly NO_CAP: number;
  13868. /**
  13869. * Mesh cap setting : one cap at the beginning of the mesh
  13870. */
  13871. static readonly CAP_START: number;
  13872. /**
  13873. * Mesh cap setting : one cap at the end of the mesh
  13874. */
  13875. static readonly CAP_END: number;
  13876. /**
  13877. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  13878. */
  13879. static readonly CAP_ALL: number;
  13880. /**
  13881. * Mesh pattern setting : no flip or rotate
  13882. */
  13883. static readonly NO_FLIP: number;
  13884. /**
  13885. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  13886. */
  13887. static readonly FLIP_TILE: number;
  13888. /**
  13889. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  13890. */
  13891. static readonly ROTATE_TILE: number;
  13892. /**
  13893. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  13894. */
  13895. static readonly FLIP_ROW: number;
  13896. /**
  13897. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  13898. */
  13899. static readonly ROTATE_ROW: number;
  13900. /**
  13901. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  13902. */
  13903. static readonly FLIP_N_ROTATE_TILE: number;
  13904. /**
  13905. * Mesh pattern setting : rotate pattern and rotate
  13906. */
  13907. static readonly FLIP_N_ROTATE_ROW: number;
  13908. /**
  13909. * Mesh tile positioning : part tiles same on left/right or top/bottom
  13910. */
  13911. static readonly CENTER: number;
  13912. /**
  13913. * Mesh tile positioning : part tiles on left
  13914. */
  13915. static readonly LEFT: number;
  13916. /**
  13917. * Mesh tile positioning : part tiles on right
  13918. */
  13919. static readonly RIGHT: number;
  13920. /**
  13921. * Mesh tile positioning : part tiles on top
  13922. */
  13923. static readonly TOP: number;
  13924. /**
  13925. * Mesh tile positioning : part tiles on bottom
  13926. */
  13927. static readonly BOTTOM: number;
  13928. /**
  13929. * Gets the default side orientation.
  13930. * @param orientation the orientation to value to attempt to get
  13931. * @returns the default orientation
  13932. * @hidden
  13933. */
  13934. static _GetDefaultSideOrientation(orientation?: number): number;
  13935. private _internalMeshDataInfo;
  13936. /**
  13937. * An event triggered before rendering the mesh
  13938. */
  13939. readonly onBeforeRenderObservable: Observable<Mesh>;
  13940. /**
  13941. * An event triggered before binding the mesh
  13942. */
  13943. readonly onBeforeBindObservable: Observable<Mesh>;
  13944. /**
  13945. * An event triggered after rendering the mesh
  13946. */
  13947. readonly onAfterRenderObservable: Observable<Mesh>;
  13948. /**
  13949. * An event triggered before drawing the mesh
  13950. */
  13951. readonly onBeforeDrawObservable: Observable<Mesh>;
  13952. private _onBeforeDrawObserver;
  13953. /**
  13954. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  13955. */
  13956. onBeforeDraw: () => void;
  13957. /**
  13958. * Gets the delay loading state of the mesh (when delay loading is turned on)
  13959. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  13960. */
  13961. delayLoadState: number;
  13962. /**
  13963. * Gets the list of instances created from this mesh
  13964. * it is not supposed to be modified manually.
  13965. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  13966. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  13967. */
  13968. instances: InstancedMesh[];
  13969. /**
  13970. * Gets the file containing delay loading data for this mesh
  13971. */
  13972. delayLoadingFile: string;
  13973. /** @hidden */
  13974. _binaryInfo: any;
  13975. /**
  13976. * User defined function used to change how LOD level selection is done
  13977. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  13978. */
  13979. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  13980. /**
  13981. * Gets or sets the morph target manager
  13982. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  13983. */
  13984. morphTargetManager: Nullable<MorphTargetManager>;
  13985. /** @hidden */
  13986. _creationDataStorage: Nullable<_CreationDataStorage>;
  13987. /** @hidden */
  13988. _geometry: Nullable<Geometry>;
  13989. /** @hidden */
  13990. _delayInfo: Array<string>;
  13991. /** @hidden */
  13992. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  13993. /** @hidden */
  13994. _instanceDataStorage: _InstanceDataStorage;
  13995. private _effectiveMaterial;
  13996. /** @hidden */
  13997. _shouldGenerateFlatShading: boolean;
  13998. /** @hidden */
  13999. _originalBuilderSideOrientation: number;
  14000. /**
  14001. * Use this property to change the original side orientation defined at construction time
  14002. */
  14003. overrideMaterialSideOrientation: Nullable<number>;
  14004. /**
  14005. * Gets the source mesh (the one used to clone this one from)
  14006. */
  14007. readonly source: Nullable<Mesh>;
  14008. /**
  14009. * Gets or sets a boolean indicating that this mesh does not use index buffer
  14010. */
  14011. isUnIndexed: boolean;
  14012. /**
  14013. * @constructor
  14014. * @param name The value used by scene.getMeshByName() to do a lookup.
  14015. * @param scene The scene to add this mesh to.
  14016. * @param parent The parent of this mesh, if it has one
  14017. * @param source An optional Mesh from which geometry is shared, cloned.
  14018. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  14019. * When false, achieved by calling a clone(), also passing False.
  14020. * This will make creation of children, recursive.
  14021. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  14022. */
  14023. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  14024. /**
  14025. * Gets the class name
  14026. * @returns the string "Mesh".
  14027. */
  14028. getClassName(): string;
  14029. /** @hidden */
  14030. readonly _isMesh: boolean;
  14031. /**
  14032. * Returns a description of this mesh
  14033. * @param fullDetails define if full details about this mesh must be used
  14034. * @returns a descriptive string representing this mesh
  14035. */
  14036. toString(fullDetails?: boolean): string;
  14037. /** @hidden */
  14038. _unBindEffect(): void;
  14039. /**
  14040. * Gets a boolean indicating if this mesh has LOD
  14041. */
  14042. readonly hasLODLevels: boolean;
  14043. /**
  14044. * Gets the list of MeshLODLevel associated with the current mesh
  14045. * @returns an array of MeshLODLevel
  14046. */
  14047. getLODLevels(): MeshLODLevel[];
  14048. private _sortLODLevels;
  14049. /**
  14050. * Add a mesh as LOD level triggered at the given distance.
  14051. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  14052. * @param distance The distance from the center of the object to show this level
  14053. * @param mesh The mesh to be added as LOD level (can be null)
  14054. * @return This mesh (for chaining)
  14055. */
  14056. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  14057. /**
  14058. * Returns the LOD level mesh at the passed distance or null if not found.
  14059. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  14060. * @param distance The distance from the center of the object to show this level
  14061. * @returns a Mesh or `null`
  14062. */
  14063. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  14064. /**
  14065. * Remove a mesh from the LOD array
  14066. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  14067. * @param mesh defines the mesh to be removed
  14068. * @return This mesh (for chaining)
  14069. */
  14070. removeLODLevel(mesh: Mesh): Mesh;
  14071. /**
  14072. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  14073. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  14074. * @param camera defines the camera to use to compute distance
  14075. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  14076. * @return This mesh (for chaining)
  14077. */
  14078. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  14079. /**
  14080. * Gets the mesh internal Geometry object
  14081. */
  14082. readonly geometry: Nullable<Geometry>;
  14083. /**
  14084. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  14085. * @returns the total number of vertices
  14086. */
  14087. getTotalVertices(): number;
  14088. /**
  14089. * Returns the content of an associated vertex buffer
  14090. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  14091. * - VertexBuffer.PositionKind
  14092. * - VertexBuffer.UVKind
  14093. * - VertexBuffer.UV2Kind
  14094. * - VertexBuffer.UV3Kind
  14095. * - VertexBuffer.UV4Kind
  14096. * - VertexBuffer.UV5Kind
  14097. * - VertexBuffer.UV6Kind
  14098. * - VertexBuffer.ColorKind
  14099. * - VertexBuffer.MatricesIndicesKind
  14100. * - VertexBuffer.MatricesIndicesExtraKind
  14101. * - VertexBuffer.MatricesWeightsKind
  14102. * - VertexBuffer.MatricesWeightsExtraKind
  14103. * @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
  14104. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  14105. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  14106. */
  14107. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  14108. /**
  14109. * Returns the mesh VertexBuffer object from the requested `kind`
  14110. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  14111. * - VertexBuffer.PositionKind
  14112. * - VertexBuffer.NormalKind
  14113. * - VertexBuffer.UVKind
  14114. * - VertexBuffer.UV2Kind
  14115. * - VertexBuffer.UV3Kind
  14116. * - VertexBuffer.UV4Kind
  14117. * - VertexBuffer.UV5Kind
  14118. * - VertexBuffer.UV6Kind
  14119. * - VertexBuffer.ColorKind
  14120. * - VertexBuffer.MatricesIndicesKind
  14121. * - VertexBuffer.MatricesIndicesExtraKind
  14122. * - VertexBuffer.MatricesWeightsKind
  14123. * - VertexBuffer.MatricesWeightsExtraKind
  14124. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  14125. */
  14126. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  14127. /**
  14128. * Tests if a specific vertex buffer is associated with this mesh
  14129. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  14130. * - VertexBuffer.PositionKind
  14131. * - VertexBuffer.NormalKind
  14132. * - VertexBuffer.UVKind
  14133. * - VertexBuffer.UV2Kind
  14134. * - VertexBuffer.UV3Kind
  14135. * - VertexBuffer.UV4Kind
  14136. * - VertexBuffer.UV5Kind
  14137. * - VertexBuffer.UV6Kind
  14138. * - VertexBuffer.ColorKind
  14139. * - VertexBuffer.MatricesIndicesKind
  14140. * - VertexBuffer.MatricesIndicesExtraKind
  14141. * - VertexBuffer.MatricesWeightsKind
  14142. * - VertexBuffer.MatricesWeightsExtraKind
  14143. * @returns a boolean
  14144. */
  14145. isVerticesDataPresent(kind: string): boolean;
  14146. /**
  14147. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  14148. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  14149. * - VertexBuffer.PositionKind
  14150. * - VertexBuffer.UVKind
  14151. * - VertexBuffer.UV2Kind
  14152. * - VertexBuffer.UV3Kind
  14153. * - VertexBuffer.UV4Kind
  14154. * - VertexBuffer.UV5Kind
  14155. * - VertexBuffer.UV6Kind
  14156. * - VertexBuffer.ColorKind
  14157. * - VertexBuffer.MatricesIndicesKind
  14158. * - VertexBuffer.MatricesIndicesExtraKind
  14159. * - VertexBuffer.MatricesWeightsKind
  14160. * - VertexBuffer.MatricesWeightsExtraKind
  14161. * @returns a boolean
  14162. */
  14163. isVertexBufferUpdatable(kind: string): boolean;
  14164. /**
  14165. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  14166. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  14167. * - VertexBuffer.PositionKind
  14168. * - VertexBuffer.NormalKind
  14169. * - VertexBuffer.UVKind
  14170. * - VertexBuffer.UV2Kind
  14171. * - VertexBuffer.UV3Kind
  14172. * - VertexBuffer.UV4Kind
  14173. * - VertexBuffer.UV5Kind
  14174. * - VertexBuffer.UV6Kind
  14175. * - VertexBuffer.ColorKind
  14176. * - VertexBuffer.MatricesIndicesKind
  14177. * - VertexBuffer.MatricesIndicesExtraKind
  14178. * - VertexBuffer.MatricesWeightsKind
  14179. * - VertexBuffer.MatricesWeightsExtraKind
  14180. * @returns an array of strings
  14181. */
  14182. getVerticesDataKinds(): string[];
  14183. /**
  14184. * Returns a positive integer : the total number of indices in this mesh geometry.
  14185. * @returns the numner of indices or zero if the mesh has no geometry.
  14186. */
  14187. getTotalIndices(): number;
  14188. /**
  14189. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  14190. * @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.
  14191. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  14192. * @returns the indices array or an empty array if the mesh has no geometry
  14193. */
  14194. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  14195. readonly isBlocked: boolean;
  14196. /**
  14197. * Determine if the current mesh is ready to be rendered
  14198. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  14199. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  14200. * @returns true if all associated assets are ready (material, textures, shaders)
  14201. */
  14202. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  14203. /**
  14204. * 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.
  14205. */
  14206. readonly areNormalsFrozen: boolean;
  14207. /**
  14208. * 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.
  14209. * @returns the current mesh
  14210. */
  14211. freezeNormals(): Mesh;
  14212. /**
  14213. * 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
  14214. * @returns the current mesh
  14215. */
  14216. unfreezeNormals(): Mesh;
  14217. /**
  14218. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  14219. */
  14220. overridenInstanceCount: number;
  14221. /** @hidden */
  14222. _preActivate(): Mesh;
  14223. /** @hidden */
  14224. _preActivateForIntermediateRendering(renderId: number): Mesh;
  14225. /** @hidden */
  14226. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  14227. /**
  14228. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  14229. * This means the mesh underlying bounding box and sphere are recomputed.
  14230. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  14231. * @returns the current mesh
  14232. */
  14233. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  14234. /** @hidden */
  14235. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  14236. /**
  14237. * This function will subdivide the mesh into multiple submeshes
  14238. * @param count defines the expected number of submeshes
  14239. */
  14240. subdivide(count: number): void;
  14241. /**
  14242. * Copy a FloatArray into a specific associated vertex buffer
  14243. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  14244. * - VertexBuffer.PositionKind
  14245. * - VertexBuffer.UVKind
  14246. * - VertexBuffer.UV2Kind
  14247. * - VertexBuffer.UV3Kind
  14248. * - VertexBuffer.UV4Kind
  14249. * - VertexBuffer.UV5Kind
  14250. * - VertexBuffer.UV6Kind
  14251. * - VertexBuffer.ColorKind
  14252. * - VertexBuffer.MatricesIndicesKind
  14253. * - VertexBuffer.MatricesIndicesExtraKind
  14254. * - VertexBuffer.MatricesWeightsKind
  14255. * - VertexBuffer.MatricesWeightsExtraKind
  14256. * @param data defines the data source
  14257. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  14258. * @param stride defines the data stride size (can be null)
  14259. * @returns the current mesh
  14260. */
  14261. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  14262. /**
  14263. * Flags an associated vertex buffer as updatable
  14264. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  14265. * - VertexBuffer.PositionKind
  14266. * - VertexBuffer.UVKind
  14267. * - VertexBuffer.UV2Kind
  14268. * - VertexBuffer.UV3Kind
  14269. * - VertexBuffer.UV4Kind
  14270. * - VertexBuffer.UV5Kind
  14271. * - VertexBuffer.UV6Kind
  14272. * - VertexBuffer.ColorKind
  14273. * - VertexBuffer.MatricesIndicesKind
  14274. * - VertexBuffer.MatricesIndicesExtraKind
  14275. * - VertexBuffer.MatricesWeightsKind
  14276. * - VertexBuffer.MatricesWeightsExtraKind
  14277. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  14278. */
  14279. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  14280. /**
  14281. * Sets the mesh global Vertex Buffer
  14282. * @param buffer defines the buffer to use
  14283. * @returns the current mesh
  14284. */
  14285. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  14286. /**
  14287. * Update a specific associated vertex buffer
  14288. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  14289. * - VertexBuffer.PositionKind
  14290. * - VertexBuffer.UVKind
  14291. * - VertexBuffer.UV2Kind
  14292. * - VertexBuffer.UV3Kind
  14293. * - VertexBuffer.UV4Kind
  14294. * - VertexBuffer.UV5Kind
  14295. * - VertexBuffer.UV6Kind
  14296. * - VertexBuffer.ColorKind
  14297. * - VertexBuffer.MatricesIndicesKind
  14298. * - VertexBuffer.MatricesIndicesExtraKind
  14299. * - VertexBuffer.MatricesWeightsKind
  14300. * - VertexBuffer.MatricesWeightsExtraKind
  14301. * @param data defines the data source
  14302. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  14303. * @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)
  14304. * @returns the current mesh
  14305. */
  14306. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  14307. /**
  14308. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  14309. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  14310. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  14311. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  14312. * @returns the current mesh
  14313. */
  14314. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  14315. /**
  14316. * Creates a un-shared specific occurence of the geometry for the mesh.
  14317. * @returns the current mesh
  14318. */
  14319. makeGeometryUnique(): Mesh;
  14320. /**
  14321. * Set the index buffer of this mesh
  14322. * @param indices defines the source data
  14323. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  14324. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  14325. * @returns the current mesh
  14326. */
  14327. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  14328. /**
  14329. * Update the current index buffer
  14330. * @param indices defines the source data
  14331. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  14332. * @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)
  14333. * @returns the current mesh
  14334. */
  14335. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): Mesh;
  14336. /**
  14337. * Invert the geometry to move from a right handed system to a left handed one.
  14338. * @returns the current mesh
  14339. */
  14340. toLeftHanded(): Mesh;
  14341. /** @hidden */
  14342. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  14343. /** @hidden */
  14344. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  14345. /**
  14346. * Registers for this mesh a javascript function called just before the rendering process
  14347. * @param func defines the function to call before rendering this mesh
  14348. * @returns the current mesh
  14349. */
  14350. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  14351. /**
  14352. * Disposes a previously registered javascript function called before the rendering
  14353. * @param func defines the function to remove
  14354. * @returns the current mesh
  14355. */
  14356. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  14357. /**
  14358. * Registers for this mesh a javascript function called just after the rendering is complete
  14359. * @param func defines the function to call after rendering this mesh
  14360. * @returns the current mesh
  14361. */
  14362. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  14363. /**
  14364. * Disposes a previously registered javascript function called after the rendering.
  14365. * @param func defines the function to remove
  14366. * @returns the current mesh
  14367. */
  14368. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  14369. /** @hidden */
  14370. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  14371. /** @hidden */
  14372. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  14373. /** @hidden */
  14374. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  14375. /** @hidden */
  14376. _freeze(): void;
  14377. /** @hidden */
  14378. _unFreeze(): void;
  14379. /**
  14380. * 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
  14381. * @param subMesh defines the subMesh to render
  14382. * @param enableAlphaMode defines if alpha mode can be changed
  14383. * @returns the current mesh
  14384. */
  14385. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  14386. private _onBeforeDraw;
  14387. /**
  14388. * Renormalize the mesh and patch it up if there are no weights
  14389. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  14390. * However in the case of zero weights then we set just a single influence to 1.
  14391. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  14392. */
  14393. cleanMatrixWeights(): void;
  14394. private normalizeSkinFourWeights;
  14395. private normalizeSkinWeightsAndExtra;
  14396. /**
  14397. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  14398. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  14399. * the user know there was an issue with importing the mesh
  14400. * @returns a validation object with skinned, valid and report string
  14401. */
  14402. validateSkinning(): {
  14403. skinned: boolean;
  14404. valid: boolean;
  14405. report: string;
  14406. };
  14407. /** @hidden */
  14408. _checkDelayState(): Mesh;
  14409. private _queueLoad;
  14410. /**
  14411. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  14412. * A mesh is in the frustum if its bounding box intersects the frustum
  14413. * @param frustumPlanes defines the frustum to test
  14414. * @returns true if the mesh is in the frustum planes
  14415. */
  14416. isInFrustum(frustumPlanes: Plane[]): boolean;
  14417. /**
  14418. * Sets the mesh material by the material or multiMaterial `id` property
  14419. * @param id is a string identifying the material or the multiMaterial
  14420. * @returns the current mesh
  14421. */
  14422. setMaterialByID(id: string): Mesh;
  14423. /**
  14424. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  14425. * @returns an array of IAnimatable
  14426. */
  14427. getAnimatables(): IAnimatable[];
  14428. /**
  14429. * Modifies the mesh geometry according to the passed transformation matrix.
  14430. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  14431. * The mesh normals are modified using the same transformation.
  14432. * Note that, under the hood, this method sets a new VertexBuffer each call.
  14433. * @param transform defines the transform matrix to use
  14434. * @see http://doc.babylonjs.com/resources/baking_transformations
  14435. * @returns the current mesh
  14436. */
  14437. bakeTransformIntoVertices(transform: Matrix): Mesh;
  14438. /**
  14439. * Modifies the mesh geometry according to its own current World Matrix.
  14440. * The mesh World Matrix is then reset.
  14441. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  14442. * Note that, under the hood, this method sets a new VertexBuffer each call.
  14443. * @see http://doc.babylonjs.com/resources/baking_transformations
  14444. * @returns the current mesh
  14445. */
  14446. bakeCurrentTransformIntoVertices(): Mesh;
  14447. /** @hidden */
  14448. readonly _positions: Nullable<Vector3[]>;
  14449. /** @hidden */
  14450. _resetPointsArrayCache(): Mesh;
  14451. /** @hidden */
  14452. _generatePointsArray(): boolean;
  14453. /**
  14454. * Returns a new Mesh object generated from the current mesh properties.
  14455. * This method must not get confused with createInstance()
  14456. * @param name is a string, the name given to the new mesh
  14457. * @param newParent can be any Node object (default `null`)
  14458. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  14459. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  14460. * @returns a new mesh
  14461. */
  14462. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  14463. /**
  14464. * Releases resources associated with this mesh.
  14465. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14466. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14467. */
  14468. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14469. /**
  14470. * Modifies the mesh geometry according to a displacement map.
  14471. * 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.
  14472. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  14473. * @param url is a string, the URL from the image file is to be downloaded.
  14474. * @param minHeight is the lower limit of the displacement.
  14475. * @param maxHeight is the upper limit of the displacement.
  14476. * @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.
  14477. * @param uvOffset is an optional vector2 used to offset UV.
  14478. * @param uvScale is an optional vector2 used to scale UV.
  14479. * @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.
  14480. * @returns the Mesh.
  14481. */
  14482. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  14483. /**
  14484. * Modifies the mesh geometry according to a displacementMap buffer.
  14485. * 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.
  14486. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  14487. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  14488. * @param heightMapWidth is the width of the buffer image.
  14489. * @param heightMapHeight is the height of the buffer image.
  14490. * @param minHeight is the lower limit of the displacement.
  14491. * @param maxHeight is the upper limit of the displacement.
  14492. * @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.
  14493. * @param uvOffset is an optional vector2 used to offset UV.
  14494. * @param uvScale is an optional vector2 used to scale UV.
  14495. * @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.
  14496. * @returns the Mesh.
  14497. */
  14498. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  14499. /**
  14500. * Modify the mesh to get a flat shading rendering.
  14501. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  14502. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  14503. * @returns current mesh
  14504. */
  14505. convertToFlatShadedMesh(): Mesh;
  14506. /**
  14507. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  14508. * In other words, more vertices, no more indices and a single bigger VBO.
  14509. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  14510. * @returns current mesh
  14511. */
  14512. convertToUnIndexedMesh(): Mesh;
  14513. /**
  14514. * Inverses facet orientations.
  14515. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  14516. * @param flipNormals will also inverts the normals
  14517. * @returns current mesh
  14518. */
  14519. flipFaces(flipNormals?: boolean): Mesh;
  14520. /**
  14521. * Increase the number of facets and hence vertices in a mesh
  14522. * Vertex normals are interpolated from existing vertex normals
  14523. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  14524. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  14525. */
  14526. increaseVertices(numberPerEdge: number): void;
  14527. /**
  14528. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  14529. * This will undo any application of covertToFlatShadedMesh
  14530. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  14531. */
  14532. forceSharedVertices(): void;
  14533. /** @hidden */
  14534. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  14535. /** @hidden */
  14536. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  14537. /**
  14538. * Creates a new InstancedMesh object from the mesh model.
  14539. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  14540. * @param name defines the name of the new instance
  14541. * @returns a new InstancedMesh
  14542. */
  14543. createInstance(name: string): InstancedMesh;
  14544. /**
  14545. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  14546. * After this call, all the mesh instances have the same submeshes than the current mesh.
  14547. * @returns the current mesh
  14548. */
  14549. synchronizeInstances(): Mesh;
  14550. /**
  14551. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  14552. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  14553. * This should be used together with the simplification to avoid disappearing triangles.
  14554. * @param successCallback an optional success callback to be called after the optimization finished.
  14555. * @returns the current mesh
  14556. */
  14557. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  14558. /**
  14559. * Serialize current mesh
  14560. * @param serializationObject defines the object which will receive the serialization data
  14561. */
  14562. serialize(serializationObject: any): void;
  14563. /** @hidden */
  14564. _syncGeometryWithMorphTargetManager(): void;
  14565. /** @hidden */
  14566. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  14567. /**
  14568. * Returns a new Mesh object parsed from the source provided.
  14569. * @param parsedMesh is the source
  14570. * @param scene defines the hosting scene
  14571. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  14572. * @returns a new Mesh
  14573. */
  14574. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  14575. /**
  14576. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  14577. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  14578. * @param name defines the name of the mesh to create
  14579. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  14580. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  14581. * @param closePath creates a seam between the first and the last points of each path of the path array
  14582. * @param offset is taken in account only if the `pathArray` is containing a single path
  14583. * @param scene defines the hosting scene
  14584. * @param updatable defines if the mesh must be flagged as updatable
  14585. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  14586. * @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)
  14587. * @returns a new Mesh
  14588. */
  14589. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  14590. /**
  14591. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  14592. * @param name defines the name of the mesh to create
  14593. * @param radius sets the radius size (float) of the polygon (default 0.5)
  14594. * @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
  14595. * @param scene defines the hosting scene
  14596. * @param updatable defines if the mesh must be flagged as updatable
  14597. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  14598. * @returns a new Mesh
  14599. */
  14600. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  14601. /**
  14602. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  14603. * @param name defines the name of the mesh to create
  14604. * @param size sets the size (float) of each box side (default 1)
  14605. * @param scene defines the hosting scene
  14606. * @param updatable defines if the mesh must be flagged as updatable
  14607. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  14608. * @returns a new Mesh
  14609. */
  14610. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  14611. /**
  14612. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  14613. * @param name defines the name of the mesh to create
  14614. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  14615. * @param diameter sets the diameter size (float) of the sphere (default 1)
  14616. * @param scene defines the hosting scene
  14617. * @param updatable defines if the mesh must be flagged as updatable
  14618. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  14619. * @returns a new Mesh
  14620. */
  14621. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  14622. /**
  14623. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  14624. * @param name defines the name of the mesh to create
  14625. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  14626. * @param diameter sets the diameter size (float) of the sphere (default 1)
  14627. * @param scene defines the hosting scene
  14628. * @returns a new Mesh
  14629. */
  14630. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  14631. /**
  14632. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  14633. * @param name defines the name of the mesh to create
  14634. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  14635. * @param diameterTop set the top cap diameter (floats, default 1)
  14636. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  14637. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  14638. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  14639. * @param scene defines the hosting scene
  14640. * @param updatable defines if the mesh must be flagged as updatable
  14641. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  14642. * @returns a new Mesh
  14643. */
  14644. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  14645. /**
  14646. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  14647. * @param name defines the name of the mesh to create
  14648. * @param diameter sets the diameter size (float) of the torus (default 1)
  14649. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  14650. * @param tessellation sets the number of torus sides (postive integer, default 16)
  14651. * @param scene defines the hosting scene
  14652. * @param updatable defines if the mesh must be flagged as updatable
  14653. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  14654. * @returns a new Mesh
  14655. */
  14656. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  14657. /**
  14658. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  14659. * @param name defines the name of the mesh to create
  14660. * @param radius sets the global radius size (float) of the torus knot (default 2)
  14661. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  14662. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  14663. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  14664. * @param p the number of windings on X axis (positive integers, default 2)
  14665. * @param q the number of windings on Y axis (positive integers, default 3)
  14666. * @param scene defines the hosting scene
  14667. * @param updatable defines if the mesh must be flagged as updatable
  14668. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  14669. * @returns a new Mesh
  14670. */
  14671. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  14672. /**
  14673. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  14674. * @param name defines the name of the mesh to create
  14675. * @param points is an array successive Vector3
  14676. * @param scene defines the hosting scene
  14677. * @param updatable defines if the mesh must be flagged as updatable
  14678. * @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).
  14679. * @returns a new Mesh
  14680. */
  14681. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  14682. /**
  14683. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  14684. * @param name defines the name of the mesh to create
  14685. * @param points is an array successive Vector3
  14686. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  14687. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  14688. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  14689. * @param scene defines the hosting scene
  14690. * @param updatable defines if the mesh must be flagged as updatable
  14691. * @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)
  14692. * @returns a new Mesh
  14693. */
  14694. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  14695. /**
  14696. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  14697. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  14698. * 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.
  14699. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  14700. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  14701. * Remember you can only change the shape positions, not their number when updating a polygon.
  14702. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  14703. * @param name defines the name of the mesh to create
  14704. * @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
  14705. * @param scene defines the hosting scene
  14706. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  14707. * @param updatable defines if the mesh must be flagged as updatable
  14708. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  14709. * @param earcutInjection can be used to inject your own earcut reference
  14710. * @returns a new Mesh
  14711. */
  14712. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  14713. /**
  14714. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  14715. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  14716. * @param name defines the name of the mesh to create
  14717. * @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
  14718. * @param depth defines the height of extrusion
  14719. * @param scene defines the hosting scene
  14720. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  14721. * @param updatable defines if the mesh must be flagged as updatable
  14722. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  14723. * @param earcutInjection can be used to inject your own earcut reference
  14724. * @returns a new Mesh
  14725. */
  14726. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  14727. /**
  14728. * Creates an extruded shape mesh.
  14729. * 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
  14730. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  14731. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  14732. * @param name defines the name of the mesh to create
  14733. * @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
  14734. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  14735. * @param scale is the value to scale the shape
  14736. * @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
  14737. * @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
  14738. * @param scene defines the hosting scene
  14739. * @param updatable defines if the mesh must be flagged as updatable
  14740. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  14741. * @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)
  14742. * @returns a new Mesh
  14743. */
  14744. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  14745. /**
  14746. * Creates an custom extruded shape mesh.
  14747. * The custom extrusion is a parametric shape.
  14748. * It has no predefined shape. Its final shape will depend on the input parameters.
  14749. * Please consider using the same method from the MeshBuilder class instead
  14750. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  14751. * @param name defines the name of the mesh to create
  14752. * @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
  14753. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  14754. * @param scaleFunction is a custom Javascript function called on each path point
  14755. * @param rotationFunction is a custom Javascript function called on each path point
  14756. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  14757. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  14758. * @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
  14759. * @param scene defines the hosting scene
  14760. * @param updatable defines if the mesh must be flagged as updatable
  14761. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  14762. * @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)
  14763. * @returns a new Mesh
  14764. */
  14765. 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;
  14766. /**
  14767. * Creates lathe mesh.
  14768. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  14769. * Please consider using the same method from the MeshBuilder class instead
  14770. * @param name defines the name of the mesh to create
  14771. * @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
  14772. * @param radius is the radius value of the lathe
  14773. * @param tessellation is the side number of the lathe.
  14774. * @param scene defines the hosting scene
  14775. * @param updatable defines if the mesh must be flagged as updatable
  14776. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  14777. * @returns a new Mesh
  14778. */
  14779. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  14780. /**
  14781. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  14782. * @param name defines the name of the mesh to create
  14783. * @param size sets the size (float) of both sides of the plane at once (default 1)
  14784. * @param scene defines the hosting scene
  14785. * @param updatable defines if the mesh must be flagged as updatable
  14786. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  14787. * @returns a new Mesh
  14788. */
  14789. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  14790. /**
  14791. * Creates a ground mesh.
  14792. * Please consider using the same method from the MeshBuilder class instead
  14793. * @param name defines the name of the mesh to create
  14794. * @param width set the width of the ground
  14795. * @param height set the height of the ground
  14796. * @param subdivisions sets the number of subdivisions per side
  14797. * @param scene defines the hosting scene
  14798. * @param updatable defines if the mesh must be flagged as updatable
  14799. * @returns a new Mesh
  14800. */
  14801. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  14802. /**
  14803. * Creates a tiled ground mesh.
  14804. * Please consider using the same method from the MeshBuilder class instead
  14805. * @param name defines the name of the mesh to create
  14806. * @param xmin set the ground minimum X coordinate
  14807. * @param zmin set the ground minimum Y coordinate
  14808. * @param xmax set the ground maximum X coordinate
  14809. * @param zmax set the ground maximum Z coordinate
  14810. * @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
  14811. * @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
  14812. * @param scene defines the hosting scene
  14813. * @param updatable defines if the mesh must be flagged as updatable
  14814. * @returns a new Mesh
  14815. */
  14816. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  14817. w: number;
  14818. h: number;
  14819. }, precision: {
  14820. w: number;
  14821. h: number;
  14822. }, scene: Scene, updatable?: boolean): Mesh;
  14823. /**
  14824. * Creates a ground mesh from a height map.
  14825. * Please consider using the same method from the MeshBuilder class instead
  14826. * @see http://doc.babylonjs.com/babylon101/height_map
  14827. * @param name defines the name of the mesh to create
  14828. * @param url sets the URL of the height map image resource
  14829. * @param width set the ground width size
  14830. * @param height set the ground height size
  14831. * @param subdivisions sets the number of subdivision per side
  14832. * @param minHeight is the minimum altitude on the ground
  14833. * @param maxHeight is the maximum altitude on the ground
  14834. * @param scene defines the hosting scene
  14835. * @param updatable defines if the mesh must be flagged as updatable
  14836. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  14837. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  14838. * @returns a new Mesh
  14839. */
  14840. 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;
  14841. /**
  14842. * Creates a tube mesh.
  14843. * The tube is a parametric shape.
  14844. * It has no predefined shape. Its final shape will depend on the input parameters.
  14845. * Please consider using the same method from the MeshBuilder class instead
  14846. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  14847. * @param name defines the name of the mesh to create
  14848. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  14849. * @param radius sets the tube radius size
  14850. * @param tessellation is the number of sides on the tubular surface
  14851. * @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
  14852. * @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
  14853. * @param scene defines the hosting scene
  14854. * @param updatable defines if the mesh must be flagged as updatable
  14855. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  14856. * @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)
  14857. * @returns a new Mesh
  14858. */
  14859. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  14860. (i: number, distance: number): number;
  14861. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  14862. /**
  14863. * Creates a polyhedron mesh.
  14864. * Please consider using the same method from the MeshBuilder class instead.
  14865. * * 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
  14866. * * The parameter `size` (positive float, default 1) sets the polygon size
  14867. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  14868. * * 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`
  14869. * * 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
  14870. * * 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)`)
  14871. * * 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
  14872. * * 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
  14873. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  14874. * * 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
  14875. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  14876. * @param name defines the name of the mesh to create
  14877. * @param options defines the options used to create the mesh
  14878. * @param scene defines the hosting scene
  14879. * @returns a new Mesh
  14880. */
  14881. static CreatePolyhedron(name: string, options: {
  14882. type?: number;
  14883. size?: number;
  14884. sizeX?: number;
  14885. sizeY?: number;
  14886. sizeZ?: number;
  14887. custom?: any;
  14888. faceUV?: Vector4[];
  14889. faceColors?: Color4[];
  14890. updatable?: boolean;
  14891. sideOrientation?: number;
  14892. }, scene: Scene): Mesh;
  14893. /**
  14894. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  14895. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  14896. * * 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`)
  14897. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  14898. * * 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
  14899. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  14900. * * 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
  14901. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  14902. * @param name defines the name of the mesh
  14903. * @param options defines the options used to create the mesh
  14904. * @param scene defines the hosting scene
  14905. * @returns a new Mesh
  14906. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  14907. */
  14908. static CreateIcoSphere(name: string, options: {
  14909. radius?: number;
  14910. flat?: boolean;
  14911. subdivisions?: number;
  14912. sideOrientation?: number;
  14913. updatable?: boolean;
  14914. }, scene: Scene): Mesh;
  14915. /**
  14916. * Creates a decal mesh.
  14917. * Please consider using the same method from the MeshBuilder class instead.
  14918. * A decal is a mesh usually applied as a model onto the surface of another mesh
  14919. * @param name defines the name of the mesh
  14920. * @param sourceMesh defines the mesh receiving the decal
  14921. * @param position sets the position of the decal in world coordinates
  14922. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  14923. * @param size sets the decal scaling
  14924. * @param angle sets the angle to rotate the decal
  14925. * @returns a new Mesh
  14926. */
  14927. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  14928. /**
  14929. * Prepare internal position array for software CPU skinning
  14930. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  14931. */
  14932. setPositionsForCPUSkinning(): Float32Array;
  14933. /**
  14934. * Prepare internal normal array for software CPU skinning
  14935. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  14936. */
  14937. setNormalsForCPUSkinning(): Float32Array;
  14938. /**
  14939. * Updates the vertex buffer by applying transformation from the bones
  14940. * @param skeleton defines the skeleton to apply to current mesh
  14941. * @returns the current mesh
  14942. */
  14943. applySkeleton(skeleton: Skeleton): Mesh;
  14944. /**
  14945. * 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
  14946. * @param meshes defines the list of meshes to scan
  14947. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  14948. */
  14949. static MinMax(meshes: AbstractMesh[]): {
  14950. min: Vector3;
  14951. max: Vector3;
  14952. };
  14953. /**
  14954. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  14955. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  14956. * @returns a vector3
  14957. */
  14958. static Center(meshesOrMinMaxVector: {
  14959. min: Vector3;
  14960. max: Vector3;
  14961. } | AbstractMesh[]): Vector3;
  14962. /**
  14963. * Merge the array of meshes into a single mesh for performance reasons.
  14964. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  14965. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  14966. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  14967. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  14968. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  14969. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  14970. * @returns a new mesh
  14971. */
  14972. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  14973. /** @hidden */
  14974. addInstance(instance: InstancedMesh): void;
  14975. /** @hidden */
  14976. removeInstance(instance: InstancedMesh): void;
  14977. }
  14978. }
  14979. declare module BABYLON {
  14980. /**
  14981. * Interface used to define Action
  14982. */
  14983. export interface IAction {
  14984. /**
  14985. * Trigger for the action
  14986. */
  14987. trigger: number;
  14988. /** Options of the trigger */
  14989. triggerOptions: any;
  14990. /**
  14991. * Gets the trigger parameters
  14992. * @returns the trigger parameters
  14993. */
  14994. getTriggerParameter(): any;
  14995. /**
  14996. * Internal only - executes current action event
  14997. * @hidden
  14998. */
  14999. _executeCurrent(evt?: ActionEvent): void;
  15000. /**
  15001. * Serialize placeholder for child classes
  15002. * @param parent of child
  15003. * @returns the serialized object
  15004. */
  15005. serialize(parent: any): any;
  15006. /**
  15007. * Internal only
  15008. * @hidden
  15009. */
  15010. _prepare(): void;
  15011. /**
  15012. * Internal only - manager for action
  15013. * @hidden
  15014. */
  15015. _actionManager: AbstractActionManager;
  15016. /**
  15017. * Adds action to chain of actions, may be a DoNothingAction
  15018. * @param action defines the next action to execute
  15019. * @returns The action passed in
  15020. * @see https://www.babylonjs-playground.com/#1T30HR#0
  15021. */
  15022. then(action: IAction): IAction;
  15023. }
  15024. /**
  15025. * The action to be carried out following a trigger
  15026. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  15027. */
  15028. export class Action implements IAction {
  15029. /** the trigger, with or without parameters, for the action */
  15030. triggerOptions: any;
  15031. /**
  15032. * Trigger for the action
  15033. */
  15034. trigger: number;
  15035. /**
  15036. * Internal only - manager for action
  15037. * @hidden
  15038. */
  15039. _actionManager: ActionManager;
  15040. private _nextActiveAction;
  15041. private _child;
  15042. private _condition?;
  15043. private _triggerParameter;
  15044. /**
  15045. * An event triggered prior to action being executed.
  15046. */
  15047. onBeforeExecuteObservable: Observable<Action>;
  15048. /**
  15049. * Creates a new Action
  15050. * @param triggerOptions the trigger, with or without parameters, for the action
  15051. * @param condition an optional determinant of action
  15052. */
  15053. constructor(
  15054. /** the trigger, with or without parameters, for the action */
  15055. triggerOptions: any, condition?: Condition);
  15056. /**
  15057. * Internal only
  15058. * @hidden
  15059. */
  15060. _prepare(): void;
  15061. /**
  15062. * Gets the trigger parameters
  15063. * @returns the trigger parameters
  15064. */
  15065. getTriggerParameter(): any;
  15066. /**
  15067. * Internal only - executes current action event
  15068. * @hidden
  15069. */
  15070. _executeCurrent(evt?: ActionEvent): void;
  15071. /**
  15072. * Execute placeholder for child classes
  15073. * @param evt optional action event
  15074. */
  15075. execute(evt?: ActionEvent): void;
  15076. /**
  15077. * Skips to next active action
  15078. */
  15079. skipToNextActiveAction(): void;
  15080. /**
  15081. * Adds action to chain of actions, may be a DoNothingAction
  15082. * @param action defines the next action to execute
  15083. * @returns The action passed in
  15084. * @see https://www.babylonjs-playground.com/#1T30HR#0
  15085. */
  15086. then(action: Action): Action;
  15087. /**
  15088. * Internal only
  15089. * @hidden
  15090. */
  15091. _getProperty(propertyPath: string): string;
  15092. /**
  15093. * Internal only
  15094. * @hidden
  15095. */
  15096. _getEffectiveTarget(target: any, propertyPath: string): any;
  15097. /**
  15098. * Serialize placeholder for child classes
  15099. * @param parent of child
  15100. * @returns the serialized object
  15101. */
  15102. serialize(parent: any): any;
  15103. /**
  15104. * Internal only called by serialize
  15105. * @hidden
  15106. */
  15107. protected _serialize(serializedAction: any, parent?: any): any;
  15108. /**
  15109. * Internal only
  15110. * @hidden
  15111. */
  15112. static _SerializeValueAsString: (value: any) => string;
  15113. /**
  15114. * Internal only
  15115. * @hidden
  15116. */
  15117. static _GetTargetProperty: (target: Scene | Node) => {
  15118. name: string;
  15119. targetType: string;
  15120. value: string;
  15121. };
  15122. }
  15123. }
  15124. declare module BABYLON {
  15125. /**
  15126. * A Condition applied to an Action
  15127. */
  15128. export class Condition {
  15129. /**
  15130. * Internal only - manager for action
  15131. * @hidden
  15132. */
  15133. _actionManager: ActionManager;
  15134. /**
  15135. * Internal only
  15136. * @hidden
  15137. */
  15138. _evaluationId: number;
  15139. /**
  15140. * Internal only
  15141. * @hidden
  15142. */
  15143. _currentResult: boolean;
  15144. /**
  15145. * Creates a new Condition
  15146. * @param actionManager the manager of the action the condition is applied to
  15147. */
  15148. constructor(actionManager: ActionManager);
  15149. /**
  15150. * Check if the current condition is valid
  15151. * @returns a boolean
  15152. */
  15153. isValid(): boolean;
  15154. /**
  15155. * Internal only
  15156. * @hidden
  15157. */
  15158. _getProperty(propertyPath: string): string;
  15159. /**
  15160. * Internal only
  15161. * @hidden
  15162. */
  15163. _getEffectiveTarget(target: any, propertyPath: string): any;
  15164. /**
  15165. * Serialize placeholder for child classes
  15166. * @returns the serialized object
  15167. */
  15168. serialize(): any;
  15169. /**
  15170. * Internal only
  15171. * @hidden
  15172. */
  15173. protected _serialize(serializedCondition: any): any;
  15174. }
  15175. /**
  15176. * Defines specific conditional operators as extensions of Condition
  15177. */
  15178. export class ValueCondition extends Condition {
  15179. /** path to specify the property of the target the conditional operator uses */
  15180. propertyPath: string;
  15181. /** the value compared by the conditional operator against the current value of the property */
  15182. value: any;
  15183. /** the conditional operator, default ValueCondition.IsEqual */
  15184. operator: number;
  15185. /**
  15186. * Internal only
  15187. * @hidden
  15188. */
  15189. private static _IsEqual;
  15190. /**
  15191. * Internal only
  15192. * @hidden
  15193. */
  15194. private static _IsDifferent;
  15195. /**
  15196. * Internal only
  15197. * @hidden
  15198. */
  15199. private static _IsGreater;
  15200. /**
  15201. * Internal only
  15202. * @hidden
  15203. */
  15204. private static _IsLesser;
  15205. /**
  15206. * returns the number for IsEqual
  15207. */
  15208. static readonly IsEqual: number;
  15209. /**
  15210. * Returns the number for IsDifferent
  15211. */
  15212. static readonly IsDifferent: number;
  15213. /**
  15214. * Returns the number for IsGreater
  15215. */
  15216. static readonly IsGreater: number;
  15217. /**
  15218. * Returns the number for IsLesser
  15219. */
  15220. static readonly IsLesser: number;
  15221. /**
  15222. * Internal only The action manager for the condition
  15223. * @hidden
  15224. */
  15225. _actionManager: ActionManager;
  15226. /**
  15227. * Internal only
  15228. * @hidden
  15229. */
  15230. private _target;
  15231. /**
  15232. * Internal only
  15233. * @hidden
  15234. */
  15235. private _effectiveTarget;
  15236. /**
  15237. * Internal only
  15238. * @hidden
  15239. */
  15240. private _property;
  15241. /**
  15242. * Creates a new ValueCondition
  15243. * @param actionManager manager for the action the condition applies to
  15244. * @param target for the action
  15245. * @param propertyPath path to specify the property of the target the conditional operator uses
  15246. * @param value the value compared by the conditional operator against the current value of the property
  15247. * @param operator the conditional operator, default ValueCondition.IsEqual
  15248. */
  15249. constructor(actionManager: ActionManager, target: any,
  15250. /** path to specify the property of the target the conditional operator uses */
  15251. propertyPath: string,
  15252. /** the value compared by the conditional operator against the current value of the property */
  15253. value: any,
  15254. /** the conditional operator, default ValueCondition.IsEqual */
  15255. operator?: number);
  15256. /**
  15257. * Compares the given value with the property value for the specified conditional operator
  15258. * @returns the result of the comparison
  15259. */
  15260. isValid(): boolean;
  15261. /**
  15262. * Serialize the ValueCondition into a JSON compatible object
  15263. * @returns serialization object
  15264. */
  15265. serialize(): any;
  15266. /**
  15267. * Gets the name of the conditional operator for the ValueCondition
  15268. * @param operator the conditional operator
  15269. * @returns the name
  15270. */
  15271. static GetOperatorName(operator: number): string;
  15272. }
  15273. /**
  15274. * Defines a predicate condition as an extension of Condition
  15275. */
  15276. export class PredicateCondition extends Condition {
  15277. /** defines the predicate function used to validate the condition */
  15278. predicate: () => boolean;
  15279. /**
  15280. * Internal only - manager for action
  15281. * @hidden
  15282. */
  15283. _actionManager: ActionManager;
  15284. /**
  15285. * Creates a new PredicateCondition
  15286. * @param actionManager manager for the action the condition applies to
  15287. * @param predicate defines the predicate function used to validate the condition
  15288. */
  15289. constructor(actionManager: ActionManager,
  15290. /** defines the predicate function used to validate the condition */
  15291. predicate: () => boolean);
  15292. /**
  15293. * @returns the validity of the predicate condition
  15294. */
  15295. isValid(): boolean;
  15296. }
  15297. /**
  15298. * Defines a state condition as an extension of Condition
  15299. */
  15300. export class StateCondition extends Condition {
  15301. /** Value to compare with target state */
  15302. value: string;
  15303. /**
  15304. * Internal only - manager for action
  15305. * @hidden
  15306. */
  15307. _actionManager: ActionManager;
  15308. /**
  15309. * Internal only
  15310. * @hidden
  15311. */
  15312. private _target;
  15313. /**
  15314. * Creates a new StateCondition
  15315. * @param actionManager manager for the action the condition applies to
  15316. * @param target of the condition
  15317. * @param value to compare with target state
  15318. */
  15319. constructor(actionManager: ActionManager, target: any,
  15320. /** Value to compare with target state */
  15321. value: string);
  15322. /**
  15323. * Gets a boolean indicating if the current condition is met
  15324. * @returns the validity of the state
  15325. */
  15326. isValid(): boolean;
  15327. /**
  15328. * Serialize the StateCondition into a JSON compatible object
  15329. * @returns serialization object
  15330. */
  15331. serialize(): any;
  15332. }
  15333. }
  15334. declare module BABYLON {
  15335. /**
  15336. * This defines an action responsible to toggle a boolean once triggered.
  15337. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15338. */
  15339. export class SwitchBooleanAction extends Action {
  15340. /**
  15341. * The path to the boolean property in the target object
  15342. */
  15343. propertyPath: string;
  15344. private _target;
  15345. private _effectiveTarget;
  15346. private _property;
  15347. /**
  15348. * Instantiate the action
  15349. * @param triggerOptions defines the trigger options
  15350. * @param target defines the object containing the boolean
  15351. * @param propertyPath defines the path to the boolean property in the target object
  15352. * @param condition defines the trigger related conditions
  15353. */
  15354. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  15355. /** @hidden */
  15356. _prepare(): void;
  15357. /**
  15358. * Execute the action toggle the boolean value.
  15359. */
  15360. execute(): void;
  15361. /**
  15362. * Serializes the actions and its related information.
  15363. * @param parent defines the object to serialize in
  15364. * @returns the serialized object
  15365. */
  15366. serialize(parent: any): any;
  15367. }
  15368. /**
  15369. * This defines an action responsible to set a the state field of the target
  15370. * to a desired value once triggered.
  15371. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15372. */
  15373. export class SetStateAction extends Action {
  15374. /**
  15375. * The value to store in the state field.
  15376. */
  15377. value: string;
  15378. private _target;
  15379. /**
  15380. * Instantiate the action
  15381. * @param triggerOptions defines the trigger options
  15382. * @param target defines the object containing the state property
  15383. * @param value defines the value to store in the state field
  15384. * @param condition defines the trigger related conditions
  15385. */
  15386. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  15387. /**
  15388. * Execute the action and store the value on the target state property.
  15389. */
  15390. execute(): void;
  15391. /**
  15392. * Serializes the actions and its related information.
  15393. * @param parent defines the object to serialize in
  15394. * @returns the serialized object
  15395. */
  15396. serialize(parent: any): any;
  15397. }
  15398. /**
  15399. * This defines an action responsible to set a property of the target
  15400. * to a desired value once triggered.
  15401. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15402. */
  15403. export class SetValueAction extends Action {
  15404. /**
  15405. * The path of the property to set in the target.
  15406. */
  15407. propertyPath: string;
  15408. /**
  15409. * The value to set in the property
  15410. */
  15411. value: any;
  15412. private _target;
  15413. private _effectiveTarget;
  15414. private _property;
  15415. /**
  15416. * Instantiate the action
  15417. * @param triggerOptions defines the trigger options
  15418. * @param target defines the object containing the property
  15419. * @param propertyPath defines the path of the property to set in the target
  15420. * @param value defines the value to set in the property
  15421. * @param condition defines the trigger related conditions
  15422. */
  15423. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  15424. /** @hidden */
  15425. _prepare(): void;
  15426. /**
  15427. * Execute the action and set the targetted property to the desired value.
  15428. */
  15429. execute(): void;
  15430. /**
  15431. * Serializes the actions and its related information.
  15432. * @param parent defines the object to serialize in
  15433. * @returns the serialized object
  15434. */
  15435. serialize(parent: any): any;
  15436. }
  15437. /**
  15438. * This defines an action responsible to increment the target value
  15439. * to a desired value once triggered.
  15440. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15441. */
  15442. export class IncrementValueAction extends Action {
  15443. /**
  15444. * The path of the property to increment in the target.
  15445. */
  15446. propertyPath: string;
  15447. /**
  15448. * The value we should increment the property by.
  15449. */
  15450. value: any;
  15451. private _target;
  15452. private _effectiveTarget;
  15453. private _property;
  15454. /**
  15455. * Instantiate the action
  15456. * @param triggerOptions defines the trigger options
  15457. * @param target defines the object containing the property
  15458. * @param propertyPath defines the path of the property to increment in the target
  15459. * @param value defines the value value we should increment the property by
  15460. * @param condition defines the trigger related conditions
  15461. */
  15462. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  15463. /** @hidden */
  15464. _prepare(): void;
  15465. /**
  15466. * Execute the action and increment the target of the value amount.
  15467. */
  15468. execute(): void;
  15469. /**
  15470. * Serializes the actions and its related information.
  15471. * @param parent defines the object to serialize in
  15472. * @returns the serialized object
  15473. */
  15474. serialize(parent: any): any;
  15475. }
  15476. /**
  15477. * This defines an action responsible to start an animation once triggered.
  15478. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15479. */
  15480. export class PlayAnimationAction extends Action {
  15481. /**
  15482. * Where the animation should start (animation frame)
  15483. */
  15484. from: number;
  15485. /**
  15486. * Where the animation should stop (animation frame)
  15487. */
  15488. to: number;
  15489. /**
  15490. * Define if the animation should loop or stop after the first play.
  15491. */
  15492. loop?: boolean;
  15493. private _target;
  15494. /**
  15495. * Instantiate the action
  15496. * @param triggerOptions defines the trigger options
  15497. * @param target defines the target animation or animation name
  15498. * @param from defines from where the animation should start (animation frame)
  15499. * @param end defines where the animation should stop (animation frame)
  15500. * @param loop defines if the animation should loop or stop after the first play
  15501. * @param condition defines the trigger related conditions
  15502. */
  15503. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  15504. /** @hidden */
  15505. _prepare(): void;
  15506. /**
  15507. * Execute the action and play the animation.
  15508. */
  15509. execute(): void;
  15510. /**
  15511. * Serializes the actions and its related information.
  15512. * @param parent defines the object to serialize in
  15513. * @returns the serialized object
  15514. */
  15515. serialize(parent: any): any;
  15516. }
  15517. /**
  15518. * This defines an action responsible to stop an animation once triggered.
  15519. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15520. */
  15521. export class StopAnimationAction extends Action {
  15522. private _target;
  15523. /**
  15524. * Instantiate the action
  15525. * @param triggerOptions defines the trigger options
  15526. * @param target defines the target animation or animation name
  15527. * @param condition defines the trigger related conditions
  15528. */
  15529. constructor(triggerOptions: any, target: any, condition?: Condition);
  15530. /** @hidden */
  15531. _prepare(): void;
  15532. /**
  15533. * Execute the action and stop the animation.
  15534. */
  15535. execute(): void;
  15536. /**
  15537. * Serializes the actions and its related information.
  15538. * @param parent defines the object to serialize in
  15539. * @returns the serialized object
  15540. */
  15541. serialize(parent: any): any;
  15542. }
  15543. /**
  15544. * This defines an action responsible that does nothing once triggered.
  15545. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15546. */
  15547. export class DoNothingAction extends Action {
  15548. /**
  15549. * Instantiate the action
  15550. * @param triggerOptions defines the trigger options
  15551. * @param condition defines the trigger related conditions
  15552. */
  15553. constructor(triggerOptions?: any, condition?: Condition);
  15554. /**
  15555. * Execute the action and do nothing.
  15556. */
  15557. execute(): void;
  15558. /**
  15559. * Serializes the actions and its related information.
  15560. * @param parent defines the object to serialize in
  15561. * @returns the serialized object
  15562. */
  15563. serialize(parent: any): any;
  15564. }
  15565. /**
  15566. * This defines an action responsible to trigger several actions once triggered.
  15567. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15568. */
  15569. export class CombineAction extends Action {
  15570. /**
  15571. * The list of aggregated animations to run.
  15572. */
  15573. children: Action[];
  15574. /**
  15575. * Instantiate the action
  15576. * @param triggerOptions defines the trigger options
  15577. * @param children defines the list of aggregated animations to run
  15578. * @param condition defines the trigger related conditions
  15579. */
  15580. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  15581. /** @hidden */
  15582. _prepare(): void;
  15583. /**
  15584. * Execute the action and executes all the aggregated actions.
  15585. */
  15586. execute(evt: ActionEvent): void;
  15587. /**
  15588. * Serializes the actions and its related information.
  15589. * @param parent defines the object to serialize in
  15590. * @returns the serialized object
  15591. */
  15592. serialize(parent: any): any;
  15593. }
  15594. /**
  15595. * This defines an action responsible to run code (external event) once triggered.
  15596. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15597. */
  15598. export class ExecuteCodeAction extends Action {
  15599. /**
  15600. * The callback function to run.
  15601. */
  15602. func: (evt: ActionEvent) => void;
  15603. /**
  15604. * Instantiate the action
  15605. * @param triggerOptions defines the trigger options
  15606. * @param func defines the callback function to run
  15607. * @param condition defines the trigger related conditions
  15608. */
  15609. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  15610. /**
  15611. * Execute the action and run the attached code.
  15612. */
  15613. execute(evt: ActionEvent): void;
  15614. }
  15615. /**
  15616. * This defines an action responsible to set the parent property of the target once triggered.
  15617. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15618. */
  15619. export class SetParentAction extends Action {
  15620. private _parent;
  15621. private _target;
  15622. /**
  15623. * Instantiate the action
  15624. * @param triggerOptions defines the trigger options
  15625. * @param target defines the target containing the parent property
  15626. * @param parent defines from where the animation should start (animation frame)
  15627. * @param condition defines the trigger related conditions
  15628. */
  15629. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  15630. /** @hidden */
  15631. _prepare(): void;
  15632. /**
  15633. * Execute the action and set the parent property.
  15634. */
  15635. execute(): void;
  15636. /**
  15637. * Serializes the actions and its related information.
  15638. * @param parent defines the object to serialize in
  15639. * @returns the serialized object
  15640. */
  15641. serialize(parent: any): any;
  15642. }
  15643. }
  15644. declare module BABYLON {
  15645. /**
  15646. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  15647. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  15648. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15649. */
  15650. export class ActionManager extends AbstractActionManager {
  15651. /**
  15652. * Nothing
  15653. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  15654. */
  15655. static readonly NothingTrigger: number;
  15656. /**
  15657. * On pick
  15658. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  15659. */
  15660. static readonly OnPickTrigger: number;
  15661. /**
  15662. * On left pick
  15663. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  15664. */
  15665. static readonly OnLeftPickTrigger: number;
  15666. /**
  15667. * On right pick
  15668. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  15669. */
  15670. static readonly OnRightPickTrigger: number;
  15671. /**
  15672. * On center pick
  15673. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  15674. */
  15675. static readonly OnCenterPickTrigger: number;
  15676. /**
  15677. * On pick down
  15678. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  15679. */
  15680. static readonly OnPickDownTrigger: number;
  15681. /**
  15682. * On double pick
  15683. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  15684. */
  15685. static readonly OnDoublePickTrigger: number;
  15686. /**
  15687. * On pick up
  15688. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  15689. */
  15690. static readonly OnPickUpTrigger: number;
  15691. /**
  15692. * On pick out.
  15693. * This trigger will only be raised if you also declared a OnPickDown
  15694. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  15695. */
  15696. static readonly OnPickOutTrigger: number;
  15697. /**
  15698. * On long press
  15699. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  15700. */
  15701. static readonly OnLongPressTrigger: number;
  15702. /**
  15703. * On pointer over
  15704. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  15705. */
  15706. static readonly OnPointerOverTrigger: number;
  15707. /**
  15708. * On pointer out
  15709. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  15710. */
  15711. static readonly OnPointerOutTrigger: number;
  15712. /**
  15713. * On every frame
  15714. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  15715. */
  15716. static readonly OnEveryFrameTrigger: number;
  15717. /**
  15718. * On intersection enter
  15719. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  15720. */
  15721. static readonly OnIntersectionEnterTrigger: number;
  15722. /**
  15723. * On intersection exit
  15724. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  15725. */
  15726. static readonly OnIntersectionExitTrigger: number;
  15727. /**
  15728. * On key down
  15729. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  15730. */
  15731. static readonly OnKeyDownTrigger: number;
  15732. /**
  15733. * On key up
  15734. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  15735. */
  15736. static readonly OnKeyUpTrigger: number;
  15737. private _scene;
  15738. /**
  15739. * Creates a new action manager
  15740. * @param scene defines the hosting scene
  15741. */
  15742. constructor(scene: Scene);
  15743. /**
  15744. * Releases all associated resources
  15745. */
  15746. dispose(): void;
  15747. /**
  15748. * Gets hosting scene
  15749. * @returns the hosting scene
  15750. */
  15751. getScene(): Scene;
  15752. /**
  15753. * Does this action manager handles actions of any of the given triggers
  15754. * @param triggers defines the triggers to be tested
  15755. * @return a boolean indicating whether one (or more) of the triggers is handled
  15756. */
  15757. hasSpecificTriggers(triggers: number[]): boolean;
  15758. /**
  15759. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  15760. * speed.
  15761. * @param triggerA defines the trigger to be tested
  15762. * @param triggerB defines the trigger to be tested
  15763. * @return a boolean indicating whether one (or more) of the triggers is handled
  15764. */
  15765. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  15766. /**
  15767. * Does this action manager handles actions of a given trigger
  15768. * @param trigger defines the trigger to be tested
  15769. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  15770. * @return whether the trigger is handled
  15771. */
  15772. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  15773. /**
  15774. * Does this action manager has pointer triggers
  15775. */
  15776. readonly hasPointerTriggers: boolean;
  15777. /**
  15778. * Does this action manager has pick triggers
  15779. */
  15780. readonly hasPickTriggers: boolean;
  15781. /**
  15782. * Registers an action to this action manager
  15783. * @param action defines the action to be registered
  15784. * @return the action amended (prepared) after registration
  15785. */
  15786. registerAction(action: IAction): Nullable<IAction>;
  15787. /**
  15788. * Unregisters an action to this action manager
  15789. * @param action defines the action to be unregistered
  15790. * @return a boolean indicating whether the action has been unregistered
  15791. */
  15792. unregisterAction(action: IAction): Boolean;
  15793. /**
  15794. * Process a specific trigger
  15795. * @param trigger defines the trigger to process
  15796. * @param evt defines the event details to be processed
  15797. */
  15798. processTrigger(trigger: number, evt?: IActionEvent): void;
  15799. /** @hidden */
  15800. _getEffectiveTarget(target: any, propertyPath: string): any;
  15801. /** @hidden */
  15802. _getProperty(propertyPath: string): string;
  15803. /**
  15804. * Serialize this manager to a JSON object
  15805. * @param name defines the property name to store this manager
  15806. * @returns a JSON representation of this manager
  15807. */
  15808. serialize(name: string): any;
  15809. /**
  15810. * Creates a new ActionManager from a JSON data
  15811. * @param parsedActions defines the JSON data to read from
  15812. * @param object defines the hosting mesh
  15813. * @param scene defines the hosting scene
  15814. */
  15815. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  15816. /**
  15817. * Get a trigger name by index
  15818. * @param trigger defines the trigger index
  15819. * @returns a trigger name
  15820. */
  15821. static GetTriggerName(trigger: number): string;
  15822. }
  15823. }
  15824. declare module BABYLON {
  15825. /**
  15826. * Class representing a ray with position and direction
  15827. */
  15828. export class Ray {
  15829. /** origin point */
  15830. origin: Vector3;
  15831. /** direction */
  15832. direction: Vector3;
  15833. /** length of the ray */
  15834. length: number;
  15835. private static readonly TmpVector3;
  15836. private _tmpRay;
  15837. /**
  15838. * Creates a new ray
  15839. * @param origin origin point
  15840. * @param direction direction
  15841. * @param length length of the ray
  15842. */
  15843. constructor(
  15844. /** origin point */
  15845. origin: Vector3,
  15846. /** direction */
  15847. direction: Vector3,
  15848. /** length of the ray */
  15849. length?: number);
  15850. /**
  15851. * Checks if the ray intersects a box
  15852. * @param minimum bound of the box
  15853. * @param maximum bound of the box
  15854. * @param intersectionTreshold extra extend to be added to the box in all direction
  15855. * @returns if the box was hit
  15856. */
  15857. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  15858. /**
  15859. * Checks if the ray intersects a box
  15860. * @param box the bounding box to check
  15861. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  15862. * @returns if the box was hit
  15863. */
  15864. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  15865. /**
  15866. * If the ray hits a sphere
  15867. * @param sphere the bounding sphere to check
  15868. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  15869. * @returns true if it hits the sphere
  15870. */
  15871. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  15872. /**
  15873. * If the ray hits a triange
  15874. * @param vertex0 triangle vertex
  15875. * @param vertex1 triangle vertex
  15876. * @param vertex2 triangle vertex
  15877. * @returns intersection information if hit
  15878. */
  15879. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  15880. /**
  15881. * Checks if ray intersects a plane
  15882. * @param plane the plane to check
  15883. * @returns the distance away it was hit
  15884. */
  15885. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  15886. /**
  15887. * Checks if ray intersects a mesh
  15888. * @param mesh the mesh to check
  15889. * @param fastCheck if only the bounding box should checked
  15890. * @returns picking info of the intersecton
  15891. */
  15892. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  15893. /**
  15894. * Checks if ray intersects a mesh
  15895. * @param meshes the meshes to check
  15896. * @param fastCheck if only the bounding box should checked
  15897. * @param results array to store result in
  15898. * @returns Array of picking infos
  15899. */
  15900. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  15901. private _comparePickingInfo;
  15902. private static smallnum;
  15903. private static rayl;
  15904. /**
  15905. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  15906. * @param sega the first point of the segment to test the intersection against
  15907. * @param segb the second point of the segment to test the intersection against
  15908. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  15909. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  15910. */
  15911. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  15912. /**
  15913. * Update the ray from viewport position
  15914. * @param x position
  15915. * @param y y position
  15916. * @param viewportWidth viewport width
  15917. * @param viewportHeight viewport height
  15918. * @param world world matrix
  15919. * @param view view matrix
  15920. * @param projection projection matrix
  15921. * @returns this ray updated
  15922. */
  15923. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  15924. /**
  15925. * Creates a ray with origin and direction of 0,0,0
  15926. * @returns the new ray
  15927. */
  15928. static Zero(): Ray;
  15929. /**
  15930. * Creates a new ray from screen space and viewport
  15931. * @param x position
  15932. * @param y y position
  15933. * @param viewportWidth viewport width
  15934. * @param viewportHeight viewport height
  15935. * @param world world matrix
  15936. * @param view view matrix
  15937. * @param projection projection matrix
  15938. * @returns new ray
  15939. */
  15940. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  15941. /**
  15942. * 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
  15943. * transformed to the given world matrix.
  15944. * @param origin The origin point
  15945. * @param end The end point
  15946. * @param world a matrix to transform the ray to. Default is the identity matrix.
  15947. * @returns the new ray
  15948. */
  15949. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  15950. /**
  15951. * Transforms a ray by a matrix
  15952. * @param ray ray to transform
  15953. * @param matrix matrix to apply
  15954. * @returns the resulting new ray
  15955. */
  15956. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  15957. /**
  15958. * Transforms a ray by a matrix
  15959. * @param ray ray to transform
  15960. * @param matrix matrix to apply
  15961. * @param result ray to store result in
  15962. */
  15963. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  15964. /**
  15965. * Unproject a ray from screen space to object space
  15966. * @param sourceX defines the screen space x coordinate to use
  15967. * @param sourceY defines the screen space y coordinate to use
  15968. * @param viewportWidth defines the current width of the viewport
  15969. * @param viewportHeight defines the current height of the viewport
  15970. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  15971. * @param view defines the view matrix to use
  15972. * @param projection defines the projection matrix to use
  15973. */
  15974. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  15975. }
  15976. /**
  15977. * Type used to define predicate used to select faces when a mesh intersection is detected
  15978. */
  15979. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  15980. interface Scene {
  15981. /** @hidden */
  15982. _tempPickingRay: Nullable<Ray>;
  15983. /** @hidden */
  15984. _cachedRayForTransform: Ray;
  15985. /** @hidden */
  15986. _pickWithRayInverseMatrix: Matrix;
  15987. /** @hidden */
  15988. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  15989. /** @hidden */
  15990. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  15991. }
  15992. }
  15993. declare module BABYLON {
  15994. interface Scene {
  15995. /** @hidden */
  15996. _pointerOverSprite: Nullable<Sprite>;
  15997. /** @hidden */
  15998. _pickedDownSprite: Nullable<Sprite>;
  15999. /** @hidden */
  16000. _tempSpritePickingRay: Nullable<Ray>;
  16001. /**
  16002. * All of the sprite managers added to this scene
  16003. * @see http://doc.babylonjs.com/babylon101/sprites
  16004. */
  16005. spriteManagers: Array<ISpriteManager>;
  16006. /**
  16007. * An event triggered when sprites rendering is about to start
  16008. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  16009. */
  16010. onBeforeSpritesRenderingObservable: Observable<Scene>;
  16011. /**
  16012. * An event triggered when sprites rendering is done
  16013. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  16014. */
  16015. onAfterSpritesRenderingObservable: Observable<Scene>;
  16016. /** @hidden */
  16017. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  16018. /** Launch a ray to try to pick a sprite in the scene
  16019. * @param x position on screen
  16020. * @param y position on screen
  16021. * @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
  16022. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  16023. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  16024. * @returns a PickingInfo
  16025. */
  16026. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  16027. /** Use the given ray to pick a sprite in the scene
  16028. * @param ray The ray (in world space) to use to pick meshes
  16029. * @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
  16030. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  16031. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  16032. * @returns a PickingInfo
  16033. */
  16034. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  16035. /**
  16036. * Force the sprite under the pointer
  16037. * @param sprite defines the sprite to use
  16038. */
  16039. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  16040. /**
  16041. * Gets the sprite under the pointer
  16042. * @returns a Sprite or null if no sprite is under the pointer
  16043. */
  16044. getPointerOverSprite(): Nullable<Sprite>;
  16045. }
  16046. /**
  16047. * Defines the sprite scene component responsible to manage sprites
  16048. * in a given scene.
  16049. */
  16050. export class SpriteSceneComponent implements ISceneComponent {
  16051. /**
  16052. * The component name helpfull to identify the component in the list of scene components.
  16053. */
  16054. readonly name: string;
  16055. /**
  16056. * The scene the component belongs to.
  16057. */
  16058. scene: Scene;
  16059. /** @hidden */
  16060. private _spritePredicate;
  16061. /**
  16062. * Creates a new instance of the component for the given scene
  16063. * @param scene Defines the scene to register the component in
  16064. */
  16065. constructor(scene: Scene);
  16066. /**
  16067. * Registers the component in a given scene
  16068. */
  16069. register(): void;
  16070. /**
  16071. * Rebuilds the elements related to this component in case of
  16072. * context lost for instance.
  16073. */
  16074. rebuild(): void;
  16075. /**
  16076. * Disposes the component and the associated ressources.
  16077. */
  16078. dispose(): void;
  16079. private _pickSpriteButKeepRay;
  16080. private _pointerMove;
  16081. private _pointerDown;
  16082. private _pointerUp;
  16083. }
  16084. }
  16085. declare module BABYLON {
  16086. /** @hidden */
  16087. export var fogFragmentDeclaration: {
  16088. name: string;
  16089. shader: string;
  16090. };
  16091. }
  16092. declare module BABYLON {
  16093. /** @hidden */
  16094. export var fogFragment: {
  16095. name: string;
  16096. shader: string;
  16097. };
  16098. }
  16099. declare module BABYLON {
  16100. /** @hidden */
  16101. export var spritesPixelShader: {
  16102. name: string;
  16103. shader: string;
  16104. };
  16105. }
  16106. declare module BABYLON {
  16107. /** @hidden */
  16108. export var fogVertexDeclaration: {
  16109. name: string;
  16110. shader: string;
  16111. };
  16112. }
  16113. declare module BABYLON {
  16114. /** @hidden */
  16115. export var spritesVertexShader: {
  16116. name: string;
  16117. shader: string;
  16118. };
  16119. }
  16120. declare module BABYLON {
  16121. /**
  16122. * Defines the minimum interface to fullfil in order to be a sprite manager.
  16123. */
  16124. export interface ISpriteManager extends IDisposable {
  16125. /**
  16126. * Restricts the camera to viewing objects with the same layerMask.
  16127. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  16128. */
  16129. layerMask: number;
  16130. /**
  16131. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  16132. */
  16133. isPickable: boolean;
  16134. /**
  16135. * Specifies the rendering group id for this mesh (0 by default)
  16136. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  16137. */
  16138. renderingGroupId: number;
  16139. /**
  16140. * Defines the list of sprites managed by the manager.
  16141. */
  16142. sprites: Array<Sprite>;
  16143. /**
  16144. * Tests the intersection of a sprite with a specific ray.
  16145. * @param ray The ray we are sending to test the collision
  16146. * @param camera The camera space we are sending rays in
  16147. * @param predicate A predicate allowing excluding sprites from the list of object to test
  16148. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  16149. * @returns picking info or null.
  16150. */
  16151. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  16152. /**
  16153. * Renders the list of sprites on screen.
  16154. */
  16155. render(): void;
  16156. }
  16157. /**
  16158. * Class used to manage multiple sprites on the same spritesheet
  16159. * @see http://doc.babylonjs.com/babylon101/sprites
  16160. */
  16161. export class SpriteManager implements ISpriteManager {
  16162. /** defines the manager's name */
  16163. name: string;
  16164. /** Gets the list of sprites */
  16165. sprites: Sprite[];
  16166. /** Gets or sets the rendering group id (0 by default) */
  16167. renderingGroupId: number;
  16168. /** Gets or sets camera layer mask */
  16169. layerMask: number;
  16170. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  16171. fogEnabled: boolean;
  16172. /** Gets or sets a boolean indicating if the sprites are pickable */
  16173. isPickable: boolean;
  16174. /** Defines the default width of a cell in the spritesheet */
  16175. cellWidth: number;
  16176. /** Defines the default height of a cell in the spritesheet */
  16177. cellHeight: number;
  16178. /**
  16179. * An event triggered when the manager is disposed.
  16180. */
  16181. onDisposeObservable: Observable<SpriteManager>;
  16182. private _onDisposeObserver;
  16183. /**
  16184. * Callback called when the manager is disposed
  16185. */
  16186. onDispose: () => void;
  16187. private _capacity;
  16188. private _spriteTexture;
  16189. private _epsilon;
  16190. private _scene;
  16191. private _vertexData;
  16192. private _buffer;
  16193. private _vertexBuffers;
  16194. private _indexBuffer;
  16195. private _effectBase;
  16196. private _effectFog;
  16197. /**
  16198. * Gets or sets the spritesheet texture
  16199. */
  16200. texture: Texture;
  16201. /**
  16202. * Creates a new sprite manager
  16203. * @param name defines the manager's name
  16204. * @param imgUrl defines the sprite sheet url
  16205. * @param capacity defines the maximum allowed number of sprites
  16206. * @param cellSize defines the size of a sprite cell
  16207. * @param scene defines the hosting scene
  16208. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  16209. * @param samplingMode defines the smapling mode to use with spritesheet
  16210. */
  16211. constructor(
  16212. /** defines the manager's name */
  16213. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  16214. private _appendSpriteVertex;
  16215. /**
  16216. * Intersects the sprites with a ray
  16217. * @param ray defines the ray to intersect with
  16218. * @param camera defines the current active camera
  16219. * @param predicate defines a predicate used to select candidate sprites
  16220. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  16221. * @returns null if no hit or a PickingInfo
  16222. */
  16223. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  16224. /**
  16225. * Render all child sprites
  16226. */
  16227. render(): void;
  16228. /**
  16229. * Release associated resources
  16230. */
  16231. dispose(): void;
  16232. }
  16233. }
  16234. declare module BABYLON {
  16235. /**
  16236. * Class used to represent a sprite
  16237. * @see http://doc.babylonjs.com/babylon101/sprites
  16238. */
  16239. export class Sprite {
  16240. /** defines the name */
  16241. name: string;
  16242. /** Gets or sets the current world position */
  16243. position: Vector3;
  16244. /** Gets or sets the main color */
  16245. color: Color4;
  16246. /** Gets or sets the width */
  16247. width: number;
  16248. /** Gets or sets the height */
  16249. height: number;
  16250. /** Gets or sets rotation angle */
  16251. angle: number;
  16252. /** Gets or sets the cell index in the sprite sheet */
  16253. cellIndex: number;
  16254. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  16255. invertU: number;
  16256. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  16257. invertV: number;
  16258. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  16259. disposeWhenFinishedAnimating: boolean;
  16260. /** Gets the list of attached animations */
  16261. animations: Animation[];
  16262. /** Gets or sets a boolean indicating if the sprite can be picked */
  16263. isPickable: boolean;
  16264. /**
  16265. * Gets or sets the associated action manager
  16266. */
  16267. actionManager: Nullable<ActionManager>;
  16268. private _animationStarted;
  16269. private _loopAnimation;
  16270. private _fromIndex;
  16271. private _toIndex;
  16272. private _delay;
  16273. private _direction;
  16274. private _manager;
  16275. private _time;
  16276. private _onAnimationEnd;
  16277. /**
  16278. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  16279. */
  16280. isVisible: boolean;
  16281. /**
  16282. * Gets or sets the sprite size
  16283. */
  16284. size: number;
  16285. /**
  16286. * Creates a new Sprite
  16287. * @param name defines the name
  16288. * @param manager defines the manager
  16289. */
  16290. constructor(
  16291. /** defines the name */
  16292. name: string, manager: ISpriteManager);
  16293. /**
  16294. * Starts an animation
  16295. * @param from defines the initial key
  16296. * @param to defines the end key
  16297. * @param loop defines if the animation must loop
  16298. * @param delay defines the start delay (in ms)
  16299. * @param onAnimationEnd defines a callback to call when animation ends
  16300. */
  16301. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  16302. /** Stops current animation (if any) */
  16303. stopAnimation(): void;
  16304. /** @hidden */
  16305. _animate(deltaTime: number): void;
  16306. /** Release associated resources */
  16307. dispose(): void;
  16308. }
  16309. }
  16310. declare module BABYLON {
  16311. /**
  16312. * Information about the result of picking within a scene
  16313. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  16314. */
  16315. export class PickingInfo {
  16316. /** @hidden */
  16317. _pickingUnavailable: boolean;
  16318. /**
  16319. * If the pick collided with an object
  16320. */
  16321. hit: boolean;
  16322. /**
  16323. * Distance away where the pick collided
  16324. */
  16325. distance: number;
  16326. /**
  16327. * The location of pick collision
  16328. */
  16329. pickedPoint: Nullable<Vector3>;
  16330. /**
  16331. * The mesh corresponding the the pick collision
  16332. */
  16333. pickedMesh: Nullable<AbstractMesh>;
  16334. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  16335. bu: number;
  16336. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  16337. bv: number;
  16338. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  16339. faceId: number;
  16340. /** Id of the the submesh that was picked */
  16341. subMeshId: number;
  16342. /** If a sprite was picked, this will be the sprite the pick collided with */
  16343. pickedSprite: Nullable<Sprite>;
  16344. /**
  16345. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  16346. */
  16347. originMesh: Nullable<AbstractMesh>;
  16348. /**
  16349. * The ray that was used to perform the picking.
  16350. */
  16351. ray: Nullable<Ray>;
  16352. /**
  16353. * Gets the normal correspodning to the face the pick collided with
  16354. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  16355. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  16356. * @returns The normal correspodning to the face the pick collided with
  16357. */
  16358. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  16359. /**
  16360. * Gets the texture coordinates of where the pick occured
  16361. * @returns the vector containing the coordnates of the texture
  16362. */
  16363. getTextureCoordinates(): Nullable<Vector2>;
  16364. }
  16365. }
  16366. declare module BABYLON {
  16367. /**
  16368. * Gather the list of pointer event types as constants.
  16369. */
  16370. export class PointerEventTypes {
  16371. /**
  16372. * 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.
  16373. */
  16374. static readonly POINTERDOWN: number;
  16375. /**
  16376. * The pointerup event is fired when a pointer is no longer active.
  16377. */
  16378. static readonly POINTERUP: number;
  16379. /**
  16380. * The pointermove event is fired when a pointer changes coordinates.
  16381. */
  16382. static readonly POINTERMOVE: number;
  16383. /**
  16384. * The pointerwheel event is fired when a mouse wheel has been rotated.
  16385. */
  16386. static readonly POINTERWHEEL: number;
  16387. /**
  16388. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  16389. */
  16390. static readonly POINTERPICK: number;
  16391. /**
  16392. * The pointertap event is fired when a the object has been touched and released without drag.
  16393. */
  16394. static readonly POINTERTAP: number;
  16395. /**
  16396. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  16397. */
  16398. static readonly POINTERDOUBLETAP: number;
  16399. }
  16400. /**
  16401. * Base class of pointer info types.
  16402. */
  16403. export class PointerInfoBase {
  16404. /**
  16405. * Defines the type of event (PointerEventTypes)
  16406. */
  16407. type: number;
  16408. /**
  16409. * Defines the related dom event
  16410. */
  16411. event: PointerEvent | MouseWheelEvent;
  16412. /**
  16413. * Instantiates the base class of pointers info.
  16414. * @param type Defines the type of event (PointerEventTypes)
  16415. * @param event Defines the related dom event
  16416. */
  16417. constructor(
  16418. /**
  16419. * Defines the type of event (PointerEventTypes)
  16420. */
  16421. type: number,
  16422. /**
  16423. * Defines the related dom event
  16424. */
  16425. event: PointerEvent | MouseWheelEvent);
  16426. }
  16427. /**
  16428. * This class is used to store pointer related info for the onPrePointerObservable event.
  16429. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  16430. */
  16431. export class PointerInfoPre extends PointerInfoBase {
  16432. /**
  16433. * Ray from a pointer if availible (eg. 6dof controller)
  16434. */
  16435. ray: Nullable<Ray>;
  16436. /**
  16437. * Defines the local position of the pointer on the canvas.
  16438. */
  16439. localPosition: Vector2;
  16440. /**
  16441. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  16442. */
  16443. skipOnPointerObservable: boolean;
  16444. /**
  16445. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  16446. * @param type Defines the type of event (PointerEventTypes)
  16447. * @param event Defines the related dom event
  16448. * @param localX Defines the local x coordinates of the pointer when the event occured
  16449. * @param localY Defines the local y coordinates of the pointer when the event occured
  16450. */
  16451. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  16452. }
  16453. /**
  16454. * This type contains all the data related to a pointer event in Babylon.js.
  16455. * 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.
  16456. */
  16457. export class PointerInfo extends PointerInfoBase {
  16458. /**
  16459. * Defines the picking info associated to the info (if any)\
  16460. */
  16461. pickInfo: Nullable<PickingInfo>;
  16462. /**
  16463. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  16464. * @param type Defines the type of event (PointerEventTypes)
  16465. * @param event Defines the related dom event
  16466. * @param pickInfo Defines the picking info associated to the info (if any)\
  16467. */
  16468. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  16469. /**
  16470. * Defines the picking info associated to the info (if any)\
  16471. */
  16472. pickInfo: Nullable<PickingInfo>);
  16473. }
  16474. /**
  16475. * Data relating to a touch event on the screen.
  16476. */
  16477. export interface PointerTouch {
  16478. /**
  16479. * X coordinate of touch.
  16480. */
  16481. x: number;
  16482. /**
  16483. * Y coordinate of touch.
  16484. */
  16485. y: number;
  16486. /**
  16487. * Id of touch. Unique for each finger.
  16488. */
  16489. pointerId: number;
  16490. /**
  16491. * Event type passed from DOM.
  16492. */
  16493. type: any;
  16494. }
  16495. }
  16496. declare module BABYLON {
  16497. /**
  16498. * Manage the mouse inputs to control the movement of a free camera.
  16499. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  16500. */
  16501. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  16502. /**
  16503. * Define if touch is enabled in the mouse input
  16504. */
  16505. touchEnabled: boolean;
  16506. /**
  16507. * Defines the camera the input is attached to.
  16508. */
  16509. camera: FreeCamera;
  16510. /**
  16511. * Defines the buttons associated with the input to handle camera move.
  16512. */
  16513. buttons: number[];
  16514. /**
  16515. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  16516. */
  16517. angularSensibility: number;
  16518. private _pointerInput;
  16519. private _onMouseMove;
  16520. private _observer;
  16521. private previousPosition;
  16522. /**
  16523. * Observable for when a pointer move event occurs containing the move offset
  16524. */
  16525. onPointerMovedObservable: Observable<{
  16526. offsetX: number;
  16527. offsetY: number;
  16528. }>;
  16529. /**
  16530. * @hidden
  16531. * If the camera should be rotated automatically based on pointer movement
  16532. */
  16533. _allowCameraRotation: boolean;
  16534. /**
  16535. * Manage the mouse inputs to control the movement of a free camera.
  16536. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  16537. * @param touchEnabled Defines if touch is enabled or not
  16538. */
  16539. constructor(
  16540. /**
  16541. * Define if touch is enabled in the mouse input
  16542. */
  16543. touchEnabled?: boolean);
  16544. /**
  16545. * Attach the input controls to a specific dom element to get the input from.
  16546. * @param element Defines the element the controls should be listened from
  16547. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  16548. */
  16549. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  16550. /**
  16551. * Called on JS contextmenu event.
  16552. * Override this method to provide functionality.
  16553. */
  16554. protected onContextMenu(evt: PointerEvent): void;
  16555. /**
  16556. * Detach the current controls from the specified dom element.
  16557. * @param element Defines the element to stop listening the inputs from
  16558. */
  16559. detachControl(element: Nullable<HTMLElement>): void;
  16560. /**
  16561. * Gets the class name of the current intput.
  16562. * @returns the class name
  16563. */
  16564. getClassName(): string;
  16565. /**
  16566. * Get the friendly name associated with the input class.
  16567. * @returns the input friendly name
  16568. */
  16569. getSimpleName(): string;
  16570. }
  16571. }
  16572. declare module BABYLON {
  16573. /**
  16574. * Manage the touch inputs to control the movement of a free camera.
  16575. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  16576. */
  16577. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  16578. /**
  16579. * Defines the camera the input is attached to.
  16580. */
  16581. camera: FreeCamera;
  16582. /**
  16583. * Defines the touch sensibility for rotation.
  16584. * The higher the faster.
  16585. */
  16586. touchAngularSensibility: number;
  16587. /**
  16588. * Defines the touch sensibility for move.
  16589. * The higher the faster.
  16590. */
  16591. touchMoveSensibility: number;
  16592. private _offsetX;
  16593. private _offsetY;
  16594. private _pointerPressed;
  16595. private _pointerInput;
  16596. private _observer;
  16597. private _onLostFocus;
  16598. /**
  16599. * Attach the input controls to a specific dom element to get the input from.
  16600. * @param element Defines the element the controls should be listened from
  16601. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  16602. */
  16603. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  16604. /**
  16605. * Detach the current controls from the specified dom element.
  16606. * @param element Defines the element to stop listening the inputs from
  16607. */
  16608. detachControl(element: Nullable<HTMLElement>): void;
  16609. /**
  16610. * Update the current camera state depending on the inputs that have been used this frame.
  16611. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  16612. */
  16613. checkInputs(): void;
  16614. /**
  16615. * Gets the class name of the current intput.
  16616. * @returns the class name
  16617. */
  16618. getClassName(): string;
  16619. /**
  16620. * Get the friendly name associated with the input class.
  16621. * @returns the input friendly name
  16622. */
  16623. getSimpleName(): string;
  16624. }
  16625. }
  16626. declare module BABYLON {
  16627. /**
  16628. * Default Inputs manager for the FreeCamera.
  16629. * It groups all the default supported inputs for ease of use.
  16630. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  16631. */
  16632. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  16633. /**
  16634. * @hidden
  16635. */
  16636. _mouseInput: Nullable<FreeCameraMouseInput>;
  16637. /**
  16638. * Instantiates a new FreeCameraInputsManager.
  16639. * @param camera Defines the camera the inputs belong to
  16640. */
  16641. constructor(camera: FreeCamera);
  16642. /**
  16643. * Add keyboard input support to the input manager.
  16644. * @returns the current input manager
  16645. */
  16646. addKeyboard(): FreeCameraInputsManager;
  16647. /**
  16648. * Add mouse input support to the input manager.
  16649. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  16650. * @returns the current input manager
  16651. */
  16652. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  16653. /**
  16654. * Removes the mouse input support from the manager
  16655. * @returns the current input manager
  16656. */
  16657. removeMouse(): FreeCameraInputsManager;
  16658. /**
  16659. * Add touch input support to the input manager.
  16660. * @returns the current input manager
  16661. */
  16662. addTouch(): FreeCameraInputsManager;
  16663. /**
  16664. * Remove all attached input methods from a camera
  16665. */
  16666. clear(): void;
  16667. }
  16668. }
  16669. declare module BABYLON {
  16670. /**
  16671. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  16672. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  16673. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  16674. */
  16675. export class FreeCamera extends TargetCamera {
  16676. /**
  16677. * Define the collision ellipsoid of the camera.
  16678. * This is helpful to simulate a camera body like the player body around the camera
  16679. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  16680. */
  16681. ellipsoid: Vector3;
  16682. /**
  16683. * Define an offset for the position of the ellipsoid around the camera.
  16684. * This can be helpful to determine the center of the body near the gravity center of the body
  16685. * instead of its head.
  16686. */
  16687. ellipsoidOffset: Vector3;
  16688. /**
  16689. * Enable or disable collisions of the camera with the rest of the scene objects.
  16690. */
  16691. checkCollisions: boolean;
  16692. /**
  16693. * Enable or disable gravity on the camera.
  16694. */
  16695. applyGravity: boolean;
  16696. /**
  16697. * Define the input manager associated to the camera.
  16698. */
  16699. inputs: FreeCameraInputsManager;
  16700. /**
  16701. * Gets the input sensibility for a mouse input. (default is 2000.0)
  16702. * Higher values reduce sensitivity.
  16703. */
  16704. /**
  16705. * Sets the input sensibility for a mouse input. (default is 2000.0)
  16706. * Higher values reduce sensitivity.
  16707. */
  16708. angularSensibility: number;
  16709. /**
  16710. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  16711. */
  16712. keysUp: number[];
  16713. /**
  16714. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  16715. */
  16716. keysDown: number[];
  16717. /**
  16718. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  16719. */
  16720. keysLeft: number[];
  16721. /**
  16722. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  16723. */
  16724. keysRight: number[];
  16725. /**
  16726. * Event raised when the camera collide with a mesh in the scene.
  16727. */
  16728. onCollide: (collidedMesh: AbstractMesh) => void;
  16729. private _collider;
  16730. private _needMoveForGravity;
  16731. private _oldPosition;
  16732. private _diffPosition;
  16733. private _newPosition;
  16734. /** @hidden */
  16735. _localDirection: Vector3;
  16736. /** @hidden */
  16737. _transformedDirection: Vector3;
  16738. /**
  16739. * Instantiates a Free Camera.
  16740. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  16741. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  16742. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  16743. * @param name Define the name of the camera in the scene
  16744. * @param position Define the start position of the camera in the scene
  16745. * @param scene Define the scene the camera belongs to
  16746. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  16747. */
  16748. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  16749. /**
  16750. * Attached controls to the current camera.
  16751. * @param element Defines the element the controls should be listened from
  16752. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  16753. */
  16754. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  16755. /**
  16756. * Detach the current controls from the camera.
  16757. * The camera will stop reacting to inputs.
  16758. * @param element Defines the element to stop listening the inputs from
  16759. */
  16760. detachControl(element: HTMLElement): void;
  16761. private _collisionMask;
  16762. /**
  16763. * Define a collision mask to limit the list of object the camera can collide with
  16764. */
  16765. collisionMask: number;
  16766. /** @hidden */
  16767. _collideWithWorld(displacement: Vector3): void;
  16768. private _onCollisionPositionChange;
  16769. /** @hidden */
  16770. _checkInputs(): void;
  16771. /** @hidden */
  16772. _decideIfNeedsToMove(): boolean;
  16773. /** @hidden */
  16774. _updatePosition(): void;
  16775. /**
  16776. * Destroy the camera and release the current resources hold by it.
  16777. */
  16778. dispose(): void;
  16779. /**
  16780. * Gets the current object class name.
  16781. * @return the class name
  16782. */
  16783. getClassName(): string;
  16784. }
  16785. }
  16786. declare module BABYLON {
  16787. /**
  16788. * Represents a gamepad control stick position
  16789. */
  16790. export class StickValues {
  16791. /**
  16792. * The x component of the control stick
  16793. */
  16794. x: number;
  16795. /**
  16796. * The y component of the control stick
  16797. */
  16798. y: number;
  16799. /**
  16800. * Initializes the gamepad x and y control stick values
  16801. * @param x The x component of the gamepad control stick value
  16802. * @param y The y component of the gamepad control stick value
  16803. */
  16804. constructor(
  16805. /**
  16806. * The x component of the control stick
  16807. */
  16808. x: number,
  16809. /**
  16810. * The y component of the control stick
  16811. */
  16812. y: number);
  16813. }
  16814. /**
  16815. * An interface which manages callbacks for gamepad button changes
  16816. */
  16817. export interface GamepadButtonChanges {
  16818. /**
  16819. * Called when a gamepad has been changed
  16820. */
  16821. changed: boolean;
  16822. /**
  16823. * Called when a gamepad press event has been triggered
  16824. */
  16825. pressChanged: boolean;
  16826. /**
  16827. * Called when a touch event has been triggered
  16828. */
  16829. touchChanged: boolean;
  16830. /**
  16831. * Called when a value has changed
  16832. */
  16833. valueChanged: boolean;
  16834. }
  16835. /**
  16836. * Represents a gamepad
  16837. */
  16838. export class Gamepad {
  16839. /**
  16840. * The id of the gamepad
  16841. */
  16842. id: string;
  16843. /**
  16844. * The index of the gamepad
  16845. */
  16846. index: number;
  16847. /**
  16848. * The browser gamepad
  16849. */
  16850. browserGamepad: any;
  16851. /**
  16852. * Specifies what type of gamepad this represents
  16853. */
  16854. type: number;
  16855. private _leftStick;
  16856. private _rightStick;
  16857. /** @hidden */
  16858. _isConnected: boolean;
  16859. private _leftStickAxisX;
  16860. private _leftStickAxisY;
  16861. private _rightStickAxisX;
  16862. private _rightStickAxisY;
  16863. /**
  16864. * Triggered when the left control stick has been changed
  16865. */
  16866. private _onleftstickchanged;
  16867. /**
  16868. * Triggered when the right control stick has been changed
  16869. */
  16870. private _onrightstickchanged;
  16871. /**
  16872. * Represents a gamepad controller
  16873. */
  16874. static GAMEPAD: number;
  16875. /**
  16876. * Represents a generic controller
  16877. */
  16878. static GENERIC: number;
  16879. /**
  16880. * Represents an XBox controller
  16881. */
  16882. static XBOX: number;
  16883. /**
  16884. * Represents a pose-enabled controller
  16885. */
  16886. static POSE_ENABLED: number;
  16887. /**
  16888. * Specifies whether the left control stick should be Y-inverted
  16889. */
  16890. protected _invertLeftStickY: boolean;
  16891. /**
  16892. * Specifies if the gamepad has been connected
  16893. */
  16894. readonly isConnected: boolean;
  16895. /**
  16896. * Initializes the gamepad
  16897. * @param id The id of the gamepad
  16898. * @param index The index of the gamepad
  16899. * @param browserGamepad The browser gamepad
  16900. * @param leftStickX The x component of the left joystick
  16901. * @param leftStickY The y component of the left joystick
  16902. * @param rightStickX The x component of the right joystick
  16903. * @param rightStickY The y component of the right joystick
  16904. */
  16905. constructor(
  16906. /**
  16907. * The id of the gamepad
  16908. */
  16909. id: string,
  16910. /**
  16911. * The index of the gamepad
  16912. */
  16913. index: number,
  16914. /**
  16915. * The browser gamepad
  16916. */
  16917. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  16918. /**
  16919. * Callback triggered when the left joystick has changed
  16920. * @param callback
  16921. */
  16922. onleftstickchanged(callback: (values: StickValues) => void): void;
  16923. /**
  16924. * Callback triggered when the right joystick has changed
  16925. * @param callback
  16926. */
  16927. onrightstickchanged(callback: (values: StickValues) => void): void;
  16928. /**
  16929. * Gets the left joystick
  16930. */
  16931. /**
  16932. * Sets the left joystick values
  16933. */
  16934. leftStick: StickValues;
  16935. /**
  16936. * Gets the right joystick
  16937. */
  16938. /**
  16939. * Sets the right joystick value
  16940. */
  16941. rightStick: StickValues;
  16942. /**
  16943. * Updates the gamepad joystick positions
  16944. */
  16945. update(): void;
  16946. /**
  16947. * Disposes the gamepad
  16948. */
  16949. dispose(): void;
  16950. }
  16951. /**
  16952. * Represents a generic gamepad
  16953. */
  16954. export class GenericPad extends Gamepad {
  16955. private _buttons;
  16956. private _onbuttondown;
  16957. private _onbuttonup;
  16958. /**
  16959. * Observable triggered when a button has been pressed
  16960. */
  16961. onButtonDownObservable: Observable<number>;
  16962. /**
  16963. * Observable triggered when a button has been released
  16964. */
  16965. onButtonUpObservable: Observable<number>;
  16966. /**
  16967. * Callback triggered when a button has been pressed
  16968. * @param callback Called when a button has been pressed
  16969. */
  16970. onbuttondown(callback: (buttonPressed: number) => void): void;
  16971. /**
  16972. * Callback triggered when a button has been released
  16973. * @param callback Called when a button has been released
  16974. */
  16975. onbuttonup(callback: (buttonReleased: number) => void): void;
  16976. /**
  16977. * Initializes the generic gamepad
  16978. * @param id The id of the generic gamepad
  16979. * @param index The index of the generic gamepad
  16980. * @param browserGamepad The browser gamepad
  16981. */
  16982. constructor(id: string, index: number, browserGamepad: any);
  16983. private _setButtonValue;
  16984. /**
  16985. * Updates the generic gamepad
  16986. */
  16987. update(): void;
  16988. /**
  16989. * Disposes the generic gamepad
  16990. */
  16991. dispose(): void;
  16992. }
  16993. }
  16994. declare module BABYLON {
  16995. /**
  16996. * Defines the types of pose enabled controllers that are supported
  16997. */
  16998. export enum PoseEnabledControllerType {
  16999. /**
  17000. * HTC Vive
  17001. */
  17002. VIVE = 0,
  17003. /**
  17004. * Oculus Rift
  17005. */
  17006. OCULUS = 1,
  17007. /**
  17008. * Windows mixed reality
  17009. */
  17010. WINDOWS = 2,
  17011. /**
  17012. * Samsung gear VR
  17013. */
  17014. GEAR_VR = 3,
  17015. /**
  17016. * Google Daydream
  17017. */
  17018. DAYDREAM = 4,
  17019. /**
  17020. * Generic
  17021. */
  17022. GENERIC = 5
  17023. }
  17024. /**
  17025. * Defines the MutableGamepadButton interface for the state of a gamepad button
  17026. */
  17027. export interface MutableGamepadButton {
  17028. /**
  17029. * Value of the button/trigger
  17030. */
  17031. value: number;
  17032. /**
  17033. * If the button/trigger is currently touched
  17034. */
  17035. touched: boolean;
  17036. /**
  17037. * If the button/trigger is currently pressed
  17038. */
  17039. pressed: boolean;
  17040. }
  17041. /**
  17042. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  17043. * @hidden
  17044. */
  17045. export interface ExtendedGamepadButton extends GamepadButton {
  17046. /**
  17047. * If the button/trigger is currently pressed
  17048. */
  17049. readonly pressed: boolean;
  17050. /**
  17051. * If the button/trigger is currently touched
  17052. */
  17053. readonly touched: boolean;
  17054. /**
  17055. * Value of the button/trigger
  17056. */
  17057. readonly value: number;
  17058. }
  17059. /** @hidden */
  17060. export interface _GamePadFactory {
  17061. /**
  17062. * Returns wether or not the current gamepad can be created for this type of controller.
  17063. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  17064. * @returns true if it can be created, otherwise false
  17065. */
  17066. canCreate(gamepadInfo: any): boolean;
  17067. /**
  17068. * Creates a new instance of the Gamepad.
  17069. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  17070. * @returns the new gamepad instance
  17071. */
  17072. create(gamepadInfo: any): Gamepad;
  17073. }
  17074. /**
  17075. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  17076. */
  17077. export class PoseEnabledControllerHelper {
  17078. /** @hidden */
  17079. static _ControllerFactories: _GamePadFactory[];
  17080. /** @hidden */
  17081. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  17082. /**
  17083. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  17084. * @param vrGamepad the gamepad to initialized
  17085. * @returns a vr controller of the type the gamepad identified as
  17086. */
  17087. static InitiateController(vrGamepad: any): Gamepad;
  17088. }
  17089. /**
  17090. * Defines the PoseEnabledController object that contains state of a vr capable controller
  17091. */
  17092. export class PoseEnabledController extends Gamepad implements PoseControlled {
  17093. private _deviceRoomPosition;
  17094. private _deviceRoomRotationQuaternion;
  17095. /**
  17096. * The device position in babylon space
  17097. */
  17098. devicePosition: Vector3;
  17099. /**
  17100. * The device rotation in babylon space
  17101. */
  17102. deviceRotationQuaternion: Quaternion;
  17103. /**
  17104. * The scale factor of the device in babylon space
  17105. */
  17106. deviceScaleFactor: number;
  17107. /**
  17108. * (Likely devicePosition should be used instead) The device position in its room space
  17109. */
  17110. position: Vector3;
  17111. /**
  17112. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  17113. */
  17114. rotationQuaternion: Quaternion;
  17115. /**
  17116. * The type of controller (Eg. Windows mixed reality)
  17117. */
  17118. controllerType: PoseEnabledControllerType;
  17119. protected _calculatedPosition: Vector3;
  17120. private _calculatedRotation;
  17121. /**
  17122. * The raw pose from the device
  17123. */
  17124. rawPose: DevicePose;
  17125. private _trackPosition;
  17126. private _maxRotationDistFromHeadset;
  17127. private _draggedRoomRotation;
  17128. /**
  17129. * @hidden
  17130. */
  17131. _disableTrackPosition(fixedPosition: Vector3): void;
  17132. /**
  17133. * Internal, the mesh attached to the controller
  17134. * @hidden
  17135. */
  17136. _mesh: Nullable<AbstractMesh>;
  17137. private _poseControlledCamera;
  17138. private _leftHandSystemQuaternion;
  17139. /**
  17140. * Internal, matrix used to convert room space to babylon space
  17141. * @hidden
  17142. */
  17143. _deviceToWorld: Matrix;
  17144. /**
  17145. * Node to be used when casting a ray from the controller
  17146. * @hidden
  17147. */
  17148. _pointingPoseNode: Nullable<TransformNode>;
  17149. /**
  17150. * Name of the child mesh that can be used to cast a ray from the controller
  17151. */
  17152. static readonly POINTING_POSE: string;
  17153. /**
  17154. * Creates a new PoseEnabledController from a gamepad
  17155. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  17156. */
  17157. constructor(browserGamepad: any);
  17158. private _workingMatrix;
  17159. /**
  17160. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  17161. */
  17162. update(): void;
  17163. /**
  17164. * Updates only the pose device and mesh without doing any button event checking
  17165. */
  17166. protected _updatePoseAndMesh(): void;
  17167. /**
  17168. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  17169. * @param poseData raw pose fromthe device
  17170. */
  17171. updateFromDevice(poseData: DevicePose): void;
  17172. /**
  17173. * @hidden
  17174. */
  17175. _meshAttachedObservable: Observable<AbstractMesh>;
  17176. /**
  17177. * Attaches a mesh to the controller
  17178. * @param mesh the mesh to be attached
  17179. */
  17180. attachToMesh(mesh: AbstractMesh): void;
  17181. /**
  17182. * Attaches the controllers mesh to a camera
  17183. * @param camera the camera the mesh should be attached to
  17184. */
  17185. attachToPoseControlledCamera(camera: TargetCamera): void;
  17186. /**
  17187. * Disposes of the controller
  17188. */
  17189. dispose(): void;
  17190. /**
  17191. * The mesh that is attached to the controller
  17192. */
  17193. readonly mesh: Nullable<AbstractMesh>;
  17194. /**
  17195. * Gets the ray of the controller in the direction the controller is pointing
  17196. * @param length the length the resulting ray should be
  17197. * @returns a ray in the direction the controller is pointing
  17198. */
  17199. getForwardRay(length?: number): Ray;
  17200. }
  17201. }
  17202. declare module BABYLON {
  17203. /**
  17204. * Defines the WebVRController object that represents controllers tracked in 3D space
  17205. */
  17206. export abstract class WebVRController extends PoseEnabledController {
  17207. /**
  17208. * Internal, the default controller model for the controller
  17209. */
  17210. protected _defaultModel: AbstractMesh;
  17211. /**
  17212. * Fired when the trigger state has changed
  17213. */
  17214. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  17215. /**
  17216. * Fired when the main button state has changed
  17217. */
  17218. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  17219. /**
  17220. * Fired when the secondary button state has changed
  17221. */
  17222. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  17223. /**
  17224. * Fired when the pad state has changed
  17225. */
  17226. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  17227. /**
  17228. * Fired when controllers stick values have changed
  17229. */
  17230. onPadValuesChangedObservable: Observable<StickValues>;
  17231. /**
  17232. * Array of button availible on the controller
  17233. */
  17234. protected _buttons: Array<MutableGamepadButton>;
  17235. private _onButtonStateChange;
  17236. /**
  17237. * Fired when a controller button's state has changed
  17238. * @param callback the callback containing the button that was modified
  17239. */
  17240. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  17241. /**
  17242. * X and Y axis corresponding to the controllers joystick
  17243. */
  17244. pad: StickValues;
  17245. /**
  17246. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  17247. */
  17248. hand: string;
  17249. /**
  17250. * The default controller model for the controller
  17251. */
  17252. readonly defaultModel: AbstractMesh;
  17253. /**
  17254. * Creates a new WebVRController from a gamepad
  17255. * @param vrGamepad the gamepad that the WebVRController should be created from
  17256. */
  17257. constructor(vrGamepad: any);
  17258. /**
  17259. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  17260. */
  17261. update(): void;
  17262. /**
  17263. * Function to be called when a button is modified
  17264. */
  17265. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  17266. /**
  17267. * Loads a mesh and attaches it to the controller
  17268. * @param scene the scene the mesh should be added to
  17269. * @param meshLoaded callback for when the mesh has been loaded
  17270. */
  17271. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  17272. private _setButtonValue;
  17273. private _changes;
  17274. private _checkChanges;
  17275. /**
  17276. * Disposes of th webVRCOntroller
  17277. */
  17278. dispose(): void;
  17279. }
  17280. }
  17281. declare module BABYLON {
  17282. /**
  17283. * The HemisphericLight simulates the ambient environment light,
  17284. * so the passed direction is the light reflection direction, not the incoming direction.
  17285. */
  17286. export class HemisphericLight extends Light {
  17287. /**
  17288. * The groundColor is the light in the opposite direction to the one specified during creation.
  17289. * 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.
  17290. */
  17291. groundColor: Color3;
  17292. /**
  17293. * The light reflection direction, not the incoming direction.
  17294. */
  17295. direction: Vector3;
  17296. /**
  17297. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  17298. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  17299. * The HemisphericLight can't cast shadows.
  17300. * Documentation : https://doc.babylonjs.com/babylon101/lights
  17301. * @param name The friendly name of the light
  17302. * @param direction The direction of the light reflection
  17303. * @param scene The scene the light belongs to
  17304. */
  17305. constructor(name: string, direction: Vector3, scene: Scene);
  17306. protected _buildUniformLayout(): void;
  17307. /**
  17308. * Returns the string "HemisphericLight".
  17309. * @return The class name
  17310. */
  17311. getClassName(): string;
  17312. /**
  17313. * Sets the HemisphericLight direction towards the passed target (Vector3).
  17314. * Returns the updated direction.
  17315. * @param target The target the direction should point to
  17316. * @return The computed direction
  17317. */
  17318. setDirectionToTarget(target: Vector3): Vector3;
  17319. /**
  17320. * Returns the shadow generator associated to the light.
  17321. * @returns Always null for hemispheric lights because it does not support shadows.
  17322. */
  17323. getShadowGenerator(): Nullable<IShadowGenerator>;
  17324. /**
  17325. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  17326. * @param effect The effect to update
  17327. * @param lightIndex The index of the light in the effect to update
  17328. * @returns The hemispheric light
  17329. */
  17330. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  17331. /**
  17332. * Computes the world matrix of the node
  17333. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  17334. * @param useWasUpdatedFlag defines a reserved property
  17335. * @returns the world matrix
  17336. */
  17337. computeWorldMatrix(): Matrix;
  17338. /**
  17339. * Returns the integer 3.
  17340. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  17341. */
  17342. getTypeID(): number;
  17343. /**
  17344. * Prepares the list of defines specific to the light type.
  17345. * @param defines the list of defines
  17346. * @param lightIndex defines the index of the light for the effect
  17347. */
  17348. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  17349. }
  17350. }
  17351. declare module BABYLON {
  17352. /** @hidden */
  17353. export var vrMultiviewToSingleviewPixelShader: {
  17354. name: string;
  17355. shader: string;
  17356. };
  17357. }
  17358. declare module BABYLON {
  17359. /**
  17360. * Renders to multiple views with a single draw call
  17361. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  17362. */
  17363. export class MultiviewRenderTarget extends RenderTargetTexture {
  17364. /**
  17365. * Creates a multiview render target
  17366. * @param scene scene used with the render target
  17367. * @param size the size of the render target (used for each view)
  17368. */
  17369. constructor(scene: Scene, size?: number | {
  17370. width: number;
  17371. height: number;
  17372. } | {
  17373. ratio: number;
  17374. });
  17375. /**
  17376. * @hidden
  17377. * @param faceIndex the face index, if its a cube texture
  17378. */
  17379. _bindFrameBuffer(faceIndex?: number): void;
  17380. /**
  17381. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  17382. * @returns the view count
  17383. */
  17384. getViewCount(): number;
  17385. }
  17386. }
  17387. declare module BABYLON {
  17388. interface Engine {
  17389. /**
  17390. * Creates a new multiview render target
  17391. * @param width defines the width of the texture
  17392. * @param height defines the height of the texture
  17393. * @returns the created multiview texture
  17394. */
  17395. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  17396. /**
  17397. * Binds a multiview framebuffer to be drawn to
  17398. * @param multiviewTexture texture to bind
  17399. */
  17400. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  17401. }
  17402. interface Camera {
  17403. /**
  17404. * @hidden
  17405. * 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)
  17406. */
  17407. _useMultiviewToSingleView: boolean;
  17408. /**
  17409. * @hidden
  17410. * 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)
  17411. */
  17412. _multiviewTexture: Nullable<RenderTargetTexture>;
  17413. /**
  17414. * @hidden
  17415. * ensures the multiview texture of the camera exists and has the specified width/height
  17416. * @param width height to set on the multiview texture
  17417. * @param height width to set on the multiview texture
  17418. */
  17419. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  17420. }
  17421. interface Scene {
  17422. /** @hidden */
  17423. _transformMatrixR: Matrix;
  17424. /** @hidden */
  17425. _multiviewSceneUbo: Nullable<UniformBuffer>;
  17426. /** @hidden */
  17427. _createMultiviewUbo(): void;
  17428. /** @hidden */
  17429. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  17430. /** @hidden */
  17431. _renderMultiviewToSingleView(camera: Camera): void;
  17432. }
  17433. }
  17434. declare module BABYLON {
  17435. /**
  17436. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  17437. * This will not be used for webXR as it supports displaying texture arrays directly
  17438. */
  17439. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  17440. /**
  17441. * Initializes a VRMultiviewToSingleview
  17442. * @param name name of the post process
  17443. * @param camera camera to be applied to
  17444. * @param scaleFactor scaling factor to the size of the output texture
  17445. */
  17446. constructor(name: string, camera: Camera, scaleFactor: number);
  17447. }
  17448. }
  17449. declare module BABYLON {
  17450. interface Engine {
  17451. /** @hidden */
  17452. _vrDisplay: any;
  17453. /** @hidden */
  17454. _vrSupported: boolean;
  17455. /** @hidden */
  17456. _oldSize: Size;
  17457. /** @hidden */
  17458. _oldHardwareScaleFactor: number;
  17459. /** @hidden */
  17460. _vrExclusivePointerMode: boolean;
  17461. /** @hidden */
  17462. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  17463. /** @hidden */
  17464. _onVRDisplayPointerRestricted: () => void;
  17465. /** @hidden */
  17466. _onVRDisplayPointerUnrestricted: () => void;
  17467. /** @hidden */
  17468. _onVrDisplayConnect: Nullable<(display: any) => void>;
  17469. /** @hidden */
  17470. _onVrDisplayDisconnect: Nullable<() => void>;
  17471. /** @hidden */
  17472. _onVrDisplayPresentChange: Nullable<() => void>;
  17473. /**
  17474. * Observable signaled when VR display mode changes
  17475. */
  17476. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  17477. /**
  17478. * Observable signaled when VR request present is complete
  17479. */
  17480. onVRRequestPresentComplete: Observable<boolean>;
  17481. /**
  17482. * Observable signaled when VR request present starts
  17483. */
  17484. onVRRequestPresentStart: Observable<Engine>;
  17485. /**
  17486. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  17487. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  17488. */
  17489. isInVRExclusivePointerMode: boolean;
  17490. /**
  17491. * Gets a boolean indicating if a webVR device was detected
  17492. * @returns true if a webVR device was detected
  17493. */
  17494. isVRDevicePresent(): boolean;
  17495. /**
  17496. * Gets the current webVR device
  17497. * @returns the current webVR device (or null)
  17498. */
  17499. getVRDevice(): any;
  17500. /**
  17501. * Initializes a webVR display and starts listening to display change events
  17502. * The onVRDisplayChangedObservable will be notified upon these changes
  17503. * @returns A promise containing a VRDisplay and if vr is supported
  17504. */
  17505. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  17506. /** @hidden */
  17507. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  17508. /**
  17509. * Call this function to switch to webVR mode
  17510. * Will do nothing if webVR is not supported or if there is no webVR device
  17511. * @see http://doc.babylonjs.com/how_to/webvr_camera
  17512. */
  17513. enableVR(): void;
  17514. /** @hidden */
  17515. _onVRFullScreenTriggered(): void;
  17516. }
  17517. }
  17518. declare module BABYLON {
  17519. /**
  17520. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  17521. * IMPORTANT!! The data is right-hand data.
  17522. * @export
  17523. * @interface DevicePose
  17524. */
  17525. export interface DevicePose {
  17526. /**
  17527. * The position of the device, values in array are [x,y,z].
  17528. */
  17529. readonly position: Nullable<Float32Array>;
  17530. /**
  17531. * The linearVelocity of the device, values in array are [x,y,z].
  17532. */
  17533. readonly linearVelocity: Nullable<Float32Array>;
  17534. /**
  17535. * The linearAcceleration of the device, values in array are [x,y,z].
  17536. */
  17537. readonly linearAcceleration: Nullable<Float32Array>;
  17538. /**
  17539. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  17540. */
  17541. readonly orientation: Nullable<Float32Array>;
  17542. /**
  17543. * The angularVelocity of the device, values in array are [x,y,z].
  17544. */
  17545. readonly angularVelocity: Nullable<Float32Array>;
  17546. /**
  17547. * The angularAcceleration of the device, values in array are [x,y,z].
  17548. */
  17549. readonly angularAcceleration: Nullable<Float32Array>;
  17550. }
  17551. /**
  17552. * Interface representing a pose controlled object in Babylon.
  17553. * A pose controlled object has both regular pose values as well as pose values
  17554. * from an external device such as a VR head mounted display
  17555. */
  17556. export interface PoseControlled {
  17557. /**
  17558. * The position of the object in babylon space.
  17559. */
  17560. position: Vector3;
  17561. /**
  17562. * The rotation quaternion of the object in babylon space.
  17563. */
  17564. rotationQuaternion: Quaternion;
  17565. /**
  17566. * The position of the device in babylon space.
  17567. */
  17568. devicePosition?: Vector3;
  17569. /**
  17570. * The rotation quaternion of the device in babylon space.
  17571. */
  17572. deviceRotationQuaternion: Quaternion;
  17573. /**
  17574. * The raw pose coming from the device.
  17575. */
  17576. rawPose: Nullable<DevicePose>;
  17577. /**
  17578. * The scale of the device to be used when translating from device space to babylon space.
  17579. */
  17580. deviceScaleFactor: number;
  17581. /**
  17582. * Updates the poseControlled values based on the input device pose.
  17583. * @param poseData the pose data to update the object with
  17584. */
  17585. updateFromDevice(poseData: DevicePose): void;
  17586. }
  17587. /**
  17588. * Set of options to customize the webVRCamera
  17589. */
  17590. export interface WebVROptions {
  17591. /**
  17592. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  17593. */
  17594. trackPosition?: boolean;
  17595. /**
  17596. * Sets the scale of the vrDevice in babylon space. (default: 1)
  17597. */
  17598. positionScale?: number;
  17599. /**
  17600. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  17601. */
  17602. displayName?: string;
  17603. /**
  17604. * Should the native controller meshes be initialized. (default: true)
  17605. */
  17606. controllerMeshes?: boolean;
  17607. /**
  17608. * Creating a default HemiLight only on controllers. (default: true)
  17609. */
  17610. defaultLightingOnControllers?: boolean;
  17611. /**
  17612. * If you don't want to use the default VR button of the helper. (default: false)
  17613. */
  17614. useCustomVRButton?: boolean;
  17615. /**
  17616. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  17617. */
  17618. customVRButton?: HTMLButtonElement;
  17619. /**
  17620. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  17621. */
  17622. rayLength?: number;
  17623. /**
  17624. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  17625. */
  17626. defaultHeight?: number;
  17627. /**
  17628. * If multiview should be used if availible (default: false)
  17629. */
  17630. useMultiview?: boolean;
  17631. }
  17632. /**
  17633. * This represents a WebVR camera.
  17634. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  17635. * @example http://doc.babylonjs.com/how_to/webvr_camera
  17636. */
  17637. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  17638. private webVROptions;
  17639. /**
  17640. * @hidden
  17641. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  17642. */
  17643. _vrDevice: any;
  17644. /**
  17645. * The rawPose of the vrDevice.
  17646. */
  17647. rawPose: Nullable<DevicePose>;
  17648. private _onVREnabled;
  17649. private _specsVersion;
  17650. private _attached;
  17651. private _frameData;
  17652. protected _descendants: Array<Node>;
  17653. private _deviceRoomPosition;
  17654. /** @hidden */
  17655. _deviceRoomRotationQuaternion: Quaternion;
  17656. private _standingMatrix;
  17657. /**
  17658. * Represents device position in babylon space.
  17659. */
  17660. devicePosition: Vector3;
  17661. /**
  17662. * Represents device rotation in babylon space.
  17663. */
  17664. deviceRotationQuaternion: Quaternion;
  17665. /**
  17666. * The scale of the device to be used when translating from device space to babylon space.
  17667. */
  17668. deviceScaleFactor: number;
  17669. private _deviceToWorld;
  17670. private _worldToDevice;
  17671. /**
  17672. * References to the webVR controllers for the vrDevice.
  17673. */
  17674. controllers: Array<WebVRController>;
  17675. /**
  17676. * Emits an event when a controller is attached.
  17677. */
  17678. onControllersAttachedObservable: Observable<WebVRController[]>;
  17679. /**
  17680. * Emits an event when a controller's mesh has been loaded;
  17681. */
  17682. onControllerMeshLoadedObservable: Observable<WebVRController>;
  17683. /**
  17684. * Emits an event when the HMD's pose has been updated.
  17685. */
  17686. onPoseUpdatedFromDeviceObservable: Observable<any>;
  17687. private _poseSet;
  17688. /**
  17689. * If the rig cameras be used as parent instead of this camera.
  17690. */
  17691. rigParenting: boolean;
  17692. private _lightOnControllers;
  17693. private _defaultHeight?;
  17694. /**
  17695. * Instantiates a WebVRFreeCamera.
  17696. * @param name The name of the WebVRFreeCamera
  17697. * @param position The starting anchor position for the camera
  17698. * @param scene The scene the camera belongs to
  17699. * @param webVROptions a set of customizable options for the webVRCamera
  17700. */
  17701. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  17702. /**
  17703. * Gets the device distance from the ground in meters.
  17704. * @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.
  17705. */
  17706. deviceDistanceToRoomGround(): number;
  17707. /**
  17708. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  17709. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  17710. */
  17711. useStandingMatrix(callback?: (bool: boolean) => void): void;
  17712. /**
  17713. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  17714. * @returns A promise with a boolean set to if the standing matrix is supported.
  17715. */
  17716. useStandingMatrixAsync(): Promise<boolean>;
  17717. /**
  17718. * Disposes the camera
  17719. */
  17720. dispose(): void;
  17721. /**
  17722. * Gets a vrController by name.
  17723. * @param name The name of the controller to retreive
  17724. * @returns the controller matching the name specified or null if not found
  17725. */
  17726. getControllerByName(name: string): Nullable<WebVRController>;
  17727. private _leftController;
  17728. /**
  17729. * The controller corresponding to the users left hand.
  17730. */
  17731. readonly leftController: Nullable<WebVRController>;
  17732. private _rightController;
  17733. /**
  17734. * The controller corresponding to the users right hand.
  17735. */
  17736. readonly rightController: Nullable<WebVRController>;
  17737. /**
  17738. * Casts a ray forward from the vrCamera's gaze.
  17739. * @param length Length of the ray (default: 100)
  17740. * @returns the ray corresponding to the gaze
  17741. */
  17742. getForwardRay(length?: number): Ray;
  17743. /**
  17744. * @hidden
  17745. * Updates the camera based on device's frame data
  17746. */
  17747. _checkInputs(): void;
  17748. /**
  17749. * Updates the poseControlled values based on the input device pose.
  17750. * @param poseData Pose coming from the device
  17751. */
  17752. updateFromDevice(poseData: DevicePose): void;
  17753. private _htmlElementAttached;
  17754. private _detachIfAttached;
  17755. /**
  17756. * WebVR's attach control will start broadcasting frames to the device.
  17757. * Note that in certain browsers (chrome for example) this function must be called
  17758. * within a user-interaction callback. Example:
  17759. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  17760. *
  17761. * @param element html element to attach the vrDevice to
  17762. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  17763. */
  17764. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  17765. /**
  17766. * Detaches the camera from the html element and disables VR
  17767. *
  17768. * @param element html element to detach from
  17769. */
  17770. detachControl(element: HTMLElement): void;
  17771. /**
  17772. * @returns the name of this class
  17773. */
  17774. getClassName(): string;
  17775. /**
  17776. * Calls resetPose on the vrDisplay
  17777. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  17778. */
  17779. resetToCurrentRotation(): void;
  17780. /**
  17781. * @hidden
  17782. * Updates the rig cameras (left and right eye)
  17783. */
  17784. _updateRigCameras(): void;
  17785. private _workingVector;
  17786. private _oneVector;
  17787. private _workingMatrix;
  17788. private updateCacheCalled;
  17789. private _correctPositionIfNotTrackPosition;
  17790. /**
  17791. * @hidden
  17792. * Updates the cached values of the camera
  17793. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  17794. */
  17795. _updateCache(ignoreParentClass?: boolean): void;
  17796. /**
  17797. * @hidden
  17798. * Get current device position in babylon world
  17799. */
  17800. _computeDevicePosition(): void;
  17801. /**
  17802. * Updates the current device position and rotation in the babylon world
  17803. */
  17804. update(): void;
  17805. /**
  17806. * @hidden
  17807. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  17808. * @returns an identity matrix
  17809. */
  17810. _getViewMatrix(): Matrix;
  17811. private _tmpMatrix;
  17812. /**
  17813. * This function is called by the two RIG cameras.
  17814. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  17815. * @hidden
  17816. */
  17817. _getWebVRViewMatrix(): Matrix;
  17818. /** @hidden */
  17819. _getWebVRProjectionMatrix(): Matrix;
  17820. private _onGamepadConnectedObserver;
  17821. private _onGamepadDisconnectedObserver;
  17822. private _updateCacheWhenTrackingDisabledObserver;
  17823. /**
  17824. * Initializes the controllers and their meshes
  17825. */
  17826. initControllers(): void;
  17827. }
  17828. }
  17829. declare module BABYLON {
  17830. /**
  17831. * Size options for a post process
  17832. */
  17833. export type PostProcessOptions = {
  17834. width: number;
  17835. height: number;
  17836. };
  17837. /**
  17838. * PostProcess can be used to apply a shader to a texture after it has been rendered
  17839. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  17840. */
  17841. export class PostProcess {
  17842. /** Name of the PostProcess. */
  17843. name: string;
  17844. /**
  17845. * Gets or sets the unique id of the post process
  17846. */
  17847. uniqueId: number;
  17848. /**
  17849. * Width of the texture to apply the post process on
  17850. */
  17851. width: number;
  17852. /**
  17853. * Height of the texture to apply the post process on
  17854. */
  17855. height: number;
  17856. /**
  17857. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  17858. * @hidden
  17859. */
  17860. _outputTexture: Nullable<InternalTexture>;
  17861. /**
  17862. * Sampling mode used by the shader
  17863. * See https://doc.babylonjs.com/classes/3.1/texture
  17864. */
  17865. renderTargetSamplingMode: number;
  17866. /**
  17867. * Clear color to use when screen clearing
  17868. */
  17869. clearColor: Color4;
  17870. /**
  17871. * If the buffer needs to be cleared before applying the post process. (default: true)
  17872. * Should be set to false if shader will overwrite all previous pixels.
  17873. */
  17874. autoClear: boolean;
  17875. /**
  17876. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  17877. */
  17878. alphaMode: number;
  17879. /**
  17880. * Sets the setAlphaBlendConstants of the babylon engine
  17881. */
  17882. alphaConstants: Color4;
  17883. /**
  17884. * Animations to be used for the post processing
  17885. */
  17886. animations: Animation[];
  17887. /**
  17888. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  17889. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  17890. */
  17891. enablePixelPerfectMode: boolean;
  17892. /**
  17893. * Force the postprocess to be applied without taking in account viewport
  17894. */
  17895. forceFullscreenViewport: boolean;
  17896. /**
  17897. * List of inspectable custom properties (used by the Inspector)
  17898. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  17899. */
  17900. inspectableCustomProperties: IInspectable[];
  17901. /**
  17902. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  17903. *
  17904. * | Value | Type | Description |
  17905. * | ----- | ----------------------------------- | ----------- |
  17906. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  17907. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  17908. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  17909. *
  17910. */
  17911. scaleMode: number;
  17912. /**
  17913. * Force textures to be a power of two (default: false)
  17914. */
  17915. alwaysForcePOT: boolean;
  17916. private _samples;
  17917. /**
  17918. * Number of sample textures (default: 1)
  17919. */
  17920. samples: number;
  17921. /**
  17922. * Modify the scale of the post process to be the same as the viewport (default: false)
  17923. */
  17924. adaptScaleToCurrentViewport: boolean;
  17925. private _camera;
  17926. private _scene;
  17927. private _engine;
  17928. private _options;
  17929. private _reusable;
  17930. private _textureType;
  17931. /**
  17932. * Smart array of input and output textures for the post process.
  17933. * @hidden
  17934. */
  17935. _textures: SmartArray<InternalTexture>;
  17936. /**
  17937. * The index in _textures that corresponds to the output texture.
  17938. * @hidden
  17939. */
  17940. _currentRenderTextureInd: number;
  17941. private _effect;
  17942. private _samplers;
  17943. private _fragmentUrl;
  17944. private _vertexUrl;
  17945. private _parameters;
  17946. private _scaleRatio;
  17947. protected _indexParameters: any;
  17948. private _shareOutputWithPostProcess;
  17949. private _texelSize;
  17950. private _forcedOutputTexture;
  17951. /**
  17952. * Returns the fragment url or shader name used in the post process.
  17953. * @returns the fragment url or name in the shader store.
  17954. */
  17955. getEffectName(): string;
  17956. /**
  17957. * An event triggered when the postprocess is activated.
  17958. */
  17959. onActivateObservable: Observable<Camera>;
  17960. private _onActivateObserver;
  17961. /**
  17962. * A function that is added to the onActivateObservable
  17963. */
  17964. onActivate: Nullable<(camera: Camera) => void>;
  17965. /**
  17966. * An event triggered when the postprocess changes its size.
  17967. */
  17968. onSizeChangedObservable: Observable<PostProcess>;
  17969. private _onSizeChangedObserver;
  17970. /**
  17971. * A function that is added to the onSizeChangedObservable
  17972. */
  17973. onSizeChanged: (postProcess: PostProcess) => void;
  17974. /**
  17975. * An event triggered when the postprocess applies its effect.
  17976. */
  17977. onApplyObservable: Observable<Effect>;
  17978. private _onApplyObserver;
  17979. /**
  17980. * A function that is added to the onApplyObservable
  17981. */
  17982. onApply: (effect: Effect) => void;
  17983. /**
  17984. * An event triggered before rendering the postprocess
  17985. */
  17986. onBeforeRenderObservable: Observable<Effect>;
  17987. private _onBeforeRenderObserver;
  17988. /**
  17989. * A function that is added to the onBeforeRenderObservable
  17990. */
  17991. onBeforeRender: (effect: Effect) => void;
  17992. /**
  17993. * An event triggered after rendering the postprocess
  17994. */
  17995. onAfterRenderObservable: Observable<Effect>;
  17996. private _onAfterRenderObserver;
  17997. /**
  17998. * A function that is added to the onAfterRenderObservable
  17999. */
  18000. onAfterRender: (efect: Effect) => void;
  18001. /**
  18002. * 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
  18003. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  18004. */
  18005. inputTexture: InternalTexture;
  18006. /**
  18007. * Gets the camera which post process is applied to.
  18008. * @returns The camera the post process is applied to.
  18009. */
  18010. getCamera(): Camera;
  18011. /**
  18012. * Gets the texel size of the postprocess.
  18013. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  18014. */
  18015. readonly texelSize: Vector2;
  18016. /**
  18017. * Creates a new instance PostProcess
  18018. * @param name The name of the PostProcess.
  18019. * @param fragmentUrl The url of the fragment shader to be used.
  18020. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  18021. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  18022. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  18023. * @param camera The camera to apply the render pass to.
  18024. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  18025. * @param engine The engine which the post process will be applied. (default: current engine)
  18026. * @param reusable If the post process can be reused on the same frame. (default: false)
  18027. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  18028. * @param textureType Type of textures used when performing the post process. (default: 0)
  18029. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  18030. * @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
  18031. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  18032. */
  18033. constructor(
  18034. /** Name of the PostProcess. */
  18035. 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);
  18036. /**
  18037. * Gets a string idenfifying the name of the class
  18038. * @returns "PostProcess" string
  18039. */
  18040. getClassName(): string;
  18041. /**
  18042. * Gets the engine which this post process belongs to.
  18043. * @returns The engine the post process was enabled with.
  18044. */
  18045. getEngine(): Engine;
  18046. /**
  18047. * The effect that is created when initializing the post process.
  18048. * @returns The created effect corresponding the the postprocess.
  18049. */
  18050. getEffect(): Effect;
  18051. /**
  18052. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  18053. * @param postProcess The post process to share the output with.
  18054. * @returns This post process.
  18055. */
  18056. shareOutputWith(postProcess: PostProcess): PostProcess;
  18057. /**
  18058. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  18059. * This should be called if the post process that shares output with this post process is disabled/disposed.
  18060. */
  18061. useOwnOutput(): void;
  18062. /**
  18063. * Updates the effect with the current post process compile time values and recompiles the shader.
  18064. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  18065. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  18066. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  18067. * @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
  18068. * @param onCompiled Called when the shader has been compiled.
  18069. * @param onError Called if there is an error when compiling a shader.
  18070. */
  18071. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  18072. /**
  18073. * The post process is reusable if it can be used multiple times within one frame.
  18074. * @returns If the post process is reusable
  18075. */
  18076. isReusable(): boolean;
  18077. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  18078. markTextureDirty(): void;
  18079. /**
  18080. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  18081. * 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.
  18082. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  18083. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  18084. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  18085. * @returns The target texture that was bound to be written to.
  18086. */
  18087. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  18088. /**
  18089. * If the post process is supported.
  18090. */
  18091. readonly isSupported: boolean;
  18092. /**
  18093. * The aspect ratio of the output texture.
  18094. */
  18095. readonly aspectRatio: number;
  18096. /**
  18097. * Get a value indicating if the post-process is ready to be used
  18098. * @returns true if the post-process is ready (shader is compiled)
  18099. */
  18100. isReady(): boolean;
  18101. /**
  18102. * Binds all textures and uniforms to the shader, this will be run on every pass.
  18103. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  18104. */
  18105. apply(): Nullable<Effect>;
  18106. private _disposeTextures;
  18107. /**
  18108. * Disposes the post process.
  18109. * @param camera The camera to dispose the post process on.
  18110. */
  18111. dispose(camera?: Camera): void;
  18112. }
  18113. }
  18114. declare module BABYLON {
  18115. /** @hidden */
  18116. export var kernelBlurVaryingDeclaration: {
  18117. name: string;
  18118. shader: string;
  18119. };
  18120. }
  18121. declare module BABYLON {
  18122. /** @hidden */
  18123. export var kernelBlurFragment: {
  18124. name: string;
  18125. shader: string;
  18126. };
  18127. }
  18128. declare module BABYLON {
  18129. /** @hidden */
  18130. export var kernelBlurFragment2: {
  18131. name: string;
  18132. shader: string;
  18133. };
  18134. }
  18135. declare module BABYLON {
  18136. /** @hidden */
  18137. export var kernelBlurPixelShader: {
  18138. name: string;
  18139. shader: string;
  18140. };
  18141. }
  18142. declare module BABYLON {
  18143. /** @hidden */
  18144. export var kernelBlurVertex: {
  18145. name: string;
  18146. shader: string;
  18147. };
  18148. }
  18149. declare module BABYLON {
  18150. /** @hidden */
  18151. export var kernelBlurVertexShader: {
  18152. name: string;
  18153. shader: string;
  18154. };
  18155. }
  18156. declare module BABYLON {
  18157. /**
  18158. * The Blur Post Process which blurs an image based on a kernel and direction.
  18159. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  18160. */
  18161. export class BlurPostProcess extends PostProcess {
  18162. /** The direction in which to blur the image. */
  18163. direction: Vector2;
  18164. private blockCompilation;
  18165. protected _kernel: number;
  18166. protected _idealKernel: number;
  18167. protected _packedFloat: boolean;
  18168. private _staticDefines;
  18169. /**
  18170. * Sets the length in pixels of the blur sample region
  18171. */
  18172. /**
  18173. * Gets the length in pixels of the blur sample region
  18174. */
  18175. kernel: number;
  18176. /**
  18177. * Sets wether or not the blur needs to unpack/repack floats
  18178. */
  18179. /**
  18180. * Gets wether or not the blur is unpacking/repacking floats
  18181. */
  18182. packedFloat: boolean;
  18183. /**
  18184. * Creates a new instance BlurPostProcess
  18185. * @param name The name of the effect.
  18186. * @param direction The direction in which to blur the image.
  18187. * @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.
  18188. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  18189. * @param camera The camera to apply the render pass to.
  18190. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  18191. * @param engine The engine which the post process will be applied. (default: current engine)
  18192. * @param reusable If the post process can be reused on the same frame. (default: false)
  18193. * @param textureType Type of textures used when performing the post process. (default: 0)
  18194. * @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)
  18195. */
  18196. constructor(name: string,
  18197. /** The direction in which to blur the image. */
  18198. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  18199. /**
  18200. * Updates the effect with the current post process compile time values and recompiles the shader.
  18201. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  18202. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  18203. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  18204. * @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
  18205. * @param onCompiled Called when the shader has been compiled.
  18206. * @param onError Called if there is an error when compiling a shader.
  18207. */
  18208. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  18209. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  18210. /**
  18211. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  18212. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  18213. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  18214. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  18215. * The gaps between physical kernels are compensated for in the weighting of the samples
  18216. * @param idealKernel Ideal blur kernel.
  18217. * @return Nearest best kernel.
  18218. */
  18219. protected _nearestBestKernel(idealKernel: number): number;
  18220. /**
  18221. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  18222. * @param x The point on the Gaussian distribution to sample.
  18223. * @return the value of the Gaussian function at x.
  18224. */
  18225. protected _gaussianWeight(x: number): number;
  18226. /**
  18227. * Generates a string that can be used as a floating point number in GLSL.
  18228. * @param x Value to print.
  18229. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  18230. * @return GLSL float string.
  18231. */
  18232. protected _glslFloat(x: number, decimalFigures?: number): string;
  18233. }
  18234. }
  18235. declare module BABYLON {
  18236. /**
  18237. * Mirror texture can be used to simulate the view from a mirror in a scene.
  18238. * It will dynamically be rendered every frame to adapt to the camera point of view.
  18239. * You can then easily use it as a reflectionTexture on a flat surface.
  18240. * In case the surface is not a plane, please consider relying on reflection probes.
  18241. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  18242. */
  18243. export class MirrorTexture extends RenderTargetTexture {
  18244. private scene;
  18245. /**
  18246. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  18247. * 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.
  18248. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  18249. */
  18250. mirrorPlane: Plane;
  18251. /**
  18252. * Define the blur ratio used to blur the reflection if needed.
  18253. */
  18254. blurRatio: number;
  18255. /**
  18256. * Define the adaptive blur kernel used to blur the reflection if needed.
  18257. * This will autocompute the closest best match for the `blurKernel`
  18258. */
  18259. adaptiveBlurKernel: number;
  18260. /**
  18261. * Define the blur kernel used to blur the reflection if needed.
  18262. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  18263. */
  18264. blurKernel: number;
  18265. /**
  18266. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  18267. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  18268. */
  18269. blurKernelX: number;
  18270. /**
  18271. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  18272. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  18273. */
  18274. blurKernelY: number;
  18275. private _autoComputeBlurKernel;
  18276. protected _onRatioRescale(): void;
  18277. private _updateGammaSpace;
  18278. private _imageProcessingConfigChangeObserver;
  18279. private _transformMatrix;
  18280. private _mirrorMatrix;
  18281. private _savedViewMatrix;
  18282. private _blurX;
  18283. private _blurY;
  18284. private _adaptiveBlurKernel;
  18285. private _blurKernelX;
  18286. private _blurKernelY;
  18287. private _blurRatio;
  18288. /**
  18289. * Instantiates a Mirror Texture.
  18290. * Mirror texture can be used to simulate the view from a mirror in a scene.
  18291. * It will dynamically be rendered every frame to adapt to the camera point of view.
  18292. * You can then easily use it as a reflectionTexture on a flat surface.
  18293. * In case the surface is not a plane, please consider relying on reflection probes.
  18294. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  18295. * @param name
  18296. * @param size
  18297. * @param scene
  18298. * @param generateMipMaps
  18299. * @param type
  18300. * @param samplingMode
  18301. * @param generateDepthBuffer
  18302. */
  18303. constructor(name: string, size: number | {
  18304. width: number;
  18305. height: number;
  18306. } | {
  18307. ratio: number;
  18308. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  18309. private _preparePostProcesses;
  18310. /**
  18311. * Clone the mirror texture.
  18312. * @returns the cloned texture
  18313. */
  18314. clone(): MirrorTexture;
  18315. /**
  18316. * Serialize the texture to a JSON representation you could use in Parse later on
  18317. * @returns the serialized JSON representation
  18318. */
  18319. serialize(): any;
  18320. /**
  18321. * Dispose the texture and release its associated resources.
  18322. */
  18323. dispose(): void;
  18324. }
  18325. }
  18326. declare module BABYLON {
  18327. /**
  18328. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  18329. * @see http://doc.babylonjs.com/babylon101/materials#texture
  18330. */
  18331. export class Texture extends BaseTexture {
  18332. /** @hidden */
  18333. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  18334. /** @hidden */
  18335. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  18336. /** @hidden */
  18337. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  18338. /** nearest is mag = nearest and min = nearest and mip = linear */
  18339. static readonly NEAREST_SAMPLINGMODE: number;
  18340. /** nearest is mag = nearest and min = nearest and mip = linear */
  18341. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  18342. /** Bilinear is mag = linear and min = linear and mip = nearest */
  18343. static readonly BILINEAR_SAMPLINGMODE: number;
  18344. /** Bilinear is mag = linear and min = linear and mip = nearest */
  18345. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  18346. /** Trilinear is mag = linear and min = linear and mip = linear */
  18347. static readonly TRILINEAR_SAMPLINGMODE: number;
  18348. /** Trilinear is mag = linear and min = linear and mip = linear */
  18349. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  18350. /** mag = nearest and min = nearest and mip = nearest */
  18351. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  18352. /** mag = nearest and min = linear and mip = nearest */
  18353. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  18354. /** mag = nearest and min = linear and mip = linear */
  18355. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  18356. /** mag = nearest and min = linear and mip = none */
  18357. static readonly NEAREST_LINEAR: number;
  18358. /** mag = nearest and min = nearest and mip = none */
  18359. static readonly NEAREST_NEAREST: number;
  18360. /** mag = linear and min = nearest and mip = nearest */
  18361. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  18362. /** mag = linear and min = nearest and mip = linear */
  18363. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  18364. /** mag = linear and min = linear and mip = none */
  18365. static readonly LINEAR_LINEAR: number;
  18366. /** mag = linear and min = nearest and mip = none */
  18367. static readonly LINEAR_NEAREST: number;
  18368. /** Explicit coordinates mode */
  18369. static readonly EXPLICIT_MODE: number;
  18370. /** Spherical coordinates mode */
  18371. static readonly SPHERICAL_MODE: number;
  18372. /** Planar coordinates mode */
  18373. static readonly PLANAR_MODE: number;
  18374. /** Cubic coordinates mode */
  18375. static readonly CUBIC_MODE: number;
  18376. /** Projection coordinates mode */
  18377. static readonly PROJECTION_MODE: number;
  18378. /** Inverse Cubic coordinates mode */
  18379. static readonly SKYBOX_MODE: number;
  18380. /** Inverse Cubic coordinates mode */
  18381. static readonly INVCUBIC_MODE: number;
  18382. /** Equirectangular coordinates mode */
  18383. static readonly EQUIRECTANGULAR_MODE: number;
  18384. /** Equirectangular Fixed coordinates mode */
  18385. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  18386. /** Equirectangular Fixed Mirrored coordinates mode */
  18387. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  18388. /** Texture is not repeating outside of 0..1 UVs */
  18389. static readonly CLAMP_ADDRESSMODE: number;
  18390. /** Texture is repeating outside of 0..1 UVs */
  18391. static readonly WRAP_ADDRESSMODE: number;
  18392. /** Texture is repeating and mirrored */
  18393. static readonly MIRROR_ADDRESSMODE: number;
  18394. /**
  18395. * 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
  18396. */
  18397. static UseSerializedUrlIfAny: boolean;
  18398. /**
  18399. * Define the url of the texture.
  18400. */
  18401. url: Nullable<string>;
  18402. /**
  18403. * Define an offset on the texture to offset the u coordinates of the UVs
  18404. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  18405. */
  18406. uOffset: number;
  18407. /**
  18408. * Define an offset on the texture to offset the v coordinates of the UVs
  18409. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  18410. */
  18411. vOffset: number;
  18412. /**
  18413. * Define an offset on the texture to scale the u coordinates of the UVs
  18414. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  18415. */
  18416. uScale: number;
  18417. /**
  18418. * Define an offset on the texture to scale the v coordinates of the UVs
  18419. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  18420. */
  18421. vScale: number;
  18422. /**
  18423. * Define an offset on the texture to rotate around the u coordinates of the UVs
  18424. * @see http://doc.babylonjs.com/how_to/more_materials
  18425. */
  18426. uAng: number;
  18427. /**
  18428. * Define an offset on the texture to rotate around the v coordinates of the UVs
  18429. * @see http://doc.babylonjs.com/how_to/more_materials
  18430. */
  18431. vAng: number;
  18432. /**
  18433. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  18434. * @see http://doc.babylonjs.com/how_to/more_materials
  18435. */
  18436. wAng: number;
  18437. /**
  18438. * Defines the center of rotation (U)
  18439. */
  18440. uRotationCenter: number;
  18441. /**
  18442. * Defines the center of rotation (V)
  18443. */
  18444. vRotationCenter: number;
  18445. /**
  18446. * Defines the center of rotation (W)
  18447. */
  18448. wRotationCenter: number;
  18449. /**
  18450. * Are mip maps generated for this texture or not.
  18451. */
  18452. readonly noMipmap: boolean;
  18453. /**
  18454. * List of inspectable custom properties (used by the Inspector)
  18455. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  18456. */
  18457. inspectableCustomProperties: Nullable<IInspectable[]>;
  18458. private _noMipmap;
  18459. /** @hidden */
  18460. _invertY: boolean;
  18461. private _rowGenerationMatrix;
  18462. private _cachedTextureMatrix;
  18463. private _projectionModeMatrix;
  18464. private _t0;
  18465. private _t1;
  18466. private _t2;
  18467. private _cachedUOffset;
  18468. private _cachedVOffset;
  18469. private _cachedUScale;
  18470. private _cachedVScale;
  18471. private _cachedUAng;
  18472. private _cachedVAng;
  18473. private _cachedWAng;
  18474. private _cachedProjectionMatrixId;
  18475. private _cachedCoordinatesMode;
  18476. /** @hidden */
  18477. protected _initialSamplingMode: number;
  18478. /** @hidden */
  18479. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  18480. private _deleteBuffer;
  18481. protected _format: Nullable<number>;
  18482. private _delayedOnLoad;
  18483. private _delayedOnError;
  18484. /**
  18485. * Observable triggered once the texture has been loaded.
  18486. */
  18487. onLoadObservable: Observable<Texture>;
  18488. protected _isBlocking: boolean;
  18489. /**
  18490. * Is the texture preventing material to render while loading.
  18491. * If false, a default texture will be used instead of the loading one during the preparation step.
  18492. */
  18493. isBlocking: boolean;
  18494. /**
  18495. * Get the current sampling mode associated with the texture.
  18496. */
  18497. readonly samplingMode: number;
  18498. /**
  18499. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  18500. */
  18501. readonly invertY: boolean;
  18502. /**
  18503. * Instantiates a new texture.
  18504. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  18505. * @see http://doc.babylonjs.com/babylon101/materials#texture
  18506. * @param url define the url of the picture to load as a texture
  18507. * @param scene define the scene the texture will belong to
  18508. * @param noMipmap define if the texture will require mip maps or not
  18509. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18510. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18511. * @param onLoad define a callback triggered when the texture has been loaded
  18512. * @param onError define a callback triggered when an error occurred during the loading session
  18513. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  18514. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  18515. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18516. */
  18517. constructor(url: Nullable<string>, scene: Nullable<Scene>, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, deleteBuffer?: boolean, format?: number);
  18518. /**
  18519. * Update the url (and optional buffer) of this texture if url was null during construction.
  18520. * @param url the url of the texture
  18521. * @param buffer the buffer of the texture (defaults to null)
  18522. * @param onLoad callback called when the texture is loaded (defaults to null)
  18523. */
  18524. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  18525. /**
  18526. * Finish the loading sequence of a texture flagged as delayed load.
  18527. * @hidden
  18528. */
  18529. delayLoad(): void;
  18530. private _prepareRowForTextureGeneration;
  18531. /**
  18532. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  18533. * @returns the transform matrix of the texture.
  18534. */
  18535. getTextureMatrix(): Matrix;
  18536. /**
  18537. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  18538. * @returns The reflection texture transform
  18539. */
  18540. getReflectionTextureMatrix(): Matrix;
  18541. /**
  18542. * Clones the texture.
  18543. * @returns the cloned texture
  18544. */
  18545. clone(): Texture;
  18546. /**
  18547. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  18548. * @returns The JSON representation of the texture
  18549. */
  18550. serialize(): any;
  18551. /**
  18552. * Get the current class name of the texture useful for serialization or dynamic coding.
  18553. * @returns "Texture"
  18554. */
  18555. getClassName(): string;
  18556. /**
  18557. * Dispose the texture and release its associated resources.
  18558. */
  18559. dispose(): void;
  18560. /**
  18561. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  18562. * @param parsedTexture Define the JSON representation of the texture
  18563. * @param scene Define the scene the parsed texture should be instantiated in
  18564. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  18565. * @returns The parsed texture if successful
  18566. */
  18567. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  18568. /**
  18569. * Creates a texture from its base 64 representation.
  18570. * @param data Define the base64 payload without the data: prefix
  18571. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  18572. * @param scene Define the scene the texture should belong to
  18573. * @param noMipmap Forces the texture to not create mip map information if true
  18574. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18575. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18576. * @param onLoad define a callback triggered when the texture has been loaded
  18577. * @param onError define a callback triggered when an error occurred during the loading session
  18578. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18579. * @returns the created texture
  18580. */
  18581. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  18582. /**
  18583. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  18584. * @param data Define the base64 payload without the data: prefix
  18585. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  18586. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  18587. * @param scene Define the scene the texture should belong to
  18588. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  18589. * @param noMipmap Forces the texture to not create mip map information if true
  18590. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18591. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18592. * @param onLoad define a callback triggered when the texture has been loaded
  18593. * @param onError define a callback triggered when an error occurred during the loading session
  18594. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18595. * @returns the created texture
  18596. */
  18597. 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;
  18598. }
  18599. }
  18600. declare module BABYLON {
  18601. /**
  18602. * PostProcessManager is used to manage one or more post processes or post process pipelines
  18603. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  18604. */
  18605. export class PostProcessManager {
  18606. private _scene;
  18607. private _indexBuffer;
  18608. private _vertexBuffers;
  18609. /**
  18610. * Creates a new instance PostProcess
  18611. * @param scene The scene that the post process is associated with.
  18612. */
  18613. constructor(scene: Scene);
  18614. private _prepareBuffers;
  18615. private _buildIndexBuffer;
  18616. /**
  18617. * Rebuilds the vertex buffers of the manager.
  18618. * @hidden
  18619. */
  18620. _rebuild(): void;
  18621. /**
  18622. * Prepares a frame to be run through a post process.
  18623. * @param sourceTexture The input texture to the post procesess. (default: null)
  18624. * @param postProcesses An array of post processes to be run. (default: null)
  18625. * @returns True if the post processes were able to be run.
  18626. * @hidden
  18627. */
  18628. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  18629. /**
  18630. * Manually render a set of post processes to a texture.
  18631. * @param postProcesses An array of post processes to be run.
  18632. * @param targetTexture The target texture to render to.
  18633. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  18634. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  18635. * @param lodLevel defines which lod of the texture to render to
  18636. */
  18637. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  18638. /**
  18639. * Finalize the result of the output of the postprocesses.
  18640. * @param doNotPresent If true the result will not be displayed to the screen.
  18641. * @param targetTexture The target texture to render to.
  18642. * @param faceIndex The index of the face to bind the target texture to.
  18643. * @param postProcesses The array of post processes to render.
  18644. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  18645. * @hidden
  18646. */
  18647. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  18648. /**
  18649. * Disposes of the post process manager.
  18650. */
  18651. dispose(): void;
  18652. }
  18653. }
  18654. declare module BABYLON {
  18655. interface AbstractScene {
  18656. /**
  18657. * The list of procedural textures added to the scene
  18658. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  18659. */
  18660. proceduralTextures: Array<ProceduralTexture>;
  18661. }
  18662. /**
  18663. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  18664. * in a given scene.
  18665. */
  18666. export class ProceduralTextureSceneComponent implements ISceneComponent {
  18667. /**
  18668. * The component name helpfull to identify the component in the list of scene components.
  18669. */
  18670. readonly name: string;
  18671. /**
  18672. * The scene the component belongs to.
  18673. */
  18674. scene: Scene;
  18675. /**
  18676. * Creates a new instance of the component for the given scene
  18677. * @param scene Defines the scene to register the component in
  18678. */
  18679. constructor(scene: Scene);
  18680. /**
  18681. * Registers the component in a given scene
  18682. */
  18683. register(): void;
  18684. /**
  18685. * Rebuilds the elements related to this component in case of
  18686. * context lost for instance.
  18687. */
  18688. rebuild(): void;
  18689. /**
  18690. * Disposes the component and the associated ressources.
  18691. */
  18692. dispose(): void;
  18693. private _beforeClear;
  18694. }
  18695. }
  18696. declare module BABYLON {
  18697. interface Engine {
  18698. /**
  18699. * Creates a new render target cube texture
  18700. * @param size defines the size of the texture
  18701. * @param options defines the options used to create the texture
  18702. * @returns a new render target cube texture stored in an InternalTexture
  18703. */
  18704. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  18705. }
  18706. }
  18707. declare module BABYLON {
  18708. /** @hidden */
  18709. export var proceduralVertexShader: {
  18710. name: string;
  18711. shader: string;
  18712. };
  18713. }
  18714. declare module BABYLON {
  18715. /**
  18716. * 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.
  18717. * This is the base class of any Procedural texture and contains most of the shareable code.
  18718. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  18719. */
  18720. export class ProceduralTexture extends Texture {
  18721. isCube: boolean;
  18722. /**
  18723. * Define if the texture is enabled or not (disabled texture will not render)
  18724. */
  18725. isEnabled: boolean;
  18726. /**
  18727. * Define if the texture must be cleared before rendering (default is true)
  18728. */
  18729. autoClear: boolean;
  18730. /**
  18731. * Callback called when the texture is generated
  18732. */
  18733. onGenerated: () => void;
  18734. /**
  18735. * Event raised when the texture is generated
  18736. */
  18737. onGeneratedObservable: Observable<ProceduralTexture>;
  18738. /** @hidden */
  18739. _generateMipMaps: boolean;
  18740. /** @hidden **/
  18741. _effect: Effect;
  18742. /** @hidden */
  18743. _textures: {
  18744. [key: string]: Texture;
  18745. };
  18746. private _size;
  18747. private _currentRefreshId;
  18748. private _refreshRate;
  18749. private _vertexBuffers;
  18750. private _indexBuffer;
  18751. private _uniforms;
  18752. private _samplers;
  18753. private _fragment;
  18754. private _floats;
  18755. private _ints;
  18756. private _floatsArrays;
  18757. private _colors3;
  18758. private _colors4;
  18759. private _vectors2;
  18760. private _vectors3;
  18761. private _matrices;
  18762. private _fallbackTexture;
  18763. private _fallbackTextureUsed;
  18764. private _engine;
  18765. private _cachedDefines;
  18766. private _contentUpdateId;
  18767. private _contentData;
  18768. /**
  18769. * Instantiates a new procedural texture.
  18770. * 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.
  18771. * This is the base class of any Procedural texture and contains most of the shareable code.
  18772. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  18773. * @param name Define the name of the texture
  18774. * @param size Define the size of the texture to create
  18775. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  18776. * @param scene Define the scene the texture belongs to
  18777. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  18778. * @param generateMipMaps Define if the texture should creates mip maps or not
  18779. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  18780. */
  18781. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  18782. /**
  18783. * The effect that is created when initializing the post process.
  18784. * @returns The created effect corresponding the the postprocess.
  18785. */
  18786. getEffect(): Effect;
  18787. /**
  18788. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  18789. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  18790. */
  18791. getContent(): Nullable<ArrayBufferView>;
  18792. private _createIndexBuffer;
  18793. /** @hidden */
  18794. _rebuild(): void;
  18795. /**
  18796. * Resets the texture in order to recreate its associated resources.
  18797. * This can be called in case of context loss
  18798. */
  18799. reset(): void;
  18800. protected _getDefines(): string;
  18801. /**
  18802. * Is the texture ready to be used ? (rendered at least once)
  18803. * @returns true if ready, otherwise, false.
  18804. */
  18805. isReady(): boolean;
  18806. /**
  18807. * Resets the refresh counter of the texture and start bak from scratch.
  18808. * Could be useful to regenerate the texture if it is setup to render only once.
  18809. */
  18810. resetRefreshCounter(): void;
  18811. /**
  18812. * Set the fragment shader to use in order to render the texture.
  18813. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  18814. */
  18815. setFragment(fragment: any): void;
  18816. /**
  18817. * Define the refresh rate of the texture or the rendering frequency.
  18818. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  18819. */
  18820. refreshRate: number;
  18821. /** @hidden */
  18822. _shouldRender(): boolean;
  18823. /**
  18824. * Get the size the texture is rendering at.
  18825. * @returns the size (texture is always squared)
  18826. */
  18827. getRenderSize(): number;
  18828. /**
  18829. * Resize the texture to new value.
  18830. * @param size Define the new size the texture should have
  18831. * @param generateMipMaps Define whether the new texture should create mip maps
  18832. */
  18833. resize(size: number, generateMipMaps: boolean): void;
  18834. private _checkUniform;
  18835. /**
  18836. * Set a texture in the shader program used to render.
  18837. * @param name Define the name of the uniform samplers as defined in the shader
  18838. * @param texture Define the texture to bind to this sampler
  18839. * @return the texture itself allowing "fluent" like uniform updates
  18840. */
  18841. setTexture(name: string, texture: Texture): ProceduralTexture;
  18842. /**
  18843. * Set a float in the shader.
  18844. * @param name Define the name of the uniform as defined in the shader
  18845. * @param value Define the value to give to the uniform
  18846. * @return the texture itself allowing "fluent" like uniform updates
  18847. */
  18848. setFloat(name: string, value: number): ProceduralTexture;
  18849. /**
  18850. * Set a int in the shader.
  18851. * @param name Define the name of the uniform as defined in the shader
  18852. * @param value Define the value to give to the uniform
  18853. * @return the texture itself allowing "fluent" like uniform updates
  18854. */
  18855. setInt(name: string, value: number): ProceduralTexture;
  18856. /**
  18857. * Set an array of floats in the shader.
  18858. * @param name Define the name of the uniform as defined in the shader
  18859. * @param value Define the value to give to the uniform
  18860. * @return the texture itself allowing "fluent" like uniform updates
  18861. */
  18862. setFloats(name: string, value: number[]): ProceduralTexture;
  18863. /**
  18864. * Set a vec3 in the shader from a Color3.
  18865. * @param name Define the name of the uniform as defined in the shader
  18866. * @param value Define the value to give to the uniform
  18867. * @return the texture itself allowing "fluent" like uniform updates
  18868. */
  18869. setColor3(name: string, value: Color3): ProceduralTexture;
  18870. /**
  18871. * Set a vec4 in the shader from a Color4.
  18872. * @param name Define the name of the uniform as defined in the shader
  18873. * @param value Define the value to give to the uniform
  18874. * @return the texture itself allowing "fluent" like uniform updates
  18875. */
  18876. setColor4(name: string, value: Color4): ProceduralTexture;
  18877. /**
  18878. * Set a vec2 in the shader from a Vector2.
  18879. * @param name Define the name of the uniform as defined in the shader
  18880. * @param value Define the value to give to the uniform
  18881. * @return the texture itself allowing "fluent" like uniform updates
  18882. */
  18883. setVector2(name: string, value: Vector2): ProceduralTexture;
  18884. /**
  18885. * Set a vec3 in the shader from a Vector3.
  18886. * @param name Define the name of the uniform as defined in the shader
  18887. * @param value Define the value to give to the uniform
  18888. * @return the texture itself allowing "fluent" like uniform updates
  18889. */
  18890. setVector3(name: string, value: Vector3): ProceduralTexture;
  18891. /**
  18892. * Set a mat4 in the shader from a MAtrix.
  18893. * @param name Define the name of the uniform as defined in the shader
  18894. * @param value Define the value to give to the uniform
  18895. * @return the texture itself allowing "fluent" like uniform updates
  18896. */
  18897. setMatrix(name: string, value: Matrix): ProceduralTexture;
  18898. /**
  18899. * Render the texture to its associated render target.
  18900. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  18901. */
  18902. render(useCameraPostProcess?: boolean): void;
  18903. /**
  18904. * Clone the texture.
  18905. * @returns the cloned texture
  18906. */
  18907. clone(): ProceduralTexture;
  18908. /**
  18909. * Dispose the texture and release its asoociated resources.
  18910. */
  18911. dispose(): void;
  18912. }
  18913. }
  18914. declare module BABYLON {
  18915. /**
  18916. * This represents the base class for particle system in Babylon.
  18917. * 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.
  18918. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  18919. * @example https://doc.babylonjs.com/babylon101/particles
  18920. */
  18921. export class BaseParticleSystem {
  18922. /**
  18923. * Source color is added to the destination color without alpha affecting the result
  18924. */
  18925. static BLENDMODE_ONEONE: number;
  18926. /**
  18927. * Blend current color and particle color using particle’s alpha
  18928. */
  18929. static BLENDMODE_STANDARD: number;
  18930. /**
  18931. * Add current color and particle color multiplied by particle’s alpha
  18932. */
  18933. static BLENDMODE_ADD: number;
  18934. /**
  18935. * Multiply current color with particle color
  18936. */
  18937. static BLENDMODE_MULTIPLY: number;
  18938. /**
  18939. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  18940. */
  18941. static BLENDMODE_MULTIPLYADD: number;
  18942. /**
  18943. * List of animations used by the particle system.
  18944. */
  18945. animations: Animation[];
  18946. /**
  18947. * The id of the Particle system.
  18948. */
  18949. id: string;
  18950. /**
  18951. * The friendly name of the Particle system.
  18952. */
  18953. name: string;
  18954. /**
  18955. * The rendering group used by the Particle system to chose when to render.
  18956. */
  18957. renderingGroupId: number;
  18958. /**
  18959. * The emitter represents the Mesh or position we are attaching the particle system to.
  18960. */
  18961. emitter: Nullable<AbstractMesh | Vector3>;
  18962. /**
  18963. * The maximum number of particles to emit per frame
  18964. */
  18965. emitRate: number;
  18966. /**
  18967. * If you want to launch only a few particles at once, that can be done, as well.
  18968. */
  18969. manualEmitCount: number;
  18970. /**
  18971. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  18972. */
  18973. updateSpeed: number;
  18974. /**
  18975. * The amount of time the particle system is running (depends of the overall update speed).
  18976. */
  18977. targetStopDuration: number;
  18978. /**
  18979. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  18980. */
  18981. disposeOnStop: boolean;
  18982. /**
  18983. * Minimum power of emitting particles.
  18984. */
  18985. minEmitPower: number;
  18986. /**
  18987. * Maximum power of emitting particles.
  18988. */
  18989. maxEmitPower: number;
  18990. /**
  18991. * Minimum life time of emitting particles.
  18992. */
  18993. minLifeTime: number;
  18994. /**
  18995. * Maximum life time of emitting particles.
  18996. */
  18997. maxLifeTime: number;
  18998. /**
  18999. * Minimum Size of emitting particles.
  19000. */
  19001. minSize: number;
  19002. /**
  19003. * Maximum Size of emitting particles.
  19004. */
  19005. maxSize: number;
  19006. /**
  19007. * Minimum scale of emitting particles on X axis.
  19008. */
  19009. minScaleX: number;
  19010. /**
  19011. * Maximum scale of emitting particles on X axis.
  19012. */
  19013. maxScaleX: number;
  19014. /**
  19015. * Minimum scale of emitting particles on Y axis.
  19016. */
  19017. minScaleY: number;
  19018. /**
  19019. * Maximum scale of emitting particles on Y axis.
  19020. */
  19021. maxScaleY: number;
  19022. /**
  19023. * Gets or sets the minimal initial rotation in radians.
  19024. */
  19025. minInitialRotation: number;
  19026. /**
  19027. * Gets or sets the maximal initial rotation in radians.
  19028. */
  19029. maxInitialRotation: number;
  19030. /**
  19031. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  19032. */
  19033. minAngularSpeed: number;
  19034. /**
  19035. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  19036. */
  19037. maxAngularSpeed: number;
  19038. /**
  19039. * The texture used to render each particle. (this can be a spritesheet)
  19040. */
  19041. particleTexture: Nullable<Texture>;
  19042. /**
  19043. * The layer mask we are rendering the particles through.
  19044. */
  19045. layerMask: number;
  19046. /**
  19047. * This can help using your own shader to render the particle system.
  19048. * The according effect will be created
  19049. */
  19050. customShader: any;
  19051. /**
  19052. * By default particle system starts as soon as they are created. This prevents the
  19053. * automatic start to happen and let you decide when to start emitting particles.
  19054. */
  19055. preventAutoStart: boolean;
  19056. private _noiseTexture;
  19057. /**
  19058. * Gets or sets a texture used to add random noise to particle positions
  19059. */
  19060. noiseTexture: Nullable<ProceduralTexture>;
  19061. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  19062. noiseStrength: Vector3;
  19063. /**
  19064. * Callback triggered when the particle animation is ending.
  19065. */
  19066. onAnimationEnd: Nullable<() => void>;
  19067. /**
  19068. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  19069. */
  19070. blendMode: number;
  19071. /**
  19072. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  19073. * to override the particles.
  19074. */
  19075. forceDepthWrite: boolean;
  19076. /** 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 */
  19077. preWarmCycles: number;
  19078. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  19079. preWarmStepOffset: number;
  19080. /**
  19081. * 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)
  19082. */
  19083. spriteCellChangeSpeed: number;
  19084. /**
  19085. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  19086. */
  19087. startSpriteCellID: number;
  19088. /**
  19089. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  19090. */
  19091. endSpriteCellID: number;
  19092. /**
  19093. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  19094. */
  19095. spriteCellWidth: number;
  19096. /**
  19097. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  19098. */
  19099. spriteCellHeight: number;
  19100. /**
  19101. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  19102. */
  19103. spriteRandomStartCell: boolean;
  19104. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  19105. translationPivot: Vector2;
  19106. /** @hidden */
  19107. protected _isAnimationSheetEnabled: boolean;
  19108. /**
  19109. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  19110. */
  19111. beginAnimationOnStart: boolean;
  19112. /**
  19113. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  19114. */
  19115. beginAnimationFrom: number;
  19116. /**
  19117. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  19118. */
  19119. beginAnimationTo: number;
  19120. /**
  19121. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  19122. */
  19123. beginAnimationLoop: boolean;
  19124. /**
  19125. * Gets or sets a world offset applied to all particles
  19126. */
  19127. worldOffset: Vector3;
  19128. /**
  19129. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  19130. */
  19131. isAnimationSheetEnabled: boolean;
  19132. /**
  19133. * Get hosting scene
  19134. * @returns the scene
  19135. */
  19136. getScene(): Scene;
  19137. /**
  19138. * You can use gravity if you want to give an orientation to your particles.
  19139. */
  19140. gravity: Vector3;
  19141. protected _colorGradients: Nullable<Array<ColorGradient>>;
  19142. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  19143. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  19144. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  19145. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  19146. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  19147. protected _dragGradients: Nullable<Array<FactorGradient>>;
  19148. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  19149. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  19150. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  19151. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  19152. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  19153. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  19154. /**
  19155. * Defines the delay in milliseconds before starting the system (0 by default)
  19156. */
  19157. startDelay: number;
  19158. /**
  19159. * Gets the current list of drag gradients.
  19160. * You must use addDragGradient and removeDragGradient to udpate this list
  19161. * @returns the list of drag gradients
  19162. */
  19163. getDragGradients(): Nullable<Array<FactorGradient>>;
  19164. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  19165. limitVelocityDamping: number;
  19166. /**
  19167. * Gets the current list of limit velocity gradients.
  19168. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  19169. * @returns the list of limit velocity gradients
  19170. */
  19171. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  19172. /**
  19173. * Gets the current list of color gradients.
  19174. * You must use addColorGradient and removeColorGradient to udpate this list
  19175. * @returns the list of color gradients
  19176. */
  19177. getColorGradients(): Nullable<Array<ColorGradient>>;
  19178. /**
  19179. * Gets the current list of size gradients.
  19180. * You must use addSizeGradient and removeSizeGradient to udpate this list
  19181. * @returns the list of size gradients
  19182. */
  19183. getSizeGradients(): Nullable<Array<FactorGradient>>;
  19184. /**
  19185. * Gets the current list of color remap gradients.
  19186. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  19187. * @returns the list of color remap gradients
  19188. */
  19189. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  19190. /**
  19191. * Gets the current list of alpha remap gradients.
  19192. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  19193. * @returns the list of alpha remap gradients
  19194. */
  19195. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  19196. /**
  19197. * Gets the current list of life time gradients.
  19198. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  19199. * @returns the list of life time gradients
  19200. */
  19201. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  19202. /**
  19203. * Gets the current list of angular speed gradients.
  19204. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  19205. * @returns the list of angular speed gradients
  19206. */
  19207. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  19208. /**
  19209. * Gets the current list of velocity gradients.
  19210. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  19211. * @returns the list of velocity gradients
  19212. */
  19213. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  19214. /**
  19215. * Gets the current list of start size gradients.
  19216. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  19217. * @returns the list of start size gradients
  19218. */
  19219. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  19220. /**
  19221. * Gets the current list of emit rate gradients.
  19222. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  19223. * @returns the list of emit rate gradients
  19224. */
  19225. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  19226. /**
  19227. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  19228. * This only works when particleEmitterTyps is a BoxParticleEmitter
  19229. */
  19230. direction1: Vector3;
  19231. /**
  19232. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  19233. * This only works when particleEmitterTyps is a BoxParticleEmitter
  19234. */
  19235. direction2: Vector3;
  19236. /**
  19237. * 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.
  19238. * This only works when particleEmitterTyps is a BoxParticleEmitter
  19239. */
  19240. minEmitBox: Vector3;
  19241. /**
  19242. * 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.
  19243. * This only works when particleEmitterTyps is a BoxParticleEmitter
  19244. */
  19245. maxEmitBox: Vector3;
  19246. /**
  19247. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  19248. */
  19249. color1: Color4;
  19250. /**
  19251. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  19252. */
  19253. color2: Color4;
  19254. /**
  19255. * Color the particle will have at the end of its lifetime
  19256. */
  19257. colorDead: Color4;
  19258. /**
  19259. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  19260. */
  19261. textureMask: Color4;
  19262. /**
  19263. * The particle emitter type defines the emitter used by the particle system.
  19264. * It can be for example box, sphere, or cone...
  19265. */
  19266. particleEmitterType: IParticleEmitterType;
  19267. /** @hidden */
  19268. _isSubEmitter: boolean;
  19269. /**
  19270. * Gets or sets the billboard mode to use when isBillboardBased = true.
  19271. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  19272. */
  19273. billboardMode: number;
  19274. protected _isBillboardBased: boolean;
  19275. /**
  19276. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  19277. */
  19278. isBillboardBased: boolean;
  19279. /**
  19280. * The scene the particle system belongs to.
  19281. */
  19282. protected _scene: Scene;
  19283. /**
  19284. * Local cache of defines for image processing.
  19285. */
  19286. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  19287. /**
  19288. * Default configuration related to image processing available in the standard Material.
  19289. */
  19290. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  19291. /**
  19292. * Gets the image processing configuration used either in this material.
  19293. */
  19294. /**
  19295. * Sets the Default image processing configuration used either in the this material.
  19296. *
  19297. * If sets to null, the scene one is in use.
  19298. */
  19299. imageProcessingConfiguration: ImageProcessingConfiguration;
  19300. /**
  19301. * Attaches a new image processing configuration to the Standard Material.
  19302. * @param configuration
  19303. */
  19304. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  19305. /** @hidden */
  19306. protected _reset(): void;
  19307. /** @hidden */
  19308. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  19309. /**
  19310. * Instantiates a particle system.
  19311. * 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.
  19312. * @param name The name of the particle system
  19313. */
  19314. constructor(name: string);
  19315. /**
  19316. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  19317. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  19318. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  19319. * @returns the emitter
  19320. */
  19321. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  19322. /**
  19323. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  19324. * @param radius The radius of the hemisphere to emit from
  19325. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  19326. * @returns the emitter
  19327. */
  19328. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  19329. /**
  19330. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  19331. * @param radius The radius of the sphere to emit from
  19332. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  19333. * @returns the emitter
  19334. */
  19335. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  19336. /**
  19337. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  19338. * @param radius The radius of the sphere to emit from
  19339. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  19340. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  19341. * @returns the emitter
  19342. */
  19343. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  19344. /**
  19345. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  19346. * @param radius The radius of the emission cylinder
  19347. * @param height The height of the emission cylinder
  19348. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  19349. * @param directionRandomizer How much to randomize the particle direction [0-1]
  19350. * @returns the emitter
  19351. */
  19352. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  19353. /**
  19354. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  19355. * @param radius The radius of the cylinder to emit from
  19356. * @param height The height of the emission cylinder
  19357. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  19358. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  19359. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  19360. * @returns the emitter
  19361. */
  19362. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  19363. /**
  19364. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  19365. * @param radius The radius of the cone to emit from
  19366. * @param angle The base angle of the cone
  19367. * @returns the emitter
  19368. */
  19369. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  19370. /**
  19371. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  19372. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  19373. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  19374. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  19375. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  19376. * @returns the emitter
  19377. */
  19378. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  19379. }
  19380. }
  19381. declare module BABYLON {
  19382. /**
  19383. * Type of sub emitter
  19384. */
  19385. export enum SubEmitterType {
  19386. /**
  19387. * Attached to the particle over it's lifetime
  19388. */
  19389. ATTACHED = 0,
  19390. /**
  19391. * Created when the particle dies
  19392. */
  19393. END = 1
  19394. }
  19395. /**
  19396. * Sub emitter class used to emit particles from an existing particle
  19397. */
  19398. export class SubEmitter {
  19399. /**
  19400. * the particle system to be used by the sub emitter
  19401. */
  19402. particleSystem: ParticleSystem;
  19403. /**
  19404. * Type of the submitter (Default: END)
  19405. */
  19406. type: SubEmitterType;
  19407. /**
  19408. * 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)
  19409. * Note: This only is supported when using an emitter of type Mesh
  19410. */
  19411. inheritDirection: boolean;
  19412. /**
  19413. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  19414. */
  19415. inheritedVelocityAmount: number;
  19416. /**
  19417. * Creates a sub emitter
  19418. * @param particleSystem the particle system to be used by the sub emitter
  19419. */
  19420. constructor(
  19421. /**
  19422. * the particle system to be used by the sub emitter
  19423. */
  19424. particleSystem: ParticleSystem);
  19425. /**
  19426. * Clones the sub emitter
  19427. * @returns the cloned sub emitter
  19428. */
  19429. clone(): SubEmitter;
  19430. /**
  19431. * Serialize current object to a JSON object
  19432. * @returns the serialized object
  19433. */
  19434. serialize(): any;
  19435. /** @hidden */
  19436. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  19437. /**
  19438. * Creates a new SubEmitter from a serialized JSON version
  19439. * @param serializationObject defines the JSON object to read from
  19440. * @param scene defines the hosting scene
  19441. * @param rootUrl defines the rootUrl for data loading
  19442. * @returns a new SubEmitter
  19443. */
  19444. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  19445. /** Release associated resources */
  19446. dispose(): void;
  19447. }
  19448. }
  19449. declare module BABYLON {
  19450. /** @hidden */
  19451. export var imageProcessingDeclaration: {
  19452. name: string;
  19453. shader: string;
  19454. };
  19455. }
  19456. declare module BABYLON {
  19457. /** @hidden */
  19458. export var imageProcessingFunctions: {
  19459. name: string;
  19460. shader: string;
  19461. };
  19462. }
  19463. declare module BABYLON {
  19464. /** @hidden */
  19465. export var particlesPixelShader: {
  19466. name: string;
  19467. shader: string;
  19468. };
  19469. }
  19470. declare module BABYLON {
  19471. /** @hidden */
  19472. export var particlesVertexShader: {
  19473. name: string;
  19474. shader: string;
  19475. };
  19476. }
  19477. declare module BABYLON {
  19478. /**
  19479. * This represents a particle system in Babylon.
  19480. * 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.
  19481. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  19482. * @example https://doc.babylonjs.com/babylon101/particles
  19483. */
  19484. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  19485. /**
  19486. * Billboard mode will only apply to Y axis
  19487. */
  19488. static readonly BILLBOARDMODE_Y: number;
  19489. /**
  19490. * Billboard mode will apply to all axes
  19491. */
  19492. static readonly BILLBOARDMODE_ALL: number;
  19493. /**
  19494. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  19495. */
  19496. static readonly BILLBOARDMODE_STRETCHED: number;
  19497. /**
  19498. * This function can be defined to provide custom update for active particles.
  19499. * This function will be called instead of regular update (age, position, color, etc.).
  19500. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  19501. */
  19502. updateFunction: (particles: Particle[]) => void;
  19503. private _emitterWorldMatrix;
  19504. /**
  19505. * This function can be defined to specify initial direction for every new particle.
  19506. * It by default use the emitterType defined function
  19507. */
  19508. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  19509. /**
  19510. * This function can be defined to specify initial position for every new particle.
  19511. * It by default use the emitterType defined function
  19512. */
  19513. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  19514. /**
  19515. * @hidden
  19516. */
  19517. _inheritedVelocityOffset: Vector3;
  19518. /**
  19519. * An event triggered when the system is disposed
  19520. */
  19521. onDisposeObservable: Observable<ParticleSystem>;
  19522. private _onDisposeObserver;
  19523. /**
  19524. * Sets a callback that will be triggered when the system is disposed
  19525. */
  19526. onDispose: () => void;
  19527. private _particles;
  19528. private _epsilon;
  19529. private _capacity;
  19530. private _stockParticles;
  19531. private _newPartsExcess;
  19532. private _vertexData;
  19533. private _vertexBuffer;
  19534. private _vertexBuffers;
  19535. private _spriteBuffer;
  19536. private _indexBuffer;
  19537. private _effect;
  19538. private _customEffect;
  19539. private _cachedDefines;
  19540. private _scaledColorStep;
  19541. private _colorDiff;
  19542. private _scaledDirection;
  19543. private _scaledGravity;
  19544. private _currentRenderId;
  19545. private _alive;
  19546. private _useInstancing;
  19547. private _started;
  19548. private _stopped;
  19549. private _actualFrame;
  19550. private _scaledUpdateSpeed;
  19551. private _vertexBufferSize;
  19552. /** @hidden */
  19553. _currentEmitRateGradient: Nullable<FactorGradient>;
  19554. /** @hidden */
  19555. _currentEmitRate1: number;
  19556. /** @hidden */
  19557. _currentEmitRate2: number;
  19558. /** @hidden */
  19559. _currentStartSizeGradient: Nullable<FactorGradient>;
  19560. /** @hidden */
  19561. _currentStartSize1: number;
  19562. /** @hidden */
  19563. _currentStartSize2: number;
  19564. private readonly _rawTextureWidth;
  19565. private _rampGradientsTexture;
  19566. private _useRampGradients;
  19567. /** Gets or sets a boolean indicating that ramp gradients must be used
  19568. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  19569. */
  19570. useRampGradients: boolean;
  19571. /**
  19572. * 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.
  19573. * 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: [])
  19574. */
  19575. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  19576. private _subEmitters;
  19577. /**
  19578. * @hidden
  19579. * If the particle systems emitter should be disposed when the particle system is disposed
  19580. */
  19581. _disposeEmitterOnDispose: boolean;
  19582. /**
  19583. * The current active Sub-systems, this property is used by the root particle system only.
  19584. */
  19585. activeSubSystems: Array<ParticleSystem>;
  19586. private _rootParticleSystem;
  19587. /**
  19588. * Gets the current list of active particles
  19589. */
  19590. readonly particles: Particle[];
  19591. /**
  19592. * Returns the string "ParticleSystem"
  19593. * @returns a string containing the class name
  19594. */
  19595. getClassName(): string;
  19596. /**
  19597. * Instantiates a particle system.
  19598. * 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.
  19599. * @param name The name of the particle system
  19600. * @param capacity The max number of particles alive at the same time
  19601. * @param scene The scene the particle system belongs to
  19602. * @param customEffect a custom effect used to change the way particles are rendered by default
  19603. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  19604. * @param epsilon Offset used to render the particles
  19605. */
  19606. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  19607. private _addFactorGradient;
  19608. private _removeFactorGradient;
  19609. /**
  19610. * Adds a new life time gradient
  19611. * @param gradient defines the gradient to use (between 0 and 1)
  19612. * @param factor defines the life time factor to affect to the specified gradient
  19613. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19614. * @returns the current particle system
  19615. */
  19616. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19617. /**
  19618. * Remove a specific life time gradient
  19619. * @param gradient defines the gradient to remove
  19620. * @returns the current particle system
  19621. */
  19622. removeLifeTimeGradient(gradient: number): IParticleSystem;
  19623. /**
  19624. * Adds a new size gradient
  19625. * @param gradient defines the gradient to use (between 0 and 1)
  19626. * @param factor defines the size factor to affect to the specified gradient
  19627. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19628. * @returns the current particle system
  19629. */
  19630. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19631. /**
  19632. * Remove a specific size gradient
  19633. * @param gradient defines the gradient to remove
  19634. * @returns the current particle system
  19635. */
  19636. removeSizeGradient(gradient: number): IParticleSystem;
  19637. /**
  19638. * Adds a new color remap gradient
  19639. * @param gradient defines the gradient to use (between 0 and 1)
  19640. * @param min defines the color remap minimal range
  19641. * @param max defines the color remap maximal range
  19642. * @returns the current particle system
  19643. */
  19644. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  19645. /**
  19646. * Remove a specific color remap gradient
  19647. * @param gradient defines the gradient to remove
  19648. * @returns the current particle system
  19649. */
  19650. removeColorRemapGradient(gradient: number): IParticleSystem;
  19651. /**
  19652. * Adds a new alpha remap gradient
  19653. * @param gradient defines the gradient to use (between 0 and 1)
  19654. * @param min defines the alpha remap minimal range
  19655. * @param max defines the alpha remap maximal range
  19656. * @returns the current particle system
  19657. */
  19658. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  19659. /**
  19660. * Remove a specific alpha remap gradient
  19661. * @param gradient defines the gradient to remove
  19662. * @returns the current particle system
  19663. */
  19664. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  19665. /**
  19666. * Adds a new angular speed gradient
  19667. * @param gradient defines the gradient to use (between 0 and 1)
  19668. * @param factor defines the angular speed to affect to the specified gradient
  19669. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19670. * @returns the current particle system
  19671. */
  19672. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19673. /**
  19674. * Remove a specific angular speed gradient
  19675. * @param gradient defines the gradient to remove
  19676. * @returns the current particle system
  19677. */
  19678. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  19679. /**
  19680. * Adds a new velocity gradient
  19681. * @param gradient defines the gradient to use (between 0 and 1)
  19682. * @param factor defines the velocity to affect to the specified gradient
  19683. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19684. * @returns the current particle system
  19685. */
  19686. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19687. /**
  19688. * Remove a specific velocity gradient
  19689. * @param gradient defines the gradient to remove
  19690. * @returns the current particle system
  19691. */
  19692. removeVelocityGradient(gradient: number): IParticleSystem;
  19693. /**
  19694. * Adds a new limit velocity gradient
  19695. * @param gradient defines the gradient to use (between 0 and 1)
  19696. * @param factor defines the limit velocity value to affect to the specified gradient
  19697. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19698. * @returns the current particle system
  19699. */
  19700. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19701. /**
  19702. * Remove a specific limit velocity gradient
  19703. * @param gradient defines the gradient to remove
  19704. * @returns the current particle system
  19705. */
  19706. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  19707. /**
  19708. * Adds a new drag gradient
  19709. * @param gradient defines the gradient to use (between 0 and 1)
  19710. * @param factor defines the drag value to affect to the specified gradient
  19711. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19712. * @returns the current particle system
  19713. */
  19714. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19715. /**
  19716. * Remove a specific drag gradient
  19717. * @param gradient defines the gradient to remove
  19718. * @returns the current particle system
  19719. */
  19720. removeDragGradient(gradient: number): IParticleSystem;
  19721. /**
  19722. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  19723. * @param gradient defines the gradient to use (between 0 and 1)
  19724. * @param factor defines the emit rate value to affect to the specified gradient
  19725. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19726. * @returns the current particle system
  19727. */
  19728. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19729. /**
  19730. * Remove a specific emit rate gradient
  19731. * @param gradient defines the gradient to remove
  19732. * @returns the current particle system
  19733. */
  19734. removeEmitRateGradient(gradient: number): IParticleSystem;
  19735. /**
  19736. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  19737. * @param gradient defines the gradient to use (between 0 and 1)
  19738. * @param factor defines the start size value to affect to the specified gradient
  19739. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19740. * @returns the current particle system
  19741. */
  19742. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19743. /**
  19744. * Remove a specific start size gradient
  19745. * @param gradient defines the gradient to remove
  19746. * @returns the current particle system
  19747. */
  19748. removeStartSizeGradient(gradient: number): IParticleSystem;
  19749. private _createRampGradientTexture;
  19750. /**
  19751. * Gets the current list of ramp gradients.
  19752. * You must use addRampGradient and removeRampGradient to udpate this list
  19753. * @returns the list of ramp gradients
  19754. */
  19755. getRampGradients(): Nullable<Array<Color3Gradient>>;
  19756. /**
  19757. * Adds a new ramp gradient used to remap particle colors
  19758. * @param gradient defines the gradient to use (between 0 and 1)
  19759. * @param color defines the color to affect to the specified gradient
  19760. * @returns the current particle system
  19761. */
  19762. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  19763. /**
  19764. * Remove a specific ramp gradient
  19765. * @param gradient defines the gradient to remove
  19766. * @returns the current particle system
  19767. */
  19768. removeRampGradient(gradient: number): ParticleSystem;
  19769. /**
  19770. * Adds a new color gradient
  19771. * @param gradient defines the gradient to use (between 0 and 1)
  19772. * @param color1 defines the color to affect to the specified gradient
  19773. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  19774. * @returns this particle system
  19775. */
  19776. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  19777. /**
  19778. * Remove a specific color gradient
  19779. * @param gradient defines the gradient to remove
  19780. * @returns this particle system
  19781. */
  19782. removeColorGradient(gradient: number): IParticleSystem;
  19783. private _fetchR;
  19784. protected _reset(): void;
  19785. private _resetEffect;
  19786. private _createVertexBuffers;
  19787. private _createIndexBuffer;
  19788. /**
  19789. * Gets the maximum number of particles active at the same time.
  19790. * @returns The max number of active particles.
  19791. */
  19792. getCapacity(): number;
  19793. /**
  19794. * Gets whether there are still active particles in the system.
  19795. * @returns True if it is alive, otherwise false.
  19796. */
  19797. isAlive(): boolean;
  19798. /**
  19799. * Gets if the system has been started. (Note: this will still be true after stop is called)
  19800. * @returns True if it has been started, otherwise false.
  19801. */
  19802. isStarted(): boolean;
  19803. private _prepareSubEmitterInternalArray;
  19804. /**
  19805. * Starts the particle system and begins to emit
  19806. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  19807. */
  19808. start(delay?: number): void;
  19809. /**
  19810. * Stops the particle system.
  19811. * @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.
  19812. */
  19813. stop(stopSubEmitters?: boolean): void;
  19814. /**
  19815. * Remove all active particles
  19816. */
  19817. reset(): void;
  19818. /**
  19819. * @hidden (for internal use only)
  19820. */
  19821. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  19822. /**
  19823. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  19824. * Its lifetime will start back at 0.
  19825. */
  19826. recycleParticle: (particle: Particle) => void;
  19827. private _stopSubEmitters;
  19828. private _createParticle;
  19829. private _removeFromRoot;
  19830. private _emitFromParticle;
  19831. private _update;
  19832. /** @hidden */
  19833. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  19834. /** @hidden */
  19835. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  19836. /** @hidden */
  19837. private _getEffect;
  19838. /**
  19839. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  19840. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  19841. */
  19842. animate(preWarmOnly?: boolean): void;
  19843. private _appendParticleVertices;
  19844. /**
  19845. * Rebuilds the particle system.
  19846. */
  19847. rebuild(): void;
  19848. /**
  19849. * Is this system ready to be used/rendered
  19850. * @return true if the system is ready
  19851. */
  19852. isReady(): boolean;
  19853. private _render;
  19854. /**
  19855. * Renders the particle system in its current state.
  19856. * @returns the current number of particles
  19857. */
  19858. render(): number;
  19859. /**
  19860. * Disposes the particle system and free the associated resources
  19861. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  19862. */
  19863. dispose(disposeTexture?: boolean): void;
  19864. /**
  19865. * Clones the particle system.
  19866. * @param name The name of the cloned object
  19867. * @param newEmitter The new emitter to use
  19868. * @returns the cloned particle system
  19869. */
  19870. clone(name: string, newEmitter: any): ParticleSystem;
  19871. /**
  19872. * Serializes the particle system to a JSON object.
  19873. * @returns the JSON object
  19874. */
  19875. serialize(): any;
  19876. /** @hidden */
  19877. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  19878. /** @hidden */
  19879. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  19880. /**
  19881. * Parses a JSON object to create a particle system.
  19882. * @param parsedParticleSystem The JSON object to parse
  19883. * @param scene The scene to create the particle system in
  19884. * @param rootUrl The root url to use to load external dependencies like texture
  19885. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  19886. * @returns the Parsed particle system
  19887. */
  19888. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  19889. }
  19890. }
  19891. declare module BABYLON {
  19892. /**
  19893. * A particle represents one of the element emitted by a particle system.
  19894. * This is mainly define by its coordinates, direction, velocity and age.
  19895. */
  19896. export class Particle {
  19897. /**
  19898. * The particle system the particle belongs to.
  19899. */
  19900. particleSystem: ParticleSystem;
  19901. private static _Count;
  19902. /**
  19903. * Unique ID of the particle
  19904. */
  19905. id: number;
  19906. /**
  19907. * The world position of the particle in the scene.
  19908. */
  19909. position: Vector3;
  19910. /**
  19911. * The world direction of the particle in the scene.
  19912. */
  19913. direction: Vector3;
  19914. /**
  19915. * The color of the particle.
  19916. */
  19917. color: Color4;
  19918. /**
  19919. * The color change of the particle per step.
  19920. */
  19921. colorStep: Color4;
  19922. /**
  19923. * Defines how long will the life of the particle be.
  19924. */
  19925. lifeTime: number;
  19926. /**
  19927. * The current age of the particle.
  19928. */
  19929. age: number;
  19930. /**
  19931. * The current size of the particle.
  19932. */
  19933. size: number;
  19934. /**
  19935. * The current scale of the particle.
  19936. */
  19937. scale: Vector2;
  19938. /**
  19939. * The current angle of the particle.
  19940. */
  19941. angle: number;
  19942. /**
  19943. * Defines how fast is the angle changing.
  19944. */
  19945. angularSpeed: number;
  19946. /**
  19947. * Defines the cell index used by the particle to be rendered from a sprite.
  19948. */
  19949. cellIndex: number;
  19950. /**
  19951. * The information required to support color remapping
  19952. */
  19953. remapData: Vector4;
  19954. /** @hidden */
  19955. _randomCellOffset?: number;
  19956. /** @hidden */
  19957. _initialDirection: Nullable<Vector3>;
  19958. /** @hidden */
  19959. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  19960. /** @hidden */
  19961. _initialStartSpriteCellID: number;
  19962. /** @hidden */
  19963. _initialEndSpriteCellID: number;
  19964. /** @hidden */
  19965. _currentColorGradient: Nullable<ColorGradient>;
  19966. /** @hidden */
  19967. _currentColor1: Color4;
  19968. /** @hidden */
  19969. _currentColor2: Color4;
  19970. /** @hidden */
  19971. _currentSizeGradient: Nullable<FactorGradient>;
  19972. /** @hidden */
  19973. _currentSize1: number;
  19974. /** @hidden */
  19975. _currentSize2: number;
  19976. /** @hidden */
  19977. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  19978. /** @hidden */
  19979. _currentAngularSpeed1: number;
  19980. /** @hidden */
  19981. _currentAngularSpeed2: number;
  19982. /** @hidden */
  19983. _currentVelocityGradient: Nullable<FactorGradient>;
  19984. /** @hidden */
  19985. _currentVelocity1: number;
  19986. /** @hidden */
  19987. _currentVelocity2: number;
  19988. /** @hidden */
  19989. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  19990. /** @hidden */
  19991. _currentLimitVelocity1: number;
  19992. /** @hidden */
  19993. _currentLimitVelocity2: number;
  19994. /** @hidden */
  19995. _currentDragGradient: Nullable<FactorGradient>;
  19996. /** @hidden */
  19997. _currentDrag1: number;
  19998. /** @hidden */
  19999. _currentDrag2: number;
  20000. /** @hidden */
  20001. _randomNoiseCoordinates1: Vector3;
  20002. /** @hidden */
  20003. _randomNoiseCoordinates2: Vector3;
  20004. /**
  20005. * Creates a new instance Particle
  20006. * @param particleSystem the particle system the particle belongs to
  20007. */
  20008. constructor(
  20009. /**
  20010. * The particle system the particle belongs to.
  20011. */
  20012. particleSystem: ParticleSystem);
  20013. private updateCellInfoFromSystem;
  20014. /**
  20015. * Defines how the sprite cell index is updated for the particle
  20016. */
  20017. updateCellIndex(): void;
  20018. /** @hidden */
  20019. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  20020. /** @hidden */
  20021. _inheritParticleInfoToSubEmitters(): void;
  20022. /** @hidden */
  20023. _reset(): void;
  20024. /**
  20025. * Copy the properties of particle to another one.
  20026. * @param other the particle to copy the information to.
  20027. */
  20028. copyTo(other: Particle): void;
  20029. }
  20030. }
  20031. declare module BABYLON {
  20032. /**
  20033. * Particle emitter represents a volume emitting particles.
  20034. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  20035. */
  20036. export interface IParticleEmitterType {
  20037. /**
  20038. * Called by the particle System when the direction is computed for the created particle.
  20039. * @param worldMatrix is the world matrix of the particle system
  20040. * @param directionToUpdate is the direction vector to update with the result
  20041. * @param particle is the particle we are computed the direction for
  20042. */
  20043. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  20044. /**
  20045. * Called by the particle System when the position is computed for the created particle.
  20046. * @param worldMatrix is the world matrix of the particle system
  20047. * @param positionToUpdate is the position vector to update with the result
  20048. * @param particle is the particle we are computed the position for
  20049. */
  20050. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  20051. /**
  20052. * Clones the current emitter and returns a copy of it
  20053. * @returns the new emitter
  20054. */
  20055. clone(): IParticleEmitterType;
  20056. /**
  20057. * Called by the GPUParticleSystem to setup the update shader
  20058. * @param effect defines the update shader
  20059. */
  20060. applyToShader(effect: Effect): void;
  20061. /**
  20062. * Returns a string to use to update the GPU particles update shader
  20063. * @returns the effect defines string
  20064. */
  20065. getEffectDefines(): string;
  20066. /**
  20067. * Returns a string representing the class name
  20068. * @returns a string containing the class name
  20069. */
  20070. getClassName(): string;
  20071. /**
  20072. * Serializes the particle system to a JSON object.
  20073. * @returns the JSON object
  20074. */
  20075. serialize(): any;
  20076. /**
  20077. * Parse properties from a JSON object
  20078. * @param serializationObject defines the JSON object
  20079. */
  20080. parse(serializationObject: any): void;
  20081. }
  20082. }
  20083. declare module BABYLON {
  20084. /**
  20085. * Particle emitter emitting particles from the inside of a box.
  20086. * It emits the particles randomly between 2 given directions.
  20087. */
  20088. export class BoxParticleEmitter implements IParticleEmitterType {
  20089. /**
  20090. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  20091. */
  20092. direction1: Vector3;
  20093. /**
  20094. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  20095. */
  20096. direction2: Vector3;
  20097. /**
  20098. * 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.
  20099. */
  20100. minEmitBox: Vector3;
  20101. /**
  20102. * 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.
  20103. */
  20104. maxEmitBox: Vector3;
  20105. /**
  20106. * Creates a new instance BoxParticleEmitter
  20107. */
  20108. constructor();
  20109. /**
  20110. * Called by the particle System when the direction is computed for the created particle.
  20111. * @param worldMatrix is the world matrix of the particle system
  20112. * @param directionToUpdate is the direction vector to update with the result
  20113. * @param particle is the particle we are computed the direction for
  20114. */
  20115. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  20116. /**
  20117. * Called by the particle System when the position is computed for the created particle.
  20118. * @param worldMatrix is the world matrix of the particle system
  20119. * @param positionToUpdate is the position vector to update with the result
  20120. * @param particle is the particle we are computed the position for
  20121. */
  20122. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  20123. /**
  20124. * Clones the current emitter and returns a copy of it
  20125. * @returns the new emitter
  20126. */
  20127. clone(): BoxParticleEmitter;
  20128. /**
  20129. * Called by the GPUParticleSystem to setup the update shader
  20130. * @param effect defines the update shader
  20131. */
  20132. applyToShader(effect: Effect): void;
  20133. /**
  20134. * Returns a string to use to update the GPU particles update shader
  20135. * @returns a string containng the defines string
  20136. */
  20137. getEffectDefines(): string;
  20138. /**
  20139. * Returns the string "BoxParticleEmitter"
  20140. * @returns a string containing the class name
  20141. */
  20142. getClassName(): string;
  20143. /**
  20144. * Serializes the particle system to a JSON object.
  20145. * @returns the JSON object
  20146. */
  20147. serialize(): any;
  20148. /**
  20149. * Parse properties from a JSON object
  20150. * @param serializationObject defines the JSON object
  20151. */
  20152. parse(serializationObject: any): void;
  20153. }
  20154. }
  20155. declare module BABYLON {
  20156. /**
  20157. * Particle emitter emitting particles from the inside of a cone.
  20158. * It emits the particles alongside the cone volume from the base to the particle.
  20159. * The emission direction might be randomized.
  20160. */
  20161. export class ConeParticleEmitter implements IParticleEmitterType {
  20162. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  20163. directionRandomizer: number;
  20164. private _radius;
  20165. private _angle;
  20166. private _height;
  20167. /**
  20168. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  20169. */
  20170. radiusRange: number;
  20171. /**
  20172. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  20173. */
  20174. heightRange: number;
  20175. /**
  20176. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  20177. */
  20178. emitFromSpawnPointOnly: boolean;
  20179. /**
  20180. * Gets or sets the radius of the emission cone
  20181. */
  20182. radius: number;
  20183. /**
  20184. * Gets or sets the angle of the emission cone
  20185. */
  20186. angle: number;
  20187. private _buildHeight;
  20188. /**
  20189. * Creates a new instance ConeParticleEmitter
  20190. * @param radius the radius of the emission cone (1 by default)
  20191. * @param angle the cone base angle (PI by default)
  20192. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  20193. */
  20194. constructor(radius?: number, angle?: number,
  20195. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  20196. directionRandomizer?: number);
  20197. /**
  20198. * Called by the particle System when the direction is computed for the created particle.
  20199. * @param worldMatrix is the world matrix of the particle system
  20200. * @param directionToUpdate is the direction vector to update with the result
  20201. * @param particle is the particle we are computed the direction for
  20202. */
  20203. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  20204. /**
  20205. * Called by the particle System when the position is computed for the created particle.
  20206. * @param worldMatrix is the world matrix of the particle system
  20207. * @param positionToUpdate is the position vector to update with the result
  20208. * @param particle is the particle we are computed the position for
  20209. */
  20210. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  20211. /**
  20212. * Clones the current emitter and returns a copy of it
  20213. * @returns the new emitter
  20214. */
  20215. clone(): ConeParticleEmitter;
  20216. /**
  20217. * Called by the GPUParticleSystem to setup the update shader
  20218. * @param effect defines the update shader
  20219. */
  20220. applyToShader(effect: Effect): void;
  20221. /**
  20222. * Returns a string to use to update the GPU particles update shader
  20223. * @returns a string containng the defines string
  20224. */
  20225. getEffectDefines(): string;
  20226. /**
  20227. * Returns the string "ConeParticleEmitter"
  20228. * @returns a string containing the class name
  20229. */
  20230. getClassName(): string;
  20231. /**
  20232. * Serializes the particle system to a JSON object.
  20233. * @returns the JSON object
  20234. */
  20235. serialize(): any;
  20236. /**
  20237. * Parse properties from a JSON object
  20238. * @param serializationObject defines the JSON object
  20239. */
  20240. parse(serializationObject: any): void;
  20241. }
  20242. }
  20243. declare module BABYLON {
  20244. /**
  20245. * Particle emitter emitting particles from the inside of a cylinder.
  20246. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  20247. */
  20248. export class CylinderParticleEmitter implements IParticleEmitterType {
  20249. /**
  20250. * The radius of the emission cylinder.
  20251. */
  20252. radius: number;
  20253. /**
  20254. * The height of the emission cylinder.
  20255. */
  20256. height: number;
  20257. /**
  20258. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  20259. */
  20260. radiusRange: number;
  20261. /**
  20262. * How much to randomize the particle direction [0-1].
  20263. */
  20264. directionRandomizer: number;
  20265. /**
  20266. * Creates a new instance CylinderParticleEmitter
  20267. * @param radius the radius of the emission cylinder (1 by default)
  20268. * @param height the height of the emission cylinder (1 by default)
  20269. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  20270. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  20271. */
  20272. constructor(
  20273. /**
  20274. * The radius of the emission cylinder.
  20275. */
  20276. radius?: number,
  20277. /**
  20278. * The height of the emission cylinder.
  20279. */
  20280. height?: number,
  20281. /**
  20282. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  20283. */
  20284. radiusRange?: number,
  20285. /**
  20286. * How much to randomize the particle direction [0-1].
  20287. */
  20288. directionRandomizer?: number);
  20289. /**
  20290. * Called by the particle System when the direction is computed for the created particle.
  20291. * @param worldMatrix is the world matrix of the particle system
  20292. * @param directionToUpdate is the direction vector to update with the result
  20293. * @param particle is the particle we are computed the direction for
  20294. */
  20295. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  20296. /**
  20297. * Called by the particle System when the position is computed for the created particle.
  20298. * @param worldMatrix is the world matrix of the particle system
  20299. * @param positionToUpdate is the position vector to update with the result
  20300. * @param particle is the particle we are computed the position for
  20301. */
  20302. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  20303. /**
  20304. * Clones the current emitter and returns a copy of it
  20305. * @returns the new emitter
  20306. */
  20307. clone(): CylinderParticleEmitter;
  20308. /**
  20309. * Called by the GPUParticleSystem to setup the update shader
  20310. * @param effect defines the update shader
  20311. */
  20312. applyToShader(effect: Effect): void;
  20313. /**
  20314. * Returns a string to use to update the GPU particles update shader
  20315. * @returns a string containng the defines string
  20316. */
  20317. getEffectDefines(): string;
  20318. /**
  20319. * Returns the string "CylinderParticleEmitter"
  20320. * @returns a string containing the class name
  20321. */
  20322. getClassName(): string;
  20323. /**
  20324. * Serializes the particle system to a JSON object.
  20325. * @returns the JSON object
  20326. */
  20327. serialize(): any;
  20328. /**
  20329. * Parse properties from a JSON object
  20330. * @param serializationObject defines the JSON object
  20331. */
  20332. parse(serializationObject: any): void;
  20333. }
  20334. /**
  20335. * Particle emitter emitting particles from the inside of a cylinder.
  20336. * It emits the particles randomly between two vectors.
  20337. */
  20338. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  20339. /**
  20340. * The min limit of the emission direction.
  20341. */
  20342. direction1: Vector3;
  20343. /**
  20344. * The max limit of the emission direction.
  20345. */
  20346. direction2: Vector3;
  20347. /**
  20348. * Creates a new instance CylinderDirectedParticleEmitter
  20349. * @param radius the radius of the emission cylinder (1 by default)
  20350. * @param height the height of the emission cylinder (1 by default)
  20351. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  20352. * @param direction1 the min limit of the emission direction (up vector by default)
  20353. * @param direction2 the max limit of the emission direction (up vector by default)
  20354. */
  20355. constructor(radius?: number, height?: number, radiusRange?: number,
  20356. /**
  20357. * The min limit of the emission direction.
  20358. */
  20359. direction1?: Vector3,
  20360. /**
  20361. * The max limit of the emission direction.
  20362. */
  20363. direction2?: Vector3);
  20364. /**
  20365. * Called by the particle System when the direction is computed for the created particle.
  20366. * @param worldMatrix is the world matrix of the particle system
  20367. * @param directionToUpdate is the direction vector to update with the result
  20368. * @param particle is the particle we are computed the direction for
  20369. */
  20370. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  20371. /**
  20372. * Clones the current emitter and returns a copy of it
  20373. * @returns the new emitter
  20374. */
  20375. clone(): CylinderDirectedParticleEmitter;
  20376. /**
  20377. * Called by the GPUParticleSystem to setup the update shader
  20378. * @param effect defines the update shader
  20379. */
  20380. applyToShader(effect: Effect): void;
  20381. /**
  20382. * Returns a string to use to update the GPU particles update shader
  20383. * @returns a string containng the defines string
  20384. */
  20385. getEffectDefines(): string;
  20386. /**
  20387. * Returns the string "CylinderDirectedParticleEmitter"
  20388. * @returns a string containing the class name
  20389. */
  20390. getClassName(): string;
  20391. /**
  20392. * Serializes the particle system to a JSON object.
  20393. * @returns the JSON object
  20394. */
  20395. serialize(): any;
  20396. /**
  20397. * Parse properties from a JSON object
  20398. * @param serializationObject defines the JSON object
  20399. */
  20400. parse(serializationObject: any): void;
  20401. }
  20402. }
  20403. declare module BABYLON {
  20404. /**
  20405. * Particle emitter emitting particles from the inside of a hemisphere.
  20406. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  20407. */
  20408. export class HemisphericParticleEmitter implements IParticleEmitterType {
  20409. /**
  20410. * The radius of the emission hemisphere.
  20411. */
  20412. radius: number;
  20413. /**
  20414. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  20415. */
  20416. radiusRange: number;
  20417. /**
  20418. * How much to randomize the particle direction [0-1].
  20419. */
  20420. directionRandomizer: number;
  20421. /**
  20422. * Creates a new instance HemisphericParticleEmitter
  20423. * @param radius the radius of the emission hemisphere (1 by default)
  20424. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  20425. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  20426. */
  20427. constructor(
  20428. /**
  20429. * The radius of the emission hemisphere.
  20430. */
  20431. radius?: number,
  20432. /**
  20433. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  20434. */
  20435. radiusRange?: number,
  20436. /**
  20437. * How much to randomize the particle direction [0-1].
  20438. */
  20439. directionRandomizer?: number);
  20440. /**
  20441. * Called by the particle System when the direction is computed for the created particle.
  20442. * @param worldMatrix is the world matrix of the particle system
  20443. * @param directionToUpdate is the direction vector to update with the result
  20444. * @param particle is the particle we are computed the direction for
  20445. */
  20446. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  20447. /**
  20448. * Called by the particle System when the position is computed for the created particle.
  20449. * @param worldMatrix is the world matrix of the particle system
  20450. * @param positionToUpdate is the position vector to update with the result
  20451. * @param particle is the particle we are computed the position for
  20452. */
  20453. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  20454. /**
  20455. * Clones the current emitter and returns a copy of it
  20456. * @returns the new emitter
  20457. */
  20458. clone(): HemisphericParticleEmitter;
  20459. /**
  20460. * Called by the GPUParticleSystem to setup the update shader
  20461. * @param effect defines the update shader
  20462. */
  20463. applyToShader(effect: Effect): void;
  20464. /**
  20465. * Returns a string to use to update the GPU particles update shader
  20466. * @returns a string containng the defines string
  20467. */
  20468. getEffectDefines(): string;
  20469. /**
  20470. * Returns the string "HemisphericParticleEmitter"
  20471. * @returns a string containing the class name
  20472. */
  20473. getClassName(): string;
  20474. /**
  20475. * Serializes the particle system to a JSON object.
  20476. * @returns the JSON object
  20477. */
  20478. serialize(): any;
  20479. /**
  20480. * Parse properties from a JSON object
  20481. * @param serializationObject defines the JSON object
  20482. */
  20483. parse(serializationObject: any): void;
  20484. }
  20485. }
  20486. declare module BABYLON {
  20487. /**
  20488. * Particle emitter emitting particles from a point.
  20489. * It emits the particles randomly between 2 given directions.
  20490. */
  20491. export class PointParticleEmitter implements IParticleEmitterType {
  20492. /**
  20493. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  20494. */
  20495. direction1: Vector3;
  20496. /**
  20497. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  20498. */
  20499. direction2: Vector3;
  20500. /**
  20501. * Creates a new instance PointParticleEmitter
  20502. */
  20503. constructor();
  20504. /**
  20505. * Called by the particle System when the direction is computed for the created particle.
  20506. * @param worldMatrix is the world matrix of the particle system
  20507. * @param directionToUpdate is the direction vector to update with the result
  20508. * @param particle is the particle we are computed the direction for
  20509. */
  20510. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  20511. /**
  20512. * Called by the particle System when the position is computed for the created particle.
  20513. * @param worldMatrix is the world matrix of the particle system
  20514. * @param positionToUpdate is the position vector to update with the result
  20515. * @param particle is the particle we are computed the position for
  20516. */
  20517. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  20518. /**
  20519. * Clones the current emitter and returns a copy of it
  20520. * @returns the new emitter
  20521. */
  20522. clone(): PointParticleEmitter;
  20523. /**
  20524. * Called by the GPUParticleSystem to setup the update shader
  20525. * @param effect defines the update shader
  20526. */
  20527. applyToShader(effect: Effect): void;
  20528. /**
  20529. * Returns a string to use to update the GPU particles update shader
  20530. * @returns a string containng the defines string
  20531. */
  20532. getEffectDefines(): string;
  20533. /**
  20534. * Returns the string "PointParticleEmitter"
  20535. * @returns a string containing the class name
  20536. */
  20537. getClassName(): string;
  20538. /**
  20539. * Serializes the particle system to a JSON object.
  20540. * @returns the JSON object
  20541. */
  20542. serialize(): any;
  20543. /**
  20544. * Parse properties from a JSON object
  20545. * @param serializationObject defines the JSON object
  20546. */
  20547. parse(serializationObject: any): void;
  20548. }
  20549. }
  20550. declare module BABYLON {
  20551. /**
  20552. * Particle emitter emitting particles from the inside of a sphere.
  20553. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  20554. */
  20555. export class SphereParticleEmitter implements IParticleEmitterType {
  20556. /**
  20557. * The radius of the emission sphere.
  20558. */
  20559. radius: number;
  20560. /**
  20561. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  20562. */
  20563. radiusRange: number;
  20564. /**
  20565. * How much to randomize the particle direction [0-1].
  20566. */
  20567. directionRandomizer: number;
  20568. /**
  20569. * Creates a new instance SphereParticleEmitter
  20570. * @param radius the radius of the emission sphere (1 by default)
  20571. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  20572. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  20573. */
  20574. constructor(
  20575. /**
  20576. * The radius of the emission sphere.
  20577. */
  20578. radius?: number,
  20579. /**
  20580. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  20581. */
  20582. radiusRange?: number,
  20583. /**
  20584. * How much to randomize the particle direction [0-1].
  20585. */
  20586. directionRandomizer?: number);
  20587. /**
  20588. * Called by the particle System when the direction is computed for the created particle.
  20589. * @param worldMatrix is the world matrix of the particle system
  20590. * @param directionToUpdate is the direction vector to update with the result
  20591. * @param particle is the particle we are computed the direction for
  20592. */
  20593. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  20594. /**
  20595. * Called by the particle System when the position is computed for the created particle.
  20596. * @param worldMatrix is the world matrix of the particle system
  20597. * @param positionToUpdate is the position vector to update with the result
  20598. * @param particle is the particle we are computed the position for
  20599. */
  20600. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  20601. /**
  20602. * Clones the current emitter and returns a copy of it
  20603. * @returns the new emitter
  20604. */
  20605. clone(): SphereParticleEmitter;
  20606. /**
  20607. * Called by the GPUParticleSystem to setup the update shader
  20608. * @param effect defines the update shader
  20609. */
  20610. applyToShader(effect: Effect): void;
  20611. /**
  20612. * Returns a string to use to update the GPU particles update shader
  20613. * @returns a string containng the defines string
  20614. */
  20615. getEffectDefines(): string;
  20616. /**
  20617. * Returns the string "SphereParticleEmitter"
  20618. * @returns a string containing the class name
  20619. */
  20620. getClassName(): string;
  20621. /**
  20622. * Serializes the particle system to a JSON object.
  20623. * @returns the JSON object
  20624. */
  20625. serialize(): any;
  20626. /**
  20627. * Parse properties from a JSON object
  20628. * @param serializationObject defines the JSON object
  20629. */
  20630. parse(serializationObject: any): void;
  20631. }
  20632. /**
  20633. * Particle emitter emitting particles from the inside of a sphere.
  20634. * It emits the particles randomly between two vectors.
  20635. */
  20636. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  20637. /**
  20638. * The min limit of the emission direction.
  20639. */
  20640. direction1: Vector3;
  20641. /**
  20642. * The max limit of the emission direction.
  20643. */
  20644. direction2: Vector3;
  20645. /**
  20646. * Creates a new instance SphereDirectedParticleEmitter
  20647. * @param radius the radius of the emission sphere (1 by default)
  20648. * @param direction1 the min limit of the emission direction (up vector by default)
  20649. * @param direction2 the max limit of the emission direction (up vector by default)
  20650. */
  20651. constructor(radius?: number,
  20652. /**
  20653. * The min limit of the emission direction.
  20654. */
  20655. direction1?: Vector3,
  20656. /**
  20657. * The max limit of the emission direction.
  20658. */
  20659. direction2?: Vector3);
  20660. /**
  20661. * Called by the particle System when the direction is computed for the created particle.
  20662. * @param worldMatrix is the world matrix of the particle system
  20663. * @param directionToUpdate is the direction vector to update with the result
  20664. * @param particle is the particle we are computed the direction for
  20665. */
  20666. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  20667. /**
  20668. * Clones the current emitter and returns a copy of it
  20669. * @returns the new emitter
  20670. */
  20671. clone(): SphereDirectedParticleEmitter;
  20672. /**
  20673. * Called by the GPUParticleSystem to setup the update shader
  20674. * @param effect defines the update shader
  20675. */
  20676. applyToShader(effect: Effect): void;
  20677. /**
  20678. * Returns a string to use to update the GPU particles update shader
  20679. * @returns a string containng the defines string
  20680. */
  20681. getEffectDefines(): string;
  20682. /**
  20683. * Returns the string "SphereDirectedParticleEmitter"
  20684. * @returns a string containing the class name
  20685. */
  20686. getClassName(): string;
  20687. /**
  20688. * Serializes the particle system to a JSON object.
  20689. * @returns the JSON object
  20690. */
  20691. serialize(): any;
  20692. /**
  20693. * Parse properties from a JSON object
  20694. * @param serializationObject defines the JSON object
  20695. */
  20696. parse(serializationObject: any): void;
  20697. }
  20698. }
  20699. declare module BABYLON {
  20700. /**
  20701. * Interface representing a particle system in Babylon.js.
  20702. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  20703. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  20704. */
  20705. export interface IParticleSystem {
  20706. /**
  20707. * List of animations used by the particle system.
  20708. */
  20709. animations: Animation[];
  20710. /**
  20711. * The id of the Particle system.
  20712. */
  20713. id: string;
  20714. /**
  20715. * The name of the Particle system.
  20716. */
  20717. name: string;
  20718. /**
  20719. * The emitter represents the Mesh or position we are attaching the particle system to.
  20720. */
  20721. emitter: Nullable<AbstractMesh | Vector3>;
  20722. /**
  20723. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  20724. */
  20725. isBillboardBased: boolean;
  20726. /**
  20727. * The rendering group used by the Particle system to chose when to render.
  20728. */
  20729. renderingGroupId: number;
  20730. /**
  20731. * The layer mask we are rendering the particles through.
  20732. */
  20733. layerMask: number;
  20734. /**
  20735. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  20736. */
  20737. updateSpeed: number;
  20738. /**
  20739. * The amount of time the particle system is running (depends of the overall update speed).
  20740. */
  20741. targetStopDuration: number;
  20742. /**
  20743. * The texture used to render each particle. (this can be a spritesheet)
  20744. */
  20745. particleTexture: Nullable<Texture>;
  20746. /**
  20747. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  20748. */
  20749. blendMode: number;
  20750. /**
  20751. * Minimum life time of emitting particles.
  20752. */
  20753. minLifeTime: number;
  20754. /**
  20755. * Maximum life time of emitting particles.
  20756. */
  20757. maxLifeTime: number;
  20758. /**
  20759. * Minimum Size of emitting particles.
  20760. */
  20761. minSize: number;
  20762. /**
  20763. * Maximum Size of emitting particles.
  20764. */
  20765. maxSize: number;
  20766. /**
  20767. * Minimum scale of emitting particles on X axis.
  20768. */
  20769. minScaleX: number;
  20770. /**
  20771. * Maximum scale of emitting particles on X axis.
  20772. */
  20773. maxScaleX: number;
  20774. /**
  20775. * Minimum scale of emitting particles on Y axis.
  20776. */
  20777. minScaleY: number;
  20778. /**
  20779. * Maximum scale of emitting particles on Y axis.
  20780. */
  20781. maxScaleY: number;
  20782. /**
  20783. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  20784. */
  20785. color1: Color4;
  20786. /**
  20787. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  20788. */
  20789. color2: Color4;
  20790. /**
  20791. * Color the particle will have at the end of its lifetime.
  20792. */
  20793. colorDead: Color4;
  20794. /**
  20795. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  20796. */
  20797. emitRate: number;
  20798. /**
  20799. * You can use gravity if you want to give an orientation to your particles.
  20800. */
  20801. gravity: Vector3;
  20802. /**
  20803. * Minimum power of emitting particles.
  20804. */
  20805. minEmitPower: number;
  20806. /**
  20807. * Maximum power of emitting particles.
  20808. */
  20809. maxEmitPower: number;
  20810. /**
  20811. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  20812. */
  20813. minAngularSpeed: number;
  20814. /**
  20815. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  20816. */
  20817. maxAngularSpeed: number;
  20818. /**
  20819. * Gets or sets the minimal initial rotation in radians.
  20820. */
  20821. minInitialRotation: number;
  20822. /**
  20823. * Gets or sets the maximal initial rotation in radians.
  20824. */
  20825. maxInitialRotation: number;
  20826. /**
  20827. * The particle emitter type defines the emitter used by the particle system.
  20828. * It can be for example box, sphere, or cone...
  20829. */
  20830. particleEmitterType: Nullable<IParticleEmitterType>;
  20831. /**
  20832. * Defines the delay in milliseconds before starting the system (0 by default)
  20833. */
  20834. startDelay: number;
  20835. /**
  20836. * 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
  20837. */
  20838. preWarmCycles: number;
  20839. /**
  20840. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  20841. */
  20842. preWarmStepOffset: number;
  20843. /**
  20844. * 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)
  20845. */
  20846. spriteCellChangeSpeed: number;
  20847. /**
  20848. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  20849. */
  20850. startSpriteCellID: number;
  20851. /**
  20852. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  20853. */
  20854. endSpriteCellID: number;
  20855. /**
  20856. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  20857. */
  20858. spriteCellWidth: number;
  20859. /**
  20860. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  20861. */
  20862. spriteCellHeight: number;
  20863. /**
  20864. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  20865. */
  20866. spriteRandomStartCell: boolean;
  20867. /**
  20868. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  20869. */
  20870. isAnimationSheetEnabled: boolean;
  20871. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  20872. translationPivot: Vector2;
  20873. /**
  20874. * Gets or sets a texture used to add random noise to particle positions
  20875. */
  20876. noiseTexture: Nullable<BaseTexture>;
  20877. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  20878. noiseStrength: Vector3;
  20879. /**
  20880. * Gets or sets the billboard mode to use when isBillboardBased = true.
  20881. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  20882. */
  20883. billboardMode: number;
  20884. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  20885. limitVelocityDamping: number;
  20886. /**
  20887. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  20888. */
  20889. beginAnimationOnStart: boolean;
  20890. /**
  20891. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  20892. */
  20893. beginAnimationFrom: number;
  20894. /**
  20895. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  20896. */
  20897. beginAnimationTo: number;
  20898. /**
  20899. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  20900. */
  20901. beginAnimationLoop: boolean;
  20902. /**
  20903. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  20904. */
  20905. disposeOnStop: boolean;
  20906. /**
  20907. * Gets the maximum number of particles active at the same time.
  20908. * @returns The max number of active particles.
  20909. */
  20910. getCapacity(): number;
  20911. /**
  20912. * Gets if the system has been started. (Note: this will still be true after stop is called)
  20913. * @returns True if it has been started, otherwise false.
  20914. */
  20915. isStarted(): boolean;
  20916. /**
  20917. * Animates the particle system for this frame.
  20918. */
  20919. animate(): void;
  20920. /**
  20921. * Renders the particle system in its current state.
  20922. * @returns the current number of particles
  20923. */
  20924. render(): number;
  20925. /**
  20926. * Dispose the particle system and frees its associated resources.
  20927. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  20928. */
  20929. dispose(disposeTexture?: boolean): void;
  20930. /**
  20931. * Clones the particle system.
  20932. * @param name The name of the cloned object
  20933. * @param newEmitter The new emitter to use
  20934. * @returns the cloned particle system
  20935. */
  20936. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  20937. /**
  20938. * Serializes the particle system to a JSON object.
  20939. * @returns the JSON object
  20940. */
  20941. serialize(): any;
  20942. /**
  20943. * Rebuild the particle system
  20944. */
  20945. rebuild(): void;
  20946. /**
  20947. * Starts the particle system and begins to emit
  20948. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  20949. */
  20950. start(delay?: number): void;
  20951. /**
  20952. * Stops the particle system.
  20953. */
  20954. stop(): void;
  20955. /**
  20956. * Remove all active particles
  20957. */
  20958. reset(): void;
  20959. /**
  20960. * Is this system ready to be used/rendered
  20961. * @return true if the system is ready
  20962. */
  20963. isReady(): boolean;
  20964. /**
  20965. * Adds a new color gradient
  20966. * @param gradient defines the gradient to use (between 0 and 1)
  20967. * @param color1 defines the color to affect to the specified gradient
  20968. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  20969. * @returns the current particle system
  20970. */
  20971. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  20972. /**
  20973. * Remove a specific color gradient
  20974. * @param gradient defines the gradient to remove
  20975. * @returns the current particle system
  20976. */
  20977. removeColorGradient(gradient: number): IParticleSystem;
  20978. /**
  20979. * Adds a new size gradient
  20980. * @param gradient defines the gradient to use (between 0 and 1)
  20981. * @param factor defines the size factor to affect to the specified gradient
  20982. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  20983. * @returns the current particle system
  20984. */
  20985. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  20986. /**
  20987. * Remove a specific size gradient
  20988. * @param gradient defines the gradient to remove
  20989. * @returns the current particle system
  20990. */
  20991. removeSizeGradient(gradient: number): IParticleSystem;
  20992. /**
  20993. * Gets the current list of color gradients.
  20994. * You must use addColorGradient and removeColorGradient to udpate this list
  20995. * @returns the list of color gradients
  20996. */
  20997. getColorGradients(): Nullable<Array<ColorGradient>>;
  20998. /**
  20999. * Gets the current list of size gradients.
  21000. * You must use addSizeGradient and removeSizeGradient to udpate this list
  21001. * @returns the list of size gradients
  21002. */
  21003. getSizeGradients(): Nullable<Array<FactorGradient>>;
  21004. /**
  21005. * Gets the current list of angular speed gradients.
  21006. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  21007. * @returns the list of angular speed gradients
  21008. */
  21009. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  21010. /**
  21011. * Adds a new angular speed gradient
  21012. * @param gradient defines the gradient to use (between 0 and 1)
  21013. * @param factor defines the angular speed to affect to the specified gradient
  21014. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  21015. * @returns the current particle system
  21016. */
  21017. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  21018. /**
  21019. * Remove a specific angular speed gradient
  21020. * @param gradient defines the gradient to remove
  21021. * @returns the current particle system
  21022. */
  21023. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  21024. /**
  21025. * Gets the current list of velocity gradients.
  21026. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  21027. * @returns the list of velocity gradients
  21028. */
  21029. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  21030. /**
  21031. * Adds a new velocity gradient
  21032. * @param gradient defines the gradient to use (between 0 and 1)
  21033. * @param factor defines the velocity to affect to the specified gradient
  21034. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  21035. * @returns the current particle system
  21036. */
  21037. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  21038. /**
  21039. * Remove a specific velocity gradient
  21040. * @param gradient defines the gradient to remove
  21041. * @returns the current particle system
  21042. */
  21043. removeVelocityGradient(gradient: number): IParticleSystem;
  21044. /**
  21045. * Gets the current list of limit velocity gradients.
  21046. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  21047. * @returns the list of limit velocity gradients
  21048. */
  21049. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  21050. /**
  21051. * Adds a new limit velocity gradient
  21052. * @param gradient defines the gradient to use (between 0 and 1)
  21053. * @param factor defines the limit velocity to affect to the specified gradient
  21054. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  21055. * @returns the current particle system
  21056. */
  21057. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  21058. /**
  21059. * Remove a specific limit velocity gradient
  21060. * @param gradient defines the gradient to remove
  21061. * @returns the current particle system
  21062. */
  21063. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  21064. /**
  21065. * Adds a new drag gradient
  21066. * @param gradient defines the gradient to use (between 0 and 1)
  21067. * @param factor defines the drag to affect to the specified gradient
  21068. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  21069. * @returns the current particle system
  21070. */
  21071. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  21072. /**
  21073. * Remove a specific drag gradient
  21074. * @param gradient defines the gradient to remove
  21075. * @returns the current particle system
  21076. */
  21077. removeDragGradient(gradient: number): IParticleSystem;
  21078. /**
  21079. * Gets the current list of drag gradients.
  21080. * You must use addDragGradient and removeDragGradient to udpate this list
  21081. * @returns the list of drag gradients
  21082. */
  21083. getDragGradients(): Nullable<Array<FactorGradient>>;
  21084. /**
  21085. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  21086. * @param gradient defines the gradient to use (between 0 and 1)
  21087. * @param factor defines the emit rate to affect to the specified gradient
  21088. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  21089. * @returns the current particle system
  21090. */
  21091. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  21092. /**
  21093. * Remove a specific emit rate gradient
  21094. * @param gradient defines the gradient to remove
  21095. * @returns the current particle system
  21096. */
  21097. removeEmitRateGradient(gradient: number): IParticleSystem;
  21098. /**
  21099. * Gets the current list of emit rate gradients.
  21100. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  21101. * @returns the list of emit rate gradients
  21102. */
  21103. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  21104. /**
  21105. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  21106. * @param gradient defines the gradient to use (between 0 and 1)
  21107. * @param factor defines the start size to affect to the specified gradient
  21108. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  21109. * @returns the current particle system
  21110. */
  21111. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  21112. /**
  21113. * Remove a specific start size gradient
  21114. * @param gradient defines the gradient to remove
  21115. * @returns the current particle system
  21116. */
  21117. removeStartSizeGradient(gradient: number): IParticleSystem;
  21118. /**
  21119. * Gets the current list of start size gradients.
  21120. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  21121. * @returns the list of start size gradients
  21122. */
  21123. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  21124. /**
  21125. * Adds a new life time gradient
  21126. * @param gradient defines the gradient to use (between 0 and 1)
  21127. * @param factor defines the life time factor to affect to the specified gradient
  21128. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  21129. * @returns the current particle system
  21130. */
  21131. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  21132. /**
  21133. * Remove a specific life time gradient
  21134. * @param gradient defines the gradient to remove
  21135. * @returns the current particle system
  21136. */
  21137. removeLifeTimeGradient(gradient: number): IParticleSystem;
  21138. /**
  21139. * Gets the current list of life time gradients.
  21140. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  21141. * @returns the list of life time gradients
  21142. */
  21143. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  21144. /**
  21145. * Gets the current list of color gradients.
  21146. * You must use addColorGradient and removeColorGradient to udpate this list
  21147. * @returns the list of color gradients
  21148. */
  21149. getColorGradients(): Nullable<Array<ColorGradient>>;
  21150. /**
  21151. * Adds a new ramp gradient used to remap particle colors
  21152. * @param gradient defines the gradient to use (between 0 and 1)
  21153. * @param color defines the color to affect to the specified gradient
  21154. * @returns the current particle system
  21155. */
  21156. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  21157. /**
  21158. * Gets the current list of ramp gradients.
  21159. * You must use addRampGradient and removeRampGradient to udpate this list
  21160. * @returns the list of ramp gradients
  21161. */
  21162. getRampGradients(): Nullable<Array<Color3Gradient>>;
  21163. /** Gets or sets a boolean indicating that ramp gradients must be used
  21164. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  21165. */
  21166. useRampGradients: boolean;
  21167. /**
  21168. * Adds a new color remap gradient
  21169. * @param gradient defines the gradient to use (between 0 and 1)
  21170. * @param min defines the color remap minimal range
  21171. * @param max defines the color remap maximal range
  21172. * @returns the current particle system
  21173. */
  21174. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  21175. /**
  21176. * Gets the current list of color remap gradients.
  21177. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  21178. * @returns the list of color remap gradients
  21179. */
  21180. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  21181. /**
  21182. * Adds a new alpha remap gradient
  21183. * @param gradient defines the gradient to use (between 0 and 1)
  21184. * @param min defines the alpha remap minimal range
  21185. * @param max defines the alpha remap maximal range
  21186. * @returns the current particle system
  21187. */
  21188. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  21189. /**
  21190. * Gets the current list of alpha remap gradients.
  21191. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  21192. * @returns the list of alpha remap gradients
  21193. */
  21194. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  21195. /**
  21196. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  21197. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  21198. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  21199. * @returns the emitter
  21200. */
  21201. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  21202. /**
  21203. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  21204. * @param radius The radius of the hemisphere to emit from
  21205. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  21206. * @returns the emitter
  21207. */
  21208. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  21209. /**
  21210. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  21211. * @param radius The radius of the sphere to emit from
  21212. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  21213. * @returns the emitter
  21214. */
  21215. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  21216. /**
  21217. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  21218. * @param radius The radius of the sphere to emit from
  21219. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  21220. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  21221. * @returns the emitter
  21222. */
  21223. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  21224. /**
  21225. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  21226. * @param radius The radius of the emission cylinder
  21227. * @param height The height of the emission cylinder
  21228. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  21229. * @param directionRandomizer How much to randomize the particle direction [0-1]
  21230. * @returns the emitter
  21231. */
  21232. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  21233. /**
  21234. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  21235. * @param radius The radius of the cylinder to emit from
  21236. * @param height The height of the emission cylinder
  21237. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  21238. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  21239. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  21240. * @returns the emitter
  21241. */
  21242. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  21243. /**
  21244. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  21245. * @param radius The radius of the cone to emit from
  21246. * @param angle The base angle of the cone
  21247. * @returns the emitter
  21248. */
  21249. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  21250. /**
  21251. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  21252. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  21253. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  21254. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  21255. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  21256. * @returns the emitter
  21257. */
  21258. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  21259. /**
  21260. * Get hosting scene
  21261. * @returns the scene
  21262. */
  21263. getScene(): Scene;
  21264. }
  21265. }
  21266. declare module BABYLON {
  21267. /** @hidden */
  21268. export var linePixelShader: {
  21269. name: string;
  21270. shader: string;
  21271. };
  21272. }
  21273. declare module BABYLON {
  21274. /** @hidden */
  21275. export var lineVertexShader: {
  21276. name: string;
  21277. shader: string;
  21278. };
  21279. }
  21280. declare module BABYLON {
  21281. interface AbstractMesh {
  21282. /**
  21283. * Gets the edgesRenderer associated with the mesh
  21284. */
  21285. edgesRenderer: Nullable<EdgesRenderer>;
  21286. }
  21287. interface LinesMesh {
  21288. /**
  21289. * Enables the edge rendering mode on the mesh.
  21290. * This mode makes the mesh edges visible
  21291. * @param epsilon defines the maximal distance between two angles to detect a face
  21292. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  21293. * @returns the currentAbstractMesh
  21294. * @see https://www.babylonjs-playground.com/#19O9TU#0
  21295. */
  21296. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  21297. }
  21298. interface InstancedLinesMesh {
  21299. /**
  21300. * Enables the edge rendering mode on the mesh.
  21301. * This mode makes the mesh edges visible
  21302. * @param epsilon defines the maximal distance between two angles to detect a face
  21303. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  21304. * @returns the current InstancedLinesMesh
  21305. * @see https://www.babylonjs-playground.com/#19O9TU#0
  21306. */
  21307. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  21308. }
  21309. /**
  21310. * Defines the minimum contract an Edges renderer should follow.
  21311. */
  21312. export interface IEdgesRenderer extends IDisposable {
  21313. /**
  21314. * Gets or sets a boolean indicating if the edgesRenderer is active
  21315. */
  21316. isEnabled: boolean;
  21317. /**
  21318. * Renders the edges of the attached mesh,
  21319. */
  21320. render(): void;
  21321. /**
  21322. * Checks wether or not the edges renderer is ready to render.
  21323. * @return true if ready, otherwise false.
  21324. */
  21325. isReady(): boolean;
  21326. }
  21327. /**
  21328. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  21329. */
  21330. export class EdgesRenderer implements IEdgesRenderer {
  21331. /**
  21332. * Define the size of the edges with an orthographic camera
  21333. */
  21334. edgesWidthScalerForOrthographic: number;
  21335. /**
  21336. * Define the size of the edges with a perspective camera
  21337. */
  21338. edgesWidthScalerForPerspective: number;
  21339. protected _source: AbstractMesh;
  21340. protected _linesPositions: number[];
  21341. protected _linesNormals: number[];
  21342. protected _linesIndices: number[];
  21343. protected _epsilon: number;
  21344. protected _indicesCount: number;
  21345. protected _lineShader: ShaderMaterial;
  21346. protected _ib: DataBuffer;
  21347. protected _buffers: {
  21348. [key: string]: Nullable<VertexBuffer>;
  21349. };
  21350. protected _checkVerticesInsteadOfIndices: boolean;
  21351. private _meshRebuildObserver;
  21352. private _meshDisposeObserver;
  21353. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  21354. isEnabled: boolean;
  21355. /**
  21356. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  21357. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  21358. * @param source Mesh used to create edges
  21359. * @param epsilon sum of angles in adjacency to check for edge
  21360. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  21361. * @param generateEdgesLines - should generate Lines or only prepare resources.
  21362. */
  21363. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  21364. protected _prepareRessources(): void;
  21365. /** @hidden */
  21366. _rebuild(): void;
  21367. /**
  21368. * Releases the required resources for the edges renderer
  21369. */
  21370. dispose(): void;
  21371. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  21372. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  21373. /**
  21374. * Checks if the pair of p0 and p1 is en edge
  21375. * @param faceIndex
  21376. * @param edge
  21377. * @param faceNormals
  21378. * @param p0
  21379. * @param p1
  21380. * @private
  21381. */
  21382. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  21383. /**
  21384. * push line into the position, normal and index buffer
  21385. * @protected
  21386. */
  21387. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  21388. /**
  21389. * Generates lines edges from adjacencjes
  21390. * @private
  21391. */
  21392. _generateEdgesLines(): void;
  21393. /**
  21394. * Checks wether or not the edges renderer is ready to render.
  21395. * @return true if ready, otherwise false.
  21396. */
  21397. isReady(): boolean;
  21398. /**
  21399. * Renders the edges of the attached mesh,
  21400. */
  21401. render(): void;
  21402. }
  21403. /**
  21404. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  21405. */
  21406. export class LineEdgesRenderer extends EdgesRenderer {
  21407. /**
  21408. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  21409. * @param source LineMesh used to generate edges
  21410. * @param epsilon not important (specified angle for edge detection)
  21411. * @param checkVerticesInsteadOfIndices not important for LineMesh
  21412. */
  21413. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  21414. /**
  21415. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  21416. */
  21417. _generateEdgesLines(): void;
  21418. }
  21419. }
  21420. declare module BABYLON {
  21421. /**
  21422. * This represents the object necessary to create a rendering group.
  21423. * This is exclusively used and created by the rendering manager.
  21424. * To modify the behavior, you use the available helpers in your scene or meshes.
  21425. * @hidden
  21426. */
  21427. export class RenderingGroup {
  21428. index: number;
  21429. private static _zeroVector;
  21430. private _scene;
  21431. private _opaqueSubMeshes;
  21432. private _transparentSubMeshes;
  21433. private _alphaTestSubMeshes;
  21434. private _depthOnlySubMeshes;
  21435. private _particleSystems;
  21436. private _spriteManagers;
  21437. private _opaqueSortCompareFn;
  21438. private _alphaTestSortCompareFn;
  21439. private _transparentSortCompareFn;
  21440. private _renderOpaque;
  21441. private _renderAlphaTest;
  21442. private _renderTransparent;
  21443. /** @hidden */
  21444. _edgesRenderers: SmartArray<IEdgesRenderer>;
  21445. onBeforeTransparentRendering: () => void;
  21446. /**
  21447. * Set the opaque sort comparison function.
  21448. * If null the sub meshes will be render in the order they were created
  21449. */
  21450. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  21451. /**
  21452. * Set the alpha test sort comparison function.
  21453. * If null the sub meshes will be render in the order they were created
  21454. */
  21455. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  21456. /**
  21457. * Set the transparent sort comparison function.
  21458. * If null the sub meshes will be render in the order they were created
  21459. */
  21460. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  21461. /**
  21462. * Creates a new rendering group.
  21463. * @param index The rendering group index
  21464. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  21465. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  21466. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  21467. */
  21468. 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>);
  21469. /**
  21470. * Render all the sub meshes contained in the group.
  21471. * @param customRenderFunction Used to override the default render behaviour of the group.
  21472. * @returns true if rendered some submeshes.
  21473. */
  21474. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  21475. /**
  21476. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  21477. * @param subMeshes The submeshes to render
  21478. */
  21479. private renderOpaqueSorted;
  21480. /**
  21481. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  21482. * @param subMeshes The submeshes to render
  21483. */
  21484. private renderAlphaTestSorted;
  21485. /**
  21486. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  21487. * @param subMeshes The submeshes to render
  21488. */
  21489. private renderTransparentSorted;
  21490. /**
  21491. * Renders the submeshes in a specified order.
  21492. * @param subMeshes The submeshes to sort before render
  21493. * @param sortCompareFn The comparison function use to sort
  21494. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  21495. * @param transparent Specifies to activate blending if true
  21496. */
  21497. private static renderSorted;
  21498. /**
  21499. * Renders the submeshes in the order they were dispatched (no sort applied).
  21500. * @param subMeshes The submeshes to render
  21501. */
  21502. private static renderUnsorted;
  21503. /**
  21504. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  21505. * are rendered back to front if in the same alpha index.
  21506. *
  21507. * @param a The first submesh
  21508. * @param b The second submesh
  21509. * @returns The result of the comparison
  21510. */
  21511. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  21512. /**
  21513. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  21514. * are rendered back to front.
  21515. *
  21516. * @param a The first submesh
  21517. * @param b The second submesh
  21518. * @returns The result of the comparison
  21519. */
  21520. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  21521. /**
  21522. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  21523. * are rendered front to back (prevent overdraw).
  21524. *
  21525. * @param a The first submesh
  21526. * @param b The second submesh
  21527. * @returns The result of the comparison
  21528. */
  21529. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  21530. /**
  21531. * Resets the different lists of submeshes to prepare a new frame.
  21532. */
  21533. prepare(): void;
  21534. dispose(): void;
  21535. /**
  21536. * Inserts the submesh in its correct queue depending on its material.
  21537. * @param subMesh The submesh to dispatch
  21538. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  21539. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  21540. */
  21541. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  21542. dispatchSprites(spriteManager: ISpriteManager): void;
  21543. dispatchParticles(particleSystem: IParticleSystem): void;
  21544. private _renderParticles;
  21545. private _renderSprites;
  21546. }
  21547. }
  21548. declare module BABYLON {
  21549. /**
  21550. * Interface describing the different options available in the rendering manager
  21551. * regarding Auto Clear between groups.
  21552. */
  21553. export interface IRenderingManagerAutoClearSetup {
  21554. /**
  21555. * Defines whether or not autoclear is enable.
  21556. */
  21557. autoClear: boolean;
  21558. /**
  21559. * Defines whether or not to autoclear the depth buffer.
  21560. */
  21561. depth: boolean;
  21562. /**
  21563. * Defines whether or not to autoclear the stencil buffer.
  21564. */
  21565. stencil: boolean;
  21566. }
  21567. /**
  21568. * This class is used by the onRenderingGroupObservable
  21569. */
  21570. export class RenderingGroupInfo {
  21571. /**
  21572. * The Scene that being rendered
  21573. */
  21574. scene: Scene;
  21575. /**
  21576. * The camera currently used for the rendering pass
  21577. */
  21578. camera: Nullable<Camera>;
  21579. /**
  21580. * The ID of the renderingGroup being processed
  21581. */
  21582. renderingGroupId: number;
  21583. }
  21584. /**
  21585. * This is the manager responsible of all the rendering for meshes sprites and particles.
  21586. * It is enable to manage the different groups as well as the different necessary sort functions.
  21587. * This should not be used directly aside of the few static configurations
  21588. */
  21589. export class RenderingManager {
  21590. /**
  21591. * The max id used for rendering groups (not included)
  21592. */
  21593. static MAX_RENDERINGGROUPS: number;
  21594. /**
  21595. * The min id used for rendering groups (included)
  21596. */
  21597. static MIN_RENDERINGGROUPS: number;
  21598. /**
  21599. * Used to globally prevent autoclearing scenes.
  21600. */
  21601. static AUTOCLEAR: boolean;
  21602. /**
  21603. * @hidden
  21604. */
  21605. _useSceneAutoClearSetup: boolean;
  21606. private _scene;
  21607. private _renderingGroups;
  21608. private _depthStencilBufferAlreadyCleaned;
  21609. private _autoClearDepthStencil;
  21610. private _customOpaqueSortCompareFn;
  21611. private _customAlphaTestSortCompareFn;
  21612. private _customTransparentSortCompareFn;
  21613. private _renderingGroupInfo;
  21614. /**
  21615. * Instantiates a new rendering group for a particular scene
  21616. * @param scene Defines the scene the groups belongs to
  21617. */
  21618. constructor(scene: Scene);
  21619. private _clearDepthStencilBuffer;
  21620. /**
  21621. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  21622. * @hidden
  21623. */
  21624. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  21625. /**
  21626. * Resets the different information of the group to prepare a new frame
  21627. * @hidden
  21628. */
  21629. reset(): void;
  21630. /**
  21631. * Dispose and release the group and its associated resources.
  21632. * @hidden
  21633. */
  21634. dispose(): void;
  21635. /**
  21636. * Clear the info related to rendering groups preventing retention points during dispose.
  21637. */
  21638. freeRenderingGroups(): void;
  21639. private _prepareRenderingGroup;
  21640. /**
  21641. * Add a sprite manager to the rendering manager in order to render it this frame.
  21642. * @param spriteManager Define the sprite manager to render
  21643. */
  21644. dispatchSprites(spriteManager: ISpriteManager): void;
  21645. /**
  21646. * Add a particle system to the rendering manager in order to render it this frame.
  21647. * @param particleSystem Define the particle system to render
  21648. */
  21649. dispatchParticles(particleSystem: IParticleSystem): void;
  21650. /**
  21651. * Add a submesh to the manager in order to render it this frame
  21652. * @param subMesh The submesh to dispatch
  21653. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  21654. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  21655. */
  21656. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  21657. /**
  21658. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  21659. * This allowed control for front to back rendering or reversly depending of the special needs.
  21660. *
  21661. * @param renderingGroupId The rendering group id corresponding to its index
  21662. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  21663. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  21664. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  21665. */
  21666. 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;
  21667. /**
  21668. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  21669. *
  21670. * @param renderingGroupId The rendering group id corresponding to its index
  21671. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  21672. * @param depth Automatically clears depth between groups if true and autoClear is true.
  21673. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  21674. */
  21675. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  21676. /**
  21677. * Gets the current auto clear configuration for one rendering group of the rendering
  21678. * manager.
  21679. * @param index the rendering group index to get the information for
  21680. * @returns The auto clear setup for the requested rendering group
  21681. */
  21682. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  21683. }
  21684. }
  21685. declare module BABYLON {
  21686. /**
  21687. * This Helps creating a texture that will be created from a camera in your scene.
  21688. * It is basically a dynamic texture that could be used to create special effects for instance.
  21689. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  21690. */
  21691. export class RenderTargetTexture extends Texture {
  21692. isCube: boolean;
  21693. /**
  21694. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  21695. */
  21696. static readonly REFRESHRATE_RENDER_ONCE: number;
  21697. /**
  21698. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  21699. */
  21700. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  21701. /**
  21702. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  21703. * the central point of your effect and can save a lot of performances.
  21704. */
  21705. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  21706. /**
  21707. * Use this predicate to dynamically define the list of mesh you want to render.
  21708. * If set, the renderList property will be overwritten.
  21709. */
  21710. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  21711. private _renderList;
  21712. /**
  21713. * Use this list to define the list of mesh you want to render.
  21714. */
  21715. renderList: Nullable<Array<AbstractMesh>>;
  21716. private _hookArray;
  21717. /**
  21718. * Define if particles should be rendered in your texture.
  21719. */
  21720. renderParticles: boolean;
  21721. /**
  21722. * Define if sprites should be rendered in your texture.
  21723. */
  21724. renderSprites: boolean;
  21725. /**
  21726. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  21727. */
  21728. coordinatesMode: number;
  21729. /**
  21730. * Define the camera used to render the texture.
  21731. */
  21732. activeCamera: Nullable<Camera>;
  21733. /**
  21734. * Override the render function of the texture with your own one.
  21735. */
  21736. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  21737. /**
  21738. * Define if camera post processes should be use while rendering the texture.
  21739. */
  21740. useCameraPostProcesses: boolean;
  21741. /**
  21742. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  21743. */
  21744. ignoreCameraViewport: boolean;
  21745. private _postProcessManager;
  21746. private _postProcesses;
  21747. private _resizeObserver;
  21748. /**
  21749. * An event triggered when the texture is unbind.
  21750. */
  21751. onBeforeBindObservable: Observable<RenderTargetTexture>;
  21752. /**
  21753. * An event triggered when the texture is unbind.
  21754. */
  21755. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  21756. private _onAfterUnbindObserver;
  21757. /**
  21758. * Set a after unbind callback in the texture.
  21759. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  21760. */
  21761. onAfterUnbind: () => void;
  21762. /**
  21763. * An event triggered before rendering the texture
  21764. */
  21765. onBeforeRenderObservable: Observable<number>;
  21766. private _onBeforeRenderObserver;
  21767. /**
  21768. * Set a before render callback in the texture.
  21769. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  21770. */
  21771. onBeforeRender: (faceIndex: number) => void;
  21772. /**
  21773. * An event triggered after rendering the texture
  21774. */
  21775. onAfterRenderObservable: Observable<number>;
  21776. private _onAfterRenderObserver;
  21777. /**
  21778. * Set a after render callback in the texture.
  21779. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  21780. */
  21781. onAfterRender: (faceIndex: number) => void;
  21782. /**
  21783. * An event triggered after the texture clear
  21784. */
  21785. onClearObservable: Observable<Engine>;
  21786. private _onClearObserver;
  21787. /**
  21788. * Set a clear callback in the texture.
  21789. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  21790. */
  21791. onClear: (Engine: Engine) => void;
  21792. /**
  21793. * Define the clear color of the Render Target if it should be different from the scene.
  21794. */
  21795. clearColor: Color4;
  21796. protected _size: number | {
  21797. width: number;
  21798. height: number;
  21799. };
  21800. protected _initialSizeParameter: number | {
  21801. width: number;
  21802. height: number;
  21803. } | {
  21804. ratio: number;
  21805. };
  21806. protected _sizeRatio: Nullable<number>;
  21807. /** @hidden */
  21808. _generateMipMaps: boolean;
  21809. protected _renderingManager: RenderingManager;
  21810. /** @hidden */
  21811. _waitingRenderList: string[];
  21812. protected _doNotChangeAspectRatio: boolean;
  21813. protected _currentRefreshId: number;
  21814. protected _refreshRate: number;
  21815. protected _textureMatrix: Matrix;
  21816. protected _samples: number;
  21817. protected _renderTargetOptions: RenderTargetCreationOptions;
  21818. /**
  21819. * Gets render target creation options that were used.
  21820. */
  21821. readonly renderTargetOptions: RenderTargetCreationOptions;
  21822. protected _engine: Engine;
  21823. protected _onRatioRescale(): void;
  21824. /**
  21825. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  21826. * It must define where the camera used to render the texture is set
  21827. */
  21828. boundingBoxPosition: Vector3;
  21829. private _boundingBoxSize;
  21830. /**
  21831. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  21832. * When defined, the cubemap will switch to local mode
  21833. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  21834. * @example https://www.babylonjs-playground.com/#RNASML
  21835. */
  21836. boundingBoxSize: Vector3;
  21837. /**
  21838. * In case the RTT has been created with a depth texture, get the associated
  21839. * depth texture.
  21840. * Otherwise, return null.
  21841. */
  21842. depthStencilTexture: Nullable<InternalTexture>;
  21843. /**
  21844. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  21845. * or used a shadow, depth texture...
  21846. * @param name The friendly name of the texture
  21847. * @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)
  21848. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  21849. * @param generateMipMaps True if mip maps need to be generated after render.
  21850. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  21851. * @param type The type of the buffer in the RTT (int, half float, float...)
  21852. * @param isCube True if a cube texture needs to be created
  21853. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  21854. * @param generateDepthBuffer True to generate a depth buffer
  21855. * @param generateStencilBuffer True to generate a stencil buffer
  21856. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  21857. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  21858. * @param delayAllocation if the texture allocation should be delayed (default: false)
  21859. */
  21860. constructor(name: string, size: number | {
  21861. width: number;
  21862. height: number;
  21863. } | {
  21864. ratio: number;
  21865. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  21866. /**
  21867. * Creates a depth stencil texture.
  21868. * This is only available in WebGL 2 or with the depth texture extension available.
  21869. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  21870. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  21871. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  21872. */
  21873. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  21874. private _processSizeParameter;
  21875. /**
  21876. * Define the number of samples to use in case of MSAA.
  21877. * It defaults to one meaning no MSAA has been enabled.
  21878. */
  21879. samples: number;
  21880. /**
  21881. * Resets the refresh counter of the texture and start bak from scratch.
  21882. * Could be useful to regenerate the texture if it is setup to render only once.
  21883. */
  21884. resetRefreshCounter(): void;
  21885. /**
  21886. * Define the refresh rate of the texture or the rendering frequency.
  21887. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  21888. */
  21889. refreshRate: number;
  21890. /**
  21891. * Adds a post process to the render target rendering passes.
  21892. * @param postProcess define the post process to add
  21893. */
  21894. addPostProcess(postProcess: PostProcess): void;
  21895. /**
  21896. * Clear all the post processes attached to the render target
  21897. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  21898. */
  21899. clearPostProcesses(dispose?: boolean): void;
  21900. /**
  21901. * Remove one of the post process from the list of attached post processes to the texture
  21902. * @param postProcess define the post process to remove from the list
  21903. */
  21904. removePostProcess(postProcess: PostProcess): void;
  21905. /** @hidden */
  21906. _shouldRender(): boolean;
  21907. /**
  21908. * Gets the actual render size of the texture.
  21909. * @returns the width of the render size
  21910. */
  21911. getRenderSize(): number;
  21912. /**
  21913. * Gets the actual render width of the texture.
  21914. * @returns the width of the render size
  21915. */
  21916. getRenderWidth(): number;
  21917. /**
  21918. * Gets the actual render height of the texture.
  21919. * @returns the height of the render size
  21920. */
  21921. getRenderHeight(): number;
  21922. /**
  21923. * Get if the texture can be rescaled or not.
  21924. */
  21925. readonly canRescale: boolean;
  21926. /**
  21927. * Resize the texture using a ratio.
  21928. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  21929. */
  21930. scale(ratio: number): void;
  21931. /**
  21932. * Get the texture reflection matrix used to rotate/transform the reflection.
  21933. * @returns the reflection matrix
  21934. */
  21935. getReflectionTextureMatrix(): Matrix;
  21936. /**
  21937. * Resize the texture to a new desired size.
  21938. * Be carrefull as it will recreate all the data in the new texture.
  21939. * @param size Define the new size. It can be:
  21940. * - a number for squared texture,
  21941. * - an object containing { width: number, height: number }
  21942. * - or an object containing a ratio { ratio: number }
  21943. */
  21944. resize(size: number | {
  21945. width: number;
  21946. height: number;
  21947. } | {
  21948. ratio: number;
  21949. }): void;
  21950. /**
  21951. * Renders all the objects from the render list into the texture.
  21952. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  21953. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  21954. */
  21955. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  21956. private _bestReflectionRenderTargetDimension;
  21957. /**
  21958. * @hidden
  21959. * @param faceIndex face index to bind to if this is a cubetexture
  21960. */
  21961. _bindFrameBuffer(faceIndex?: number): void;
  21962. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  21963. private renderToTarget;
  21964. /**
  21965. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  21966. * This allowed control for front to back rendering or reversly depending of the special needs.
  21967. *
  21968. * @param renderingGroupId The rendering group id corresponding to its index
  21969. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  21970. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  21971. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  21972. */
  21973. 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;
  21974. /**
  21975. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  21976. *
  21977. * @param renderingGroupId The rendering group id corresponding to its index
  21978. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  21979. */
  21980. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  21981. /**
  21982. * Clones the texture.
  21983. * @returns the cloned texture
  21984. */
  21985. clone(): RenderTargetTexture;
  21986. /**
  21987. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  21988. * @returns The JSON representation of the texture
  21989. */
  21990. serialize(): any;
  21991. /**
  21992. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  21993. */
  21994. disposeFramebufferObjects(): void;
  21995. /**
  21996. * Dispose the texture and release its associated resources.
  21997. */
  21998. dispose(): void;
  21999. /** @hidden */
  22000. _rebuild(): void;
  22001. /**
  22002. * Clear the info related to rendering groups preventing retention point in material dispose.
  22003. */
  22004. freeRenderingGroups(): void;
  22005. /**
  22006. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  22007. * @returns the view count
  22008. */
  22009. getViewCount(): number;
  22010. }
  22011. }
  22012. declare module BABYLON {
  22013. /**
  22014. * Base class for the main features of a material in Babylon.js
  22015. */
  22016. export class Material implements IAnimatable {
  22017. /**
  22018. * Returns the triangle fill mode
  22019. */
  22020. static readonly TriangleFillMode: number;
  22021. /**
  22022. * Returns the wireframe mode
  22023. */
  22024. static readonly WireFrameFillMode: number;
  22025. /**
  22026. * Returns the point fill mode
  22027. */
  22028. static readonly PointFillMode: number;
  22029. /**
  22030. * Returns the point list draw mode
  22031. */
  22032. static readonly PointListDrawMode: number;
  22033. /**
  22034. * Returns the line list draw mode
  22035. */
  22036. static readonly LineListDrawMode: number;
  22037. /**
  22038. * Returns the line loop draw mode
  22039. */
  22040. static readonly LineLoopDrawMode: number;
  22041. /**
  22042. * Returns the line strip draw mode
  22043. */
  22044. static readonly LineStripDrawMode: number;
  22045. /**
  22046. * Returns the triangle strip draw mode
  22047. */
  22048. static readonly TriangleStripDrawMode: number;
  22049. /**
  22050. * Returns the triangle fan draw mode
  22051. */
  22052. static readonly TriangleFanDrawMode: number;
  22053. /**
  22054. * Stores the clock-wise side orientation
  22055. */
  22056. static readonly ClockWiseSideOrientation: number;
  22057. /**
  22058. * Stores the counter clock-wise side orientation
  22059. */
  22060. static readonly CounterClockWiseSideOrientation: number;
  22061. /**
  22062. * The dirty texture flag value
  22063. */
  22064. static readonly TextureDirtyFlag: number;
  22065. /**
  22066. * The dirty light flag value
  22067. */
  22068. static readonly LightDirtyFlag: number;
  22069. /**
  22070. * The dirty fresnel flag value
  22071. */
  22072. static readonly FresnelDirtyFlag: number;
  22073. /**
  22074. * The dirty attribute flag value
  22075. */
  22076. static readonly AttributesDirtyFlag: number;
  22077. /**
  22078. * The dirty misc flag value
  22079. */
  22080. static readonly MiscDirtyFlag: number;
  22081. /**
  22082. * The all dirty flag value
  22083. */
  22084. static readonly AllDirtyFlag: number;
  22085. /**
  22086. * The ID of the material
  22087. */
  22088. id: string;
  22089. /**
  22090. * Gets or sets the unique id of the material
  22091. */
  22092. uniqueId: number;
  22093. /**
  22094. * The name of the material
  22095. */
  22096. name: string;
  22097. /**
  22098. * Gets or sets user defined metadata
  22099. */
  22100. metadata: any;
  22101. /**
  22102. * For internal use only. Please do not use.
  22103. */
  22104. reservedDataStore: any;
  22105. /**
  22106. * Specifies if the ready state should be checked on each call
  22107. */
  22108. checkReadyOnEveryCall: boolean;
  22109. /**
  22110. * Specifies if the ready state should be checked once
  22111. */
  22112. checkReadyOnlyOnce: boolean;
  22113. /**
  22114. * The state of the material
  22115. */
  22116. state: string;
  22117. /**
  22118. * The alpha value of the material
  22119. */
  22120. protected _alpha: number;
  22121. /**
  22122. * List of inspectable custom properties (used by the Inspector)
  22123. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  22124. */
  22125. inspectableCustomProperties: IInspectable[];
  22126. /**
  22127. * Sets the alpha value of the material
  22128. */
  22129. /**
  22130. * Gets the alpha value of the material
  22131. */
  22132. alpha: number;
  22133. /**
  22134. * Specifies if back face culling is enabled
  22135. */
  22136. protected _backFaceCulling: boolean;
  22137. /**
  22138. * Sets the back-face culling state
  22139. */
  22140. /**
  22141. * Gets the back-face culling state
  22142. */
  22143. backFaceCulling: boolean;
  22144. /**
  22145. * Stores the value for side orientation
  22146. */
  22147. sideOrientation: number;
  22148. /**
  22149. * Callback triggered when the material is compiled
  22150. */
  22151. onCompiled: Nullable<(effect: Effect) => void>;
  22152. /**
  22153. * Callback triggered when an error occurs
  22154. */
  22155. onError: Nullable<(effect: Effect, errors: string) => void>;
  22156. /**
  22157. * Callback triggered to get the render target textures
  22158. */
  22159. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  22160. /**
  22161. * Gets a boolean indicating that current material needs to register RTT
  22162. */
  22163. readonly hasRenderTargetTextures: boolean;
  22164. /**
  22165. * Specifies if the material should be serialized
  22166. */
  22167. doNotSerialize: boolean;
  22168. /**
  22169. * @hidden
  22170. */
  22171. _storeEffectOnSubMeshes: boolean;
  22172. /**
  22173. * Stores the animations for the material
  22174. */
  22175. animations: Nullable<Array<Animation>>;
  22176. /**
  22177. * An event triggered when the material is disposed
  22178. */
  22179. onDisposeObservable: Observable<Material>;
  22180. /**
  22181. * An observer which watches for dispose events
  22182. */
  22183. private _onDisposeObserver;
  22184. private _onUnBindObservable;
  22185. /**
  22186. * Called during a dispose event
  22187. */
  22188. onDispose: () => void;
  22189. private _onBindObservable;
  22190. /**
  22191. * An event triggered when the material is bound
  22192. */
  22193. readonly onBindObservable: Observable<AbstractMesh>;
  22194. /**
  22195. * An observer which watches for bind events
  22196. */
  22197. private _onBindObserver;
  22198. /**
  22199. * Called during a bind event
  22200. */
  22201. onBind: (Mesh: AbstractMesh) => void;
  22202. /**
  22203. * An event triggered when the material is unbound
  22204. */
  22205. readonly onUnBindObservable: Observable<Material>;
  22206. /**
  22207. * Stores the value of the alpha mode
  22208. */
  22209. private _alphaMode;
  22210. /**
  22211. * Sets the value of the alpha mode.
  22212. *
  22213. * | Value | Type | Description |
  22214. * | --- | --- | --- |
  22215. * | 0 | ALPHA_DISABLE | |
  22216. * | 1 | ALPHA_ADD | |
  22217. * | 2 | ALPHA_COMBINE | |
  22218. * | 3 | ALPHA_SUBTRACT | |
  22219. * | 4 | ALPHA_MULTIPLY | |
  22220. * | 5 | ALPHA_MAXIMIZED | |
  22221. * | 6 | ALPHA_ONEONE | |
  22222. * | 7 | ALPHA_PREMULTIPLIED | |
  22223. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  22224. * | 9 | ALPHA_INTERPOLATE | |
  22225. * | 10 | ALPHA_SCREENMODE | |
  22226. *
  22227. */
  22228. /**
  22229. * Gets the value of the alpha mode
  22230. */
  22231. alphaMode: number;
  22232. /**
  22233. * Stores the state of the need depth pre-pass value
  22234. */
  22235. private _needDepthPrePass;
  22236. /**
  22237. * Sets the need depth pre-pass value
  22238. */
  22239. /**
  22240. * Gets the depth pre-pass value
  22241. */
  22242. needDepthPrePass: boolean;
  22243. /**
  22244. * Specifies if depth writing should be disabled
  22245. */
  22246. disableDepthWrite: boolean;
  22247. /**
  22248. * Specifies if depth writing should be forced
  22249. */
  22250. forceDepthWrite: boolean;
  22251. /**
  22252. * Specifies if there should be a separate pass for culling
  22253. */
  22254. separateCullingPass: boolean;
  22255. /**
  22256. * Stores the state specifing if fog should be enabled
  22257. */
  22258. private _fogEnabled;
  22259. /**
  22260. * Sets the state for enabling fog
  22261. */
  22262. /**
  22263. * Gets the value of the fog enabled state
  22264. */
  22265. fogEnabled: boolean;
  22266. /**
  22267. * Stores the size of points
  22268. */
  22269. pointSize: number;
  22270. /**
  22271. * Stores the z offset value
  22272. */
  22273. zOffset: number;
  22274. /**
  22275. * Gets a value specifying if wireframe mode is enabled
  22276. */
  22277. /**
  22278. * Sets the state of wireframe mode
  22279. */
  22280. wireframe: boolean;
  22281. /**
  22282. * Gets the value specifying if point clouds are enabled
  22283. */
  22284. /**
  22285. * Sets the state of point cloud mode
  22286. */
  22287. pointsCloud: boolean;
  22288. /**
  22289. * Gets the material fill mode
  22290. */
  22291. /**
  22292. * Sets the material fill mode
  22293. */
  22294. fillMode: number;
  22295. /**
  22296. * @hidden
  22297. * Stores the effects for the material
  22298. */
  22299. _effect: Nullable<Effect>;
  22300. /**
  22301. * @hidden
  22302. * Specifies if the material was previously ready
  22303. */
  22304. _wasPreviouslyReady: boolean;
  22305. /**
  22306. * Specifies if uniform buffers should be used
  22307. */
  22308. private _useUBO;
  22309. /**
  22310. * Stores a reference to the scene
  22311. */
  22312. private _scene;
  22313. /**
  22314. * Stores the fill mode state
  22315. */
  22316. private _fillMode;
  22317. /**
  22318. * Specifies if the depth write state should be cached
  22319. */
  22320. private _cachedDepthWriteState;
  22321. /**
  22322. * Stores the uniform buffer
  22323. */
  22324. protected _uniformBuffer: UniformBuffer;
  22325. /** @hidden */
  22326. _indexInSceneMaterialArray: number;
  22327. /** @hidden */
  22328. meshMap: Nullable<{
  22329. [id: string]: AbstractMesh | undefined;
  22330. }>;
  22331. /**
  22332. * Creates a material instance
  22333. * @param name defines the name of the material
  22334. * @param scene defines the scene to reference
  22335. * @param doNotAdd specifies if the material should be added to the scene
  22336. */
  22337. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  22338. /**
  22339. * Returns a string representation of the current material
  22340. * @param fullDetails defines a boolean indicating which levels of logging is desired
  22341. * @returns a string with material information
  22342. */
  22343. toString(fullDetails?: boolean): string;
  22344. /**
  22345. * Gets the class name of the material
  22346. * @returns a string with the class name of the material
  22347. */
  22348. getClassName(): string;
  22349. /**
  22350. * Specifies if updates for the material been locked
  22351. */
  22352. readonly isFrozen: boolean;
  22353. /**
  22354. * Locks updates for the material
  22355. */
  22356. freeze(): void;
  22357. /**
  22358. * Unlocks updates for the material
  22359. */
  22360. unfreeze(): void;
  22361. /**
  22362. * Specifies if the material is ready to be used
  22363. * @param mesh defines the mesh to check
  22364. * @param useInstances specifies if instances should be used
  22365. * @returns a boolean indicating if the material is ready to be used
  22366. */
  22367. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  22368. /**
  22369. * Specifies that the submesh is ready to be used
  22370. * @param mesh defines the mesh to check
  22371. * @param subMesh defines which submesh to check
  22372. * @param useInstances specifies that instances should be used
  22373. * @returns a boolean indicating that the submesh is ready or not
  22374. */
  22375. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  22376. /**
  22377. * Returns the material effect
  22378. * @returns the effect associated with the material
  22379. */
  22380. getEffect(): Nullable<Effect>;
  22381. /**
  22382. * Returns the current scene
  22383. * @returns a Scene
  22384. */
  22385. getScene(): Scene;
  22386. /**
  22387. * Specifies if the material will require alpha blending
  22388. * @returns a boolean specifying if alpha blending is needed
  22389. */
  22390. needAlphaBlending(): boolean;
  22391. /**
  22392. * Specifies if the mesh will require alpha blending
  22393. * @param mesh defines the mesh to check
  22394. * @returns a boolean specifying if alpha blending is needed for the mesh
  22395. */
  22396. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  22397. /**
  22398. * Specifies if this material should be rendered in alpha test mode
  22399. * @returns a boolean specifying if an alpha test is needed.
  22400. */
  22401. needAlphaTesting(): boolean;
  22402. /**
  22403. * Gets the texture used for the alpha test
  22404. * @returns the texture to use for alpha testing
  22405. */
  22406. getAlphaTestTexture(): Nullable<BaseTexture>;
  22407. /**
  22408. * Marks the material to indicate that it needs to be re-calculated
  22409. */
  22410. markDirty(): void;
  22411. /** @hidden */
  22412. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  22413. /**
  22414. * Binds the material to the mesh
  22415. * @param world defines the world transformation matrix
  22416. * @param mesh defines the mesh to bind the material to
  22417. */
  22418. bind(world: Matrix, mesh?: Mesh): void;
  22419. /**
  22420. * Binds the submesh to the material
  22421. * @param world defines the world transformation matrix
  22422. * @param mesh defines the mesh containing the submesh
  22423. * @param subMesh defines the submesh to bind the material to
  22424. */
  22425. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  22426. /**
  22427. * Binds the world matrix to the material
  22428. * @param world defines the world transformation matrix
  22429. */
  22430. bindOnlyWorldMatrix(world: Matrix): void;
  22431. /**
  22432. * Binds the scene's uniform buffer to the effect.
  22433. * @param effect defines the effect to bind to the scene uniform buffer
  22434. * @param sceneUbo defines the uniform buffer storing scene data
  22435. */
  22436. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  22437. /**
  22438. * Binds the view matrix to the effect
  22439. * @param effect defines the effect to bind the view matrix to
  22440. */
  22441. bindView(effect: Effect): void;
  22442. /**
  22443. * Binds the view projection matrix to the effect
  22444. * @param effect defines the effect to bind the view projection matrix to
  22445. */
  22446. bindViewProjection(effect: Effect): void;
  22447. /**
  22448. * Specifies if material alpha testing should be turned on for the mesh
  22449. * @param mesh defines the mesh to check
  22450. */
  22451. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  22452. /**
  22453. * Processes to execute after binding the material to a mesh
  22454. * @param mesh defines the rendered mesh
  22455. */
  22456. protected _afterBind(mesh?: Mesh): void;
  22457. /**
  22458. * Unbinds the material from the mesh
  22459. */
  22460. unbind(): void;
  22461. /**
  22462. * Gets the active textures from the material
  22463. * @returns an array of textures
  22464. */
  22465. getActiveTextures(): BaseTexture[];
  22466. /**
  22467. * Specifies if the material uses a texture
  22468. * @param texture defines the texture to check against the material
  22469. * @returns a boolean specifying if the material uses the texture
  22470. */
  22471. hasTexture(texture: BaseTexture): boolean;
  22472. /**
  22473. * Makes a duplicate of the material, and gives it a new name
  22474. * @param name defines the new name for the duplicated material
  22475. * @returns the cloned material
  22476. */
  22477. clone(name: string): Nullable<Material>;
  22478. /**
  22479. * Gets the meshes bound to the material
  22480. * @returns an array of meshes bound to the material
  22481. */
  22482. getBindedMeshes(): AbstractMesh[];
  22483. /**
  22484. * Force shader compilation
  22485. * @param mesh defines the mesh associated with this material
  22486. * @param onCompiled defines a function to execute once the material is compiled
  22487. * @param options defines the options to configure the compilation
  22488. */
  22489. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  22490. clipPlane: boolean;
  22491. }>): void;
  22492. /**
  22493. * Force shader compilation
  22494. * @param mesh defines the mesh that will use this material
  22495. * @param options defines additional options for compiling the shaders
  22496. * @returns a promise that resolves when the compilation completes
  22497. */
  22498. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  22499. clipPlane: boolean;
  22500. }>): Promise<void>;
  22501. private static readonly _AllDirtyCallBack;
  22502. private static readonly _ImageProcessingDirtyCallBack;
  22503. private static readonly _TextureDirtyCallBack;
  22504. private static readonly _FresnelDirtyCallBack;
  22505. private static readonly _MiscDirtyCallBack;
  22506. private static readonly _LightsDirtyCallBack;
  22507. private static readonly _AttributeDirtyCallBack;
  22508. private static _FresnelAndMiscDirtyCallBack;
  22509. private static _TextureAndMiscDirtyCallBack;
  22510. private static readonly _DirtyCallbackArray;
  22511. private static readonly _RunDirtyCallBacks;
  22512. /**
  22513. * Marks a define in the material to indicate that it needs to be re-computed
  22514. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  22515. */
  22516. markAsDirty(flag: number): void;
  22517. /**
  22518. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  22519. * @param func defines a function which checks material defines against the submeshes
  22520. */
  22521. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  22522. /**
  22523. * Indicates that we need to re-calculated for all submeshes
  22524. */
  22525. protected _markAllSubMeshesAsAllDirty(): void;
  22526. /**
  22527. * Indicates that image processing needs to be re-calculated for all submeshes
  22528. */
  22529. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  22530. /**
  22531. * Indicates that textures need to be re-calculated for all submeshes
  22532. */
  22533. protected _markAllSubMeshesAsTexturesDirty(): void;
  22534. /**
  22535. * Indicates that fresnel needs to be re-calculated for all submeshes
  22536. */
  22537. protected _markAllSubMeshesAsFresnelDirty(): void;
  22538. /**
  22539. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  22540. */
  22541. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  22542. /**
  22543. * Indicates that lights need to be re-calculated for all submeshes
  22544. */
  22545. protected _markAllSubMeshesAsLightsDirty(): void;
  22546. /**
  22547. * Indicates that attributes need to be re-calculated for all submeshes
  22548. */
  22549. protected _markAllSubMeshesAsAttributesDirty(): void;
  22550. /**
  22551. * Indicates that misc needs to be re-calculated for all submeshes
  22552. */
  22553. protected _markAllSubMeshesAsMiscDirty(): void;
  22554. /**
  22555. * Indicates that textures and misc need to be re-calculated for all submeshes
  22556. */
  22557. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  22558. /**
  22559. * Disposes the material
  22560. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  22561. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  22562. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  22563. */
  22564. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  22565. /** @hidden */
  22566. private releaseVertexArrayObject;
  22567. /**
  22568. * Serializes this material
  22569. * @returns the serialized material object
  22570. */
  22571. serialize(): any;
  22572. /**
  22573. * Creates a material from parsed material data
  22574. * @param parsedMaterial defines parsed material data
  22575. * @param scene defines the hosting scene
  22576. * @param rootUrl defines the root URL to use to load textures
  22577. * @returns a new material
  22578. */
  22579. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  22580. }
  22581. }
  22582. declare module BABYLON {
  22583. /**
  22584. * Base class for submeshes
  22585. */
  22586. export class BaseSubMesh {
  22587. /** @hidden */
  22588. _materialDefines: Nullable<MaterialDefines>;
  22589. /** @hidden */
  22590. _materialEffect: Nullable<Effect>;
  22591. /**
  22592. * Gets associated effect
  22593. */
  22594. readonly effect: Nullable<Effect>;
  22595. /**
  22596. * Sets associated effect (effect used to render this submesh)
  22597. * @param effect defines the effect to associate with
  22598. * @param defines defines the set of defines used to compile this effect
  22599. */
  22600. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  22601. }
  22602. /**
  22603. * Defines a subdivision inside a mesh
  22604. */
  22605. export class SubMesh extends BaseSubMesh implements ICullable {
  22606. /** the material index to use */
  22607. materialIndex: number;
  22608. /** vertex index start */
  22609. verticesStart: number;
  22610. /** vertices count */
  22611. verticesCount: number;
  22612. /** index start */
  22613. indexStart: number;
  22614. /** indices count */
  22615. indexCount: number;
  22616. /** @hidden */
  22617. _linesIndexCount: number;
  22618. private _mesh;
  22619. private _renderingMesh;
  22620. private _boundingInfo;
  22621. private _linesIndexBuffer;
  22622. /** @hidden */
  22623. _lastColliderWorldVertices: Nullable<Vector3[]>;
  22624. /** @hidden */
  22625. _trianglePlanes: Plane[];
  22626. /** @hidden */
  22627. _lastColliderTransformMatrix: Nullable<Matrix>;
  22628. /** @hidden */
  22629. _renderId: number;
  22630. /** @hidden */
  22631. _alphaIndex: number;
  22632. /** @hidden */
  22633. _distanceToCamera: number;
  22634. /** @hidden */
  22635. _id: number;
  22636. private _currentMaterial;
  22637. /**
  22638. * Add a new submesh to a mesh
  22639. * @param materialIndex defines the material index to use
  22640. * @param verticesStart defines vertex index start
  22641. * @param verticesCount defines vertices count
  22642. * @param indexStart defines index start
  22643. * @param indexCount defines indices count
  22644. * @param mesh defines the parent mesh
  22645. * @param renderingMesh defines an optional rendering mesh
  22646. * @param createBoundingBox defines if bounding box should be created for this submesh
  22647. * @returns the new submesh
  22648. */
  22649. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  22650. /**
  22651. * Creates a new submesh
  22652. * @param materialIndex defines the material index to use
  22653. * @param verticesStart defines vertex index start
  22654. * @param verticesCount defines vertices count
  22655. * @param indexStart defines index start
  22656. * @param indexCount defines indices count
  22657. * @param mesh defines the parent mesh
  22658. * @param renderingMesh defines an optional rendering mesh
  22659. * @param createBoundingBox defines if bounding box should be created for this submesh
  22660. */
  22661. constructor(
  22662. /** the material index to use */
  22663. materialIndex: number,
  22664. /** vertex index start */
  22665. verticesStart: number,
  22666. /** vertices count */
  22667. verticesCount: number,
  22668. /** index start */
  22669. indexStart: number,
  22670. /** indices count */
  22671. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  22672. /**
  22673. * Returns true if this submesh covers the entire parent mesh
  22674. * @ignorenaming
  22675. */
  22676. readonly IsGlobal: boolean;
  22677. /**
  22678. * Returns the submesh BoudingInfo object
  22679. * @returns current bounding info (or mesh's one if the submesh is global)
  22680. */
  22681. getBoundingInfo(): BoundingInfo;
  22682. /**
  22683. * Sets the submesh BoundingInfo
  22684. * @param boundingInfo defines the new bounding info to use
  22685. * @returns the SubMesh
  22686. */
  22687. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  22688. /**
  22689. * Returns the mesh of the current submesh
  22690. * @return the parent mesh
  22691. */
  22692. getMesh(): AbstractMesh;
  22693. /**
  22694. * Returns the rendering mesh of the submesh
  22695. * @returns the rendering mesh (could be different from parent mesh)
  22696. */
  22697. getRenderingMesh(): Mesh;
  22698. /**
  22699. * Returns the submesh material
  22700. * @returns null or the current material
  22701. */
  22702. getMaterial(): Nullable<Material>;
  22703. /**
  22704. * Sets a new updated BoundingInfo object to the submesh
  22705. * @param data defines an optional position array to use to determine the bounding info
  22706. * @returns the SubMesh
  22707. */
  22708. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  22709. /** @hidden */
  22710. _checkCollision(collider: Collider): boolean;
  22711. /**
  22712. * Updates the submesh BoundingInfo
  22713. * @param world defines the world matrix to use to update the bounding info
  22714. * @returns the submesh
  22715. */
  22716. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  22717. /**
  22718. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  22719. * @param frustumPlanes defines the frustum planes
  22720. * @returns true if the submesh is intersecting with the frustum
  22721. */
  22722. isInFrustum(frustumPlanes: Plane[]): boolean;
  22723. /**
  22724. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  22725. * @param frustumPlanes defines the frustum planes
  22726. * @returns true if the submesh is inside the frustum
  22727. */
  22728. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  22729. /**
  22730. * Renders the submesh
  22731. * @param enableAlphaMode defines if alpha needs to be used
  22732. * @returns the submesh
  22733. */
  22734. render(enableAlphaMode: boolean): SubMesh;
  22735. /**
  22736. * @hidden
  22737. */
  22738. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  22739. /**
  22740. * Checks if the submesh intersects with a ray
  22741. * @param ray defines the ray to test
  22742. * @returns true is the passed ray intersects the submesh bounding box
  22743. */
  22744. canIntersects(ray: Ray): boolean;
  22745. /**
  22746. * Intersects current submesh with a ray
  22747. * @param ray defines the ray to test
  22748. * @param positions defines mesh's positions array
  22749. * @param indices defines mesh's indices array
  22750. * @param fastCheck defines if only bounding info should be used
  22751. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  22752. * @returns intersection info or null if no intersection
  22753. */
  22754. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  22755. /** @hidden */
  22756. private _intersectLines;
  22757. /** @hidden */
  22758. private _intersectUnIndexedLines;
  22759. /** @hidden */
  22760. private _intersectTriangles;
  22761. /** @hidden */
  22762. private _intersectUnIndexedTriangles;
  22763. /** @hidden */
  22764. _rebuild(): void;
  22765. /**
  22766. * Creates a new submesh from the passed mesh
  22767. * @param newMesh defines the new hosting mesh
  22768. * @param newRenderingMesh defines an optional rendering mesh
  22769. * @returns the new submesh
  22770. */
  22771. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  22772. /**
  22773. * Release associated resources
  22774. */
  22775. dispose(): void;
  22776. /**
  22777. * Gets the class name
  22778. * @returns the string "SubMesh".
  22779. */
  22780. getClassName(): string;
  22781. /**
  22782. * Creates a new submesh from indices data
  22783. * @param materialIndex the index of the main mesh material
  22784. * @param startIndex the index where to start the copy in the mesh indices array
  22785. * @param indexCount the number of indices to copy then from the startIndex
  22786. * @param mesh the main mesh to create the submesh from
  22787. * @param renderingMesh the optional rendering mesh
  22788. * @returns a new submesh
  22789. */
  22790. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  22791. }
  22792. }
  22793. declare module BABYLON {
  22794. /**
  22795. * Class used to store geometry data (vertex buffers + index buffer)
  22796. */
  22797. export class Geometry implements IGetSetVerticesData {
  22798. /**
  22799. * Gets or sets the ID of the geometry
  22800. */
  22801. id: string;
  22802. /**
  22803. * Gets or sets the unique ID of the geometry
  22804. */
  22805. uniqueId: number;
  22806. /**
  22807. * Gets the delay loading state of the geometry (none by default which means not delayed)
  22808. */
  22809. delayLoadState: number;
  22810. /**
  22811. * Gets the file containing the data to load when running in delay load state
  22812. */
  22813. delayLoadingFile: Nullable<string>;
  22814. /**
  22815. * Callback called when the geometry is updated
  22816. */
  22817. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  22818. private _scene;
  22819. private _engine;
  22820. private _meshes;
  22821. private _totalVertices;
  22822. /** @hidden */
  22823. _indices: IndicesArray;
  22824. /** @hidden */
  22825. _vertexBuffers: {
  22826. [key: string]: VertexBuffer;
  22827. };
  22828. private _isDisposed;
  22829. private _extend;
  22830. private _boundingBias;
  22831. /** @hidden */
  22832. _delayInfo: Array<string>;
  22833. private _indexBuffer;
  22834. private _indexBufferIsUpdatable;
  22835. /** @hidden */
  22836. _boundingInfo: Nullable<BoundingInfo>;
  22837. /** @hidden */
  22838. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  22839. /** @hidden */
  22840. _softwareSkinningFrameId: number;
  22841. private _vertexArrayObjects;
  22842. private _updatable;
  22843. /** @hidden */
  22844. _positions: Nullable<Vector3[]>;
  22845. /**
  22846. * 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
  22847. */
  22848. /**
  22849. * 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
  22850. */
  22851. boundingBias: Vector2;
  22852. /**
  22853. * Static function used to attach a new empty geometry to a mesh
  22854. * @param mesh defines the mesh to attach the geometry to
  22855. * @returns the new Geometry
  22856. */
  22857. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  22858. /**
  22859. * Creates a new geometry
  22860. * @param id defines the unique ID
  22861. * @param scene defines the hosting scene
  22862. * @param vertexData defines the VertexData used to get geometry data
  22863. * @param updatable defines if geometry must be updatable (false by default)
  22864. * @param mesh defines the mesh that will be associated with the geometry
  22865. */
  22866. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  22867. /**
  22868. * Gets the current extend of the geometry
  22869. */
  22870. readonly extend: {
  22871. minimum: Vector3;
  22872. maximum: Vector3;
  22873. };
  22874. /**
  22875. * Gets the hosting scene
  22876. * @returns the hosting Scene
  22877. */
  22878. getScene(): Scene;
  22879. /**
  22880. * Gets the hosting engine
  22881. * @returns the hosting Engine
  22882. */
  22883. getEngine(): Engine;
  22884. /**
  22885. * Defines if the geometry is ready to use
  22886. * @returns true if the geometry is ready to be used
  22887. */
  22888. isReady(): boolean;
  22889. /**
  22890. * Gets a value indicating that the geometry should not be serialized
  22891. */
  22892. readonly doNotSerialize: boolean;
  22893. /** @hidden */
  22894. _rebuild(): void;
  22895. /**
  22896. * Affects all geometry data in one call
  22897. * @param vertexData defines the geometry data
  22898. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  22899. */
  22900. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  22901. /**
  22902. * Set specific vertex data
  22903. * @param kind defines the data kind (Position, normal, etc...)
  22904. * @param data defines the vertex data to use
  22905. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22906. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22907. */
  22908. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  22909. /**
  22910. * Removes a specific vertex data
  22911. * @param kind defines the data kind (Position, normal, etc...)
  22912. */
  22913. removeVerticesData(kind: string): void;
  22914. /**
  22915. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  22916. * @param buffer defines the vertex buffer to use
  22917. * @param totalVertices defines the total number of vertices for position kind (could be null)
  22918. */
  22919. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  22920. /**
  22921. * Update a specific vertex buffer
  22922. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  22923. * It will do nothing if the buffer is not updatable
  22924. * @param kind defines the data kind (Position, normal, etc...)
  22925. * @param data defines the data to use
  22926. * @param offset defines the offset in the target buffer where to store the data
  22927. * @param useBytes set to true if the offset is in bytes
  22928. */
  22929. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  22930. /**
  22931. * Update a specific vertex buffer
  22932. * This function will create a new buffer if the current one is not updatable
  22933. * @param kind defines the data kind (Position, normal, etc...)
  22934. * @param data defines the data to use
  22935. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  22936. */
  22937. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  22938. private _updateBoundingInfo;
  22939. /** @hidden */
  22940. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  22941. /**
  22942. * Gets total number of vertices
  22943. * @returns the total number of vertices
  22944. */
  22945. getTotalVertices(): number;
  22946. /**
  22947. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22948. * @param kind defines the data kind (Position, normal, etc...)
  22949. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22950. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22951. * @returns a float array containing vertex data
  22952. */
  22953. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22954. /**
  22955. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  22956. * @param kind defines the data kind (Position, normal, etc...)
  22957. * @returns true if the vertex buffer with the specified kind is updatable
  22958. */
  22959. isVertexBufferUpdatable(kind: string): boolean;
  22960. /**
  22961. * Gets a specific vertex buffer
  22962. * @param kind defines the data kind (Position, normal, etc...)
  22963. * @returns a VertexBuffer
  22964. */
  22965. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  22966. /**
  22967. * Returns all vertex buffers
  22968. * @return an object holding all vertex buffers indexed by kind
  22969. */
  22970. getVertexBuffers(): Nullable<{
  22971. [key: string]: VertexBuffer;
  22972. }>;
  22973. /**
  22974. * Gets a boolean indicating if specific vertex buffer is present
  22975. * @param kind defines the data kind (Position, normal, etc...)
  22976. * @returns true if data is present
  22977. */
  22978. isVerticesDataPresent(kind: string): boolean;
  22979. /**
  22980. * Gets a list of all attached data kinds (Position, normal, etc...)
  22981. * @returns a list of string containing all kinds
  22982. */
  22983. getVerticesDataKinds(): string[];
  22984. /**
  22985. * Update index buffer
  22986. * @param indices defines the indices to store in the index buffer
  22987. * @param offset defines the offset in the target buffer where to store the data
  22988. * @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)
  22989. */
  22990. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  22991. /**
  22992. * Creates a new index buffer
  22993. * @param indices defines the indices to store in the index buffer
  22994. * @param totalVertices defines the total number of vertices (could be null)
  22995. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22996. */
  22997. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  22998. /**
  22999. * Return the total number of indices
  23000. * @returns the total number of indices
  23001. */
  23002. getTotalIndices(): number;
  23003. /**
  23004. * Gets the index buffer array
  23005. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  23006. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23007. * @returns the index buffer array
  23008. */
  23009. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  23010. /**
  23011. * Gets the index buffer
  23012. * @return the index buffer
  23013. */
  23014. getIndexBuffer(): Nullable<DataBuffer>;
  23015. /** @hidden */
  23016. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  23017. /**
  23018. * Release the associated resources for a specific mesh
  23019. * @param mesh defines the source mesh
  23020. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  23021. */
  23022. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  23023. /**
  23024. * Apply current geometry to a given mesh
  23025. * @param mesh defines the mesh to apply geometry to
  23026. */
  23027. applyToMesh(mesh: Mesh): void;
  23028. private _updateExtend;
  23029. private _applyToMesh;
  23030. private notifyUpdate;
  23031. /**
  23032. * Load the geometry if it was flagged as delay loaded
  23033. * @param scene defines the hosting scene
  23034. * @param onLoaded defines a callback called when the geometry is loaded
  23035. */
  23036. load(scene: Scene, onLoaded?: () => void): void;
  23037. private _queueLoad;
  23038. /**
  23039. * Invert the geometry to move from a right handed system to a left handed one.
  23040. */
  23041. toLeftHanded(): void;
  23042. /** @hidden */
  23043. _resetPointsArrayCache(): void;
  23044. /** @hidden */
  23045. _generatePointsArray(): boolean;
  23046. /**
  23047. * Gets a value indicating if the geometry is disposed
  23048. * @returns true if the geometry was disposed
  23049. */
  23050. isDisposed(): boolean;
  23051. private _disposeVertexArrayObjects;
  23052. /**
  23053. * Free all associated resources
  23054. */
  23055. dispose(): void;
  23056. /**
  23057. * Clone the current geometry into a new geometry
  23058. * @param id defines the unique ID of the new geometry
  23059. * @returns a new geometry object
  23060. */
  23061. copy(id: string): Geometry;
  23062. /**
  23063. * Serialize the current geometry info (and not the vertices data) into a JSON object
  23064. * @return a JSON representation of the current geometry data (without the vertices data)
  23065. */
  23066. serialize(): any;
  23067. private toNumberArray;
  23068. /**
  23069. * Serialize all vertices data into a JSON oject
  23070. * @returns a JSON representation of the current geometry data
  23071. */
  23072. serializeVerticeData(): any;
  23073. /**
  23074. * Extracts a clone of a mesh geometry
  23075. * @param mesh defines the source mesh
  23076. * @param id defines the unique ID of the new geometry object
  23077. * @returns the new geometry object
  23078. */
  23079. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  23080. /**
  23081. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  23082. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  23083. * Be aware Math.random() could cause collisions, but:
  23084. * "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"
  23085. * @returns a string containing a new GUID
  23086. */
  23087. static RandomId(): string;
  23088. /** @hidden */
  23089. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  23090. private static _CleanMatricesWeights;
  23091. /**
  23092. * Create a new geometry from persisted data (Using .babylon file format)
  23093. * @param parsedVertexData defines the persisted data
  23094. * @param scene defines the hosting scene
  23095. * @param rootUrl defines the root url to use to load assets (like delayed data)
  23096. * @returns the new geometry object
  23097. */
  23098. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  23099. }
  23100. }
  23101. declare module BABYLON {
  23102. /**
  23103. * Define an interface for all classes that will get and set the data on vertices
  23104. */
  23105. export interface IGetSetVerticesData {
  23106. /**
  23107. * Gets a boolean indicating if specific vertex data is present
  23108. * @param kind defines the vertex data kind to use
  23109. * @returns true is data kind is present
  23110. */
  23111. isVerticesDataPresent(kind: string): boolean;
  23112. /**
  23113. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  23114. * @param kind defines the data kind (Position, normal, etc...)
  23115. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  23116. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23117. * @returns a float array containing vertex data
  23118. */
  23119. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  23120. /**
  23121. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  23122. * @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.
  23123. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23124. * @returns the indices array or an empty array if the mesh has no geometry
  23125. */
  23126. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  23127. /**
  23128. * Set specific vertex data
  23129. * @param kind defines the data kind (Position, normal, etc...)
  23130. * @param data defines the vertex data to use
  23131. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  23132. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  23133. */
  23134. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  23135. /**
  23136. * Update a specific associated vertex buffer
  23137. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  23138. * - VertexBuffer.PositionKind
  23139. * - VertexBuffer.UVKind
  23140. * - VertexBuffer.UV2Kind
  23141. * - VertexBuffer.UV3Kind
  23142. * - VertexBuffer.UV4Kind
  23143. * - VertexBuffer.UV5Kind
  23144. * - VertexBuffer.UV6Kind
  23145. * - VertexBuffer.ColorKind
  23146. * - VertexBuffer.MatricesIndicesKind
  23147. * - VertexBuffer.MatricesIndicesExtraKind
  23148. * - VertexBuffer.MatricesWeightsKind
  23149. * - VertexBuffer.MatricesWeightsExtraKind
  23150. * @param data defines the data source
  23151. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  23152. * @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)
  23153. */
  23154. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  23155. /**
  23156. * Creates a new index buffer
  23157. * @param indices defines the indices to store in the index buffer
  23158. * @param totalVertices defines the total number of vertices (could be null)
  23159. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  23160. */
  23161. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  23162. }
  23163. /**
  23164. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  23165. */
  23166. export class VertexData {
  23167. /**
  23168. * Mesh side orientation : usually the external or front surface
  23169. */
  23170. static readonly FRONTSIDE: number;
  23171. /**
  23172. * Mesh side orientation : usually the internal or back surface
  23173. */
  23174. static readonly BACKSIDE: number;
  23175. /**
  23176. * Mesh side orientation : both internal and external or front and back surfaces
  23177. */
  23178. static readonly DOUBLESIDE: number;
  23179. /**
  23180. * Mesh side orientation : by default, `FRONTSIDE`
  23181. */
  23182. static readonly DEFAULTSIDE: number;
  23183. /**
  23184. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  23185. */
  23186. positions: Nullable<FloatArray>;
  23187. /**
  23188. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  23189. */
  23190. normals: Nullable<FloatArray>;
  23191. /**
  23192. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  23193. */
  23194. tangents: Nullable<FloatArray>;
  23195. /**
  23196. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23197. */
  23198. uvs: Nullable<FloatArray>;
  23199. /**
  23200. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23201. */
  23202. uvs2: Nullable<FloatArray>;
  23203. /**
  23204. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23205. */
  23206. uvs3: Nullable<FloatArray>;
  23207. /**
  23208. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23209. */
  23210. uvs4: Nullable<FloatArray>;
  23211. /**
  23212. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23213. */
  23214. uvs5: Nullable<FloatArray>;
  23215. /**
  23216. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23217. */
  23218. uvs6: Nullable<FloatArray>;
  23219. /**
  23220. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  23221. */
  23222. colors: Nullable<FloatArray>;
  23223. /**
  23224. * 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).
  23225. */
  23226. matricesIndices: Nullable<FloatArray>;
  23227. /**
  23228. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  23229. */
  23230. matricesWeights: Nullable<FloatArray>;
  23231. /**
  23232. * An array extending the number of possible indices
  23233. */
  23234. matricesIndicesExtra: Nullable<FloatArray>;
  23235. /**
  23236. * An array extending the number of possible weights when the number of indices is extended
  23237. */
  23238. matricesWeightsExtra: Nullable<FloatArray>;
  23239. /**
  23240. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  23241. */
  23242. indices: Nullable<IndicesArray>;
  23243. /**
  23244. * Uses the passed data array to set the set the values for the specified kind of data
  23245. * @param data a linear array of floating numbers
  23246. * @param kind the type of data that is being set, eg positions, colors etc
  23247. */
  23248. set(data: FloatArray, kind: string): void;
  23249. /**
  23250. * Associates the vertexData to the passed Mesh.
  23251. * Sets it as updatable or not (default `false`)
  23252. * @param mesh the mesh the vertexData is applied to
  23253. * @param updatable when used and having the value true allows new data to update the vertexData
  23254. * @returns the VertexData
  23255. */
  23256. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  23257. /**
  23258. * Associates the vertexData to the passed Geometry.
  23259. * Sets it as updatable or not (default `false`)
  23260. * @param geometry the geometry the vertexData is applied to
  23261. * @param updatable when used and having the value true allows new data to update the vertexData
  23262. * @returns VertexData
  23263. */
  23264. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  23265. /**
  23266. * Updates the associated mesh
  23267. * @param mesh the mesh to be updated
  23268. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  23269. * @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
  23270. * @returns VertexData
  23271. */
  23272. updateMesh(mesh: Mesh): VertexData;
  23273. /**
  23274. * Updates the associated geometry
  23275. * @param geometry the geometry to be updated
  23276. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  23277. * @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
  23278. * @returns VertexData.
  23279. */
  23280. updateGeometry(geometry: Geometry): VertexData;
  23281. private _applyTo;
  23282. private _update;
  23283. /**
  23284. * Transforms each position and each normal of the vertexData according to the passed Matrix
  23285. * @param matrix the transforming matrix
  23286. * @returns the VertexData
  23287. */
  23288. transform(matrix: Matrix): VertexData;
  23289. /**
  23290. * Merges the passed VertexData into the current one
  23291. * @param other the VertexData to be merged into the current one
  23292. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  23293. * @returns the modified VertexData
  23294. */
  23295. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  23296. private _mergeElement;
  23297. private _validate;
  23298. /**
  23299. * Serializes the VertexData
  23300. * @returns a serialized object
  23301. */
  23302. serialize(): any;
  23303. /**
  23304. * Extracts the vertexData from a mesh
  23305. * @param mesh the mesh from which to extract the VertexData
  23306. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  23307. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  23308. * @returns the object VertexData associated to the passed mesh
  23309. */
  23310. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  23311. /**
  23312. * Extracts the vertexData from the geometry
  23313. * @param geometry the geometry from which to extract the VertexData
  23314. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  23315. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  23316. * @returns the object VertexData associated to the passed mesh
  23317. */
  23318. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  23319. private static _ExtractFrom;
  23320. /**
  23321. * Creates the VertexData for a Ribbon
  23322. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  23323. * * pathArray array of paths, each of which an array of successive Vector3
  23324. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  23325. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  23326. * * 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
  23327. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23328. * * 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)
  23329. * * 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)
  23330. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  23331. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  23332. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  23333. * @returns the VertexData of the ribbon
  23334. */
  23335. static CreateRibbon(options: {
  23336. pathArray: Vector3[][];
  23337. closeArray?: boolean;
  23338. closePath?: boolean;
  23339. offset?: number;
  23340. sideOrientation?: number;
  23341. frontUVs?: Vector4;
  23342. backUVs?: Vector4;
  23343. invertUV?: boolean;
  23344. uvs?: Vector2[];
  23345. colors?: Color4[];
  23346. }): VertexData;
  23347. /**
  23348. * Creates the VertexData for a box
  23349. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23350. * * size sets the width, height and depth of the box to the value of size, optional default 1
  23351. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  23352. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  23353. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  23354. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  23355. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  23356. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23357. * * 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)
  23358. * * 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)
  23359. * @returns the VertexData of the box
  23360. */
  23361. static CreateBox(options: {
  23362. size?: number;
  23363. width?: number;
  23364. height?: number;
  23365. depth?: number;
  23366. faceUV?: Vector4[];
  23367. faceColors?: Color4[];
  23368. sideOrientation?: number;
  23369. frontUVs?: Vector4;
  23370. backUVs?: Vector4;
  23371. }): VertexData;
  23372. /**
  23373. * Creates the VertexData for a tiled box
  23374. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23375. * * faceTiles sets the pattern, tile size and number of tiles for a face
  23376. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  23377. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  23378. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23379. * @returns the VertexData of the box
  23380. */
  23381. static CreateTiledBox(options: {
  23382. pattern?: number;
  23383. width?: number;
  23384. height?: number;
  23385. depth?: number;
  23386. tileSize?: number;
  23387. tileWidth?: number;
  23388. tileHeight?: number;
  23389. alignHorizontal?: number;
  23390. alignVertical?: number;
  23391. faceUV?: Vector4[];
  23392. faceColors?: Color4[];
  23393. sideOrientation?: number;
  23394. }): VertexData;
  23395. /**
  23396. * Creates the VertexData for a tiled plane
  23397. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23398. * * pattern a limited pattern arrangement depending on the number
  23399. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  23400. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  23401. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  23402. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23403. * * 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)
  23404. * * 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)
  23405. * @returns the VertexData of the tiled plane
  23406. */
  23407. static CreateTiledPlane(options: {
  23408. pattern?: number;
  23409. tileSize?: number;
  23410. tileWidth?: number;
  23411. tileHeight?: number;
  23412. size?: number;
  23413. width?: number;
  23414. height?: number;
  23415. alignHorizontal?: number;
  23416. alignVertical?: number;
  23417. sideOrientation?: number;
  23418. frontUVs?: Vector4;
  23419. backUVs?: Vector4;
  23420. }): VertexData;
  23421. /**
  23422. * Creates the VertexData for an ellipsoid, defaults to a sphere
  23423. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23424. * * segments sets the number of horizontal strips optional, default 32
  23425. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  23426. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  23427. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  23428. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  23429. * * 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
  23430. * * 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
  23431. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23432. * * 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)
  23433. * * 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)
  23434. * @returns the VertexData of the ellipsoid
  23435. */
  23436. static CreateSphere(options: {
  23437. segments?: number;
  23438. diameter?: number;
  23439. diameterX?: number;
  23440. diameterY?: number;
  23441. diameterZ?: number;
  23442. arc?: number;
  23443. slice?: number;
  23444. sideOrientation?: number;
  23445. frontUVs?: Vector4;
  23446. backUVs?: Vector4;
  23447. }): VertexData;
  23448. /**
  23449. * Creates the VertexData for a cylinder, cone or prism
  23450. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23451. * * height sets the height (y direction) of the cylinder, optional, default 2
  23452. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  23453. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  23454. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  23455. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  23456. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  23457. * * 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
  23458. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23459. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23460. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  23461. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  23462. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23463. * * 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)
  23464. * * 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)
  23465. * @returns the VertexData of the cylinder, cone or prism
  23466. */
  23467. static CreateCylinder(options: {
  23468. height?: number;
  23469. diameterTop?: number;
  23470. diameterBottom?: number;
  23471. diameter?: number;
  23472. tessellation?: number;
  23473. subdivisions?: number;
  23474. arc?: number;
  23475. faceColors?: Color4[];
  23476. faceUV?: Vector4[];
  23477. hasRings?: boolean;
  23478. enclose?: boolean;
  23479. sideOrientation?: number;
  23480. frontUVs?: Vector4;
  23481. backUVs?: Vector4;
  23482. }): VertexData;
  23483. /**
  23484. * Creates the VertexData for a torus
  23485. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23486. * * diameter the diameter of the torus, optional default 1
  23487. * * thickness the diameter of the tube forming the torus, optional default 0.5
  23488. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  23489. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23490. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  23491. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  23492. * @returns the VertexData of the torus
  23493. */
  23494. static CreateTorus(options: {
  23495. diameter?: number;
  23496. thickness?: number;
  23497. tessellation?: number;
  23498. sideOrientation?: number;
  23499. frontUVs?: Vector4;
  23500. backUVs?: Vector4;
  23501. }): VertexData;
  23502. /**
  23503. * Creates the VertexData of the LineSystem
  23504. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  23505. * - lines an array of lines, each line being an array of successive Vector3
  23506. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  23507. * @returns the VertexData of the LineSystem
  23508. */
  23509. static CreateLineSystem(options: {
  23510. lines: Vector3[][];
  23511. colors?: Nullable<Color4[][]>;
  23512. }): VertexData;
  23513. /**
  23514. * Create the VertexData for a DashedLines
  23515. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  23516. * - points an array successive Vector3
  23517. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  23518. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  23519. * - dashNb the intended total number of dashes, optional, default 200
  23520. * @returns the VertexData for the DashedLines
  23521. */
  23522. static CreateDashedLines(options: {
  23523. points: Vector3[];
  23524. dashSize?: number;
  23525. gapSize?: number;
  23526. dashNb?: number;
  23527. }): VertexData;
  23528. /**
  23529. * Creates the VertexData for a Ground
  23530. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  23531. * - width the width (x direction) of the ground, optional, default 1
  23532. * - height the height (z direction) of the ground, optional, default 1
  23533. * - subdivisions the number of subdivisions per side, optional, default 1
  23534. * @returns the VertexData of the Ground
  23535. */
  23536. static CreateGround(options: {
  23537. width?: number;
  23538. height?: number;
  23539. subdivisions?: number;
  23540. subdivisionsX?: number;
  23541. subdivisionsY?: number;
  23542. }): VertexData;
  23543. /**
  23544. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  23545. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  23546. * * xmin the ground minimum X coordinate, optional, default -1
  23547. * * zmin the ground minimum Z coordinate, optional, default -1
  23548. * * xmax the ground maximum X coordinate, optional, default 1
  23549. * * zmax the ground maximum Z coordinate, optional, default 1
  23550. * * 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}
  23551. * * 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}
  23552. * @returns the VertexData of the TiledGround
  23553. */
  23554. static CreateTiledGround(options: {
  23555. xmin: number;
  23556. zmin: number;
  23557. xmax: number;
  23558. zmax: number;
  23559. subdivisions?: {
  23560. w: number;
  23561. h: number;
  23562. };
  23563. precision?: {
  23564. w: number;
  23565. h: number;
  23566. };
  23567. }): VertexData;
  23568. /**
  23569. * Creates the VertexData of the Ground designed from a heightmap
  23570. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  23571. * * width the width (x direction) of the ground
  23572. * * height the height (z direction) of the ground
  23573. * * subdivisions the number of subdivisions per side
  23574. * * minHeight the minimum altitude on the ground, optional, default 0
  23575. * * maxHeight the maximum altitude on the ground, optional default 1
  23576. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  23577. * * buffer the array holding the image color data
  23578. * * bufferWidth the width of image
  23579. * * bufferHeight the height of image
  23580. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  23581. * @returns the VertexData of the Ground designed from a heightmap
  23582. */
  23583. static CreateGroundFromHeightMap(options: {
  23584. width: number;
  23585. height: number;
  23586. subdivisions: number;
  23587. minHeight: number;
  23588. maxHeight: number;
  23589. colorFilter: Color3;
  23590. buffer: Uint8Array;
  23591. bufferWidth: number;
  23592. bufferHeight: number;
  23593. alphaFilter: number;
  23594. }): VertexData;
  23595. /**
  23596. * Creates the VertexData for a Plane
  23597. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  23598. * * size sets the width and height of the plane to the value of size, optional default 1
  23599. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  23600. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  23601. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23602. * * 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)
  23603. * * 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)
  23604. * @returns the VertexData of the box
  23605. */
  23606. static CreatePlane(options: {
  23607. size?: number;
  23608. width?: number;
  23609. height?: number;
  23610. sideOrientation?: number;
  23611. frontUVs?: Vector4;
  23612. backUVs?: Vector4;
  23613. }): VertexData;
  23614. /**
  23615. * Creates the VertexData of the Disc or regular Polygon
  23616. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  23617. * * radius the radius of the disc, optional default 0.5
  23618. * * tessellation the number of polygon sides, optional, default 64
  23619. * * 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
  23620. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23621. * * 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)
  23622. * * 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)
  23623. * @returns the VertexData of the box
  23624. */
  23625. static CreateDisc(options: {
  23626. radius?: number;
  23627. tessellation?: number;
  23628. arc?: number;
  23629. sideOrientation?: number;
  23630. frontUVs?: Vector4;
  23631. backUVs?: Vector4;
  23632. }): VertexData;
  23633. /**
  23634. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  23635. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  23636. * @param polygon a mesh built from polygonTriangulation.build()
  23637. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23638. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23639. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23640. * @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)
  23641. * @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)
  23642. * @returns the VertexData of the Polygon
  23643. */
  23644. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  23645. /**
  23646. * Creates the VertexData of the IcoSphere
  23647. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  23648. * * radius the radius of the IcoSphere, optional default 1
  23649. * * radiusX allows stretching in the x direction, optional, default radius
  23650. * * radiusY allows stretching in the y direction, optional, default radius
  23651. * * radiusZ allows stretching in the z direction, optional, default radius
  23652. * * flat when true creates a flat shaded mesh, optional, default true
  23653. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23654. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23655. * * 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)
  23656. * * 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)
  23657. * @returns the VertexData of the IcoSphere
  23658. */
  23659. static CreateIcoSphere(options: {
  23660. radius?: number;
  23661. radiusX?: number;
  23662. radiusY?: number;
  23663. radiusZ?: number;
  23664. flat?: boolean;
  23665. subdivisions?: number;
  23666. sideOrientation?: number;
  23667. frontUVs?: Vector4;
  23668. backUVs?: Vector4;
  23669. }): VertexData;
  23670. /**
  23671. * Creates the VertexData for a Polyhedron
  23672. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  23673. * * type provided types are:
  23674. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  23675. * * 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)
  23676. * * size the size of the IcoSphere, optional default 1
  23677. * * sizeX allows stretching in the x direction, optional, default size
  23678. * * sizeY allows stretching in the y direction, optional, default size
  23679. * * sizeZ allows stretching in the z direction, optional, default size
  23680. * * 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
  23681. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23682. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23683. * * flat when true creates a flat shaded mesh, optional, default true
  23684. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23685. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23686. * * 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)
  23687. * * 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)
  23688. * @returns the VertexData of the Polyhedron
  23689. */
  23690. static CreatePolyhedron(options: {
  23691. type?: number;
  23692. size?: number;
  23693. sizeX?: number;
  23694. sizeY?: number;
  23695. sizeZ?: number;
  23696. custom?: any;
  23697. faceUV?: Vector4[];
  23698. faceColors?: Color4[];
  23699. flat?: boolean;
  23700. sideOrientation?: number;
  23701. frontUVs?: Vector4;
  23702. backUVs?: Vector4;
  23703. }): VertexData;
  23704. /**
  23705. * Creates the VertexData for a TorusKnot
  23706. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  23707. * * radius the radius of the torus knot, optional, default 2
  23708. * * tube the thickness of the tube, optional, default 0.5
  23709. * * radialSegments the number of sides on each tube segments, optional, default 32
  23710. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  23711. * * p the number of windings around the z axis, optional, default 2
  23712. * * q the number of windings around the x axis, optional, default 3
  23713. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23714. * * 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)
  23715. * * 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)
  23716. * @returns the VertexData of the Torus Knot
  23717. */
  23718. static CreateTorusKnot(options: {
  23719. radius?: number;
  23720. tube?: number;
  23721. radialSegments?: number;
  23722. tubularSegments?: number;
  23723. p?: number;
  23724. q?: number;
  23725. sideOrientation?: number;
  23726. frontUVs?: Vector4;
  23727. backUVs?: Vector4;
  23728. }): VertexData;
  23729. /**
  23730. * Compute normals for given positions and indices
  23731. * @param positions an array of vertex positions, [...., x, y, z, ......]
  23732. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  23733. * @param normals an array of vertex normals, [...., x, y, z, ......]
  23734. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  23735. * * facetNormals : optional array of facet normals (vector3)
  23736. * * facetPositions : optional array of facet positions (vector3)
  23737. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  23738. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  23739. * * bInfo : optional bounding info, required for facetPartitioning computation
  23740. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  23741. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  23742. * * useRightHandedSystem: optional boolean to for right handed system computation
  23743. * * depthSort : optional boolean to enable the facet depth sort computation
  23744. * * distanceTo : optional Vector3 to compute the facet depth from this location
  23745. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  23746. */
  23747. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  23748. facetNormals?: any;
  23749. facetPositions?: any;
  23750. facetPartitioning?: any;
  23751. ratio?: number;
  23752. bInfo?: any;
  23753. bbSize?: Vector3;
  23754. subDiv?: any;
  23755. useRightHandedSystem?: boolean;
  23756. depthSort?: boolean;
  23757. distanceTo?: Vector3;
  23758. depthSortedFacets?: any;
  23759. }): void;
  23760. /** @hidden */
  23761. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  23762. /**
  23763. * Applies VertexData created from the imported parameters to the geometry
  23764. * @param parsedVertexData the parsed data from an imported file
  23765. * @param geometry the geometry to apply the VertexData to
  23766. */
  23767. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  23768. }
  23769. }
  23770. declare module BABYLON {
  23771. /**
  23772. * Class containing static functions to help procedurally build meshes
  23773. */
  23774. export class DiscBuilder {
  23775. /**
  23776. * Creates a plane polygonal mesh. By default, this is a disc
  23777. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  23778. * * 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
  23779. * * 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
  23780. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23781. * * 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
  23782. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23783. * @param name defines the name of the mesh
  23784. * @param options defines the options used to create the mesh
  23785. * @param scene defines the hosting scene
  23786. * @returns the plane polygonal mesh
  23787. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  23788. */
  23789. static CreateDisc(name: string, options: {
  23790. radius?: number;
  23791. tessellation?: number;
  23792. arc?: number;
  23793. updatable?: boolean;
  23794. sideOrientation?: number;
  23795. frontUVs?: Vector4;
  23796. backUVs?: Vector4;
  23797. }, scene?: Nullable<Scene>): Mesh;
  23798. }
  23799. }
  23800. declare module BABYLON {
  23801. /**
  23802. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  23803. *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.
  23804. * The SPS is also a particle system. It provides some methods to manage the particles.
  23805. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  23806. *
  23807. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  23808. */
  23809. export class SolidParticleSystem implements IDisposable {
  23810. /**
  23811. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  23812. * Example : var p = SPS.particles[i];
  23813. */
  23814. particles: SolidParticle[];
  23815. /**
  23816. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  23817. */
  23818. nbParticles: number;
  23819. /**
  23820. * If the particles must ever face the camera (default false). Useful for planar particles.
  23821. */
  23822. billboard: boolean;
  23823. /**
  23824. * Recompute normals when adding a shape
  23825. */
  23826. recomputeNormals: boolean;
  23827. /**
  23828. * This a counter ofr your own usage. It's not set by any SPS functions.
  23829. */
  23830. counter: number;
  23831. /**
  23832. * The SPS name. This name is also given to the underlying mesh.
  23833. */
  23834. name: string;
  23835. /**
  23836. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  23837. */
  23838. mesh: Mesh;
  23839. /**
  23840. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  23841. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  23842. */
  23843. vars: any;
  23844. /**
  23845. * This array is populated when the SPS is set as 'pickable'.
  23846. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  23847. * Each element of this array is an object `{idx: int, faceId: int}`.
  23848. * `idx` is the picked particle index in the `SPS.particles` array
  23849. * `faceId` is the picked face index counted within this particle.
  23850. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  23851. */
  23852. pickedParticles: {
  23853. idx: number;
  23854. faceId: number;
  23855. }[];
  23856. /**
  23857. * This array is populated when `enableDepthSort` is set to true.
  23858. * Each element of this array is an instance of the class DepthSortedParticle.
  23859. */
  23860. depthSortedParticles: DepthSortedParticle[];
  23861. /**
  23862. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  23863. * @hidden
  23864. */
  23865. _bSphereOnly: boolean;
  23866. /**
  23867. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  23868. * @hidden
  23869. */
  23870. _bSphereRadiusFactor: number;
  23871. private _scene;
  23872. private _positions;
  23873. private _indices;
  23874. private _normals;
  23875. private _colors;
  23876. private _uvs;
  23877. private _indices32;
  23878. private _positions32;
  23879. private _normals32;
  23880. private _fixedNormal32;
  23881. private _colors32;
  23882. private _uvs32;
  23883. private _index;
  23884. private _updatable;
  23885. private _pickable;
  23886. private _isVisibilityBoxLocked;
  23887. private _alwaysVisible;
  23888. private _depthSort;
  23889. private _shapeCounter;
  23890. private _copy;
  23891. private _color;
  23892. private _computeParticleColor;
  23893. private _computeParticleTexture;
  23894. private _computeParticleRotation;
  23895. private _computeParticleVertex;
  23896. private _computeBoundingBox;
  23897. private _depthSortParticles;
  23898. private _camera;
  23899. private _mustUnrotateFixedNormals;
  23900. private _particlesIntersect;
  23901. private _needs32Bits;
  23902. /**
  23903. * Creates a SPS (Solid Particle System) object.
  23904. * @param name (String) is the SPS name, this will be the underlying mesh name.
  23905. * @param scene (Scene) is the scene in which the SPS is added.
  23906. * @param options defines the options of the sps e.g.
  23907. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  23908. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  23909. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  23910. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  23911. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  23912. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  23913. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  23914. */
  23915. constructor(name: string, scene: Scene, options?: {
  23916. updatable?: boolean;
  23917. isPickable?: boolean;
  23918. enableDepthSort?: boolean;
  23919. particleIntersection?: boolean;
  23920. boundingSphereOnly?: boolean;
  23921. bSphereRadiusFactor?: number;
  23922. });
  23923. /**
  23924. * Builds the SPS underlying mesh. Returns a standard Mesh.
  23925. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  23926. * @returns the created mesh
  23927. */
  23928. buildMesh(): Mesh;
  23929. /**
  23930. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  23931. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  23932. * Thus the particles generated from `digest()` have their property `position` set yet.
  23933. * @param mesh ( Mesh ) is the mesh to be digested
  23934. * @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
  23935. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  23936. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  23937. * @returns the current SPS
  23938. */
  23939. digest(mesh: Mesh, options?: {
  23940. facetNb?: number;
  23941. number?: number;
  23942. delta?: number;
  23943. }): SolidParticleSystem;
  23944. private _unrotateFixedNormals;
  23945. private _resetCopy;
  23946. private _meshBuilder;
  23947. private _posToShape;
  23948. private _uvsToShapeUV;
  23949. private _addParticle;
  23950. /**
  23951. * Adds some particles to the SPS from the model shape. Returns the shape id.
  23952. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  23953. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  23954. * @param nb (positive integer) the number of particles to be created from this model
  23955. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  23956. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  23957. * @returns the number of shapes in the system
  23958. */
  23959. addShape(mesh: Mesh, nb: number, options?: {
  23960. positionFunction?: any;
  23961. vertexFunction?: any;
  23962. }): number;
  23963. private _rebuildParticle;
  23964. /**
  23965. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  23966. * @returns the SPS.
  23967. */
  23968. rebuildMesh(): SolidParticleSystem;
  23969. /**
  23970. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  23971. * This method calls `updateParticle()` for each particle of the SPS.
  23972. * For an animated SPS, it is usually called within the render loop.
  23973. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  23974. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  23975. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  23976. * @returns the SPS.
  23977. */
  23978. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  23979. /**
  23980. * Disposes the SPS.
  23981. */
  23982. dispose(): void;
  23983. /**
  23984. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  23985. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23986. * @returns the SPS.
  23987. */
  23988. refreshVisibleSize(): SolidParticleSystem;
  23989. /**
  23990. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  23991. * @param size the size (float) of the visibility box
  23992. * note : this doesn't lock the SPS mesh bounding box.
  23993. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23994. */
  23995. setVisibilityBox(size: number): void;
  23996. /**
  23997. * Gets whether the SPS as always visible or not
  23998. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23999. */
  24000. /**
  24001. * Sets the SPS as always visible or not
  24002. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24003. */
  24004. isAlwaysVisible: boolean;
  24005. /**
  24006. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  24007. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24008. */
  24009. /**
  24010. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  24011. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24012. */
  24013. isVisibilityBoxLocked: boolean;
  24014. /**
  24015. * Tells to `setParticles()` to compute the particle rotations or not.
  24016. * Default value : true. The SPS is faster when it's set to false.
  24017. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  24018. */
  24019. /**
  24020. * Gets if `setParticles()` computes the particle rotations or not.
  24021. * Default value : true. The SPS is faster when it's set to false.
  24022. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  24023. */
  24024. computeParticleRotation: boolean;
  24025. /**
  24026. * Tells to `setParticles()` to compute the particle colors or not.
  24027. * Default value : true. The SPS is faster when it's set to false.
  24028. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  24029. */
  24030. /**
  24031. * Gets if `setParticles()` computes the particle colors or not.
  24032. * Default value : true. The SPS is faster when it's set to false.
  24033. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  24034. */
  24035. computeParticleColor: boolean;
  24036. /**
  24037. * Gets if `setParticles()` computes the particle textures or not.
  24038. * Default value : true. The SPS is faster when it's set to false.
  24039. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  24040. */
  24041. computeParticleTexture: boolean;
  24042. /**
  24043. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  24044. * Default value : false. The SPS is faster when it's set to false.
  24045. * Note : the particle custom vertex positions aren't stored values.
  24046. */
  24047. /**
  24048. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  24049. * Default value : false. The SPS is faster when it's set to false.
  24050. * Note : the particle custom vertex positions aren't stored values.
  24051. */
  24052. computeParticleVertex: boolean;
  24053. /**
  24054. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  24055. */
  24056. /**
  24057. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  24058. */
  24059. computeBoundingBox: boolean;
  24060. /**
  24061. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  24062. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  24063. * Default : `true`
  24064. */
  24065. /**
  24066. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  24067. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  24068. * Default : `true`
  24069. */
  24070. depthSortParticles: boolean;
  24071. /**
  24072. * This function does nothing. It may be overwritten to set all the particle first values.
  24073. * The SPS doesn't call this function, you may have to call it by your own.
  24074. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  24075. */
  24076. initParticles(): void;
  24077. /**
  24078. * This function does nothing. It may be overwritten to recycle a particle.
  24079. * The SPS doesn't call this function, you may have to call it by your own.
  24080. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  24081. * @param particle The particle to recycle
  24082. * @returns the recycled particle
  24083. */
  24084. recycleParticle(particle: SolidParticle): SolidParticle;
  24085. /**
  24086. * Updates a particle : this function should be overwritten by the user.
  24087. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  24088. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  24089. * @example : just set a particle position or velocity and recycle conditions
  24090. * @param particle The particle to update
  24091. * @returns the updated particle
  24092. */
  24093. updateParticle(particle: SolidParticle): SolidParticle;
  24094. /**
  24095. * Updates a vertex of a particle : it can be overwritten by the user.
  24096. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  24097. * @param particle the current particle
  24098. * @param vertex the current index of the current particle
  24099. * @param pt the index of the current vertex in the particle shape
  24100. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  24101. * @example : just set a vertex particle position
  24102. * @returns the updated vertex
  24103. */
  24104. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  24105. /**
  24106. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  24107. * This does nothing and may be overwritten by the user.
  24108. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24109. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24110. * @param update the boolean update value actually passed to setParticles()
  24111. */
  24112. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  24113. /**
  24114. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  24115. * This will be passed three parameters.
  24116. * This does nothing and may be overwritten by the user.
  24117. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24118. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24119. * @param update the boolean update value actually passed to setParticles()
  24120. */
  24121. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  24122. }
  24123. }
  24124. declare module BABYLON {
  24125. /**
  24126. * Represents one particle of a solid particle system.
  24127. */
  24128. export class SolidParticle {
  24129. /**
  24130. * particle global index
  24131. */
  24132. idx: number;
  24133. /**
  24134. * The color of the particle
  24135. */
  24136. color: Nullable<Color4>;
  24137. /**
  24138. * The world space position of the particle.
  24139. */
  24140. position: Vector3;
  24141. /**
  24142. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  24143. */
  24144. rotation: Vector3;
  24145. /**
  24146. * The world space rotation quaternion of the particle.
  24147. */
  24148. rotationQuaternion: Nullable<Quaternion>;
  24149. /**
  24150. * The scaling of the particle.
  24151. */
  24152. scaling: Vector3;
  24153. /**
  24154. * The uvs of the particle.
  24155. */
  24156. uvs: Vector4;
  24157. /**
  24158. * The current speed of the particle.
  24159. */
  24160. velocity: Vector3;
  24161. /**
  24162. * The pivot point in the particle local space.
  24163. */
  24164. pivot: Vector3;
  24165. /**
  24166. * Must the particle be translated from its pivot point in its local space ?
  24167. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  24168. * Default : false
  24169. */
  24170. translateFromPivot: boolean;
  24171. /**
  24172. * Is the particle active or not ?
  24173. */
  24174. alive: boolean;
  24175. /**
  24176. * Is the particle visible or not ?
  24177. */
  24178. isVisible: boolean;
  24179. /**
  24180. * Index of this particle in the global "positions" array (Internal use)
  24181. * @hidden
  24182. */
  24183. _pos: number;
  24184. /**
  24185. * @hidden Index of this particle in the global "indices" array (Internal use)
  24186. */
  24187. _ind: number;
  24188. /**
  24189. * @hidden ModelShape of this particle (Internal use)
  24190. */
  24191. _model: ModelShape;
  24192. /**
  24193. * ModelShape id of this particle
  24194. */
  24195. shapeId: number;
  24196. /**
  24197. * Index of the particle in its shape id (Internal use)
  24198. */
  24199. idxInShape: number;
  24200. /**
  24201. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  24202. */
  24203. _modelBoundingInfo: BoundingInfo;
  24204. /**
  24205. * @hidden Particle BoundingInfo object (Internal use)
  24206. */
  24207. _boundingInfo: BoundingInfo;
  24208. /**
  24209. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  24210. */
  24211. _sps: SolidParticleSystem;
  24212. /**
  24213. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  24214. */
  24215. _stillInvisible: boolean;
  24216. /**
  24217. * @hidden Last computed particle rotation matrix
  24218. */
  24219. _rotationMatrix: number[];
  24220. /**
  24221. * Parent particle Id, if any.
  24222. * Default null.
  24223. */
  24224. parentId: Nullable<number>;
  24225. /**
  24226. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  24227. * The possible values are :
  24228. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  24229. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  24230. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  24231. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  24232. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  24233. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  24234. * */
  24235. cullingStrategy: number;
  24236. /**
  24237. * @hidden Internal global position in the SPS.
  24238. */
  24239. _globalPosition: Vector3;
  24240. /**
  24241. * Creates a Solid Particle object.
  24242. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  24243. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  24244. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  24245. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  24246. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  24247. * @param shapeId (integer) is the model shape identifier in the SPS.
  24248. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  24249. * @param sps defines the sps it is associated to
  24250. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  24251. */
  24252. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  24253. /**
  24254. * Legacy support, changed scale to scaling
  24255. */
  24256. /**
  24257. * Legacy support, changed scale to scaling
  24258. */
  24259. scale: Vector3;
  24260. /**
  24261. * Legacy support, changed quaternion to rotationQuaternion
  24262. */
  24263. /**
  24264. * Legacy support, changed quaternion to rotationQuaternion
  24265. */
  24266. quaternion: Nullable<Quaternion>;
  24267. /**
  24268. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  24269. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  24270. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  24271. * @returns true if it intersects
  24272. */
  24273. intersectsMesh(target: Mesh | SolidParticle): boolean;
  24274. /**
  24275. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  24276. * A particle is in the frustum if its bounding box intersects the frustum
  24277. * @param frustumPlanes defines the frustum to test
  24278. * @returns true if the particle is in the frustum planes
  24279. */
  24280. isInFrustum(frustumPlanes: Plane[]): boolean;
  24281. /**
  24282. * get the rotation matrix of the particle
  24283. * @hidden
  24284. */
  24285. getRotationMatrix(m: Matrix): void;
  24286. }
  24287. /**
  24288. * Represents the shape of the model used by one particle of a solid particle system.
  24289. * SPS internal tool, don't use it manually.
  24290. */
  24291. export class ModelShape {
  24292. /**
  24293. * The shape id
  24294. * @hidden
  24295. */
  24296. shapeID: number;
  24297. /**
  24298. * flat array of model positions (internal use)
  24299. * @hidden
  24300. */
  24301. _shape: Vector3[];
  24302. /**
  24303. * flat array of model UVs (internal use)
  24304. * @hidden
  24305. */
  24306. _shapeUV: number[];
  24307. /**
  24308. * length of the shape in the model indices array (internal use)
  24309. * @hidden
  24310. */
  24311. _indicesLength: number;
  24312. /**
  24313. * Custom position function (internal use)
  24314. * @hidden
  24315. */
  24316. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  24317. /**
  24318. * Custom vertex function (internal use)
  24319. * @hidden
  24320. */
  24321. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  24322. /**
  24323. * 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.
  24324. * SPS internal tool, don't use it manually.
  24325. * @hidden
  24326. */
  24327. 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>);
  24328. }
  24329. /**
  24330. * Represents a Depth Sorted Particle in the solid particle system.
  24331. */
  24332. export class DepthSortedParticle {
  24333. /**
  24334. * Index of the particle in the "indices" array
  24335. */
  24336. ind: number;
  24337. /**
  24338. * Length of the particle shape in the "indices" array
  24339. */
  24340. indicesLength: number;
  24341. /**
  24342. * Squared distance from the particle to the camera
  24343. */
  24344. sqDistance: number;
  24345. }
  24346. }
  24347. declare module BABYLON {
  24348. /**
  24349. * @hidden
  24350. */
  24351. export class _MeshCollisionData {
  24352. _checkCollisions: boolean;
  24353. _collisionMask: number;
  24354. _collisionGroup: number;
  24355. _collider: Nullable<Collider>;
  24356. _oldPositionForCollisions: Vector3;
  24357. _diffPositionForCollisions: Vector3;
  24358. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  24359. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  24360. }
  24361. }
  24362. declare module BABYLON {
  24363. /** @hidden */
  24364. class _FacetDataStorage {
  24365. facetPositions: Vector3[];
  24366. facetNormals: Vector3[];
  24367. facetPartitioning: number[][];
  24368. facetNb: number;
  24369. partitioningSubdivisions: number;
  24370. partitioningBBoxRatio: number;
  24371. facetDataEnabled: boolean;
  24372. facetParameters: any;
  24373. bbSize: Vector3;
  24374. subDiv: {
  24375. max: number;
  24376. X: number;
  24377. Y: number;
  24378. Z: number;
  24379. };
  24380. facetDepthSort: boolean;
  24381. facetDepthSortEnabled: boolean;
  24382. depthSortedIndices: IndicesArray;
  24383. depthSortedFacets: {
  24384. ind: number;
  24385. sqDistance: number;
  24386. }[];
  24387. facetDepthSortFunction: (f1: {
  24388. ind: number;
  24389. sqDistance: number;
  24390. }, f2: {
  24391. ind: number;
  24392. sqDistance: number;
  24393. }) => number;
  24394. facetDepthSortFrom: Vector3;
  24395. facetDepthSortOrigin: Vector3;
  24396. invertedMatrix: Matrix;
  24397. }
  24398. /**
  24399. * @hidden
  24400. **/
  24401. class _InternalAbstractMeshDataInfo {
  24402. _hasVertexAlpha: boolean;
  24403. _useVertexColors: boolean;
  24404. _numBoneInfluencers: number;
  24405. _applyFog: boolean;
  24406. _receiveShadows: boolean;
  24407. _facetData: _FacetDataStorage;
  24408. _visibility: number;
  24409. _skeleton: Nullable<Skeleton>;
  24410. _layerMask: number;
  24411. _computeBonesUsingShaders: boolean;
  24412. _isActive: boolean;
  24413. _onlyForInstances: boolean;
  24414. _isActiveIntermediate: boolean;
  24415. _onlyForInstancesIntermediate: boolean;
  24416. }
  24417. /**
  24418. * Class used to store all common mesh properties
  24419. */
  24420. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  24421. /** No occlusion */
  24422. static OCCLUSION_TYPE_NONE: number;
  24423. /** Occlusion set to optimisitic */
  24424. static OCCLUSION_TYPE_OPTIMISTIC: number;
  24425. /** Occlusion set to strict */
  24426. static OCCLUSION_TYPE_STRICT: number;
  24427. /** Use an accurante occlusion algorithm */
  24428. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  24429. /** Use a conservative occlusion algorithm */
  24430. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  24431. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  24432. * Test order :
  24433. * Is the bounding sphere outside the frustum ?
  24434. * If not, are the bounding box vertices outside the frustum ?
  24435. * It not, then the cullable object is in the frustum.
  24436. */
  24437. static readonly CULLINGSTRATEGY_STANDARD: number;
  24438. /** Culling strategy : Bounding Sphere Only.
  24439. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  24440. * It's also less accurate than the standard because some not visible objects can still be selected.
  24441. * Test : is the bounding sphere outside the frustum ?
  24442. * If not, then the cullable object is in the frustum.
  24443. */
  24444. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  24445. /** Culling strategy : Optimistic Inclusion.
  24446. * This in an inclusion test first, then the standard exclusion test.
  24447. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  24448. * 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.
  24449. * Anyway, it's as accurate as the standard strategy.
  24450. * Test :
  24451. * Is the cullable object bounding sphere center in the frustum ?
  24452. * If not, apply the default culling strategy.
  24453. */
  24454. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  24455. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  24456. * This in an inclusion test first, then the bounding sphere only exclusion test.
  24457. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  24458. * 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.
  24459. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  24460. * Test :
  24461. * Is the cullable object bounding sphere center in the frustum ?
  24462. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  24463. */
  24464. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  24465. /**
  24466. * No billboard
  24467. */
  24468. static readonly BILLBOARDMODE_NONE: number;
  24469. /** Billboard on X axis */
  24470. static readonly BILLBOARDMODE_X: number;
  24471. /** Billboard on Y axis */
  24472. static readonly BILLBOARDMODE_Y: number;
  24473. /** Billboard on Z axis */
  24474. static readonly BILLBOARDMODE_Z: number;
  24475. /** Billboard on all axes */
  24476. static readonly BILLBOARDMODE_ALL: number;
  24477. /** @hidden */
  24478. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  24479. /**
  24480. * The culling strategy to use to check whether the mesh must be rendered or not.
  24481. * This value can be changed at any time and will be used on the next render mesh selection.
  24482. * The possible values are :
  24483. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  24484. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  24485. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  24486. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  24487. * Please read each static variable documentation to get details about the culling process.
  24488. * */
  24489. cullingStrategy: number;
  24490. /**
  24491. * Gets the number of facets in the mesh
  24492. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  24493. */
  24494. readonly facetNb: number;
  24495. /**
  24496. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  24497. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  24498. */
  24499. partitioningSubdivisions: number;
  24500. /**
  24501. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  24502. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  24503. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  24504. */
  24505. partitioningBBoxRatio: number;
  24506. /**
  24507. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  24508. * Works only for updatable meshes.
  24509. * Doesn't work with multi-materials
  24510. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  24511. */
  24512. mustDepthSortFacets: boolean;
  24513. /**
  24514. * The location (Vector3) where the facet depth sort must be computed from.
  24515. * By default, the active camera position.
  24516. * Used only when facet depth sort is enabled
  24517. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  24518. */
  24519. facetDepthSortFrom: Vector3;
  24520. /**
  24521. * gets a boolean indicating if facetData is enabled
  24522. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  24523. */
  24524. readonly isFacetDataEnabled: boolean;
  24525. /** @hidden */
  24526. _updateNonUniformScalingState(value: boolean): boolean;
  24527. /**
  24528. * An event triggered when this mesh collides with another one
  24529. */
  24530. onCollideObservable: Observable<AbstractMesh>;
  24531. /** Set a function to call when this mesh collides with another one */
  24532. onCollide: () => void;
  24533. /**
  24534. * An event triggered when the collision's position changes
  24535. */
  24536. onCollisionPositionChangeObservable: Observable<Vector3>;
  24537. /** Set a function to call when the collision's position changes */
  24538. onCollisionPositionChange: () => void;
  24539. /**
  24540. * An event triggered when material is changed
  24541. */
  24542. onMaterialChangedObservable: Observable<AbstractMesh>;
  24543. /**
  24544. * Gets or sets the orientation for POV movement & rotation
  24545. */
  24546. definedFacingForward: boolean;
  24547. /** @hidden */
  24548. _occlusionQuery: Nullable<WebGLQuery>;
  24549. /** @hidden */
  24550. _renderingGroup: Nullable<RenderingGroup>;
  24551. /**
  24552. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  24553. */
  24554. /**
  24555. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  24556. */
  24557. visibility: number;
  24558. /** Gets or sets the alpha index used to sort transparent meshes
  24559. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  24560. */
  24561. alphaIndex: number;
  24562. /**
  24563. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  24564. */
  24565. isVisible: boolean;
  24566. /**
  24567. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  24568. */
  24569. isPickable: boolean;
  24570. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  24571. showSubMeshesBoundingBox: boolean;
  24572. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  24573. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  24574. */
  24575. isBlocker: boolean;
  24576. /**
  24577. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  24578. */
  24579. enablePointerMoveEvents: boolean;
  24580. /**
  24581. * Specifies the rendering group id for this mesh (0 by default)
  24582. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  24583. */
  24584. renderingGroupId: number;
  24585. private _material;
  24586. /** Gets or sets current material */
  24587. material: Nullable<Material>;
  24588. /**
  24589. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  24590. * @see http://doc.babylonjs.com/babylon101/shadows
  24591. */
  24592. receiveShadows: boolean;
  24593. /** Defines color to use when rendering outline */
  24594. outlineColor: Color3;
  24595. /** Define width to use when rendering outline */
  24596. outlineWidth: number;
  24597. /** Defines color to use when rendering overlay */
  24598. overlayColor: Color3;
  24599. /** Defines alpha to use when rendering overlay */
  24600. overlayAlpha: number;
  24601. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  24602. hasVertexAlpha: boolean;
  24603. /** 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) */
  24604. useVertexColors: boolean;
  24605. /**
  24606. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  24607. */
  24608. computeBonesUsingShaders: boolean;
  24609. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  24610. numBoneInfluencers: number;
  24611. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  24612. applyFog: boolean;
  24613. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  24614. useOctreeForRenderingSelection: boolean;
  24615. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  24616. useOctreeForPicking: boolean;
  24617. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  24618. useOctreeForCollisions: boolean;
  24619. /**
  24620. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  24621. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  24622. */
  24623. layerMask: number;
  24624. /**
  24625. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  24626. */
  24627. alwaysSelectAsActiveMesh: boolean;
  24628. /**
  24629. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  24630. */
  24631. doNotSyncBoundingInfo: boolean;
  24632. /**
  24633. * Gets or sets the current action manager
  24634. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  24635. */
  24636. actionManager: Nullable<AbstractActionManager>;
  24637. private _meshCollisionData;
  24638. /**
  24639. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  24640. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24641. */
  24642. ellipsoid: Vector3;
  24643. /**
  24644. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  24645. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24646. */
  24647. ellipsoidOffset: Vector3;
  24648. /**
  24649. * Gets or sets a collision mask used to mask collisions (default is -1).
  24650. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  24651. */
  24652. collisionMask: number;
  24653. /**
  24654. * Gets or sets the current collision group mask (-1 by default).
  24655. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  24656. */
  24657. collisionGroup: number;
  24658. /**
  24659. * Defines edge width used when edgesRenderer is enabled
  24660. * @see https://www.babylonjs-playground.com/#10OJSG#13
  24661. */
  24662. edgesWidth: number;
  24663. /**
  24664. * Defines edge color used when edgesRenderer is enabled
  24665. * @see https://www.babylonjs-playground.com/#10OJSG#13
  24666. */
  24667. edgesColor: Color4;
  24668. /** @hidden */
  24669. _edgesRenderer: Nullable<IEdgesRenderer>;
  24670. /** @hidden */
  24671. _masterMesh: Nullable<AbstractMesh>;
  24672. /** @hidden */
  24673. _boundingInfo: Nullable<BoundingInfo>;
  24674. /** @hidden */
  24675. _renderId: number;
  24676. /**
  24677. * Gets or sets the list of subMeshes
  24678. * @see http://doc.babylonjs.com/how_to/multi_materials
  24679. */
  24680. subMeshes: SubMesh[];
  24681. /** @hidden */
  24682. _intersectionsInProgress: AbstractMesh[];
  24683. /** @hidden */
  24684. _unIndexed: boolean;
  24685. /** @hidden */
  24686. _lightSources: Light[];
  24687. /** Gets the list of lights affecting that mesh */
  24688. readonly lightSources: Light[];
  24689. /** @hidden */
  24690. readonly _positions: Nullable<Vector3[]>;
  24691. /** @hidden */
  24692. _waitingData: {
  24693. lods: Nullable<any>;
  24694. actions: Nullable<any>;
  24695. freezeWorldMatrix: Nullable<boolean>;
  24696. };
  24697. /** @hidden */
  24698. _bonesTransformMatrices: Nullable<Float32Array>;
  24699. /**
  24700. * Gets or sets a skeleton to apply skining transformations
  24701. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  24702. */
  24703. skeleton: Nullable<Skeleton>;
  24704. /**
  24705. * An event triggered when the mesh is rebuilt.
  24706. */
  24707. onRebuildObservable: Observable<AbstractMesh>;
  24708. /**
  24709. * Creates a new AbstractMesh
  24710. * @param name defines the name of the mesh
  24711. * @param scene defines the hosting scene
  24712. */
  24713. constructor(name: string, scene?: Nullable<Scene>);
  24714. /**
  24715. * Returns the string "AbstractMesh"
  24716. * @returns "AbstractMesh"
  24717. */
  24718. getClassName(): string;
  24719. /**
  24720. * Gets a string representation of the current mesh
  24721. * @param fullDetails defines a boolean indicating if full details must be included
  24722. * @returns a string representation of the current mesh
  24723. */
  24724. toString(fullDetails?: boolean): string;
  24725. /**
  24726. * @hidden
  24727. */
  24728. protected _getEffectiveParent(): Nullable<Node>;
  24729. /** @hidden */
  24730. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  24731. /** @hidden */
  24732. _rebuild(): void;
  24733. /** @hidden */
  24734. _resyncLightSources(): void;
  24735. /** @hidden */
  24736. _resyncLighSource(light: Light): void;
  24737. /** @hidden */
  24738. _unBindEffect(): void;
  24739. /** @hidden */
  24740. _removeLightSource(light: Light): void;
  24741. private _markSubMeshesAsDirty;
  24742. /** @hidden */
  24743. _markSubMeshesAsLightDirty(): void;
  24744. /** @hidden */
  24745. _markSubMeshesAsAttributesDirty(): void;
  24746. /** @hidden */
  24747. _markSubMeshesAsMiscDirty(): void;
  24748. /**
  24749. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  24750. */
  24751. scaling: Vector3;
  24752. /**
  24753. * Returns true if the mesh is blocked. Implemented by child classes
  24754. */
  24755. readonly isBlocked: boolean;
  24756. /**
  24757. * Returns the mesh itself by default. Implemented by child classes
  24758. * @param camera defines the camera to use to pick the right LOD level
  24759. * @returns the currentAbstractMesh
  24760. */
  24761. getLOD(camera: Camera): Nullable<AbstractMesh>;
  24762. /**
  24763. * Returns 0 by default. Implemented by child classes
  24764. * @returns an integer
  24765. */
  24766. getTotalVertices(): number;
  24767. /**
  24768. * Returns a positive integer : the total number of indices in this mesh geometry.
  24769. * @returns the numner of indices or zero if the mesh has no geometry.
  24770. */
  24771. getTotalIndices(): number;
  24772. /**
  24773. * Returns null by default. Implemented by child classes
  24774. * @returns null
  24775. */
  24776. getIndices(): Nullable<IndicesArray>;
  24777. /**
  24778. * Returns the array of the requested vertex data kind. Implemented by child classes
  24779. * @param kind defines the vertex data kind to use
  24780. * @returns null
  24781. */
  24782. getVerticesData(kind: string): Nullable<FloatArray>;
  24783. /**
  24784. * Sets the vertex data of the mesh geometry for the requested `kind`.
  24785. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  24786. * Note that a new underlying VertexBuffer object is created each call.
  24787. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  24788. * @param kind defines vertex data kind:
  24789. * * VertexBuffer.PositionKind
  24790. * * VertexBuffer.UVKind
  24791. * * VertexBuffer.UV2Kind
  24792. * * VertexBuffer.UV3Kind
  24793. * * VertexBuffer.UV4Kind
  24794. * * VertexBuffer.UV5Kind
  24795. * * VertexBuffer.UV6Kind
  24796. * * VertexBuffer.ColorKind
  24797. * * VertexBuffer.MatricesIndicesKind
  24798. * * VertexBuffer.MatricesIndicesExtraKind
  24799. * * VertexBuffer.MatricesWeightsKind
  24800. * * VertexBuffer.MatricesWeightsExtraKind
  24801. * @param data defines the data source
  24802. * @param updatable defines if the data must be flagged as updatable (or static)
  24803. * @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
  24804. * @returns the current mesh
  24805. */
  24806. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  24807. /**
  24808. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  24809. * If the mesh has no geometry, it is simply returned as it is.
  24810. * @param kind defines vertex data kind:
  24811. * * VertexBuffer.PositionKind
  24812. * * VertexBuffer.UVKind
  24813. * * VertexBuffer.UV2Kind
  24814. * * VertexBuffer.UV3Kind
  24815. * * VertexBuffer.UV4Kind
  24816. * * VertexBuffer.UV5Kind
  24817. * * VertexBuffer.UV6Kind
  24818. * * VertexBuffer.ColorKind
  24819. * * VertexBuffer.MatricesIndicesKind
  24820. * * VertexBuffer.MatricesIndicesExtraKind
  24821. * * VertexBuffer.MatricesWeightsKind
  24822. * * VertexBuffer.MatricesWeightsExtraKind
  24823. * @param data defines the data source
  24824. * @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
  24825. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  24826. * @returns the current mesh
  24827. */
  24828. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  24829. /**
  24830. * Sets the mesh indices,
  24831. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  24832. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  24833. * @param totalVertices Defines the total number of vertices
  24834. * @returns the current mesh
  24835. */
  24836. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  24837. /**
  24838. * Gets a boolean indicating if specific vertex data is present
  24839. * @param kind defines the vertex data kind to use
  24840. * @returns true is data kind is present
  24841. */
  24842. isVerticesDataPresent(kind: string): boolean;
  24843. /**
  24844. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  24845. * @returns a BoundingInfo
  24846. */
  24847. getBoundingInfo(): BoundingInfo;
  24848. /**
  24849. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  24850. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  24851. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  24852. * @returns the current mesh
  24853. */
  24854. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean): AbstractMesh;
  24855. /**
  24856. * Overwrite the current bounding info
  24857. * @param boundingInfo defines the new bounding info
  24858. * @returns the current mesh
  24859. */
  24860. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  24861. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  24862. readonly useBones: boolean;
  24863. /** @hidden */
  24864. _preActivate(): void;
  24865. /** @hidden */
  24866. _preActivateForIntermediateRendering(renderId: number): void;
  24867. /** @hidden */
  24868. _activate(renderId: number, intermediateRendering: boolean): boolean;
  24869. /** @hidden */
  24870. _postActivate(): void;
  24871. /** @hidden */
  24872. _freeze(): void;
  24873. /** @hidden */
  24874. _unFreeze(): void;
  24875. /**
  24876. * Gets the current world matrix
  24877. * @returns a Matrix
  24878. */
  24879. getWorldMatrix(): Matrix;
  24880. /** @hidden */
  24881. _getWorldMatrixDeterminant(): number;
  24882. /**
  24883. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  24884. */
  24885. readonly isAnInstance: boolean;
  24886. /**
  24887. * Perform relative position change from the point of view of behind the front of the mesh.
  24888. * This is performed taking into account the meshes current rotation, so you do not have to care.
  24889. * Supports definition of mesh facing forward or backward
  24890. * @param amountRight defines the distance on the right axis
  24891. * @param amountUp defines the distance on the up axis
  24892. * @param amountForward defines the distance on the forward axis
  24893. * @returns the current mesh
  24894. */
  24895. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  24896. /**
  24897. * Calculate relative position change from the point of view of behind the front of the mesh.
  24898. * This is performed taking into account the meshes current rotation, so you do not have to care.
  24899. * Supports definition of mesh facing forward or backward
  24900. * @param amountRight defines the distance on the right axis
  24901. * @param amountUp defines the distance on the up axis
  24902. * @param amountForward defines the distance on the forward axis
  24903. * @returns the new displacement vector
  24904. */
  24905. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  24906. /**
  24907. * Perform relative rotation change from the point of view of behind the front of the mesh.
  24908. * Supports definition of mesh facing forward or backward
  24909. * @param flipBack defines the flip
  24910. * @param twirlClockwise defines the twirl
  24911. * @param tiltRight defines the tilt
  24912. * @returns the current mesh
  24913. */
  24914. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  24915. /**
  24916. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  24917. * Supports definition of mesh facing forward or backward.
  24918. * @param flipBack defines the flip
  24919. * @param twirlClockwise defines the twirl
  24920. * @param tiltRight defines the tilt
  24921. * @returns the new rotation vector
  24922. */
  24923. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  24924. /**
  24925. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  24926. * This means the mesh underlying bounding box and sphere are recomputed.
  24927. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  24928. * @returns the current mesh
  24929. */
  24930. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  24931. /** @hidden */
  24932. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  24933. /** @hidden */
  24934. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  24935. /** @hidden */
  24936. _updateBoundingInfo(): AbstractMesh;
  24937. /** @hidden */
  24938. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  24939. /** @hidden */
  24940. protected _afterComputeWorldMatrix(): void;
  24941. /** @hidden */
  24942. readonly _effectiveMesh: AbstractMesh;
  24943. /**
  24944. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  24945. * A mesh is in the frustum if its bounding box intersects the frustum
  24946. * @param frustumPlanes defines the frustum to test
  24947. * @returns true if the mesh is in the frustum planes
  24948. */
  24949. isInFrustum(frustumPlanes: Plane[]): boolean;
  24950. /**
  24951. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  24952. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  24953. * @param frustumPlanes defines the frustum to test
  24954. * @returns true if the mesh is completely in the frustum planes
  24955. */
  24956. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  24957. /**
  24958. * True if the mesh intersects another mesh or a SolidParticle object
  24959. * @param mesh defines a target mesh or SolidParticle to test
  24960. * @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)
  24961. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  24962. * @returns true if there is an intersection
  24963. */
  24964. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  24965. /**
  24966. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  24967. * @param point defines the point to test
  24968. * @returns true if there is an intersection
  24969. */
  24970. intersectsPoint(point: Vector3): boolean;
  24971. /**
  24972. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  24973. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24974. */
  24975. checkCollisions: boolean;
  24976. /**
  24977. * Gets Collider object used to compute collisions (not physics)
  24978. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24979. */
  24980. readonly collider: Nullable<Collider>;
  24981. /**
  24982. * Move the mesh using collision engine
  24983. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24984. * @param displacement defines the requested displacement vector
  24985. * @returns the current mesh
  24986. */
  24987. moveWithCollisions(displacement: Vector3): AbstractMesh;
  24988. private _onCollisionPositionChange;
  24989. /** @hidden */
  24990. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  24991. /** @hidden */
  24992. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  24993. /** @hidden */
  24994. _checkCollision(collider: Collider): AbstractMesh;
  24995. /** @hidden */
  24996. _generatePointsArray(): boolean;
  24997. /**
  24998. * Checks if the passed Ray intersects with the mesh
  24999. * @param ray defines the ray to use
  25000. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  25001. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  25002. * @returns the picking info
  25003. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  25004. */
  25005. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  25006. /**
  25007. * Clones the current mesh
  25008. * @param name defines the mesh name
  25009. * @param newParent defines the new mesh parent
  25010. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  25011. * @returns the new mesh
  25012. */
  25013. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  25014. /**
  25015. * Disposes all the submeshes of the current meshnp
  25016. * @returns the current mesh
  25017. */
  25018. releaseSubMeshes(): AbstractMesh;
  25019. /**
  25020. * Releases resources associated with this abstract mesh.
  25021. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25022. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25023. */
  25024. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25025. /**
  25026. * Adds the passed mesh as a child to the current mesh
  25027. * @param mesh defines the child mesh
  25028. * @returns the current mesh
  25029. */
  25030. addChild(mesh: AbstractMesh): AbstractMesh;
  25031. /**
  25032. * Removes the passed mesh from the current mesh children list
  25033. * @param mesh defines the child mesh
  25034. * @returns the current mesh
  25035. */
  25036. removeChild(mesh: AbstractMesh): AbstractMesh;
  25037. /** @hidden */
  25038. private _initFacetData;
  25039. /**
  25040. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  25041. * This method can be called within the render loop.
  25042. * 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
  25043. * @returns the current mesh
  25044. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25045. */
  25046. updateFacetData(): AbstractMesh;
  25047. /**
  25048. * Returns the facetLocalNormals array.
  25049. * The normals are expressed in the mesh local spac
  25050. * @returns an array of Vector3
  25051. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25052. */
  25053. getFacetLocalNormals(): Vector3[];
  25054. /**
  25055. * Returns the facetLocalPositions array.
  25056. * The facet positions are expressed in the mesh local space
  25057. * @returns an array of Vector3
  25058. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25059. */
  25060. getFacetLocalPositions(): Vector3[];
  25061. /**
  25062. * Returns the facetLocalPartioning array
  25063. * @returns an array of array of numbers
  25064. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25065. */
  25066. getFacetLocalPartitioning(): number[][];
  25067. /**
  25068. * Returns the i-th facet position in the world system.
  25069. * This method allocates a new Vector3 per call
  25070. * @param i defines the facet index
  25071. * @returns a new Vector3
  25072. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25073. */
  25074. getFacetPosition(i: number): Vector3;
  25075. /**
  25076. * Sets the reference Vector3 with the i-th facet position in the world system
  25077. * @param i defines the facet index
  25078. * @param ref defines the target vector
  25079. * @returns the current mesh
  25080. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25081. */
  25082. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  25083. /**
  25084. * Returns the i-th facet normal in the world system.
  25085. * This method allocates a new Vector3 per call
  25086. * @param i defines the facet index
  25087. * @returns a new Vector3
  25088. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25089. */
  25090. getFacetNormal(i: number): Vector3;
  25091. /**
  25092. * Sets the reference Vector3 with the i-th facet normal in the world system
  25093. * @param i defines the facet index
  25094. * @param ref defines the target vector
  25095. * @returns the current mesh
  25096. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25097. */
  25098. getFacetNormalToRef(i: number, ref: Vector3): this;
  25099. /**
  25100. * 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)
  25101. * @param x defines x coordinate
  25102. * @param y defines y coordinate
  25103. * @param z defines z coordinate
  25104. * @returns the array of facet indexes
  25105. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25106. */
  25107. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  25108. /**
  25109. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  25110. * @param projected sets as the (x,y,z) world projection on the facet
  25111. * @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
  25112. * @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
  25113. * @param x defines x coordinate
  25114. * @param y defines y coordinate
  25115. * @param z defines z coordinate
  25116. * @returns the face index if found (or null instead)
  25117. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25118. */
  25119. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  25120. /**
  25121. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  25122. * @param projected sets as the (x,y,z) local projection on the facet
  25123. * @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
  25124. * @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
  25125. * @param x defines x coordinate
  25126. * @param y defines y coordinate
  25127. * @param z defines z coordinate
  25128. * @returns the face index if found (or null instead)
  25129. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25130. */
  25131. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  25132. /**
  25133. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  25134. * @returns the parameters
  25135. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25136. */
  25137. getFacetDataParameters(): any;
  25138. /**
  25139. * Disables the feature FacetData and frees the related memory
  25140. * @returns the current mesh
  25141. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25142. */
  25143. disableFacetData(): AbstractMesh;
  25144. /**
  25145. * Updates the AbstractMesh indices array
  25146. * @param indices defines the data source
  25147. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  25148. * @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)
  25149. * @returns the current mesh
  25150. */
  25151. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  25152. /**
  25153. * Creates new normals data for the mesh
  25154. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  25155. * @returns the current mesh
  25156. */
  25157. createNormals(updatable: boolean): AbstractMesh;
  25158. /**
  25159. * Align the mesh with a normal
  25160. * @param normal defines the normal to use
  25161. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  25162. * @returns the current mesh
  25163. */
  25164. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  25165. /** @hidden */
  25166. _checkOcclusionQuery(): boolean;
  25167. /**
  25168. * Disables the mesh edge rendering mode
  25169. * @returns the currentAbstractMesh
  25170. */
  25171. disableEdgesRendering(): AbstractMesh;
  25172. /**
  25173. * Enables the edge rendering mode on the mesh.
  25174. * This mode makes the mesh edges visible
  25175. * @param epsilon defines the maximal distance between two angles to detect a face
  25176. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  25177. * @returns the currentAbstractMesh
  25178. * @see https://www.babylonjs-playground.com/#19O9TU#0
  25179. */
  25180. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  25181. }
  25182. }
  25183. declare module BABYLON {
  25184. /**
  25185. * Interface used to define ActionEvent
  25186. */
  25187. export interface IActionEvent {
  25188. /** The mesh or sprite that triggered the action */
  25189. source: any;
  25190. /** The X mouse cursor position at the time of the event */
  25191. pointerX: number;
  25192. /** The Y mouse cursor position at the time of the event */
  25193. pointerY: number;
  25194. /** The mesh that is currently pointed at (can be null) */
  25195. meshUnderPointer: Nullable<AbstractMesh>;
  25196. /** the original (browser) event that triggered the ActionEvent */
  25197. sourceEvent?: any;
  25198. /** additional data for the event */
  25199. additionalData?: any;
  25200. }
  25201. /**
  25202. * ActionEvent is the event being sent when an action is triggered.
  25203. */
  25204. export class ActionEvent implements IActionEvent {
  25205. /** The mesh or sprite that triggered the action */
  25206. source: any;
  25207. /** The X mouse cursor position at the time of the event */
  25208. pointerX: number;
  25209. /** The Y mouse cursor position at the time of the event */
  25210. pointerY: number;
  25211. /** The mesh that is currently pointed at (can be null) */
  25212. meshUnderPointer: Nullable<AbstractMesh>;
  25213. /** the original (browser) event that triggered the ActionEvent */
  25214. sourceEvent?: any;
  25215. /** additional data for the event */
  25216. additionalData?: any;
  25217. /**
  25218. * Creates a new ActionEvent
  25219. * @param source The mesh or sprite that triggered the action
  25220. * @param pointerX The X mouse cursor position at the time of the event
  25221. * @param pointerY The Y mouse cursor position at the time of the event
  25222. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  25223. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  25224. * @param additionalData additional data for the event
  25225. */
  25226. constructor(
  25227. /** The mesh or sprite that triggered the action */
  25228. source: any,
  25229. /** The X mouse cursor position at the time of the event */
  25230. pointerX: number,
  25231. /** The Y mouse cursor position at the time of the event */
  25232. pointerY: number,
  25233. /** The mesh that is currently pointed at (can be null) */
  25234. meshUnderPointer: Nullable<AbstractMesh>,
  25235. /** the original (browser) event that triggered the ActionEvent */
  25236. sourceEvent?: any,
  25237. /** additional data for the event */
  25238. additionalData?: any);
  25239. /**
  25240. * Helper function to auto-create an ActionEvent from a source mesh.
  25241. * @param source The source mesh that triggered the event
  25242. * @param evt The original (browser) event
  25243. * @param additionalData additional data for the event
  25244. * @returns the new ActionEvent
  25245. */
  25246. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  25247. /**
  25248. * Helper function to auto-create an ActionEvent from a source sprite
  25249. * @param source The source sprite that triggered the event
  25250. * @param scene Scene associated with the sprite
  25251. * @param evt The original (browser) event
  25252. * @param additionalData additional data for the event
  25253. * @returns the new ActionEvent
  25254. */
  25255. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  25256. /**
  25257. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  25258. * @param scene the scene where the event occurred
  25259. * @param evt The original (browser) event
  25260. * @returns the new ActionEvent
  25261. */
  25262. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  25263. /**
  25264. * Helper function to auto-create an ActionEvent from a primitive
  25265. * @param prim defines the target primitive
  25266. * @param pointerPos defines the pointer position
  25267. * @param evt The original (browser) event
  25268. * @param additionalData additional data for the event
  25269. * @returns the new ActionEvent
  25270. */
  25271. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  25272. }
  25273. }
  25274. declare module BABYLON {
  25275. /**
  25276. * Abstract class used to decouple action Manager from scene and meshes.
  25277. * Do not instantiate.
  25278. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  25279. */
  25280. export abstract class AbstractActionManager implements IDisposable {
  25281. /** Gets the list of active triggers */
  25282. static Triggers: {
  25283. [key: string]: number;
  25284. };
  25285. /** Gets the cursor to use when hovering items */
  25286. hoverCursor: string;
  25287. /** Gets the list of actions */
  25288. actions: IAction[];
  25289. /**
  25290. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  25291. */
  25292. isRecursive: boolean;
  25293. /**
  25294. * Releases all associated resources
  25295. */
  25296. abstract dispose(): void;
  25297. /**
  25298. * Does this action manager has pointer triggers
  25299. */
  25300. abstract readonly hasPointerTriggers: boolean;
  25301. /**
  25302. * Does this action manager has pick triggers
  25303. */
  25304. abstract readonly hasPickTriggers: boolean;
  25305. /**
  25306. * Process a specific trigger
  25307. * @param trigger defines the trigger to process
  25308. * @param evt defines the event details to be processed
  25309. */
  25310. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  25311. /**
  25312. * Does this action manager handles actions of any of the given triggers
  25313. * @param triggers defines the triggers to be tested
  25314. * @return a boolean indicating whether one (or more) of the triggers is handled
  25315. */
  25316. abstract hasSpecificTriggers(triggers: number[]): boolean;
  25317. /**
  25318. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  25319. * speed.
  25320. * @param triggerA defines the trigger to be tested
  25321. * @param triggerB defines the trigger to be tested
  25322. * @return a boolean indicating whether one (or more) of the triggers is handled
  25323. */
  25324. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  25325. /**
  25326. * Does this action manager handles actions of a given trigger
  25327. * @param trigger defines the trigger to be tested
  25328. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  25329. * @return whether the trigger is handled
  25330. */
  25331. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  25332. /**
  25333. * Serialize this manager to a JSON object
  25334. * @param name defines the property name to store this manager
  25335. * @returns a JSON representation of this manager
  25336. */
  25337. abstract serialize(name: string): any;
  25338. /**
  25339. * Registers an action to this action manager
  25340. * @param action defines the action to be registered
  25341. * @return the action amended (prepared) after registration
  25342. */
  25343. abstract registerAction(action: IAction): Nullable<IAction>;
  25344. /**
  25345. * Unregisters an action to this action manager
  25346. * @param action defines the action to be unregistered
  25347. * @return a boolean indicating whether the action has been unregistered
  25348. */
  25349. abstract unregisterAction(action: IAction): Boolean;
  25350. /**
  25351. * Does exist one action manager with at least one trigger
  25352. **/
  25353. static readonly HasTriggers: boolean;
  25354. /**
  25355. * Does exist one action manager with at least one pick trigger
  25356. **/
  25357. static readonly HasPickTriggers: boolean;
  25358. /**
  25359. * Does exist one action manager that handles actions of a given trigger
  25360. * @param trigger defines the trigger to be tested
  25361. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  25362. **/
  25363. static HasSpecificTrigger(trigger: number): boolean;
  25364. }
  25365. }
  25366. declare module BABYLON {
  25367. /**
  25368. * Defines how a node can be built from a string name.
  25369. */
  25370. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  25371. /**
  25372. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  25373. */
  25374. export class Node implements IBehaviorAware<Node> {
  25375. /** @hidden */
  25376. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  25377. private static _NodeConstructors;
  25378. /**
  25379. * Add a new node constructor
  25380. * @param type defines the type name of the node to construct
  25381. * @param constructorFunc defines the constructor function
  25382. */
  25383. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  25384. /**
  25385. * Returns a node constructor based on type name
  25386. * @param type defines the type name
  25387. * @param name defines the new node name
  25388. * @param scene defines the hosting scene
  25389. * @param options defines optional options to transmit to constructors
  25390. * @returns the new constructor or null
  25391. */
  25392. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  25393. /**
  25394. * Gets or sets the name of the node
  25395. */
  25396. name: string;
  25397. /**
  25398. * Gets or sets the id of the node
  25399. */
  25400. id: string;
  25401. /**
  25402. * Gets or sets the unique id of the node
  25403. */
  25404. uniqueId: number;
  25405. /**
  25406. * Gets or sets a string used to store user defined state for the node
  25407. */
  25408. state: string;
  25409. /**
  25410. * Gets or sets an object used to store user defined information for the node
  25411. */
  25412. metadata: any;
  25413. /**
  25414. * For internal use only. Please do not use.
  25415. */
  25416. reservedDataStore: any;
  25417. /**
  25418. * List of inspectable custom properties (used by the Inspector)
  25419. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  25420. */
  25421. inspectableCustomProperties: IInspectable[];
  25422. /**
  25423. * Gets or sets a boolean used to define if the node must be serialized
  25424. */
  25425. doNotSerialize: boolean;
  25426. /** @hidden */
  25427. _isDisposed: boolean;
  25428. /**
  25429. * Gets a list of Animations associated with the node
  25430. */
  25431. animations: Animation[];
  25432. protected _ranges: {
  25433. [name: string]: Nullable<AnimationRange>;
  25434. };
  25435. /**
  25436. * Callback raised when the node is ready to be used
  25437. */
  25438. onReady: Nullable<(node: Node) => void>;
  25439. private _isEnabled;
  25440. private _isParentEnabled;
  25441. private _isReady;
  25442. /** @hidden */
  25443. _currentRenderId: number;
  25444. private _parentUpdateId;
  25445. /** @hidden */
  25446. _childUpdateId: number;
  25447. /** @hidden */
  25448. _waitingParentId: Nullable<string>;
  25449. /** @hidden */
  25450. _scene: Scene;
  25451. /** @hidden */
  25452. _cache: any;
  25453. private _parentNode;
  25454. private _children;
  25455. /** @hidden */
  25456. _worldMatrix: Matrix;
  25457. /** @hidden */
  25458. _worldMatrixDeterminant: number;
  25459. /** @hidden */
  25460. _worldMatrixDeterminantIsDirty: boolean;
  25461. /** @hidden */
  25462. private _sceneRootNodesIndex;
  25463. /**
  25464. * Gets a boolean indicating if the node has been disposed
  25465. * @returns true if the node was disposed
  25466. */
  25467. isDisposed(): boolean;
  25468. /**
  25469. * Gets or sets the parent of the node (without keeping the current position in the scene)
  25470. * @see https://doc.babylonjs.com/how_to/parenting
  25471. */
  25472. parent: Nullable<Node>;
  25473. private addToSceneRootNodes;
  25474. private removeFromSceneRootNodes;
  25475. private _animationPropertiesOverride;
  25476. /**
  25477. * Gets or sets the animation properties override
  25478. */
  25479. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  25480. /**
  25481. * Gets a string idenfifying the name of the class
  25482. * @returns "Node" string
  25483. */
  25484. getClassName(): string;
  25485. /** @hidden */
  25486. readonly _isNode: boolean;
  25487. /**
  25488. * An event triggered when the mesh is disposed
  25489. */
  25490. onDisposeObservable: Observable<Node>;
  25491. private _onDisposeObserver;
  25492. /**
  25493. * Sets a callback that will be raised when the node will be disposed
  25494. */
  25495. onDispose: () => void;
  25496. /**
  25497. * Creates a new Node
  25498. * @param name the name and id to be given to this node
  25499. * @param scene the scene this node will be added to
  25500. * @param addToRootNodes the node will be added to scene.rootNodes
  25501. */
  25502. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  25503. /**
  25504. * Gets the scene of the node
  25505. * @returns a scene
  25506. */
  25507. getScene(): Scene;
  25508. /**
  25509. * Gets the engine of the node
  25510. * @returns a Engine
  25511. */
  25512. getEngine(): Engine;
  25513. private _behaviors;
  25514. /**
  25515. * Attach a behavior to the node
  25516. * @see http://doc.babylonjs.com/features/behaviour
  25517. * @param behavior defines the behavior to attach
  25518. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  25519. * @returns the current Node
  25520. */
  25521. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  25522. /**
  25523. * Remove an attached behavior
  25524. * @see http://doc.babylonjs.com/features/behaviour
  25525. * @param behavior defines the behavior to attach
  25526. * @returns the current Node
  25527. */
  25528. removeBehavior(behavior: Behavior<Node>): Node;
  25529. /**
  25530. * Gets the list of attached behaviors
  25531. * @see http://doc.babylonjs.com/features/behaviour
  25532. */
  25533. readonly behaviors: Behavior<Node>[];
  25534. /**
  25535. * Gets an attached behavior by name
  25536. * @param name defines the name of the behavior to look for
  25537. * @see http://doc.babylonjs.com/features/behaviour
  25538. * @returns null if behavior was not found else the requested behavior
  25539. */
  25540. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  25541. /**
  25542. * Returns the latest update of the World matrix
  25543. * @returns a Matrix
  25544. */
  25545. getWorldMatrix(): Matrix;
  25546. /** @hidden */
  25547. _getWorldMatrixDeterminant(): number;
  25548. /**
  25549. * Returns directly the latest state of the mesh World matrix.
  25550. * A Matrix is returned.
  25551. */
  25552. readonly worldMatrixFromCache: Matrix;
  25553. /** @hidden */
  25554. _initCache(): void;
  25555. /** @hidden */
  25556. updateCache(force?: boolean): void;
  25557. /** @hidden */
  25558. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  25559. /** @hidden */
  25560. _updateCache(ignoreParentClass?: boolean): void;
  25561. /** @hidden */
  25562. _isSynchronized(): boolean;
  25563. /** @hidden */
  25564. _markSyncedWithParent(): void;
  25565. /** @hidden */
  25566. isSynchronizedWithParent(): boolean;
  25567. /** @hidden */
  25568. isSynchronized(): boolean;
  25569. /**
  25570. * Is this node ready to be used/rendered
  25571. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  25572. * @return true if the node is ready
  25573. */
  25574. isReady(completeCheck?: boolean): boolean;
  25575. /**
  25576. * Is this node enabled?
  25577. * 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
  25578. * @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
  25579. * @return whether this node (and its parent) is enabled
  25580. */
  25581. isEnabled(checkAncestors?: boolean): boolean;
  25582. /** @hidden */
  25583. protected _syncParentEnabledState(): void;
  25584. /**
  25585. * Set the enabled state of this node
  25586. * @param value defines the new enabled state
  25587. */
  25588. setEnabled(value: boolean): void;
  25589. /**
  25590. * Is this node a descendant of the given node?
  25591. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  25592. * @param ancestor defines the parent node to inspect
  25593. * @returns a boolean indicating if this node is a descendant of the given node
  25594. */
  25595. isDescendantOf(ancestor: Node): boolean;
  25596. /** @hidden */
  25597. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  25598. /**
  25599. * Will return all nodes that have this node as ascendant
  25600. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered
  25601. * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
  25602. * @return all children nodes of all types
  25603. */
  25604. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  25605. /**
  25606. * Get all child-meshes of this node
  25607. * @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)
  25608. * @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
  25609. * @returns an array of AbstractMesh
  25610. */
  25611. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  25612. /**
  25613. * Get all direct children of this node
  25614. * @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
  25615. * @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)
  25616. * @returns an array of Node
  25617. */
  25618. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  25619. /** @hidden */
  25620. _setReady(state: boolean): void;
  25621. /**
  25622. * Get an animation by name
  25623. * @param name defines the name of the animation to look for
  25624. * @returns null if not found else the requested animation
  25625. */
  25626. getAnimationByName(name: string): Nullable<Animation>;
  25627. /**
  25628. * Creates an animation range for this node
  25629. * @param name defines the name of the range
  25630. * @param from defines the starting key
  25631. * @param to defines the end key
  25632. */
  25633. createAnimationRange(name: string, from: number, to: number): void;
  25634. /**
  25635. * Delete a specific animation range
  25636. * @param name defines the name of the range to delete
  25637. * @param deleteFrames defines if animation frames from the range must be deleted as well
  25638. */
  25639. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  25640. /**
  25641. * Get an animation range by name
  25642. * @param name defines the name of the animation range to look for
  25643. * @returns null if not found else the requested animation range
  25644. */
  25645. getAnimationRange(name: string): Nullable<AnimationRange>;
  25646. /**
  25647. * Gets the list of all animation ranges defined on this node
  25648. * @returns an array
  25649. */
  25650. getAnimationRanges(): Nullable<AnimationRange>[];
  25651. /**
  25652. * Will start the animation sequence
  25653. * @param name defines the range frames for animation sequence
  25654. * @param loop defines if the animation should loop (false by default)
  25655. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  25656. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  25657. * @returns the object created for this animation. If range does not exist, it will return null
  25658. */
  25659. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  25660. /**
  25661. * Serialize animation ranges into a JSON compatible object
  25662. * @returns serialization object
  25663. */
  25664. serializeAnimationRanges(): any;
  25665. /**
  25666. * Computes the world matrix of the node
  25667. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  25668. * @returns the world matrix
  25669. */
  25670. computeWorldMatrix(force?: boolean): Matrix;
  25671. /**
  25672. * Releases resources associated with this node.
  25673. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25674. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25675. */
  25676. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25677. /**
  25678. * Parse animation range data from a serialization object and store them into a given node
  25679. * @param node defines where to store the animation ranges
  25680. * @param parsedNode defines the serialization object to read data from
  25681. * @param scene defines the hosting scene
  25682. */
  25683. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  25684. /**
  25685. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  25686. * @param includeDescendants Include bounding info from descendants as well (true by default)
  25687. * @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
  25688. * @returns the new bounding vectors
  25689. */
  25690. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  25691. min: Vector3;
  25692. max: Vector3;
  25693. };
  25694. }
  25695. }
  25696. declare module BABYLON {
  25697. /**
  25698. * @hidden
  25699. */
  25700. export class _IAnimationState {
  25701. key: number;
  25702. repeatCount: number;
  25703. workValue?: any;
  25704. loopMode?: number;
  25705. offsetValue?: any;
  25706. highLimitValue?: any;
  25707. }
  25708. /**
  25709. * Class used to store any kind of animation
  25710. */
  25711. export class Animation {
  25712. /**Name of the animation */
  25713. name: string;
  25714. /**Property to animate */
  25715. targetProperty: string;
  25716. /**The frames per second of the animation */
  25717. framePerSecond: number;
  25718. /**The data type of the animation */
  25719. dataType: number;
  25720. /**The loop mode of the animation */
  25721. loopMode?: number | undefined;
  25722. /**Specifies if blending should be enabled */
  25723. enableBlending?: boolean | undefined;
  25724. /**
  25725. * Use matrix interpolation instead of using direct key value when animating matrices
  25726. */
  25727. static AllowMatricesInterpolation: boolean;
  25728. /**
  25729. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  25730. */
  25731. static AllowMatrixDecomposeForInterpolation: boolean;
  25732. /**
  25733. * Stores the key frames of the animation
  25734. */
  25735. private _keys;
  25736. /**
  25737. * Stores the easing function of the animation
  25738. */
  25739. private _easingFunction;
  25740. /**
  25741. * @hidden Internal use only
  25742. */
  25743. _runtimeAnimations: RuntimeAnimation[];
  25744. /**
  25745. * The set of event that will be linked to this animation
  25746. */
  25747. private _events;
  25748. /**
  25749. * Stores an array of target property paths
  25750. */
  25751. targetPropertyPath: string[];
  25752. /**
  25753. * Stores the blending speed of the animation
  25754. */
  25755. blendingSpeed: number;
  25756. /**
  25757. * Stores the animation ranges for the animation
  25758. */
  25759. private _ranges;
  25760. /**
  25761. * @hidden Internal use
  25762. */
  25763. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  25764. /**
  25765. * Sets up an animation
  25766. * @param property The property to animate
  25767. * @param animationType The animation type to apply
  25768. * @param framePerSecond The frames per second of the animation
  25769. * @param easingFunction The easing function used in the animation
  25770. * @returns The created animation
  25771. */
  25772. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  25773. /**
  25774. * Create and start an animation on a node
  25775. * @param name defines the name of the global animation that will be run on all nodes
  25776. * @param node defines the root node where the animation will take place
  25777. * @param targetProperty defines property to animate
  25778. * @param framePerSecond defines the number of frame per second yo use
  25779. * @param totalFrame defines the number of frames in total
  25780. * @param from defines the initial value
  25781. * @param to defines the final value
  25782. * @param loopMode defines which loop mode you want to use (off by default)
  25783. * @param easingFunction defines the easing function to use (linear by default)
  25784. * @param onAnimationEnd defines the callback to call when animation end
  25785. * @returns the animatable created for this animation
  25786. */
  25787. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  25788. /**
  25789. * Create and start an animation on a node and its descendants
  25790. * @param name defines the name of the global animation that will be run on all nodes
  25791. * @param node defines the root node where the animation will take place
  25792. * @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
  25793. * @param targetProperty defines property to animate
  25794. * @param framePerSecond defines the number of frame per second to use
  25795. * @param totalFrame defines the number of frames in total
  25796. * @param from defines the initial value
  25797. * @param to defines the final value
  25798. * @param loopMode defines which loop mode you want to use (off by default)
  25799. * @param easingFunction defines the easing function to use (linear by default)
  25800. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  25801. * @returns the list of animatables created for all nodes
  25802. * @example https://www.babylonjs-playground.com/#MH0VLI
  25803. */
  25804. 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[]>;
  25805. /**
  25806. * Creates a new animation, merges it with the existing animations and starts it
  25807. * @param name Name of the animation
  25808. * @param node Node which contains the scene that begins the animations
  25809. * @param targetProperty Specifies which property to animate
  25810. * @param framePerSecond The frames per second of the animation
  25811. * @param totalFrame The total number of frames
  25812. * @param from The frame at the beginning of the animation
  25813. * @param to The frame at the end of the animation
  25814. * @param loopMode Specifies the loop mode of the animation
  25815. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  25816. * @param onAnimationEnd Callback to run once the animation is complete
  25817. * @returns Nullable animation
  25818. */
  25819. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  25820. /**
  25821. * Transition property of an host to the target Value
  25822. * @param property The property to transition
  25823. * @param targetValue The target Value of the property
  25824. * @param host The object where the property to animate belongs
  25825. * @param scene Scene used to run the animation
  25826. * @param frameRate Framerate (in frame/s) to use
  25827. * @param transition The transition type we want to use
  25828. * @param duration The duration of the animation, in milliseconds
  25829. * @param onAnimationEnd Callback trigger at the end of the animation
  25830. * @returns Nullable animation
  25831. */
  25832. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  25833. /**
  25834. * Return the array of runtime animations currently using this animation
  25835. */
  25836. readonly runtimeAnimations: RuntimeAnimation[];
  25837. /**
  25838. * Specifies if any of the runtime animations are currently running
  25839. */
  25840. readonly hasRunningRuntimeAnimations: boolean;
  25841. /**
  25842. * Initializes the animation
  25843. * @param name Name of the animation
  25844. * @param targetProperty Property to animate
  25845. * @param framePerSecond The frames per second of the animation
  25846. * @param dataType The data type of the animation
  25847. * @param loopMode The loop mode of the animation
  25848. * @param enableBlending Specifies if blending should be enabled
  25849. */
  25850. constructor(
  25851. /**Name of the animation */
  25852. name: string,
  25853. /**Property to animate */
  25854. targetProperty: string,
  25855. /**The frames per second of the animation */
  25856. framePerSecond: number,
  25857. /**The data type of the animation */
  25858. dataType: number,
  25859. /**The loop mode of the animation */
  25860. loopMode?: number | undefined,
  25861. /**Specifies if blending should be enabled */
  25862. enableBlending?: boolean | undefined);
  25863. /**
  25864. * Converts the animation to a string
  25865. * @param fullDetails support for multiple levels of logging within scene loading
  25866. * @returns String form of the animation
  25867. */
  25868. toString(fullDetails?: boolean): string;
  25869. /**
  25870. * Add an event to this animation
  25871. * @param event Event to add
  25872. */
  25873. addEvent(event: AnimationEvent): void;
  25874. /**
  25875. * Remove all events found at the given frame
  25876. * @param frame The frame to remove events from
  25877. */
  25878. removeEvents(frame: number): void;
  25879. /**
  25880. * Retrieves all the events from the animation
  25881. * @returns Events from the animation
  25882. */
  25883. getEvents(): AnimationEvent[];
  25884. /**
  25885. * Creates an animation range
  25886. * @param name Name of the animation range
  25887. * @param from Starting frame of the animation range
  25888. * @param to Ending frame of the animation
  25889. */
  25890. createRange(name: string, from: number, to: number): void;
  25891. /**
  25892. * Deletes an animation range by name
  25893. * @param name Name of the animation range to delete
  25894. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  25895. */
  25896. deleteRange(name: string, deleteFrames?: boolean): void;
  25897. /**
  25898. * Gets the animation range by name, or null if not defined
  25899. * @param name Name of the animation range
  25900. * @returns Nullable animation range
  25901. */
  25902. getRange(name: string): Nullable<AnimationRange>;
  25903. /**
  25904. * Gets the key frames from the animation
  25905. * @returns The key frames of the animation
  25906. */
  25907. getKeys(): Array<IAnimationKey>;
  25908. /**
  25909. * Gets the highest frame rate of the animation
  25910. * @returns Highest frame rate of the animation
  25911. */
  25912. getHighestFrame(): number;
  25913. /**
  25914. * Gets the easing function of the animation
  25915. * @returns Easing function of the animation
  25916. */
  25917. getEasingFunction(): IEasingFunction;
  25918. /**
  25919. * Sets the easing function of the animation
  25920. * @param easingFunction A custom mathematical formula for animation
  25921. */
  25922. setEasingFunction(easingFunction: EasingFunction): void;
  25923. /**
  25924. * Interpolates a scalar linearly
  25925. * @param startValue Start value of the animation curve
  25926. * @param endValue End value of the animation curve
  25927. * @param gradient Scalar amount to interpolate
  25928. * @returns Interpolated scalar value
  25929. */
  25930. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  25931. /**
  25932. * Interpolates a scalar cubically
  25933. * @param startValue Start value of the animation curve
  25934. * @param outTangent End tangent of the animation
  25935. * @param endValue End value of the animation curve
  25936. * @param inTangent Start tangent of the animation curve
  25937. * @param gradient Scalar amount to interpolate
  25938. * @returns Interpolated scalar value
  25939. */
  25940. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  25941. /**
  25942. * Interpolates a quaternion using a spherical linear interpolation
  25943. * @param startValue Start value of the animation curve
  25944. * @param endValue End value of the animation curve
  25945. * @param gradient Scalar amount to interpolate
  25946. * @returns Interpolated quaternion value
  25947. */
  25948. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  25949. /**
  25950. * Interpolates a quaternion cubically
  25951. * @param startValue Start value of the animation curve
  25952. * @param outTangent End tangent of the animation curve
  25953. * @param endValue End value of the animation curve
  25954. * @param inTangent Start tangent of the animation curve
  25955. * @param gradient Scalar amount to interpolate
  25956. * @returns Interpolated quaternion value
  25957. */
  25958. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  25959. /**
  25960. * Interpolates a Vector3 linearl
  25961. * @param startValue Start value of the animation curve
  25962. * @param endValue End value of the animation curve
  25963. * @param gradient Scalar amount to interpolate
  25964. * @returns Interpolated scalar value
  25965. */
  25966. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  25967. /**
  25968. * Interpolates a Vector3 cubically
  25969. * @param startValue Start value of the animation curve
  25970. * @param outTangent End tangent of the animation
  25971. * @param endValue End value of the animation curve
  25972. * @param inTangent Start tangent of the animation curve
  25973. * @param gradient Scalar amount to interpolate
  25974. * @returns InterpolatedVector3 value
  25975. */
  25976. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  25977. /**
  25978. * Interpolates a Vector2 linearly
  25979. * @param startValue Start value of the animation curve
  25980. * @param endValue End value of the animation curve
  25981. * @param gradient Scalar amount to interpolate
  25982. * @returns Interpolated Vector2 value
  25983. */
  25984. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  25985. /**
  25986. * Interpolates a Vector2 cubically
  25987. * @param startValue Start value of the animation curve
  25988. * @param outTangent End tangent of the animation
  25989. * @param endValue End value of the animation curve
  25990. * @param inTangent Start tangent of the animation curve
  25991. * @param gradient Scalar amount to interpolate
  25992. * @returns Interpolated Vector2 value
  25993. */
  25994. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  25995. /**
  25996. * Interpolates a size linearly
  25997. * @param startValue Start value of the animation curve
  25998. * @param endValue End value of the animation curve
  25999. * @param gradient Scalar amount to interpolate
  26000. * @returns Interpolated Size value
  26001. */
  26002. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  26003. /**
  26004. * Interpolates a Color3 linearly
  26005. * @param startValue Start value of the animation curve
  26006. * @param endValue End value of the animation curve
  26007. * @param gradient Scalar amount to interpolate
  26008. * @returns Interpolated Color3 value
  26009. */
  26010. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  26011. /**
  26012. * @hidden Internal use only
  26013. */
  26014. _getKeyValue(value: any): any;
  26015. /**
  26016. * @hidden Internal use only
  26017. */
  26018. _interpolate(currentFrame: number, state: _IAnimationState): any;
  26019. /**
  26020. * Defines the function to use to interpolate matrices
  26021. * @param startValue defines the start matrix
  26022. * @param endValue defines the end matrix
  26023. * @param gradient defines the gradient between both matrices
  26024. * @param result defines an optional target matrix where to store the interpolation
  26025. * @returns the interpolated matrix
  26026. */
  26027. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  26028. /**
  26029. * Makes a copy of the animation
  26030. * @returns Cloned animation
  26031. */
  26032. clone(): Animation;
  26033. /**
  26034. * Sets the key frames of the animation
  26035. * @param values The animation key frames to set
  26036. */
  26037. setKeys(values: Array<IAnimationKey>): void;
  26038. /**
  26039. * Serializes the animation to an object
  26040. * @returns Serialized object
  26041. */
  26042. serialize(): any;
  26043. /**
  26044. * Float animation type
  26045. */
  26046. private static _ANIMATIONTYPE_FLOAT;
  26047. /**
  26048. * Vector3 animation type
  26049. */
  26050. private static _ANIMATIONTYPE_VECTOR3;
  26051. /**
  26052. * Quaternion animation type
  26053. */
  26054. private static _ANIMATIONTYPE_QUATERNION;
  26055. /**
  26056. * Matrix animation type
  26057. */
  26058. private static _ANIMATIONTYPE_MATRIX;
  26059. /**
  26060. * Color3 animation type
  26061. */
  26062. private static _ANIMATIONTYPE_COLOR3;
  26063. /**
  26064. * Vector2 animation type
  26065. */
  26066. private static _ANIMATIONTYPE_VECTOR2;
  26067. /**
  26068. * Size animation type
  26069. */
  26070. private static _ANIMATIONTYPE_SIZE;
  26071. /**
  26072. * Relative Loop Mode
  26073. */
  26074. private static _ANIMATIONLOOPMODE_RELATIVE;
  26075. /**
  26076. * Cycle Loop Mode
  26077. */
  26078. private static _ANIMATIONLOOPMODE_CYCLE;
  26079. /**
  26080. * Constant Loop Mode
  26081. */
  26082. private static _ANIMATIONLOOPMODE_CONSTANT;
  26083. /**
  26084. * Get the float animation type
  26085. */
  26086. static readonly ANIMATIONTYPE_FLOAT: number;
  26087. /**
  26088. * Get the Vector3 animation type
  26089. */
  26090. static readonly ANIMATIONTYPE_VECTOR3: number;
  26091. /**
  26092. * Get the Vector2 animation type
  26093. */
  26094. static readonly ANIMATIONTYPE_VECTOR2: number;
  26095. /**
  26096. * Get the Size animation type
  26097. */
  26098. static readonly ANIMATIONTYPE_SIZE: number;
  26099. /**
  26100. * Get the Quaternion animation type
  26101. */
  26102. static readonly ANIMATIONTYPE_QUATERNION: number;
  26103. /**
  26104. * Get the Matrix animation type
  26105. */
  26106. static readonly ANIMATIONTYPE_MATRIX: number;
  26107. /**
  26108. * Get the Color3 animation type
  26109. */
  26110. static readonly ANIMATIONTYPE_COLOR3: number;
  26111. /**
  26112. * Get the Relative Loop Mode
  26113. */
  26114. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  26115. /**
  26116. * Get the Cycle Loop Mode
  26117. */
  26118. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  26119. /**
  26120. * Get the Constant Loop Mode
  26121. */
  26122. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  26123. /** @hidden */
  26124. static _UniversalLerp(left: any, right: any, amount: number): any;
  26125. /**
  26126. * Parses an animation object and creates an animation
  26127. * @param parsedAnimation Parsed animation object
  26128. * @returns Animation object
  26129. */
  26130. static Parse(parsedAnimation: any): Animation;
  26131. /**
  26132. * Appends the serialized animations from the source animations
  26133. * @param source Source containing the animations
  26134. * @param destination Target to store the animations
  26135. */
  26136. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  26137. }
  26138. }
  26139. declare module BABYLON {
  26140. /**
  26141. * Base class of all the textures in babylon.
  26142. * It groups all the common properties the materials, post process, lights... might need
  26143. * in order to make a correct use of the texture.
  26144. */
  26145. export class BaseTexture implements IAnimatable {
  26146. /**
  26147. * Default anisotropic filtering level for the application.
  26148. * It is set to 4 as a good tradeoff between perf and quality.
  26149. */
  26150. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  26151. /**
  26152. * Gets or sets the unique id of the texture
  26153. */
  26154. uniqueId: number;
  26155. /**
  26156. * Define the name of the texture.
  26157. */
  26158. name: string;
  26159. /**
  26160. * Gets or sets an object used to store user defined information.
  26161. */
  26162. metadata: any;
  26163. /**
  26164. * For internal use only. Please do not use.
  26165. */
  26166. reservedDataStore: any;
  26167. private _hasAlpha;
  26168. /**
  26169. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  26170. */
  26171. hasAlpha: boolean;
  26172. /**
  26173. * Defines if the alpha value should be determined via the rgb values.
  26174. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  26175. */
  26176. getAlphaFromRGB: boolean;
  26177. /**
  26178. * Intensity or strength of the texture.
  26179. * It is commonly used by materials to fine tune the intensity of the texture
  26180. */
  26181. level: number;
  26182. /**
  26183. * Define the UV chanel to use starting from 0 and defaulting to 0.
  26184. * This is part of the texture as textures usually maps to one uv set.
  26185. */
  26186. coordinatesIndex: number;
  26187. private _coordinatesMode;
  26188. /**
  26189. * How a texture is mapped.
  26190. *
  26191. * | Value | Type | Description |
  26192. * | ----- | ----------------------------------- | ----------- |
  26193. * | 0 | EXPLICIT_MODE | |
  26194. * | 1 | SPHERICAL_MODE | |
  26195. * | 2 | PLANAR_MODE | |
  26196. * | 3 | CUBIC_MODE | |
  26197. * | 4 | PROJECTION_MODE | |
  26198. * | 5 | SKYBOX_MODE | |
  26199. * | 6 | INVCUBIC_MODE | |
  26200. * | 7 | EQUIRECTANGULAR_MODE | |
  26201. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  26202. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  26203. */
  26204. coordinatesMode: number;
  26205. /**
  26206. * | Value | Type | Description |
  26207. * | ----- | ------------------ | ----------- |
  26208. * | 0 | CLAMP_ADDRESSMODE | |
  26209. * | 1 | WRAP_ADDRESSMODE | |
  26210. * | 2 | MIRROR_ADDRESSMODE | |
  26211. */
  26212. wrapU: number;
  26213. /**
  26214. * | Value | Type | Description |
  26215. * | ----- | ------------------ | ----------- |
  26216. * | 0 | CLAMP_ADDRESSMODE | |
  26217. * | 1 | WRAP_ADDRESSMODE | |
  26218. * | 2 | MIRROR_ADDRESSMODE | |
  26219. */
  26220. wrapV: number;
  26221. /**
  26222. * | Value | Type | Description |
  26223. * | ----- | ------------------ | ----------- |
  26224. * | 0 | CLAMP_ADDRESSMODE | |
  26225. * | 1 | WRAP_ADDRESSMODE | |
  26226. * | 2 | MIRROR_ADDRESSMODE | |
  26227. */
  26228. wrapR: number;
  26229. /**
  26230. * With compliant hardware and browser (supporting anisotropic filtering)
  26231. * this defines the level of anisotropic filtering in the texture.
  26232. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  26233. */
  26234. anisotropicFilteringLevel: number;
  26235. /**
  26236. * Define if the texture is a cube texture or if false a 2d texture.
  26237. */
  26238. isCube: boolean;
  26239. /**
  26240. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  26241. */
  26242. is3D: boolean;
  26243. /**
  26244. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  26245. * HDR texture are usually stored in linear space.
  26246. * This only impacts the PBR and Background materials
  26247. */
  26248. gammaSpace: boolean;
  26249. /**
  26250. * Gets whether or not the texture contains RGBD data.
  26251. */
  26252. readonly isRGBD: boolean;
  26253. /**
  26254. * Is Z inverted in the texture (useful in a cube texture).
  26255. */
  26256. invertZ: boolean;
  26257. /**
  26258. * Are mip maps generated for this texture or not.
  26259. */
  26260. readonly noMipmap: boolean;
  26261. /**
  26262. * @hidden
  26263. */
  26264. lodLevelInAlpha: boolean;
  26265. /**
  26266. * With prefiltered texture, defined the offset used during the prefiltering steps.
  26267. */
  26268. lodGenerationOffset: number;
  26269. /**
  26270. * With prefiltered texture, defined the scale used during the prefiltering steps.
  26271. */
  26272. lodGenerationScale: number;
  26273. /**
  26274. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  26275. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  26276. * average roughness values.
  26277. */
  26278. linearSpecularLOD: boolean;
  26279. /**
  26280. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  26281. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  26282. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  26283. */
  26284. irradianceTexture: Nullable<BaseTexture>;
  26285. /**
  26286. * Define if the texture is a render target.
  26287. */
  26288. isRenderTarget: boolean;
  26289. /**
  26290. * Define the unique id of the texture in the scene.
  26291. */
  26292. readonly uid: string;
  26293. /**
  26294. * Return a string representation of the texture.
  26295. * @returns the texture as a string
  26296. */
  26297. toString(): string;
  26298. /**
  26299. * Get the class name of the texture.
  26300. * @returns "BaseTexture"
  26301. */
  26302. getClassName(): string;
  26303. /**
  26304. * Define the list of animation attached to the texture.
  26305. */
  26306. animations: Animation[];
  26307. /**
  26308. * An event triggered when the texture is disposed.
  26309. */
  26310. onDisposeObservable: Observable<BaseTexture>;
  26311. private _onDisposeObserver;
  26312. /**
  26313. * Callback triggered when the texture has been disposed.
  26314. * Kept for back compatibility, you can use the onDisposeObservable instead.
  26315. */
  26316. onDispose: () => void;
  26317. /**
  26318. * Define the current state of the loading sequence when in delayed load mode.
  26319. */
  26320. delayLoadState: number;
  26321. private _scene;
  26322. /** @hidden */
  26323. _texture: Nullable<InternalTexture>;
  26324. private _uid;
  26325. /**
  26326. * Define if the texture is preventinga material to render or not.
  26327. * If not and the texture is not ready, the engine will use a default black texture instead.
  26328. */
  26329. readonly isBlocking: boolean;
  26330. /**
  26331. * Instantiates a new BaseTexture.
  26332. * Base class of all the textures in babylon.
  26333. * It groups all the common properties the materials, post process, lights... might need
  26334. * in order to make a correct use of the texture.
  26335. * @param scene Define the scene the texture blongs to
  26336. */
  26337. constructor(scene: Nullable<Scene>);
  26338. /**
  26339. * Get the scene the texture belongs to.
  26340. * @returns the scene or null if undefined
  26341. */
  26342. getScene(): Nullable<Scene>;
  26343. /**
  26344. * Get the texture transform matrix used to offset tile the texture for istance.
  26345. * @returns the transformation matrix
  26346. */
  26347. getTextureMatrix(): Matrix;
  26348. /**
  26349. * Get the texture reflection matrix used to rotate/transform the reflection.
  26350. * @returns the reflection matrix
  26351. */
  26352. getReflectionTextureMatrix(): Matrix;
  26353. /**
  26354. * Get the underlying lower level texture from Babylon.
  26355. * @returns the insternal texture
  26356. */
  26357. getInternalTexture(): Nullable<InternalTexture>;
  26358. /**
  26359. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  26360. * @returns true if ready or not blocking
  26361. */
  26362. isReadyOrNotBlocking(): boolean;
  26363. /**
  26364. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  26365. * @returns true if fully ready
  26366. */
  26367. isReady(): boolean;
  26368. private _cachedSize;
  26369. /**
  26370. * Get the size of the texture.
  26371. * @returns the texture size.
  26372. */
  26373. getSize(): ISize;
  26374. /**
  26375. * Get the base size of the texture.
  26376. * It can be different from the size if the texture has been resized for POT for instance
  26377. * @returns the base size
  26378. */
  26379. getBaseSize(): ISize;
  26380. /**
  26381. * Update the sampling mode of the texture.
  26382. * Default is Trilinear mode.
  26383. *
  26384. * | Value | Type | Description |
  26385. * | ----- | ------------------ | ----------- |
  26386. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  26387. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  26388. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  26389. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  26390. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  26391. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  26392. * | 7 | NEAREST_LINEAR | |
  26393. * | 8 | NEAREST_NEAREST | |
  26394. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  26395. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  26396. * | 11 | LINEAR_LINEAR | |
  26397. * | 12 | LINEAR_NEAREST | |
  26398. *
  26399. * > _mag_: magnification filter (close to the viewer)
  26400. * > _min_: minification filter (far from the viewer)
  26401. * > _mip_: filter used between mip map levels
  26402. *@param samplingMode Define the new sampling mode of the texture
  26403. */
  26404. updateSamplingMode(samplingMode: number): void;
  26405. /**
  26406. * Scales the texture if is `canRescale()`
  26407. * @param ratio the resize factor we want to use to rescale
  26408. */
  26409. scale(ratio: number): void;
  26410. /**
  26411. * Get if the texture can rescale.
  26412. */
  26413. readonly canRescale: boolean;
  26414. /** @hidden */
  26415. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  26416. /** @hidden */
  26417. _rebuild(): void;
  26418. /**
  26419. * Triggers the load sequence in delayed load mode.
  26420. */
  26421. delayLoad(): void;
  26422. /**
  26423. * Clones the texture.
  26424. * @returns the cloned texture
  26425. */
  26426. clone(): Nullable<BaseTexture>;
  26427. /**
  26428. * Get the texture underlying type (INT, FLOAT...)
  26429. */
  26430. readonly textureType: number;
  26431. /**
  26432. * Get the texture underlying format (RGB, RGBA...)
  26433. */
  26434. readonly textureFormat: number;
  26435. /**
  26436. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  26437. * This will returns an RGBA array buffer containing either in values (0-255) or
  26438. * float values (0-1) depending of the underlying buffer type.
  26439. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  26440. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  26441. * @param buffer defines a user defined buffer to fill with data (can be null)
  26442. * @returns The Array buffer containing the pixels data.
  26443. */
  26444. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  26445. /**
  26446. * Release and destroy the underlying lower level texture aka internalTexture.
  26447. */
  26448. releaseInternalTexture(): void;
  26449. /**
  26450. * Get the polynomial representation of the texture data.
  26451. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  26452. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  26453. */
  26454. sphericalPolynomial: Nullable<SphericalPolynomial>;
  26455. /** @hidden */
  26456. readonly _lodTextureHigh: Nullable<BaseTexture>;
  26457. /** @hidden */
  26458. readonly _lodTextureMid: Nullable<BaseTexture>;
  26459. /** @hidden */
  26460. readonly _lodTextureLow: Nullable<BaseTexture>;
  26461. /**
  26462. * Dispose the texture and release its associated resources.
  26463. */
  26464. dispose(): void;
  26465. /**
  26466. * Serialize the texture into a JSON representation that can be parsed later on.
  26467. * @returns the JSON representation of the texture
  26468. */
  26469. serialize(): any;
  26470. /**
  26471. * Helper function to be called back once a list of texture contains only ready textures.
  26472. * @param textures Define the list of textures to wait for
  26473. * @param callback Define the callback triggered once the entire list will be ready
  26474. */
  26475. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  26476. }
  26477. }
  26478. declare module BABYLON {
  26479. /**
  26480. * Uniform buffer objects.
  26481. *
  26482. * Handles blocks of uniform on the GPU.
  26483. *
  26484. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  26485. *
  26486. * For more information, please refer to :
  26487. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  26488. */
  26489. export class UniformBuffer {
  26490. private _engine;
  26491. private _buffer;
  26492. private _data;
  26493. private _bufferData;
  26494. private _dynamic?;
  26495. private _uniformLocations;
  26496. private _uniformSizes;
  26497. private _uniformLocationPointer;
  26498. private _needSync;
  26499. private _noUBO;
  26500. private _currentEffect;
  26501. private static _MAX_UNIFORM_SIZE;
  26502. private static _tempBuffer;
  26503. /**
  26504. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  26505. * This is dynamic to allow compat with webgl 1 and 2.
  26506. * You will need to pass the name of the uniform as well as the value.
  26507. */
  26508. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  26509. /**
  26510. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  26511. * This is dynamic to allow compat with webgl 1 and 2.
  26512. * You will need to pass the name of the uniform as well as the value.
  26513. */
  26514. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  26515. /**
  26516. * Lambda to Update a single float in a uniform buffer.
  26517. * This is dynamic to allow compat with webgl 1 and 2.
  26518. * You will need to pass the name of the uniform as well as the value.
  26519. */
  26520. updateFloat: (name: string, x: number) => void;
  26521. /**
  26522. * Lambda to Update a vec2 of float in a uniform buffer.
  26523. * This is dynamic to allow compat with webgl 1 and 2.
  26524. * You will need to pass the name of the uniform as well as the value.
  26525. */
  26526. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  26527. /**
  26528. * Lambda to Update a vec3 of float in a uniform buffer.
  26529. * This is dynamic to allow compat with webgl 1 and 2.
  26530. * You will need to pass the name of the uniform as well as the value.
  26531. */
  26532. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  26533. /**
  26534. * Lambda to Update a vec4 of float in a uniform buffer.
  26535. * This is dynamic to allow compat with webgl 1 and 2.
  26536. * You will need to pass the name of the uniform as well as the value.
  26537. */
  26538. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  26539. /**
  26540. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  26541. * This is dynamic to allow compat with webgl 1 and 2.
  26542. * You will need to pass the name of the uniform as well as the value.
  26543. */
  26544. updateMatrix: (name: string, mat: Matrix) => void;
  26545. /**
  26546. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  26547. * This is dynamic to allow compat with webgl 1 and 2.
  26548. * You will need to pass the name of the uniform as well as the value.
  26549. */
  26550. updateVector3: (name: string, vector: Vector3) => void;
  26551. /**
  26552. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  26553. * This is dynamic to allow compat with webgl 1 and 2.
  26554. * You will need to pass the name of the uniform as well as the value.
  26555. */
  26556. updateVector4: (name: string, vector: Vector4) => void;
  26557. /**
  26558. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  26559. * This is dynamic to allow compat with webgl 1 and 2.
  26560. * You will need to pass the name of the uniform as well as the value.
  26561. */
  26562. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  26563. /**
  26564. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  26565. * This is dynamic to allow compat with webgl 1 and 2.
  26566. * You will need to pass the name of the uniform as well as the value.
  26567. */
  26568. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  26569. /**
  26570. * Instantiates a new Uniform buffer objects.
  26571. *
  26572. * Handles blocks of uniform on the GPU.
  26573. *
  26574. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  26575. *
  26576. * For more information, please refer to :
  26577. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  26578. * @param engine Define the engine the buffer is associated with
  26579. * @param data Define the data contained in the buffer
  26580. * @param dynamic Define if the buffer is updatable
  26581. */
  26582. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  26583. /**
  26584. * Indicates if the buffer is using the WebGL2 UBO implementation,
  26585. * or just falling back on setUniformXXX calls.
  26586. */
  26587. readonly useUbo: boolean;
  26588. /**
  26589. * Indicates if the WebGL underlying uniform buffer is in sync
  26590. * with the javascript cache data.
  26591. */
  26592. readonly isSync: boolean;
  26593. /**
  26594. * Indicates if the WebGL underlying uniform buffer is dynamic.
  26595. * Also, a dynamic UniformBuffer will disable cache verification and always
  26596. * update the underlying WebGL uniform buffer to the GPU.
  26597. * @returns if Dynamic, otherwise false
  26598. */
  26599. isDynamic(): boolean;
  26600. /**
  26601. * The data cache on JS side.
  26602. * @returns the underlying data as a float array
  26603. */
  26604. getData(): Float32Array;
  26605. /**
  26606. * The underlying WebGL Uniform buffer.
  26607. * @returns the webgl buffer
  26608. */
  26609. getBuffer(): Nullable<DataBuffer>;
  26610. /**
  26611. * std140 layout specifies how to align data within an UBO structure.
  26612. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  26613. * for specs.
  26614. */
  26615. private _fillAlignment;
  26616. /**
  26617. * Adds an uniform in the buffer.
  26618. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  26619. * for the layout to be correct !
  26620. * @param name Name of the uniform, as used in the uniform block in the shader.
  26621. * @param size Data size, or data directly.
  26622. */
  26623. addUniform(name: string, size: number | number[]): void;
  26624. /**
  26625. * Adds a Matrix 4x4 to the uniform buffer.
  26626. * @param name Name of the uniform, as used in the uniform block in the shader.
  26627. * @param mat A 4x4 matrix.
  26628. */
  26629. addMatrix(name: string, mat: Matrix): void;
  26630. /**
  26631. * Adds a vec2 to the uniform buffer.
  26632. * @param name Name of the uniform, as used in the uniform block in the shader.
  26633. * @param x Define the x component value of the vec2
  26634. * @param y Define the y component value of the vec2
  26635. */
  26636. addFloat2(name: string, x: number, y: number): void;
  26637. /**
  26638. * Adds a vec3 to the uniform buffer.
  26639. * @param name Name of the uniform, as used in the uniform block in the shader.
  26640. * @param x Define the x component value of the vec3
  26641. * @param y Define the y component value of the vec3
  26642. * @param z Define the z component value of the vec3
  26643. */
  26644. addFloat3(name: string, x: number, y: number, z: number): void;
  26645. /**
  26646. * Adds a vec3 to the uniform buffer.
  26647. * @param name Name of the uniform, as used in the uniform block in the shader.
  26648. * @param color Define the vec3 from a Color
  26649. */
  26650. addColor3(name: string, color: Color3): void;
  26651. /**
  26652. * Adds a vec4 to the uniform buffer.
  26653. * @param name Name of the uniform, as used in the uniform block in the shader.
  26654. * @param color Define the rgb components from a Color
  26655. * @param alpha Define the a component of the vec4
  26656. */
  26657. addColor4(name: string, color: Color3, alpha: number): void;
  26658. /**
  26659. * Adds a vec3 to the uniform buffer.
  26660. * @param name Name of the uniform, as used in the uniform block in the shader.
  26661. * @param vector Define the vec3 components from a Vector
  26662. */
  26663. addVector3(name: string, vector: Vector3): void;
  26664. /**
  26665. * Adds a Matrix 3x3 to the uniform buffer.
  26666. * @param name Name of the uniform, as used in the uniform block in the shader.
  26667. */
  26668. addMatrix3x3(name: string): void;
  26669. /**
  26670. * Adds a Matrix 2x2 to the uniform buffer.
  26671. * @param name Name of the uniform, as used in the uniform block in the shader.
  26672. */
  26673. addMatrix2x2(name: string): void;
  26674. /**
  26675. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  26676. */
  26677. create(): void;
  26678. /** @hidden */
  26679. _rebuild(): void;
  26680. /**
  26681. * Updates the WebGL Uniform Buffer on the GPU.
  26682. * If the `dynamic` flag is set to true, no cache comparison is done.
  26683. * Otherwise, the buffer will be updated only if the cache differs.
  26684. */
  26685. update(): void;
  26686. /**
  26687. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  26688. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  26689. * @param data Define the flattened data
  26690. * @param size Define the size of the data.
  26691. */
  26692. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  26693. private _updateMatrix3x3ForUniform;
  26694. private _updateMatrix3x3ForEffect;
  26695. private _updateMatrix2x2ForEffect;
  26696. private _updateMatrix2x2ForUniform;
  26697. private _updateFloatForEffect;
  26698. private _updateFloatForUniform;
  26699. private _updateFloat2ForEffect;
  26700. private _updateFloat2ForUniform;
  26701. private _updateFloat3ForEffect;
  26702. private _updateFloat3ForUniform;
  26703. private _updateFloat4ForEffect;
  26704. private _updateFloat4ForUniform;
  26705. private _updateMatrixForEffect;
  26706. private _updateMatrixForUniform;
  26707. private _updateVector3ForEffect;
  26708. private _updateVector3ForUniform;
  26709. private _updateVector4ForEffect;
  26710. private _updateVector4ForUniform;
  26711. private _updateColor3ForEffect;
  26712. private _updateColor3ForUniform;
  26713. private _updateColor4ForEffect;
  26714. private _updateColor4ForUniform;
  26715. /**
  26716. * Sets a sampler uniform on the effect.
  26717. * @param name Define the name of the sampler.
  26718. * @param texture Define the texture to set in the sampler
  26719. */
  26720. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  26721. /**
  26722. * Directly updates the value of the uniform in the cache AND on the GPU.
  26723. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  26724. * @param data Define the flattened data
  26725. */
  26726. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  26727. /**
  26728. * Binds this uniform buffer to an effect.
  26729. * @param effect Define the effect to bind the buffer to
  26730. * @param name Name of the uniform block in the shader.
  26731. */
  26732. bindToEffect(effect: Effect, name: string): void;
  26733. /**
  26734. * Disposes the uniform buffer.
  26735. */
  26736. dispose(): void;
  26737. }
  26738. }
  26739. declare module BABYLON {
  26740. /**
  26741. * Class used to work with sound analyzer using fast fourier transform (FFT)
  26742. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26743. */
  26744. export class Analyser {
  26745. /**
  26746. * Gets or sets the smoothing
  26747. * @ignorenaming
  26748. */
  26749. SMOOTHING: number;
  26750. /**
  26751. * Gets or sets the FFT table size
  26752. * @ignorenaming
  26753. */
  26754. FFT_SIZE: number;
  26755. /**
  26756. * Gets or sets the bar graph amplitude
  26757. * @ignorenaming
  26758. */
  26759. BARGRAPHAMPLITUDE: number;
  26760. /**
  26761. * Gets or sets the position of the debug canvas
  26762. * @ignorenaming
  26763. */
  26764. DEBUGCANVASPOS: {
  26765. x: number;
  26766. y: number;
  26767. };
  26768. /**
  26769. * Gets or sets the debug canvas size
  26770. * @ignorenaming
  26771. */
  26772. DEBUGCANVASSIZE: {
  26773. width: number;
  26774. height: number;
  26775. };
  26776. private _byteFreqs;
  26777. private _byteTime;
  26778. private _floatFreqs;
  26779. private _webAudioAnalyser;
  26780. private _debugCanvas;
  26781. private _debugCanvasContext;
  26782. private _scene;
  26783. private _registerFunc;
  26784. private _audioEngine;
  26785. /**
  26786. * Creates a new analyser
  26787. * @param scene defines hosting scene
  26788. */
  26789. constructor(scene: Scene);
  26790. /**
  26791. * Get the number of data values you will have to play with for the visualization
  26792. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  26793. * @returns a number
  26794. */
  26795. getFrequencyBinCount(): number;
  26796. /**
  26797. * Gets the current frequency data as a byte array
  26798. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  26799. * @returns a Uint8Array
  26800. */
  26801. getByteFrequencyData(): Uint8Array;
  26802. /**
  26803. * Gets the current waveform as a byte array
  26804. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  26805. * @returns a Uint8Array
  26806. */
  26807. getByteTimeDomainData(): Uint8Array;
  26808. /**
  26809. * Gets the current frequency data as a float array
  26810. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  26811. * @returns a Float32Array
  26812. */
  26813. getFloatFrequencyData(): Float32Array;
  26814. /**
  26815. * Renders the debug canvas
  26816. */
  26817. drawDebugCanvas(): void;
  26818. /**
  26819. * Stops rendering the debug canvas and removes it
  26820. */
  26821. stopDebugCanvas(): void;
  26822. /**
  26823. * Connects two audio nodes
  26824. * @param inputAudioNode defines first node to connect
  26825. * @param outputAudioNode defines second node to connect
  26826. */
  26827. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  26828. /**
  26829. * Releases all associated resources
  26830. */
  26831. dispose(): void;
  26832. }
  26833. }
  26834. declare module BABYLON {
  26835. /**
  26836. * This represents an audio engine and it is responsible
  26837. * to play, synchronize and analyse sounds throughout the application.
  26838. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26839. */
  26840. export interface IAudioEngine extends IDisposable {
  26841. /**
  26842. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  26843. */
  26844. readonly canUseWebAudio: boolean;
  26845. /**
  26846. * Gets the current AudioContext if available.
  26847. */
  26848. readonly audioContext: Nullable<AudioContext>;
  26849. /**
  26850. * The master gain node defines the global audio volume of your audio engine.
  26851. */
  26852. readonly masterGain: GainNode;
  26853. /**
  26854. * Gets whether or not mp3 are supported by your browser.
  26855. */
  26856. readonly isMP3supported: boolean;
  26857. /**
  26858. * Gets whether or not ogg are supported by your browser.
  26859. */
  26860. readonly isOGGsupported: boolean;
  26861. /**
  26862. * Defines if Babylon should emit a warning if WebAudio is not supported.
  26863. * @ignoreNaming
  26864. */
  26865. WarnedWebAudioUnsupported: boolean;
  26866. /**
  26867. * Defines if the audio engine relies on a custom unlocked button.
  26868. * In this case, the embedded button will not be displayed.
  26869. */
  26870. useCustomUnlockedButton: boolean;
  26871. /**
  26872. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  26873. */
  26874. readonly unlocked: boolean;
  26875. /**
  26876. * Event raised when audio has been unlocked on the browser.
  26877. */
  26878. onAudioUnlockedObservable: Observable<AudioEngine>;
  26879. /**
  26880. * Event raised when audio has been locked on the browser.
  26881. */
  26882. onAudioLockedObservable: Observable<AudioEngine>;
  26883. /**
  26884. * Flags the audio engine in Locked state.
  26885. * This happens due to new browser policies preventing audio to autoplay.
  26886. */
  26887. lock(): void;
  26888. /**
  26889. * Unlocks the audio engine once a user action has been done on the dom.
  26890. * This is helpful to resume play once browser policies have been satisfied.
  26891. */
  26892. unlock(): void;
  26893. }
  26894. /**
  26895. * This represents the default audio engine used in babylon.
  26896. * It is responsible to play, synchronize and analyse sounds throughout the application.
  26897. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26898. */
  26899. export class AudioEngine implements IAudioEngine {
  26900. private _audioContext;
  26901. private _audioContextInitialized;
  26902. private _muteButton;
  26903. private _hostElement;
  26904. /**
  26905. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  26906. */
  26907. canUseWebAudio: boolean;
  26908. /**
  26909. * The master gain node defines the global audio volume of your audio engine.
  26910. */
  26911. masterGain: GainNode;
  26912. /**
  26913. * Defines if Babylon should emit a warning if WebAudio is not supported.
  26914. * @ignoreNaming
  26915. */
  26916. WarnedWebAudioUnsupported: boolean;
  26917. /**
  26918. * Gets whether or not mp3 are supported by your browser.
  26919. */
  26920. isMP3supported: boolean;
  26921. /**
  26922. * Gets whether or not ogg are supported by your browser.
  26923. */
  26924. isOGGsupported: boolean;
  26925. /**
  26926. * Gets whether audio has been unlocked on the device.
  26927. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  26928. * a user interaction has happened.
  26929. */
  26930. unlocked: boolean;
  26931. /**
  26932. * Defines if the audio engine relies on a custom unlocked button.
  26933. * In this case, the embedded button will not be displayed.
  26934. */
  26935. useCustomUnlockedButton: boolean;
  26936. /**
  26937. * Event raised when audio has been unlocked on the browser.
  26938. */
  26939. onAudioUnlockedObservable: Observable<AudioEngine>;
  26940. /**
  26941. * Event raised when audio has been locked on the browser.
  26942. */
  26943. onAudioLockedObservable: Observable<AudioEngine>;
  26944. /**
  26945. * Gets the current AudioContext if available.
  26946. */
  26947. readonly audioContext: Nullable<AudioContext>;
  26948. private _connectedAnalyser;
  26949. /**
  26950. * Instantiates a new audio engine.
  26951. *
  26952. * There should be only one per page as some browsers restrict the number
  26953. * of audio contexts you can create.
  26954. * @param hostElement defines the host element where to display the mute icon if necessary
  26955. */
  26956. constructor(hostElement?: Nullable<HTMLElement>);
  26957. /**
  26958. * Flags the audio engine in Locked state.
  26959. * This happens due to new browser policies preventing audio to autoplay.
  26960. */
  26961. lock(): void;
  26962. /**
  26963. * Unlocks the audio engine once a user action has been done on the dom.
  26964. * This is helpful to resume play once browser policies have been satisfied.
  26965. */
  26966. unlock(): void;
  26967. private _resumeAudioContext;
  26968. private _initializeAudioContext;
  26969. private _tryToRun;
  26970. private _triggerRunningState;
  26971. private _triggerSuspendedState;
  26972. private _displayMuteButton;
  26973. private _moveButtonToTopLeft;
  26974. private _onResize;
  26975. private _hideMuteButton;
  26976. /**
  26977. * Destroy and release the resources associated with the audio ccontext.
  26978. */
  26979. dispose(): void;
  26980. /**
  26981. * Gets the global volume sets on the master gain.
  26982. * @returns the global volume if set or -1 otherwise
  26983. */
  26984. getGlobalVolume(): number;
  26985. /**
  26986. * Sets the global volume of your experience (sets on the master gain).
  26987. * @param newVolume Defines the new global volume of the application
  26988. */
  26989. setGlobalVolume(newVolume: number): void;
  26990. /**
  26991. * Connect the audio engine to an audio analyser allowing some amazing
  26992. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  26993. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  26994. * @param analyser The analyser to connect to the engine
  26995. */
  26996. connectToAnalyser(analyser: Analyser): void;
  26997. }
  26998. }
  26999. declare module BABYLON {
  27000. /**
  27001. * Interface used to present a loading screen while loading a scene
  27002. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  27003. */
  27004. export interface ILoadingScreen {
  27005. /**
  27006. * Function called to display the loading screen
  27007. */
  27008. displayLoadingUI: () => void;
  27009. /**
  27010. * Function called to hide the loading screen
  27011. */
  27012. hideLoadingUI: () => void;
  27013. /**
  27014. * Gets or sets the color to use for the background
  27015. */
  27016. loadingUIBackgroundColor: string;
  27017. /**
  27018. * Gets or sets the text to display while loading
  27019. */
  27020. loadingUIText: string;
  27021. }
  27022. /**
  27023. * Class used for the default loading screen
  27024. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  27025. */
  27026. export class DefaultLoadingScreen implements ILoadingScreen {
  27027. private _renderingCanvas;
  27028. private _loadingText;
  27029. private _loadingDivBackgroundColor;
  27030. private _loadingDiv;
  27031. private _loadingTextDiv;
  27032. /** Gets or sets the logo url to use for the default loading screen */
  27033. static DefaultLogoUrl: string;
  27034. /** Gets or sets the spinner url to use for the default loading screen */
  27035. static DefaultSpinnerUrl: string;
  27036. /**
  27037. * Creates a new default loading screen
  27038. * @param _renderingCanvas defines the canvas used to render the scene
  27039. * @param _loadingText defines the default text to display
  27040. * @param _loadingDivBackgroundColor defines the default background color
  27041. */
  27042. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  27043. /**
  27044. * Function called to display the loading screen
  27045. */
  27046. displayLoadingUI(): void;
  27047. /**
  27048. * Function called to hide the loading screen
  27049. */
  27050. hideLoadingUI(): void;
  27051. /**
  27052. * Gets or sets the text to display while loading
  27053. */
  27054. loadingUIText: string;
  27055. /**
  27056. * Gets or sets the color to use for the background
  27057. */
  27058. loadingUIBackgroundColor: string;
  27059. private _resizeLoadingUI;
  27060. }
  27061. }
  27062. declare module BABYLON {
  27063. /** @hidden */
  27064. export class WebGLPipelineContext implements IPipelineContext {
  27065. engine: Engine;
  27066. program: Nullable<WebGLProgram>;
  27067. context?: WebGLRenderingContext;
  27068. vertexShader?: WebGLShader;
  27069. fragmentShader?: WebGLShader;
  27070. isParallelCompiled: boolean;
  27071. onCompiled?: () => void;
  27072. transformFeedback?: WebGLTransformFeedback | null;
  27073. readonly isAsync: boolean;
  27074. readonly isReady: boolean;
  27075. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  27076. }
  27077. }
  27078. declare module BABYLON {
  27079. /** @hidden */
  27080. export class WebGLDataBuffer extends DataBuffer {
  27081. private _buffer;
  27082. constructor(resource: WebGLBuffer);
  27083. readonly underlyingResource: any;
  27084. }
  27085. }
  27086. declare module BABYLON {
  27087. /** @hidden */
  27088. export class WebGL2ShaderProcessor implements IShaderProcessor {
  27089. attributeProcessor(attribute: string): string;
  27090. varyingProcessor(varying: string, isFragment: boolean): string;
  27091. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  27092. }
  27093. }
  27094. declare module BABYLON {
  27095. /**
  27096. * Settings for finer control over video usage
  27097. */
  27098. export interface VideoTextureSettings {
  27099. /**
  27100. * Applies `autoplay` to video, if specified
  27101. */
  27102. autoPlay?: boolean;
  27103. /**
  27104. * Applies `loop` to video, if specified
  27105. */
  27106. loop?: boolean;
  27107. /**
  27108. * Automatically updates internal texture from video at every frame in the render loop
  27109. */
  27110. autoUpdateTexture: boolean;
  27111. /**
  27112. * Image src displayed during the video loading or until the user interacts with the video.
  27113. */
  27114. poster?: string;
  27115. }
  27116. /**
  27117. * If you want to display a video in your scene, this is the special texture for that.
  27118. * This special texture works similar to other textures, with the exception of a few parameters.
  27119. * @see https://doc.babylonjs.com/how_to/video_texture
  27120. */
  27121. export class VideoTexture extends Texture {
  27122. /**
  27123. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  27124. */
  27125. readonly autoUpdateTexture: boolean;
  27126. /**
  27127. * The video instance used by the texture internally
  27128. */
  27129. readonly video: HTMLVideoElement;
  27130. private _onUserActionRequestedObservable;
  27131. /**
  27132. * Event triggerd when a dom action is required by the user to play the video.
  27133. * This happens due to recent changes in browser policies preventing video to auto start.
  27134. */
  27135. readonly onUserActionRequestedObservable: Observable<Texture>;
  27136. private _generateMipMaps;
  27137. private _engine;
  27138. private _stillImageCaptured;
  27139. private _displayingPosterTexture;
  27140. private _settings;
  27141. private _createInternalTextureOnEvent;
  27142. /**
  27143. * Creates a video texture.
  27144. * If you want to display a video in your scene, this is the special texture for that.
  27145. * This special texture works similar to other textures, with the exception of a few parameters.
  27146. * @see https://doc.babylonjs.com/how_to/video_texture
  27147. * @param name optional name, will detect from video source, if not defined
  27148. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  27149. * @param scene is obviously the current scene.
  27150. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  27151. * @param invertY is false by default but can be used to invert video on Y axis
  27152. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  27153. * @param settings allows finer control over video usage
  27154. */
  27155. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  27156. private _getName;
  27157. private _getVideo;
  27158. private _createInternalTexture;
  27159. private reset;
  27160. /**
  27161. * @hidden Internal method to initiate `update`.
  27162. */
  27163. _rebuild(): void;
  27164. /**
  27165. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  27166. */
  27167. update(): void;
  27168. /**
  27169. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  27170. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  27171. */
  27172. updateTexture(isVisible: boolean): void;
  27173. protected _updateInternalTexture: () => void;
  27174. /**
  27175. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  27176. * @param url New url.
  27177. */
  27178. updateURL(url: string): void;
  27179. /**
  27180. * Dispose the texture and release its associated resources.
  27181. */
  27182. dispose(): void;
  27183. /**
  27184. * Creates a video texture straight from a stream.
  27185. * @param scene Define the scene the texture should be created in
  27186. * @param stream Define the stream the texture should be created from
  27187. * @returns The created video texture as a promise
  27188. */
  27189. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  27190. /**
  27191. * Creates a video texture straight from your WebCam video feed.
  27192. * @param scene Define the scene the texture should be created in
  27193. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  27194. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  27195. * @returns The created video texture as a promise
  27196. */
  27197. static CreateFromWebCamAsync(scene: Scene, constraints: {
  27198. minWidth: number;
  27199. maxWidth: number;
  27200. minHeight: number;
  27201. maxHeight: number;
  27202. deviceId: string;
  27203. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  27204. /**
  27205. * Creates a video texture straight from your WebCam video feed.
  27206. * @param scene Define the scene the texture should be created in
  27207. * @param onReady Define a callback to triggered once the texture will be ready
  27208. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  27209. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  27210. */
  27211. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  27212. minWidth: number;
  27213. maxWidth: number;
  27214. minHeight: number;
  27215. maxHeight: number;
  27216. deviceId: string;
  27217. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  27218. }
  27219. }
  27220. declare module BABYLON {
  27221. /**
  27222. * Interface for attribute information associated with buffer instanciation
  27223. */
  27224. export class InstancingAttributeInfo {
  27225. /**
  27226. * Index/offset of the attribute in the vertex shader
  27227. */
  27228. index: number;
  27229. /**
  27230. * size of the attribute, 1, 2, 3 or 4
  27231. */
  27232. attributeSize: number;
  27233. /**
  27234. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  27235. * default is FLOAT
  27236. */
  27237. attribyteType: number;
  27238. /**
  27239. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  27240. */
  27241. normalized: boolean;
  27242. /**
  27243. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  27244. */
  27245. offset: number;
  27246. /**
  27247. * Name of the GLSL attribute, for debugging purpose only
  27248. */
  27249. attributeName: string;
  27250. }
  27251. /**
  27252. * Define options used to create a depth texture
  27253. */
  27254. export class DepthTextureCreationOptions {
  27255. /** Specifies whether or not a stencil should be allocated in the texture */
  27256. generateStencil?: boolean;
  27257. /** Specifies whether or not bilinear filtering is enable on the texture */
  27258. bilinearFiltering?: boolean;
  27259. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  27260. comparisonFunction?: number;
  27261. /** Specifies if the created texture is a cube texture */
  27262. isCube?: boolean;
  27263. }
  27264. /**
  27265. * Class used to describe the capabilities of the engine relatively to the current browser
  27266. */
  27267. export class EngineCapabilities {
  27268. /** Maximum textures units per fragment shader */
  27269. maxTexturesImageUnits: number;
  27270. /** Maximum texture units per vertex shader */
  27271. maxVertexTextureImageUnits: number;
  27272. /** Maximum textures units in the entire pipeline */
  27273. maxCombinedTexturesImageUnits: number;
  27274. /** Maximum texture size */
  27275. maxTextureSize: number;
  27276. /** Maximum cube texture size */
  27277. maxCubemapTextureSize: number;
  27278. /** Maximum render texture size */
  27279. maxRenderTextureSize: number;
  27280. /** Maximum number of vertex attributes */
  27281. maxVertexAttribs: number;
  27282. /** Maximum number of varyings */
  27283. maxVaryingVectors: number;
  27284. /** Maximum number of uniforms per vertex shader */
  27285. maxVertexUniformVectors: number;
  27286. /** Maximum number of uniforms per fragment shader */
  27287. maxFragmentUniformVectors: number;
  27288. /** Defines if standard derivates (dx/dy) are supported */
  27289. standardDerivatives: boolean;
  27290. /** Defines if s3tc texture compression is supported */
  27291. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  27292. /** Defines if pvrtc texture compression is supported */
  27293. pvrtc: any;
  27294. /** Defines if etc1 texture compression is supported */
  27295. etc1: any;
  27296. /** Defines if etc2 texture compression is supported */
  27297. etc2: any;
  27298. /** Defines if astc texture compression is supported */
  27299. astc: any;
  27300. /** Defines if float textures are supported */
  27301. textureFloat: boolean;
  27302. /** Defines if vertex array objects are supported */
  27303. vertexArrayObject: boolean;
  27304. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  27305. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  27306. /** Gets the maximum level of anisotropy supported */
  27307. maxAnisotropy: number;
  27308. /** Defines if instancing is supported */
  27309. instancedArrays: boolean;
  27310. /** Defines if 32 bits indices are supported */
  27311. uintIndices: boolean;
  27312. /** Defines if high precision shaders are supported */
  27313. highPrecisionShaderSupported: boolean;
  27314. /** Defines if depth reading in the fragment shader is supported */
  27315. fragmentDepthSupported: boolean;
  27316. /** Defines if float texture linear filtering is supported*/
  27317. textureFloatLinearFiltering: boolean;
  27318. /** Defines if rendering to float textures is supported */
  27319. textureFloatRender: boolean;
  27320. /** Defines if half float textures are supported*/
  27321. textureHalfFloat: boolean;
  27322. /** Defines if half float texture linear filtering is supported*/
  27323. textureHalfFloatLinearFiltering: boolean;
  27324. /** Defines if rendering to half float textures is supported */
  27325. textureHalfFloatRender: boolean;
  27326. /** Defines if textureLOD shader command is supported */
  27327. textureLOD: boolean;
  27328. /** Defines if draw buffers extension is supported */
  27329. drawBuffersExtension: boolean;
  27330. /** Defines if depth textures are supported */
  27331. depthTextureExtension: boolean;
  27332. /** Defines if float color buffer are supported */
  27333. colorBufferFloat: boolean;
  27334. /** Gets disjoint timer query extension (null if not supported) */
  27335. timerQuery: EXT_disjoint_timer_query;
  27336. /** Defines if timestamp can be used with timer query */
  27337. canUseTimestampForTimerQuery: boolean;
  27338. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  27339. multiview: any;
  27340. /** Function used to let the system compiles shaders in background */
  27341. parallelShaderCompile: {
  27342. COMPLETION_STATUS_KHR: number;
  27343. };
  27344. }
  27345. /** Interface defining initialization parameters for Engine class */
  27346. export interface EngineOptions extends WebGLContextAttributes {
  27347. /**
  27348. * Defines if the engine should no exceed a specified device ratio
  27349. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  27350. */
  27351. limitDeviceRatio?: number;
  27352. /**
  27353. * Defines if webvr should be enabled automatically
  27354. * @see http://doc.babylonjs.com/how_to/webvr_camera
  27355. */
  27356. autoEnableWebVR?: boolean;
  27357. /**
  27358. * Defines if webgl2 should be turned off even if supported
  27359. * @see http://doc.babylonjs.com/features/webgl2
  27360. */
  27361. disableWebGL2Support?: boolean;
  27362. /**
  27363. * Defines if webaudio should be initialized as well
  27364. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27365. */
  27366. audioEngine?: boolean;
  27367. /**
  27368. * Defines if animations should run using a deterministic lock step
  27369. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  27370. */
  27371. deterministicLockstep?: boolean;
  27372. /** Defines the maximum steps to use with deterministic lock step mode */
  27373. lockstepMaxSteps?: number;
  27374. /**
  27375. * Defines that engine should ignore context lost events
  27376. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  27377. */
  27378. doNotHandleContextLost?: boolean;
  27379. /**
  27380. * Defines that engine should ignore modifying touch action attribute and style
  27381. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  27382. */
  27383. doNotHandleTouchAction?: boolean;
  27384. /**
  27385. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  27386. */
  27387. useHighPrecisionFloats?: boolean;
  27388. }
  27389. /**
  27390. * Defines the interface used by display changed events
  27391. */
  27392. export interface IDisplayChangedEventArgs {
  27393. /** Gets the vrDisplay object (if any) */
  27394. vrDisplay: Nullable<any>;
  27395. /** Gets a boolean indicating if webVR is supported */
  27396. vrSupported: boolean;
  27397. }
  27398. /**
  27399. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  27400. */
  27401. export class Engine {
  27402. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  27403. static ExceptionList: ({
  27404. key: string;
  27405. capture: string;
  27406. captureConstraint: number;
  27407. targets: string[];
  27408. } | {
  27409. key: string;
  27410. capture: null;
  27411. captureConstraint: null;
  27412. targets: string[];
  27413. })[];
  27414. /** Gets the list of created engines */
  27415. static readonly Instances: Engine[];
  27416. /**
  27417. * Gets the latest created engine
  27418. */
  27419. static readonly LastCreatedEngine: Nullable<Engine>;
  27420. /**
  27421. * Gets the latest created scene
  27422. */
  27423. static readonly LastCreatedScene: Nullable<Scene>;
  27424. /**
  27425. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  27426. * @param flag defines which part of the materials must be marked as dirty
  27427. * @param predicate defines a predicate used to filter which materials should be affected
  27428. */
  27429. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  27430. /** @hidden */
  27431. static _TextureLoaders: IInternalTextureLoader[];
  27432. /** Defines that alpha blending is disabled */
  27433. static readonly ALPHA_DISABLE: number;
  27434. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  27435. static readonly ALPHA_ADD: number;
  27436. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  27437. static readonly ALPHA_COMBINE: number;
  27438. /** Defines that alpha blending to DEST - SRC * DEST */
  27439. static readonly ALPHA_SUBTRACT: number;
  27440. /** Defines that alpha blending to SRC * DEST */
  27441. static readonly ALPHA_MULTIPLY: number;
  27442. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  27443. static readonly ALPHA_MAXIMIZED: number;
  27444. /** Defines that alpha blending to SRC + DEST */
  27445. static readonly ALPHA_ONEONE: number;
  27446. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  27447. static readonly ALPHA_PREMULTIPLIED: number;
  27448. /**
  27449. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  27450. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  27451. */
  27452. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  27453. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  27454. static readonly ALPHA_INTERPOLATE: number;
  27455. /**
  27456. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  27457. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  27458. */
  27459. static readonly ALPHA_SCREENMODE: number;
  27460. /** Defines that the ressource is not delayed*/
  27461. static readonly DELAYLOADSTATE_NONE: number;
  27462. /** Defines that the ressource was successfully delay loaded */
  27463. static readonly DELAYLOADSTATE_LOADED: number;
  27464. /** Defines that the ressource is currently delay loading */
  27465. static readonly DELAYLOADSTATE_LOADING: number;
  27466. /** Defines that the ressource is delayed and has not started loading */
  27467. static readonly DELAYLOADSTATE_NOTLOADED: number;
  27468. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  27469. static readonly NEVER: number;
  27470. /** 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 */
  27471. static readonly ALWAYS: number;
  27472. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  27473. static readonly LESS: number;
  27474. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  27475. static readonly EQUAL: number;
  27476. /** 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 */
  27477. static readonly LEQUAL: number;
  27478. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  27479. static readonly GREATER: number;
  27480. /** 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 */
  27481. static readonly GEQUAL: number;
  27482. /** 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 */
  27483. static readonly NOTEQUAL: number;
  27484. /** Passed to stencilOperation to specify that stencil value must be kept */
  27485. static readonly KEEP: number;
  27486. /** Passed to stencilOperation to specify that stencil value must be replaced */
  27487. static readonly REPLACE: number;
  27488. /** Passed to stencilOperation to specify that stencil value must be incremented */
  27489. static readonly INCR: number;
  27490. /** Passed to stencilOperation to specify that stencil value must be decremented */
  27491. static readonly DECR: number;
  27492. /** Passed to stencilOperation to specify that stencil value must be inverted */
  27493. static readonly INVERT: number;
  27494. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  27495. static readonly INCR_WRAP: number;
  27496. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  27497. static readonly DECR_WRAP: number;
  27498. /** Texture is not repeating outside of 0..1 UVs */
  27499. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  27500. /** Texture is repeating outside of 0..1 UVs */
  27501. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  27502. /** Texture is repeating and mirrored */
  27503. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  27504. /** ALPHA */
  27505. static readonly TEXTUREFORMAT_ALPHA: number;
  27506. /** LUMINANCE */
  27507. static readonly TEXTUREFORMAT_LUMINANCE: number;
  27508. /** LUMINANCE_ALPHA */
  27509. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  27510. /** RGB */
  27511. static readonly TEXTUREFORMAT_RGB: number;
  27512. /** RGBA */
  27513. static readonly TEXTUREFORMAT_RGBA: number;
  27514. /** RED */
  27515. static readonly TEXTUREFORMAT_RED: number;
  27516. /** RED (2nd reference) */
  27517. static readonly TEXTUREFORMAT_R: number;
  27518. /** RG */
  27519. static readonly TEXTUREFORMAT_RG: number;
  27520. /** RED_INTEGER */
  27521. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  27522. /** RED_INTEGER (2nd reference) */
  27523. static readonly TEXTUREFORMAT_R_INTEGER: number;
  27524. /** RG_INTEGER */
  27525. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  27526. /** RGB_INTEGER */
  27527. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  27528. /** RGBA_INTEGER */
  27529. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  27530. /** UNSIGNED_BYTE */
  27531. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  27532. /** UNSIGNED_BYTE (2nd reference) */
  27533. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  27534. /** FLOAT */
  27535. static readonly TEXTURETYPE_FLOAT: number;
  27536. /** HALF_FLOAT */
  27537. static readonly TEXTURETYPE_HALF_FLOAT: number;
  27538. /** BYTE */
  27539. static readonly TEXTURETYPE_BYTE: number;
  27540. /** SHORT */
  27541. static readonly TEXTURETYPE_SHORT: number;
  27542. /** UNSIGNED_SHORT */
  27543. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  27544. /** INT */
  27545. static readonly TEXTURETYPE_INT: number;
  27546. /** UNSIGNED_INT */
  27547. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  27548. /** UNSIGNED_SHORT_4_4_4_4 */
  27549. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  27550. /** UNSIGNED_SHORT_5_5_5_1 */
  27551. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  27552. /** UNSIGNED_SHORT_5_6_5 */
  27553. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  27554. /** UNSIGNED_INT_2_10_10_10_REV */
  27555. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  27556. /** UNSIGNED_INT_24_8 */
  27557. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  27558. /** UNSIGNED_INT_10F_11F_11F_REV */
  27559. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  27560. /** UNSIGNED_INT_5_9_9_9_REV */
  27561. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  27562. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  27563. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  27564. /** nearest is mag = nearest and min = nearest and mip = linear */
  27565. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  27566. /** Bilinear is mag = linear and min = linear and mip = nearest */
  27567. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  27568. /** Trilinear is mag = linear and min = linear and mip = linear */
  27569. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  27570. /** nearest is mag = nearest and min = nearest and mip = linear */
  27571. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  27572. /** Bilinear is mag = linear and min = linear and mip = nearest */
  27573. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  27574. /** Trilinear is mag = linear and min = linear and mip = linear */
  27575. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  27576. /** mag = nearest and min = nearest and mip = nearest */
  27577. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  27578. /** mag = nearest and min = linear and mip = nearest */
  27579. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  27580. /** mag = nearest and min = linear and mip = linear */
  27581. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  27582. /** mag = nearest and min = linear and mip = none */
  27583. static readonly TEXTURE_NEAREST_LINEAR: number;
  27584. /** mag = nearest and min = nearest and mip = none */
  27585. static readonly TEXTURE_NEAREST_NEAREST: number;
  27586. /** mag = linear and min = nearest and mip = nearest */
  27587. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  27588. /** mag = linear and min = nearest and mip = linear */
  27589. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  27590. /** mag = linear and min = linear and mip = none */
  27591. static readonly TEXTURE_LINEAR_LINEAR: number;
  27592. /** mag = linear and min = nearest and mip = none */
  27593. static readonly TEXTURE_LINEAR_NEAREST: number;
  27594. /** Explicit coordinates mode */
  27595. static readonly TEXTURE_EXPLICIT_MODE: number;
  27596. /** Spherical coordinates mode */
  27597. static readonly TEXTURE_SPHERICAL_MODE: number;
  27598. /** Planar coordinates mode */
  27599. static readonly TEXTURE_PLANAR_MODE: number;
  27600. /** Cubic coordinates mode */
  27601. static readonly TEXTURE_CUBIC_MODE: number;
  27602. /** Projection coordinates mode */
  27603. static readonly TEXTURE_PROJECTION_MODE: number;
  27604. /** Skybox coordinates mode */
  27605. static readonly TEXTURE_SKYBOX_MODE: number;
  27606. /** Inverse Cubic coordinates mode */
  27607. static readonly TEXTURE_INVCUBIC_MODE: number;
  27608. /** Equirectangular coordinates mode */
  27609. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  27610. /** Equirectangular Fixed coordinates mode */
  27611. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  27612. /** Equirectangular Fixed Mirrored coordinates mode */
  27613. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  27614. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  27615. static readonly SCALEMODE_FLOOR: number;
  27616. /** Defines that texture rescaling will look for the nearest power of 2 size */
  27617. static readonly SCALEMODE_NEAREST: number;
  27618. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  27619. static readonly SCALEMODE_CEILING: number;
  27620. /**
  27621. * Returns the current npm package of the sdk
  27622. */
  27623. static readonly NpmPackage: string;
  27624. /**
  27625. * Returns the current version of the framework
  27626. */
  27627. static readonly Version: string;
  27628. /**
  27629. * Returns a string describing the current engine
  27630. */
  27631. readonly description: string;
  27632. /**
  27633. * Gets or sets the epsilon value used by collision engine
  27634. */
  27635. static CollisionsEpsilon: number;
  27636. /**
  27637. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  27638. */
  27639. static ShadersRepository: string;
  27640. /**
  27641. * Method called to create the default loading screen.
  27642. * This can be overriden in your own app.
  27643. * @param canvas The rendering canvas element
  27644. * @returns The loading screen
  27645. */
  27646. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  27647. /**
  27648. * Method called to create the default rescale post process on each engine.
  27649. */
  27650. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  27651. /** @hidden */
  27652. _shaderProcessor: IShaderProcessor;
  27653. /**
  27654. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  27655. */
  27656. forcePOTTextures: boolean;
  27657. /**
  27658. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  27659. */
  27660. isFullscreen: boolean;
  27661. /**
  27662. * Gets a boolean indicating if the pointer is currently locked
  27663. */
  27664. isPointerLock: boolean;
  27665. /**
  27666. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  27667. */
  27668. cullBackFaces: boolean;
  27669. /**
  27670. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  27671. */
  27672. renderEvenInBackground: boolean;
  27673. /**
  27674. * Gets or sets a boolean indicating that cache can be kept between frames
  27675. */
  27676. preventCacheWipeBetweenFrames: boolean;
  27677. /**
  27678. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  27679. **/
  27680. enableOfflineSupport: boolean;
  27681. /**
  27682. * 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)
  27683. **/
  27684. disableManifestCheck: boolean;
  27685. /**
  27686. * Gets the list of created scenes
  27687. */
  27688. scenes: Scene[];
  27689. /**
  27690. * Event raised when a new scene is created
  27691. */
  27692. onNewSceneAddedObservable: Observable<Scene>;
  27693. /**
  27694. * Gets the list of created postprocesses
  27695. */
  27696. postProcesses: PostProcess[];
  27697. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  27698. validateShaderPrograms: boolean;
  27699. /**
  27700. * Observable event triggered each time the rendering canvas is resized
  27701. */
  27702. onResizeObservable: Observable<Engine>;
  27703. /**
  27704. * Observable event triggered each time the canvas loses focus
  27705. */
  27706. onCanvasBlurObservable: Observable<Engine>;
  27707. /**
  27708. * Observable event triggered each time the canvas gains focus
  27709. */
  27710. onCanvasFocusObservable: Observable<Engine>;
  27711. /**
  27712. * Observable event triggered each time the canvas receives pointerout event
  27713. */
  27714. onCanvasPointerOutObservable: Observable<PointerEvent>;
  27715. /**
  27716. * Observable event triggered before each texture is initialized
  27717. */
  27718. onBeforeTextureInitObservable: Observable<Texture>;
  27719. /**
  27720. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  27721. */
  27722. disableUniformBuffers: boolean;
  27723. /** @hidden */
  27724. _uniformBuffers: UniformBuffer[];
  27725. /**
  27726. * Gets a boolean indicating that the engine supports uniform buffers
  27727. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  27728. */
  27729. readonly supportsUniformBuffers: boolean;
  27730. /**
  27731. * Observable raised when the engine begins a new frame
  27732. */
  27733. onBeginFrameObservable: Observable<Engine>;
  27734. /**
  27735. * If set, will be used to request the next animation frame for the render loop
  27736. */
  27737. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  27738. /**
  27739. * Observable raised when the engine ends the current frame
  27740. */
  27741. onEndFrameObservable: Observable<Engine>;
  27742. /**
  27743. * Observable raised when the engine is about to compile a shader
  27744. */
  27745. onBeforeShaderCompilationObservable: Observable<Engine>;
  27746. /**
  27747. * Observable raised when the engine has jsut compiled a shader
  27748. */
  27749. onAfterShaderCompilationObservable: Observable<Engine>;
  27750. /** @hidden */
  27751. _gl: WebGLRenderingContext;
  27752. private _renderingCanvas;
  27753. private _windowIsBackground;
  27754. private _webGLVersion;
  27755. protected _highPrecisionShadersAllowed: boolean;
  27756. /** @hidden */
  27757. readonly _shouldUseHighPrecisionShader: boolean;
  27758. /**
  27759. * Gets a boolean indicating that only power of 2 textures are supported
  27760. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  27761. */
  27762. readonly needPOTTextures: boolean;
  27763. /** @hidden */
  27764. _badOS: boolean;
  27765. /** @hidden */
  27766. _badDesktopOS: boolean;
  27767. /**
  27768. * Gets the audio engine
  27769. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27770. * @ignorenaming
  27771. */
  27772. static audioEngine: IAudioEngine;
  27773. /**
  27774. * Default AudioEngine factory responsible of creating the Audio Engine.
  27775. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  27776. */
  27777. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  27778. /**
  27779. * Default offline support factory responsible of creating a tool used to store data locally.
  27780. * By default, this will create a Database object if the workload has been embedded.
  27781. */
  27782. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  27783. private _onFocus;
  27784. private _onBlur;
  27785. private _onCanvasPointerOut;
  27786. private _onCanvasBlur;
  27787. private _onCanvasFocus;
  27788. private _onFullscreenChange;
  27789. private _onPointerLockChange;
  27790. private _hardwareScalingLevel;
  27791. /** @hidden */
  27792. _caps: EngineCapabilities;
  27793. private _pointerLockRequested;
  27794. private _isStencilEnable;
  27795. private _colorWrite;
  27796. private _loadingScreen;
  27797. /** @hidden */
  27798. _drawCalls: PerfCounter;
  27799. private _glVersion;
  27800. private _glRenderer;
  27801. private _glVendor;
  27802. private _videoTextureSupported;
  27803. private _renderingQueueLaunched;
  27804. private _activeRenderLoops;
  27805. private _deterministicLockstep;
  27806. private _lockstepMaxSteps;
  27807. /**
  27808. * Observable signaled when a context lost event is raised
  27809. */
  27810. onContextLostObservable: Observable<Engine>;
  27811. /**
  27812. * Observable signaled when a context restored event is raised
  27813. */
  27814. onContextRestoredObservable: Observable<Engine>;
  27815. private _onContextLost;
  27816. private _onContextRestored;
  27817. private _contextWasLost;
  27818. /** @hidden */
  27819. _doNotHandleContextLost: boolean;
  27820. /**
  27821. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  27822. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  27823. */
  27824. doNotHandleContextLost: boolean;
  27825. private _performanceMonitor;
  27826. private _fps;
  27827. private _deltaTime;
  27828. /**
  27829. * Turn this value on if you want to pause FPS computation when in background
  27830. */
  27831. disablePerformanceMonitorInBackground: boolean;
  27832. /**
  27833. * Gets the performance monitor attached to this engine
  27834. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  27835. */
  27836. readonly performanceMonitor: PerformanceMonitor;
  27837. /**
  27838. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  27839. */
  27840. disableVertexArrayObjects: boolean;
  27841. /** @hidden */
  27842. protected _depthCullingState: _DepthCullingState;
  27843. /** @hidden */
  27844. protected _stencilState: _StencilState;
  27845. /** @hidden */
  27846. protected _alphaState: _AlphaState;
  27847. /** @hidden */
  27848. protected _alphaMode: number;
  27849. /** @hidden */
  27850. _internalTexturesCache: InternalTexture[];
  27851. /** @hidden */
  27852. protected _activeChannel: number;
  27853. private _currentTextureChannel;
  27854. /** @hidden */
  27855. protected _boundTexturesCache: {
  27856. [key: string]: Nullable<InternalTexture>;
  27857. };
  27858. /** @hidden */
  27859. protected _currentEffect: Nullable<Effect>;
  27860. /** @hidden */
  27861. protected _currentProgram: Nullable<WebGLProgram>;
  27862. private _compiledEffects;
  27863. private _vertexAttribArraysEnabled;
  27864. /** @hidden */
  27865. protected _cachedViewport: Nullable<Viewport>;
  27866. private _cachedVertexArrayObject;
  27867. /** @hidden */
  27868. protected _cachedVertexBuffers: any;
  27869. /** @hidden */
  27870. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  27871. /** @hidden */
  27872. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  27873. /** @hidden */
  27874. _currentRenderTarget: Nullable<InternalTexture>;
  27875. private _uintIndicesCurrentlySet;
  27876. private _currentBoundBuffer;
  27877. /** @hidden */
  27878. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  27879. private _currentBufferPointers;
  27880. private _currentInstanceLocations;
  27881. private _currentInstanceBuffers;
  27882. private _textureUnits;
  27883. /** @hidden */
  27884. _workingCanvas: Nullable<HTMLCanvasElement>;
  27885. /** @hidden */
  27886. _workingContext: Nullable<CanvasRenderingContext2D>;
  27887. private _rescalePostProcess;
  27888. private _dummyFramebuffer;
  27889. private _externalData;
  27890. /** @hidden */
  27891. _bindedRenderFunction: any;
  27892. private _vaoRecordInProgress;
  27893. private _mustWipeVertexAttributes;
  27894. private _emptyTexture;
  27895. private _emptyCubeTexture;
  27896. private _emptyTexture3D;
  27897. /** @hidden */
  27898. _frameHandler: number;
  27899. private _nextFreeTextureSlots;
  27900. private _maxSimultaneousTextures;
  27901. private _activeRequests;
  27902. private _texturesSupported;
  27903. /** @hidden */
  27904. _textureFormatInUse: Nullable<string>;
  27905. /**
  27906. * Gets the list of texture formats supported
  27907. */
  27908. readonly texturesSupported: Array<string>;
  27909. /**
  27910. * Gets the list of texture formats in use
  27911. */
  27912. readonly textureFormatInUse: Nullable<string>;
  27913. /**
  27914. * Gets the current viewport
  27915. */
  27916. readonly currentViewport: Nullable<Viewport>;
  27917. /**
  27918. * Gets the default empty texture
  27919. */
  27920. readonly emptyTexture: InternalTexture;
  27921. /**
  27922. * Gets the default empty 3D texture
  27923. */
  27924. readonly emptyTexture3D: InternalTexture;
  27925. /**
  27926. * Gets the default empty cube texture
  27927. */
  27928. readonly emptyCubeTexture: InternalTexture;
  27929. /**
  27930. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  27931. */
  27932. readonly premultipliedAlpha: boolean;
  27933. /**
  27934. * Creates a new engine
  27935. * @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
  27936. * @param antialias defines enable antialiasing (default: false)
  27937. * @param options defines further options to be sent to the getContext() function
  27938. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  27939. */
  27940. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  27941. /**
  27942. * Initializes a webVR display and starts listening to display change events
  27943. * The onVRDisplayChangedObservable will be notified upon these changes
  27944. * @returns The onVRDisplayChangedObservable
  27945. */
  27946. initWebVR(): Observable<IDisplayChangedEventArgs>;
  27947. /** @hidden */
  27948. _prepareVRComponent(): void;
  27949. /** @hidden */
  27950. _connectVREvents(canvas: HTMLCanvasElement, document: any): void;
  27951. /** @hidden */
  27952. _submitVRFrame(): void;
  27953. /**
  27954. * Call this function to leave webVR mode
  27955. * Will do nothing if webVR is not supported or if there is no webVR device
  27956. * @see http://doc.babylonjs.com/how_to/webvr_camera
  27957. */
  27958. disableVR(): void;
  27959. /**
  27960. * Gets a boolean indicating that the system is in VR mode and is presenting
  27961. * @returns true if VR mode is engaged
  27962. */
  27963. isVRPresenting(): boolean;
  27964. /** @hidden */
  27965. _requestVRFrame(): void;
  27966. private _disableTouchAction;
  27967. private _rebuildInternalTextures;
  27968. private _rebuildEffects;
  27969. /**
  27970. * Gets a boolean indicating if all created effects are ready
  27971. * @returns true if all effects are ready
  27972. */
  27973. areAllEffectsReady(): boolean;
  27974. private _rebuildBuffers;
  27975. private _initGLContext;
  27976. /**
  27977. * Gets version of the current webGL context
  27978. */
  27979. readonly webGLVersion: number;
  27980. /**
  27981. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  27982. */
  27983. readonly isStencilEnable: boolean;
  27984. /** @hidden */
  27985. _prepareWorkingCanvas(): void;
  27986. /**
  27987. * Reset the texture cache to empty state
  27988. */
  27989. resetTextureCache(): void;
  27990. /**
  27991. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  27992. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  27993. * @returns true if engine is in deterministic lock step mode
  27994. */
  27995. isDeterministicLockStep(): boolean;
  27996. /**
  27997. * Gets the max steps when engine is running in deterministic lock step
  27998. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  27999. * @returns the max steps
  28000. */
  28001. getLockstepMaxSteps(): number;
  28002. /**
  28003. * Gets an object containing information about the current webGL context
  28004. * @returns an object containing the vender, the renderer and the version of the current webGL context
  28005. */
  28006. getGlInfo(): {
  28007. vendor: string;
  28008. renderer: string;
  28009. version: string;
  28010. };
  28011. /**
  28012. * Gets current aspect ratio
  28013. * @param camera defines the camera to use to get the aspect ratio
  28014. * @param useScreen defines if screen size must be used (or the current render target if any)
  28015. * @returns a number defining the aspect ratio
  28016. */
  28017. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  28018. /**
  28019. * Gets current screen aspect ratio
  28020. * @returns a number defining the aspect ratio
  28021. */
  28022. getScreenAspectRatio(): number;
  28023. /**
  28024. * Gets the current render width
  28025. * @param useScreen defines if screen size must be used (or the current render target if any)
  28026. * @returns a number defining the current render width
  28027. */
  28028. getRenderWidth(useScreen?: boolean): number;
  28029. /**
  28030. * Gets the current render height
  28031. * @param useScreen defines if screen size must be used (or the current render target if any)
  28032. * @returns a number defining the current render height
  28033. */
  28034. getRenderHeight(useScreen?: boolean): number;
  28035. /**
  28036. * Gets the HTML canvas attached with the current webGL context
  28037. * @returns a HTML canvas
  28038. */
  28039. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  28040. /**
  28041. * Gets the client rect of the HTML canvas attached with the current webGL context
  28042. * @returns a client rectanglee
  28043. */
  28044. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  28045. /**
  28046. * Defines the hardware scaling level.
  28047. * By default the hardware scaling level is computed from the window device ratio.
  28048. * if level = 1 then the engine will render at the exact resolution of the canvas. If level = 0.5 then the engine will render at twice the size of the canvas.
  28049. * @param level defines the level to use
  28050. */
  28051. setHardwareScalingLevel(level: number): void;
  28052. /**
  28053. * Gets the current hardware scaling level.
  28054. * By default the hardware scaling level is computed from the window device ratio.
  28055. * 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.
  28056. * @returns a number indicating the current hardware scaling level
  28057. */
  28058. getHardwareScalingLevel(): number;
  28059. /**
  28060. * Gets the list of loaded textures
  28061. * @returns an array containing all loaded textures
  28062. */
  28063. getLoadedTexturesCache(): InternalTexture[];
  28064. /**
  28065. * Gets the object containing all engine capabilities
  28066. * @returns the EngineCapabilities object
  28067. */
  28068. getCaps(): EngineCapabilities;
  28069. /**
  28070. * Gets the current depth function
  28071. * @returns a number defining the depth function
  28072. */
  28073. getDepthFunction(): Nullable<number>;
  28074. /**
  28075. * Sets the current depth function
  28076. * @param depthFunc defines the function to use
  28077. */
  28078. setDepthFunction(depthFunc: number): void;
  28079. /**
  28080. * Sets the current depth function to GREATER
  28081. */
  28082. setDepthFunctionToGreater(): void;
  28083. /**
  28084. * Sets the current depth function to GEQUAL
  28085. */
  28086. setDepthFunctionToGreaterOrEqual(): void;
  28087. /**
  28088. * Sets the current depth function to LESS
  28089. */
  28090. setDepthFunctionToLess(): void;
  28091. private _cachedStencilBuffer;
  28092. private _cachedStencilFunction;
  28093. private _cachedStencilMask;
  28094. private _cachedStencilOperationPass;
  28095. private _cachedStencilOperationFail;
  28096. private _cachedStencilOperationDepthFail;
  28097. private _cachedStencilReference;
  28098. /**
  28099. * Caches the the state of the stencil buffer
  28100. */
  28101. cacheStencilState(): void;
  28102. /**
  28103. * Restores the state of the stencil buffer
  28104. */
  28105. restoreStencilState(): void;
  28106. /**
  28107. * Sets the current depth function to LEQUAL
  28108. */
  28109. setDepthFunctionToLessOrEqual(): void;
  28110. /**
  28111. * Gets a boolean indicating if stencil buffer is enabled
  28112. * @returns the current stencil buffer state
  28113. */
  28114. getStencilBuffer(): boolean;
  28115. /**
  28116. * Enable or disable the stencil buffer
  28117. * @param enable defines if the stencil buffer must be enabled or disabled
  28118. */
  28119. setStencilBuffer(enable: boolean): void;
  28120. /**
  28121. * Gets the current stencil mask
  28122. * @returns a number defining the new stencil mask to use
  28123. */
  28124. getStencilMask(): number;
  28125. /**
  28126. * Sets the current stencil mask
  28127. * @param mask defines the new stencil mask to use
  28128. */
  28129. setStencilMask(mask: number): void;
  28130. /**
  28131. * Gets the current stencil function
  28132. * @returns a number defining the stencil function to use
  28133. */
  28134. getStencilFunction(): number;
  28135. /**
  28136. * Gets the current stencil reference value
  28137. * @returns a number defining the stencil reference value to use
  28138. */
  28139. getStencilFunctionReference(): number;
  28140. /**
  28141. * Gets the current stencil mask
  28142. * @returns a number defining the stencil mask to use
  28143. */
  28144. getStencilFunctionMask(): number;
  28145. /**
  28146. * Sets the current stencil function
  28147. * @param stencilFunc defines the new stencil function to use
  28148. */
  28149. setStencilFunction(stencilFunc: number): void;
  28150. /**
  28151. * Sets the current stencil reference
  28152. * @param reference defines the new stencil reference to use
  28153. */
  28154. setStencilFunctionReference(reference: number): void;
  28155. /**
  28156. * Sets the current stencil mask
  28157. * @param mask defines the new stencil mask to use
  28158. */
  28159. setStencilFunctionMask(mask: number): void;
  28160. /**
  28161. * Gets the current stencil operation when stencil fails
  28162. * @returns a number defining stencil operation to use when stencil fails
  28163. */
  28164. getStencilOperationFail(): number;
  28165. /**
  28166. * Gets the current stencil operation when depth fails
  28167. * @returns a number defining stencil operation to use when depth fails
  28168. */
  28169. getStencilOperationDepthFail(): number;
  28170. /**
  28171. * Gets the current stencil operation when stencil passes
  28172. * @returns a number defining stencil operation to use when stencil passes
  28173. */
  28174. getStencilOperationPass(): number;
  28175. /**
  28176. * Sets the stencil operation to use when stencil fails
  28177. * @param operation defines the stencil operation to use when stencil fails
  28178. */
  28179. setStencilOperationFail(operation: number): void;
  28180. /**
  28181. * Sets the stencil operation to use when depth fails
  28182. * @param operation defines the stencil operation to use when depth fails
  28183. */
  28184. setStencilOperationDepthFail(operation: number): void;
  28185. /**
  28186. * Sets the stencil operation to use when stencil passes
  28187. * @param operation defines the stencil operation to use when stencil passes
  28188. */
  28189. setStencilOperationPass(operation: number): void;
  28190. /**
  28191. * Sets a boolean indicating if the dithering state is enabled or disabled
  28192. * @param value defines the dithering state
  28193. */
  28194. setDitheringState(value: boolean): void;
  28195. /**
  28196. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  28197. * @param value defines the rasterizer state
  28198. */
  28199. setRasterizerState(value: boolean): void;
  28200. /**
  28201. * stop executing a render loop function and remove it from the execution array
  28202. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  28203. */
  28204. stopRenderLoop(renderFunction?: () => void): void;
  28205. /** @hidden */
  28206. _renderLoop(): void;
  28207. /**
  28208. * Register and execute a render loop. The engine can have more than one render function
  28209. * @param renderFunction defines the function to continuously execute
  28210. */
  28211. runRenderLoop(renderFunction: () => void): void;
  28212. /**
  28213. * Toggle full screen mode
  28214. * @param requestPointerLock defines if a pointer lock should be requested from the user
  28215. */
  28216. switchFullscreen(requestPointerLock: boolean): void;
  28217. /**
  28218. * Enters full screen mode
  28219. * @param requestPointerLock defines if a pointer lock should be requested from the user
  28220. */
  28221. enterFullscreen(requestPointerLock: boolean): void;
  28222. /**
  28223. * Exits full screen mode
  28224. */
  28225. exitFullscreen(): void;
  28226. /**
  28227. * Enters Pointerlock mode
  28228. */
  28229. enterPointerlock(): void;
  28230. /**
  28231. * Exits Pointerlock mode
  28232. */
  28233. exitPointerlock(): void;
  28234. /**
  28235. * Clear the current render buffer or the current render target (if any is set up)
  28236. * @param color defines the color to use
  28237. * @param backBuffer defines if the back buffer must be cleared
  28238. * @param depth defines if the depth buffer must be cleared
  28239. * @param stencil defines if the stencil buffer must be cleared
  28240. */
  28241. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  28242. /**
  28243. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  28244. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  28245. * @param y defines the y-coordinate of the corner of the clear rectangle
  28246. * @param width defines the width of the clear rectangle
  28247. * @param height defines the height of the clear rectangle
  28248. * @param clearColor defines the clear color
  28249. */
  28250. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  28251. /**
  28252. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  28253. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  28254. * @param y defines the y-coordinate of the corner of the clear rectangle
  28255. * @param width defines the width of the clear rectangle
  28256. * @param height defines the height of the clear rectangle
  28257. */
  28258. enableScissor(x: number, y: number, width: number, height: number): void;
  28259. /**
  28260. * Disable previously set scissor test rectangle
  28261. */
  28262. disableScissor(): void;
  28263. private _viewportCached;
  28264. /** @hidden */
  28265. _viewport(x: number, y: number, width: number, height: number): void;
  28266. /**
  28267. * Set the WebGL's viewport
  28268. * @param viewport defines the viewport element to be used
  28269. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  28270. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  28271. */
  28272. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  28273. /**
  28274. * Directly set the WebGL Viewport
  28275. * @param x defines the x coordinate of the viewport (in screen space)
  28276. * @param y defines the y coordinate of the viewport (in screen space)
  28277. * @param width defines the width of the viewport (in screen space)
  28278. * @param height defines the height of the viewport (in screen space)
  28279. * @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
  28280. */
  28281. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  28282. /**
  28283. * Begin a new frame
  28284. */
  28285. beginFrame(): void;
  28286. /**
  28287. * Enf the current frame
  28288. */
  28289. endFrame(): void;
  28290. /**
  28291. * Resize the view according to the canvas' size
  28292. */
  28293. resize(): void;
  28294. /**
  28295. * Force a specific size of the canvas
  28296. * @param width defines the new canvas' width
  28297. * @param height defines the new canvas' height
  28298. */
  28299. setSize(width: number, height: number): void;
  28300. /**
  28301. * Binds the frame buffer to the specified texture.
  28302. * @param texture The texture to render to or null for the default canvas
  28303. * @param faceIndex The face of the texture to render to in case of cube texture
  28304. * @param requiredWidth The width of the target to render to
  28305. * @param requiredHeight The height of the target to render to
  28306. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  28307. * @param depthStencilTexture The depth stencil texture to use to render
  28308. * @param lodLevel defines le lod level to bind to the frame buffer
  28309. */
  28310. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  28311. /** @hidden */
  28312. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  28313. /**
  28314. * Unbind the current render target texture from the webGL context
  28315. * @param texture defines the render target texture to unbind
  28316. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  28317. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  28318. */
  28319. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  28320. /**
  28321. * Force the mipmap generation for the given render target texture
  28322. * @param texture defines the render target texture to use
  28323. */
  28324. generateMipMapsForCubemap(texture: InternalTexture): void;
  28325. /**
  28326. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  28327. */
  28328. flushFramebuffer(): void;
  28329. /**
  28330. * Unbind the current render target and bind the default framebuffer
  28331. */
  28332. restoreDefaultFramebuffer(): void;
  28333. /**
  28334. * Create an uniform buffer
  28335. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28336. * @param elements defines the content of the uniform buffer
  28337. * @returns the webGL uniform buffer
  28338. */
  28339. createUniformBuffer(elements: FloatArray): DataBuffer;
  28340. /**
  28341. * Create a dynamic uniform buffer
  28342. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28343. * @param elements defines the content of the uniform buffer
  28344. * @returns the webGL uniform buffer
  28345. */
  28346. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  28347. /**
  28348. * Update an existing uniform buffer
  28349. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28350. * @param uniformBuffer defines the target uniform buffer
  28351. * @param elements defines the content to update
  28352. * @param offset defines the offset in the uniform buffer where update should start
  28353. * @param count defines the size of the data to update
  28354. */
  28355. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  28356. private _resetVertexBufferBinding;
  28357. /**
  28358. * Creates a vertex buffer
  28359. * @param data the data for the vertex buffer
  28360. * @returns the new WebGL static buffer
  28361. */
  28362. createVertexBuffer(data: DataArray): DataBuffer;
  28363. /**
  28364. * Creates a dynamic vertex buffer
  28365. * @param data the data for the dynamic vertex buffer
  28366. * @returns the new WebGL dynamic buffer
  28367. */
  28368. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  28369. /**
  28370. * Update a dynamic index buffer
  28371. * @param indexBuffer defines the target index buffer
  28372. * @param indices defines the data to update
  28373. * @param offset defines the offset in the target index buffer where update should start
  28374. */
  28375. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  28376. /**
  28377. * Updates a dynamic vertex buffer.
  28378. * @param vertexBuffer the vertex buffer to update
  28379. * @param data the data used to update the vertex buffer
  28380. * @param byteOffset the byte offset of the data
  28381. * @param byteLength the byte length of the data
  28382. */
  28383. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  28384. private _resetIndexBufferBinding;
  28385. /**
  28386. * Creates a new index buffer
  28387. * @param indices defines the content of the index buffer
  28388. * @param updatable defines if the index buffer must be updatable
  28389. * @returns a new webGL buffer
  28390. */
  28391. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  28392. /**
  28393. * Bind a webGL buffer to the webGL context
  28394. * @param buffer defines the buffer to bind
  28395. */
  28396. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  28397. /**
  28398. * Bind an uniform buffer to the current webGL context
  28399. * @param buffer defines the buffer to bind
  28400. */
  28401. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  28402. /**
  28403. * Bind a buffer to the current webGL context at a given location
  28404. * @param buffer defines the buffer to bind
  28405. * @param location defines the index where to bind the buffer
  28406. */
  28407. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  28408. /**
  28409. * Bind a specific block at a given index in a specific shader program
  28410. * @param pipelineContext defines the pipeline context to use
  28411. * @param blockName defines the block name
  28412. * @param index defines the index where to bind the block
  28413. */
  28414. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  28415. private bindIndexBuffer;
  28416. private bindBuffer;
  28417. /**
  28418. * update the bound buffer with the given data
  28419. * @param data defines the data to update
  28420. */
  28421. updateArrayBuffer(data: Float32Array): void;
  28422. private _vertexAttribPointer;
  28423. private _bindIndexBufferWithCache;
  28424. private _bindVertexBuffersAttributes;
  28425. /**
  28426. * Records a vertex array object
  28427. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  28428. * @param vertexBuffers defines the list of vertex buffers to store
  28429. * @param indexBuffer defines the index buffer to store
  28430. * @param effect defines the effect to store
  28431. * @returns the new vertex array object
  28432. */
  28433. recordVertexArrayObject(vertexBuffers: {
  28434. [key: string]: VertexBuffer;
  28435. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  28436. /**
  28437. * Bind a specific vertex array object
  28438. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  28439. * @param vertexArrayObject defines the vertex array object to bind
  28440. * @param indexBuffer defines the index buffer to bind
  28441. */
  28442. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  28443. /**
  28444. * Bind webGl buffers directly to the webGL context
  28445. * @param vertexBuffer defines the vertex buffer to bind
  28446. * @param indexBuffer defines the index buffer to bind
  28447. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  28448. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  28449. * @param effect defines the effect associated with the vertex buffer
  28450. */
  28451. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  28452. private _unbindVertexArrayObject;
  28453. /**
  28454. * Bind a list of vertex buffers to the webGL context
  28455. * @param vertexBuffers defines the list of vertex buffers to bind
  28456. * @param indexBuffer defines the index buffer to bind
  28457. * @param effect defines the effect associated with the vertex buffers
  28458. */
  28459. bindBuffers(vertexBuffers: {
  28460. [key: string]: Nullable<VertexBuffer>;
  28461. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  28462. /**
  28463. * Unbind all instance attributes
  28464. */
  28465. unbindInstanceAttributes(): void;
  28466. /**
  28467. * Release and free the memory of a vertex array object
  28468. * @param vao defines the vertex array object to delete
  28469. */
  28470. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  28471. /** @hidden */
  28472. _releaseBuffer(buffer: DataBuffer): boolean;
  28473. /**
  28474. * Creates a webGL buffer to use with instanciation
  28475. * @param capacity defines the size of the buffer
  28476. * @returns the webGL buffer
  28477. */
  28478. createInstancesBuffer(capacity: number): DataBuffer;
  28479. /**
  28480. * Delete a webGL buffer used with instanciation
  28481. * @param buffer defines the webGL buffer to delete
  28482. */
  28483. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  28484. /**
  28485. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  28486. * @param instancesBuffer defines the webGL buffer to update and bind
  28487. * @param data defines the data to store in the buffer
  28488. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  28489. */
  28490. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  28491. /**
  28492. * Apply all cached states (depth, culling, stencil and alpha)
  28493. */
  28494. applyStates(): void;
  28495. /**
  28496. * Send a draw order
  28497. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  28498. * @param indexStart defines the starting index
  28499. * @param indexCount defines the number of index to draw
  28500. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28501. */
  28502. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  28503. /**
  28504. * Draw a list of points
  28505. * @param verticesStart defines the index of first vertex to draw
  28506. * @param verticesCount defines the count of vertices to draw
  28507. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28508. */
  28509. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  28510. /**
  28511. * Draw a list of unindexed primitives
  28512. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  28513. * @param verticesStart defines the index of first vertex to draw
  28514. * @param verticesCount defines the count of vertices to draw
  28515. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28516. */
  28517. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  28518. /**
  28519. * Draw a list of indexed primitives
  28520. * @param fillMode defines the primitive to use
  28521. * @param indexStart defines the starting index
  28522. * @param indexCount defines the number of index to draw
  28523. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28524. */
  28525. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  28526. /**
  28527. * Draw a list of unindexed primitives
  28528. * @param fillMode defines the primitive to use
  28529. * @param verticesStart defines the index of first vertex to draw
  28530. * @param verticesCount defines the count of vertices to draw
  28531. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28532. */
  28533. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  28534. private _drawMode;
  28535. /** @hidden */
  28536. _releaseEffect(effect: Effect): void;
  28537. /** @hidden */
  28538. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  28539. /**
  28540. * Create a new effect (used to store vertex/fragment shaders)
  28541. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  28542. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  28543. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  28544. * @param samplers defines an array of string used to represent textures
  28545. * @param defines defines the string containing the defines to use to compile the shaders
  28546. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  28547. * @param onCompiled defines a function to call when the effect creation is successful
  28548. * @param onError defines a function to call when the effect creation has failed
  28549. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  28550. * @returns the new Effect
  28551. */
  28552. createEffect(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | Engine, samplers?: string[], defines?: string, fallbacks?: EffectFallbacks, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any): Effect;
  28553. private _compileShader;
  28554. private _compileRawShader;
  28555. /**
  28556. * Directly creates a webGL program
  28557. * @param pipelineContext defines the pipeline context to attach to
  28558. * @param vertexCode defines the vertex shader code to use
  28559. * @param fragmentCode defines the fragment shader code to use
  28560. * @param context defines the webGL context to use (if not set, the current one will be used)
  28561. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  28562. * @returns the new webGL program
  28563. */
  28564. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  28565. /**
  28566. * Creates a webGL program
  28567. * @param pipelineContext defines the pipeline context to attach to
  28568. * @param vertexCode defines the vertex shader code to use
  28569. * @param fragmentCode defines the fragment shader code to use
  28570. * @param defines defines the string containing the defines to use to compile the shaders
  28571. * @param context defines the webGL context to use (if not set, the current one will be used)
  28572. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  28573. * @returns the new webGL program
  28574. */
  28575. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  28576. /**
  28577. * Creates a new pipeline context
  28578. * @returns the new pipeline
  28579. */
  28580. createPipelineContext(): WebGLPipelineContext;
  28581. private _createShaderProgram;
  28582. private _finalizePipelineContext;
  28583. /** @hidden */
  28584. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  28585. /** @hidden */
  28586. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  28587. /** @hidden */
  28588. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  28589. /**
  28590. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  28591. * @param pipelineContext defines the pipeline context to use
  28592. * @param uniformsNames defines the list of uniform names
  28593. * @returns an array of webGL uniform locations
  28594. */
  28595. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  28596. /**
  28597. * Gets the lsit of active attributes for a given webGL program
  28598. * @param pipelineContext defines the pipeline context to use
  28599. * @param attributesNames defines the list of attribute names to get
  28600. * @returns an array of indices indicating the offset of each attribute
  28601. */
  28602. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  28603. /**
  28604. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  28605. * @param effect defines the effect to activate
  28606. */
  28607. enableEffect(effect: Nullable<Effect>): void;
  28608. /**
  28609. * Set the value of an uniform to an array of int32
  28610. * @param uniform defines the webGL uniform location where to store the value
  28611. * @param array defines the array of int32 to store
  28612. */
  28613. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28614. /**
  28615. * Set the value of an uniform to an array of int32 (stored as vec2)
  28616. * @param uniform defines the webGL uniform location where to store the value
  28617. * @param array defines the array of int32 to store
  28618. */
  28619. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28620. /**
  28621. * Set the value of an uniform to an array of int32 (stored as vec3)
  28622. * @param uniform defines the webGL uniform location where to store the value
  28623. * @param array defines the array of int32 to store
  28624. */
  28625. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28626. /**
  28627. * Set the value of an uniform to an array of int32 (stored as vec4)
  28628. * @param uniform defines the webGL uniform location where to store the value
  28629. * @param array defines the array of int32 to store
  28630. */
  28631. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28632. /**
  28633. * Set the value of an uniform to an array of float32
  28634. * @param uniform defines the webGL uniform location where to store the value
  28635. * @param array defines the array of float32 to store
  28636. */
  28637. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28638. /**
  28639. * Set the value of an uniform to an array of float32 (stored as vec2)
  28640. * @param uniform defines the webGL uniform location where to store the value
  28641. * @param array defines the array of float32 to store
  28642. */
  28643. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28644. /**
  28645. * Set the value of an uniform to an array of float32 (stored as vec3)
  28646. * @param uniform defines the webGL uniform location where to store the value
  28647. * @param array defines the array of float32 to store
  28648. */
  28649. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28650. /**
  28651. * Set the value of an uniform to an array of float32 (stored as vec4)
  28652. * @param uniform defines the webGL uniform location where to store the value
  28653. * @param array defines the array of float32 to store
  28654. */
  28655. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28656. /**
  28657. * Set the value of an uniform to an array of number
  28658. * @param uniform defines the webGL uniform location where to store the value
  28659. * @param array defines the array of number to store
  28660. */
  28661. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28662. /**
  28663. * Set the value of an uniform to an array of number (stored as vec2)
  28664. * @param uniform defines the webGL uniform location where to store the value
  28665. * @param array defines the array of number to store
  28666. */
  28667. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28668. /**
  28669. * Set the value of an uniform to an array of number (stored as vec3)
  28670. * @param uniform defines the webGL uniform location where to store the value
  28671. * @param array defines the array of number to store
  28672. */
  28673. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28674. /**
  28675. * Set the value of an uniform to an array of number (stored as vec4)
  28676. * @param uniform defines the webGL uniform location where to store the value
  28677. * @param array defines the array of number to store
  28678. */
  28679. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28680. /**
  28681. * Set the value of an uniform to an array of float32 (stored as matrices)
  28682. * @param uniform defines the webGL uniform location where to store the value
  28683. * @param matrices defines the array of float32 to store
  28684. */
  28685. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  28686. /**
  28687. * Set the value of an uniform to a matrix
  28688. * @param uniform defines the webGL uniform location where to store the value
  28689. * @param matrix defines the matrix to store
  28690. */
  28691. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  28692. /**
  28693. * Set the value of an uniform to a matrix (3x3)
  28694. * @param uniform defines the webGL uniform location where to store the value
  28695. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  28696. */
  28697. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  28698. /**
  28699. * Set the value of an uniform to a matrix (2x2)
  28700. * @param uniform defines the webGL uniform location where to store the value
  28701. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  28702. */
  28703. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  28704. /**
  28705. * Set the value of an uniform to a number (int)
  28706. * @param uniform defines the webGL uniform location where to store the value
  28707. * @param value defines the int number to store
  28708. */
  28709. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  28710. /**
  28711. * Set the value of an uniform to a number (float)
  28712. * @param uniform defines the webGL uniform location where to store the value
  28713. * @param value defines the float number to store
  28714. */
  28715. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  28716. /**
  28717. * Set the value of an uniform to a vec2
  28718. * @param uniform defines the webGL uniform location where to store the value
  28719. * @param x defines the 1st component of the value
  28720. * @param y defines the 2nd component of the value
  28721. */
  28722. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  28723. /**
  28724. * Set the value of an uniform to a vec3
  28725. * @param uniform defines the webGL uniform location where to store the value
  28726. * @param x defines the 1st component of the value
  28727. * @param y defines the 2nd component of the value
  28728. * @param z defines the 3rd component of the value
  28729. */
  28730. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  28731. /**
  28732. * Set the value of an uniform to a boolean
  28733. * @param uniform defines the webGL uniform location where to store the value
  28734. * @param bool defines the boolean to store
  28735. */
  28736. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  28737. /**
  28738. * Set the value of an uniform to a vec4
  28739. * @param uniform defines the webGL uniform location where to store the value
  28740. * @param x defines the 1st component of the value
  28741. * @param y defines the 2nd component of the value
  28742. * @param z defines the 3rd component of the value
  28743. * @param w defines the 4th component of the value
  28744. */
  28745. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  28746. /**
  28747. * Set the value of an uniform to a Color3
  28748. * @param uniform defines the webGL uniform location where to store the value
  28749. * @param color3 defines the color to store
  28750. */
  28751. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  28752. /**
  28753. * Set the value of an uniform to a Color3 and an alpha value
  28754. * @param uniform defines the webGL uniform location where to store the value
  28755. * @param color3 defines the color to store
  28756. * @param alpha defines the alpha component to store
  28757. */
  28758. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  28759. /**
  28760. * Sets a Color4 on a uniform variable
  28761. * @param uniform defines the uniform location
  28762. * @param color4 defines the value to be set
  28763. */
  28764. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  28765. /**
  28766. * Set various states to the webGL context
  28767. * @param culling defines backface culling state
  28768. * @param zOffset defines the value to apply to zOffset (0 by default)
  28769. * @param force defines if states must be applied even if cache is up to date
  28770. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  28771. */
  28772. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  28773. /**
  28774. * Set the z offset to apply to current rendering
  28775. * @param value defines the offset to apply
  28776. */
  28777. setZOffset(value: number): void;
  28778. /**
  28779. * Gets the current value of the zOffset
  28780. * @returns the current zOffset state
  28781. */
  28782. getZOffset(): number;
  28783. /**
  28784. * Enable or disable depth buffering
  28785. * @param enable defines the state to set
  28786. */
  28787. setDepthBuffer(enable: boolean): void;
  28788. /**
  28789. * Gets a boolean indicating if depth writing is enabled
  28790. * @returns the current depth writing state
  28791. */
  28792. getDepthWrite(): boolean;
  28793. /**
  28794. * Enable or disable depth writing
  28795. * @param enable defines the state to set
  28796. */
  28797. setDepthWrite(enable: boolean): void;
  28798. /**
  28799. * Enable or disable color writing
  28800. * @param enable defines the state to set
  28801. */
  28802. setColorWrite(enable: boolean): void;
  28803. /**
  28804. * Gets a boolean indicating if color writing is enabled
  28805. * @returns the current color writing state
  28806. */
  28807. getColorWrite(): boolean;
  28808. /**
  28809. * Sets alpha constants used by some alpha blending modes
  28810. * @param r defines the red component
  28811. * @param g defines the green component
  28812. * @param b defines the blue component
  28813. * @param a defines the alpha component
  28814. */
  28815. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  28816. /**
  28817. * Sets the current alpha mode
  28818. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  28819. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  28820. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  28821. */
  28822. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  28823. /**
  28824. * Gets the current alpha mode
  28825. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  28826. * @returns the current alpha mode
  28827. */
  28828. getAlphaMode(): number;
  28829. /**
  28830. * Clears the list of texture accessible through engine.
  28831. * This can help preventing texture load conflict due to name collision.
  28832. */
  28833. clearInternalTexturesCache(): void;
  28834. /**
  28835. * Force the entire cache to be cleared
  28836. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  28837. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  28838. */
  28839. wipeCaches(bruteForce?: boolean): void;
  28840. /**
  28841. * Set the compressed texture format to use, based on the formats you have, and the formats
  28842. * supported by the hardware / browser.
  28843. *
  28844. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  28845. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  28846. * to API arguments needed to compressed textures. This puts the burden on the container
  28847. * generator to house the arcane code for determining these for current & future formats.
  28848. *
  28849. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  28850. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  28851. *
  28852. * Note: The result of this call is not taken into account when a texture is base64.
  28853. *
  28854. * @param formatsAvailable defines the list of those format families you have created
  28855. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  28856. *
  28857. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  28858. * @returns The extension selected.
  28859. */
  28860. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  28861. /** @hidden */
  28862. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  28863. min: number;
  28864. mag: number;
  28865. };
  28866. /** @hidden */
  28867. _createTexture(): WebGLTexture;
  28868. /**
  28869. * Usually called from Texture.ts.
  28870. * Passed information to create a WebGLTexture
  28871. * @param urlArg defines a value which contains one of the following:
  28872. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  28873. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  28874. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  28875. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  28876. * @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)
  28877. * @param scene needed for loading to the correct scene
  28878. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  28879. * @param onLoad optional callback to be called upon successful completion
  28880. * @param onError optional callback to be called upon failure
  28881. * @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
  28882. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  28883. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  28884. * @param forcedExtension defines the extension to use to pick the right loader
  28885. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  28886. * @returns a InternalTexture for assignment back into BABYLON.Texture
  28887. */
  28888. createTexture(urlArg: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<Scene>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, excludeLoaders?: Array<IInternalTextureLoader>): InternalTexture;
  28889. /**
  28890. * @hidden
  28891. * Rescales a texture
  28892. * @param source input texutre
  28893. * @param destination destination texture
  28894. * @param scene scene to use to render the resize
  28895. * @param internalFormat format to use when resizing
  28896. * @param onComplete callback to be called when resize has completed
  28897. */
  28898. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<Scene>, internalFormat: number, onComplete: () => void): void;
  28899. private _unpackFlipYCached;
  28900. /**
  28901. * In case you are sharing the context with other applications, it might
  28902. * be interested to not cache the unpack flip y state to ensure a consistent
  28903. * value would be set.
  28904. */
  28905. enableUnpackFlipYCached: boolean;
  28906. /** @hidden */
  28907. _unpackFlipY(value: boolean): void;
  28908. /** @hidden */
  28909. _getUnpackAlignement(): number;
  28910. /**
  28911. * Creates a dynamic texture
  28912. * @param width defines the width of the texture
  28913. * @param height defines the height of the texture
  28914. * @param generateMipMaps defines if the engine should generate the mip levels
  28915. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  28916. * @returns the dynamic texture inside an InternalTexture
  28917. */
  28918. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  28919. /**
  28920. * Update the sampling mode of a given texture
  28921. * @param samplingMode defines the required sampling mode
  28922. * @param texture defines the texture to update
  28923. */
  28924. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  28925. /**
  28926. * Update the content of a dynamic texture
  28927. * @param texture defines the texture to update
  28928. * @param canvas defines the canvas containing the source
  28929. * @param invertY defines if data must be stored with Y axis inverted
  28930. * @param premulAlpha defines if alpha is stored as premultiplied
  28931. * @param format defines the format of the data
  28932. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  28933. */
  28934. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  28935. /**
  28936. * Update a video texture
  28937. * @param texture defines the texture to update
  28938. * @param video defines the video element to use
  28939. * @param invertY defines if data must be stored with Y axis inverted
  28940. */
  28941. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  28942. /**
  28943. * Updates a depth texture Comparison Mode and Function.
  28944. * If the comparison Function is equal to 0, the mode will be set to none.
  28945. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  28946. * @param texture The texture to set the comparison function for
  28947. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  28948. */
  28949. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  28950. /** @hidden */
  28951. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  28952. width: number;
  28953. height: number;
  28954. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  28955. /**
  28956. * Creates a depth stencil texture.
  28957. * This is only available in WebGL 2 or with the depth texture extension available.
  28958. * @param size The size of face edge in the texture.
  28959. * @param options The options defining the texture.
  28960. * @returns The texture
  28961. */
  28962. createDepthStencilTexture(size: number | {
  28963. width: number;
  28964. height: number;
  28965. }, options: DepthTextureCreationOptions): InternalTexture;
  28966. /**
  28967. * Creates a depth stencil texture.
  28968. * This is only available in WebGL 2 or with the depth texture extension available.
  28969. * @param size The size of face edge in the texture.
  28970. * @param options The options defining the texture.
  28971. * @returns The texture
  28972. */
  28973. private _createDepthStencilTexture;
  28974. /**
  28975. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  28976. * @param renderTarget The render target to set the frame buffer for
  28977. */
  28978. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  28979. /**
  28980. * Creates a new render target texture
  28981. * @param size defines the size of the texture
  28982. * @param options defines the options used to create the texture
  28983. * @returns a new render target texture stored in an InternalTexture
  28984. */
  28985. createRenderTargetTexture(size: number | {
  28986. width: number;
  28987. height: number;
  28988. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  28989. /** @hidden */
  28990. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  28991. /**
  28992. * Updates the sample count of a render target texture
  28993. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  28994. * @param texture defines the texture to update
  28995. * @param samples defines the sample count to set
  28996. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  28997. */
  28998. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  28999. /** @hidden */
  29000. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  29001. /** @hidden */
  29002. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  29003. /** @hidden */
  29004. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  29005. /** @hidden */
  29006. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  29007. /**
  29008. * @hidden
  29009. */
  29010. _setCubeMapTextureParams(loadMipmap: boolean): void;
  29011. private _prepareWebGLTextureContinuation;
  29012. private _prepareWebGLTexture;
  29013. /** @hidden */
  29014. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  29015. /** @hidden */
  29016. _releaseFramebufferObjects(texture: InternalTexture): void;
  29017. /** @hidden */
  29018. _releaseTexture(texture: InternalTexture): void;
  29019. private setProgram;
  29020. private _boundUniforms;
  29021. /**
  29022. * Binds an effect to the webGL context
  29023. * @param effect defines the effect to bind
  29024. */
  29025. bindSamplers(effect: Effect): void;
  29026. private _activateCurrentTexture;
  29027. /** @hidden */
  29028. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  29029. /** @hidden */
  29030. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  29031. /**
  29032. * Sets a texture to the webGL context from a postprocess
  29033. * @param channel defines the channel to use
  29034. * @param postProcess defines the source postprocess
  29035. */
  29036. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  29037. /**
  29038. * Binds the output of the passed in post process to the texture channel specified
  29039. * @param channel The channel the texture should be bound to
  29040. * @param postProcess The post process which's output should be bound
  29041. */
  29042. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  29043. /**
  29044. * Unbind all textures from the webGL context
  29045. */
  29046. unbindAllTextures(): void;
  29047. /**
  29048. * Sets a texture to the according uniform.
  29049. * @param channel The texture channel
  29050. * @param uniform The uniform to set
  29051. * @param texture The texture to apply
  29052. */
  29053. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  29054. /**
  29055. * Sets a depth stencil texture from a render target to the according uniform.
  29056. * @param channel The texture channel
  29057. * @param uniform The uniform to set
  29058. * @param texture The render target texture containing the depth stencil texture to apply
  29059. */
  29060. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  29061. private _bindSamplerUniformToChannel;
  29062. private _getTextureWrapMode;
  29063. private _setTexture;
  29064. /**
  29065. * Sets an array of texture to the webGL context
  29066. * @param channel defines the channel where the texture array must be set
  29067. * @param uniform defines the associated uniform location
  29068. * @param textures defines the array of textures to bind
  29069. */
  29070. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  29071. /** @hidden */
  29072. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  29073. private _setTextureParameterFloat;
  29074. private _setTextureParameterInteger;
  29075. /**
  29076. * Reads pixels from the current frame buffer. Please note that this function can be slow
  29077. * @param x defines the x coordinate of the rectangle where pixels must be read
  29078. * @param y defines the y coordinate of the rectangle where pixels must be read
  29079. * @param width defines the width of the rectangle where pixels must be read
  29080. * @param height defines the height of the rectangle where pixels must be read
  29081. * @returns a Uint8Array containing RGBA colors
  29082. */
  29083. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  29084. /**
  29085. * Add an externaly attached data from its key.
  29086. * This method call will fail and return false, if such key already exists.
  29087. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  29088. * @param key the unique key that identifies the data
  29089. * @param data the data object to associate to the key for this Engine instance
  29090. * @return true if no such key were already present and the data was added successfully, false otherwise
  29091. */
  29092. addExternalData<T>(key: string, data: T): boolean;
  29093. /**
  29094. * Get an externaly attached data from its key
  29095. * @param key the unique key that identifies the data
  29096. * @return the associated data, if present (can be null), or undefined if not present
  29097. */
  29098. getExternalData<T>(key: string): T;
  29099. /**
  29100. * Get an externaly attached data from its key, create it using a factory if it's not already present
  29101. * @param key the unique key that identifies the data
  29102. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  29103. * @return the associated data, can be null if the factory returned null.
  29104. */
  29105. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  29106. /**
  29107. * Remove an externaly attached data from the Engine instance
  29108. * @param key the unique key that identifies the data
  29109. * @return true if the data was successfully removed, false if it doesn't exist
  29110. */
  29111. removeExternalData(key: string): boolean;
  29112. /**
  29113. * Unbind all vertex attributes from the webGL context
  29114. */
  29115. unbindAllAttributes(): void;
  29116. /**
  29117. * 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
  29118. */
  29119. releaseEffects(): void;
  29120. /**
  29121. * Dispose and release all associated resources
  29122. */
  29123. dispose(): void;
  29124. /**
  29125. * Display the loading screen
  29126. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29127. */
  29128. displayLoadingUI(): void;
  29129. /**
  29130. * Hide the loading screen
  29131. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29132. */
  29133. hideLoadingUI(): void;
  29134. /**
  29135. * Gets the current loading screen object
  29136. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29137. */
  29138. /**
  29139. * Sets the current loading screen object
  29140. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29141. */
  29142. loadingScreen: ILoadingScreen;
  29143. /**
  29144. * Sets the current loading screen text
  29145. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29146. */
  29147. loadingUIText: string;
  29148. /**
  29149. * Sets the current loading screen background color
  29150. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29151. */
  29152. loadingUIBackgroundColor: string;
  29153. /**
  29154. * Attach a new callback raised when context lost event is fired
  29155. * @param callback defines the callback to call
  29156. */
  29157. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  29158. /**
  29159. * Attach a new callback raised when context restored event is fired
  29160. * @param callback defines the callback to call
  29161. */
  29162. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  29163. /**
  29164. * Gets the source code of the vertex shader associated with a specific webGL program
  29165. * @param program defines the program to use
  29166. * @returns a string containing the source code of the vertex shader associated with the program
  29167. */
  29168. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  29169. /**
  29170. * Gets the source code of the fragment shader associated with a specific webGL program
  29171. * @param program defines the program to use
  29172. * @returns a string containing the source code of the fragment shader associated with the program
  29173. */
  29174. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  29175. /**
  29176. * Get the current error code of the webGL context
  29177. * @returns the error code
  29178. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  29179. */
  29180. getError(): number;
  29181. /**
  29182. * Gets the current framerate
  29183. * @returns a number representing the framerate
  29184. */
  29185. getFps(): number;
  29186. /**
  29187. * Gets the time spent between current and previous frame
  29188. * @returns a number representing the delta time in ms
  29189. */
  29190. getDeltaTime(): number;
  29191. private _measureFps;
  29192. /** @hidden */
  29193. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  29194. private _canRenderToFloatFramebuffer;
  29195. private _canRenderToHalfFloatFramebuffer;
  29196. private _canRenderToFramebuffer;
  29197. /** @hidden */
  29198. _getWebGLTextureType(type: number): number;
  29199. /** @hidden */
  29200. _getInternalFormat(format: number): number;
  29201. /** @hidden */
  29202. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  29203. /** @hidden */
  29204. _getRGBAMultiSampleBufferFormat(type: number): number;
  29205. /** @hidden */
  29206. _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;
  29207. /** @hidden */
  29208. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  29209. /**
  29210. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  29211. * @returns true if the engine can be created
  29212. * @ignorenaming
  29213. */
  29214. static isSupported(): boolean;
  29215. }
  29216. }
  29217. declare module BABYLON {
  29218. /**
  29219. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  29220. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  29221. */
  29222. export class EffectFallbacks {
  29223. private _defines;
  29224. private _currentRank;
  29225. private _maxRank;
  29226. private _mesh;
  29227. /**
  29228. * Removes the fallback from the bound mesh.
  29229. */
  29230. unBindMesh(): void;
  29231. /**
  29232. * Adds a fallback on the specified property.
  29233. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  29234. * @param define The name of the define in the shader
  29235. */
  29236. addFallback(rank: number, define: string): void;
  29237. /**
  29238. * Sets the mesh to use CPU skinning when needing to fallback.
  29239. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  29240. * @param mesh The mesh to use the fallbacks.
  29241. */
  29242. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  29243. /**
  29244. * Checks to see if more fallbacks are still availible.
  29245. */
  29246. readonly isMoreFallbacks: boolean;
  29247. /**
  29248. * Removes the defines that should be removed when falling back.
  29249. * @param currentDefines defines the current define statements for the shader.
  29250. * @param effect defines the current effect we try to compile
  29251. * @returns The resulting defines with defines of the current rank removed.
  29252. */
  29253. reduce(currentDefines: string, effect: Effect): string;
  29254. }
  29255. /**
  29256. * Options to be used when creating an effect.
  29257. */
  29258. export class EffectCreationOptions {
  29259. /**
  29260. * Atrributes that will be used in the shader.
  29261. */
  29262. attributes: string[];
  29263. /**
  29264. * Uniform varible names that will be set in the shader.
  29265. */
  29266. uniformsNames: string[];
  29267. /**
  29268. * Uniform buffer varible names that will be set in the shader.
  29269. */
  29270. uniformBuffersNames: string[];
  29271. /**
  29272. * Sampler texture variable names that will be set in the shader.
  29273. */
  29274. samplers: string[];
  29275. /**
  29276. * Define statements that will be set in the shader.
  29277. */
  29278. defines: any;
  29279. /**
  29280. * Possible fallbacks for this effect to improve performance when needed.
  29281. */
  29282. fallbacks: Nullable<EffectFallbacks>;
  29283. /**
  29284. * Callback that will be called when the shader is compiled.
  29285. */
  29286. onCompiled: Nullable<(effect: Effect) => void>;
  29287. /**
  29288. * Callback that will be called if an error occurs during shader compilation.
  29289. */
  29290. onError: Nullable<(effect: Effect, errors: string) => void>;
  29291. /**
  29292. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29293. */
  29294. indexParameters: any;
  29295. /**
  29296. * Max number of lights that can be used in the shader.
  29297. */
  29298. maxSimultaneousLights: number;
  29299. /**
  29300. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  29301. */
  29302. transformFeedbackVaryings: Nullable<string[]>;
  29303. }
  29304. /**
  29305. * Effect containing vertex and fragment shader that can be executed on an object.
  29306. */
  29307. export class Effect implements IDisposable {
  29308. /**
  29309. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  29310. */
  29311. static ShadersRepository: string;
  29312. /**
  29313. * Name of the effect.
  29314. */
  29315. name: any;
  29316. /**
  29317. * String container all the define statements that should be set on the shader.
  29318. */
  29319. defines: string;
  29320. /**
  29321. * Callback that will be called when the shader is compiled.
  29322. */
  29323. onCompiled: Nullable<(effect: Effect) => void>;
  29324. /**
  29325. * Callback that will be called if an error occurs during shader compilation.
  29326. */
  29327. onError: Nullable<(effect: Effect, errors: string) => void>;
  29328. /**
  29329. * Callback that will be called when effect is bound.
  29330. */
  29331. onBind: Nullable<(effect: Effect) => void>;
  29332. /**
  29333. * Unique ID of the effect.
  29334. */
  29335. uniqueId: number;
  29336. /**
  29337. * Observable that will be called when the shader is compiled.
  29338. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  29339. */
  29340. onCompileObservable: Observable<Effect>;
  29341. /**
  29342. * Observable that will be called if an error occurs during shader compilation.
  29343. */
  29344. onErrorObservable: Observable<Effect>;
  29345. /** @hidden */
  29346. _onBindObservable: Nullable<Observable<Effect>>;
  29347. /**
  29348. * Observable that will be called when effect is bound.
  29349. */
  29350. readonly onBindObservable: Observable<Effect>;
  29351. /** @hidden */
  29352. _bonesComputationForcedToCPU: boolean;
  29353. private static _uniqueIdSeed;
  29354. private _engine;
  29355. private _uniformBuffersNames;
  29356. private _uniformsNames;
  29357. private _samplerList;
  29358. private _samplers;
  29359. private _isReady;
  29360. private _compilationError;
  29361. private _attributesNames;
  29362. private _attributes;
  29363. private _uniforms;
  29364. /**
  29365. * Key for the effect.
  29366. * @hidden
  29367. */
  29368. _key: string;
  29369. private _indexParameters;
  29370. private _fallbacks;
  29371. private _vertexSourceCode;
  29372. private _fragmentSourceCode;
  29373. private _vertexSourceCodeOverride;
  29374. private _fragmentSourceCodeOverride;
  29375. private _transformFeedbackVaryings;
  29376. /**
  29377. * Compiled shader to webGL program.
  29378. * @hidden
  29379. */
  29380. _pipelineContext: Nullable<IPipelineContext>;
  29381. private _valueCache;
  29382. private static _baseCache;
  29383. /**
  29384. * Instantiates an effect.
  29385. * An effect can be used to create/manage/execute vertex and fragment shaders.
  29386. * @param baseName Name of the effect.
  29387. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  29388. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  29389. * @param samplers List of sampler variables that will be passed to the shader.
  29390. * @param engine Engine to be used to render the effect
  29391. * @param defines Define statements to be added to the shader.
  29392. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  29393. * @param onCompiled Callback that will be called when the shader is compiled.
  29394. * @param onError Callback that will be called if an error occurs during shader compilation.
  29395. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29396. */
  29397. constructor(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | Engine, samplers?: Nullable<string[]>, engine?: Engine, defines?: Nullable<string>, fallbacks?: Nullable<EffectFallbacks>, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any);
  29398. private _useFinalCode;
  29399. /**
  29400. * Unique key for this effect
  29401. */
  29402. readonly key: string;
  29403. /**
  29404. * If the effect has been compiled and prepared.
  29405. * @returns if the effect is compiled and prepared.
  29406. */
  29407. isReady(): boolean;
  29408. /**
  29409. * The engine the effect was initialized with.
  29410. * @returns the engine.
  29411. */
  29412. getEngine(): Engine;
  29413. /**
  29414. * The pipeline context for this effect
  29415. * @returns the associated pipeline context
  29416. */
  29417. getPipelineContext(): Nullable<IPipelineContext>;
  29418. /**
  29419. * The set of names of attribute variables for the shader.
  29420. * @returns An array of attribute names.
  29421. */
  29422. getAttributesNames(): string[];
  29423. /**
  29424. * Returns the attribute at the given index.
  29425. * @param index The index of the attribute.
  29426. * @returns The location of the attribute.
  29427. */
  29428. getAttributeLocation(index: number): number;
  29429. /**
  29430. * Returns the attribute based on the name of the variable.
  29431. * @param name of the attribute to look up.
  29432. * @returns the attribute location.
  29433. */
  29434. getAttributeLocationByName(name: string): number;
  29435. /**
  29436. * The number of attributes.
  29437. * @returns the numnber of attributes.
  29438. */
  29439. getAttributesCount(): number;
  29440. /**
  29441. * Gets the index of a uniform variable.
  29442. * @param uniformName of the uniform to look up.
  29443. * @returns the index.
  29444. */
  29445. getUniformIndex(uniformName: string): number;
  29446. /**
  29447. * Returns the attribute based on the name of the variable.
  29448. * @param uniformName of the uniform to look up.
  29449. * @returns the location of the uniform.
  29450. */
  29451. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  29452. /**
  29453. * Returns an array of sampler variable names
  29454. * @returns The array of sampler variable neames.
  29455. */
  29456. getSamplers(): string[];
  29457. /**
  29458. * The error from the last compilation.
  29459. * @returns the error string.
  29460. */
  29461. getCompilationError(): string;
  29462. /**
  29463. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  29464. * @param func The callback to be used.
  29465. */
  29466. executeWhenCompiled(func: (effect: Effect) => void): void;
  29467. private _checkIsReady;
  29468. /** @hidden */
  29469. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  29470. /** @hidden */
  29471. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  29472. /** @hidden */
  29473. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  29474. /**
  29475. * Recompiles the webGL program
  29476. * @param vertexSourceCode The source code for the vertex shader.
  29477. * @param fragmentSourceCode The source code for the fragment shader.
  29478. * @param onCompiled Callback called when completed.
  29479. * @param onError Callback called on error.
  29480. * @hidden
  29481. */
  29482. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  29483. /**
  29484. * Prepares the effect
  29485. * @hidden
  29486. */
  29487. _prepareEffect(): void;
  29488. /**
  29489. * Checks if the effect is supported. (Must be called after compilation)
  29490. */
  29491. readonly isSupported: boolean;
  29492. /**
  29493. * Binds a texture to the engine to be used as output of the shader.
  29494. * @param channel Name of the output variable.
  29495. * @param texture Texture to bind.
  29496. * @hidden
  29497. */
  29498. _bindTexture(channel: string, texture: InternalTexture): void;
  29499. /**
  29500. * Sets a texture on the engine to be used in the shader.
  29501. * @param channel Name of the sampler variable.
  29502. * @param texture Texture to set.
  29503. */
  29504. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  29505. /**
  29506. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  29507. * @param channel Name of the sampler variable.
  29508. * @param texture Texture to set.
  29509. */
  29510. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  29511. /**
  29512. * Sets an array of textures on the engine to be used in the shader.
  29513. * @param channel Name of the variable.
  29514. * @param textures Textures to set.
  29515. */
  29516. setTextureArray(channel: string, textures: BaseTexture[]): void;
  29517. /**
  29518. * 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)
  29519. * @param channel Name of the sampler variable.
  29520. * @param postProcess Post process to get the input texture from.
  29521. */
  29522. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  29523. /**
  29524. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  29525. * 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)
  29526. * @param channel Name of the sampler variable.
  29527. * @param postProcess Post process to get the output texture from.
  29528. */
  29529. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  29530. /** @hidden */
  29531. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  29532. /** @hidden */
  29533. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  29534. /** @hidden */
  29535. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  29536. /** @hidden */
  29537. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  29538. /**
  29539. * Binds a buffer to a uniform.
  29540. * @param buffer Buffer to bind.
  29541. * @param name Name of the uniform variable to bind to.
  29542. */
  29543. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  29544. /**
  29545. * Binds block to a uniform.
  29546. * @param blockName Name of the block to bind.
  29547. * @param index Index to bind.
  29548. */
  29549. bindUniformBlock(blockName: string, index: number): void;
  29550. /**
  29551. * Sets an interger value on a uniform variable.
  29552. * @param uniformName Name of the variable.
  29553. * @param value Value to be set.
  29554. * @returns this effect.
  29555. */
  29556. setInt(uniformName: string, value: number): Effect;
  29557. /**
  29558. * Sets an int array on a uniform variable.
  29559. * @param uniformName Name of the variable.
  29560. * @param array array to be set.
  29561. * @returns this effect.
  29562. */
  29563. setIntArray(uniformName: string, array: Int32Array): Effect;
  29564. /**
  29565. * 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)
  29566. * @param uniformName Name of the variable.
  29567. * @param array array to be set.
  29568. * @returns this effect.
  29569. */
  29570. setIntArray2(uniformName: string, array: Int32Array): Effect;
  29571. /**
  29572. * 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)
  29573. * @param uniformName Name of the variable.
  29574. * @param array array to be set.
  29575. * @returns this effect.
  29576. */
  29577. setIntArray3(uniformName: string, array: Int32Array): Effect;
  29578. /**
  29579. * 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)
  29580. * @param uniformName Name of the variable.
  29581. * @param array array to be set.
  29582. * @returns this effect.
  29583. */
  29584. setIntArray4(uniformName: string, array: Int32Array): Effect;
  29585. /**
  29586. * Sets an float array on a uniform variable.
  29587. * @param uniformName Name of the variable.
  29588. * @param array array to be set.
  29589. * @returns this effect.
  29590. */
  29591. setFloatArray(uniformName: string, array: Float32Array): Effect;
  29592. /**
  29593. * 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)
  29594. * @param uniformName Name of the variable.
  29595. * @param array array to be set.
  29596. * @returns this effect.
  29597. */
  29598. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  29599. /**
  29600. * 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)
  29601. * @param uniformName Name of the variable.
  29602. * @param array array to be set.
  29603. * @returns this effect.
  29604. */
  29605. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  29606. /**
  29607. * 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)
  29608. * @param uniformName Name of the variable.
  29609. * @param array array to be set.
  29610. * @returns this effect.
  29611. */
  29612. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  29613. /**
  29614. * Sets an array on a uniform variable.
  29615. * @param uniformName Name of the variable.
  29616. * @param array array to be set.
  29617. * @returns this effect.
  29618. */
  29619. setArray(uniformName: string, array: number[]): Effect;
  29620. /**
  29621. * 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)
  29622. * @param uniformName Name of the variable.
  29623. * @param array array to be set.
  29624. * @returns this effect.
  29625. */
  29626. setArray2(uniformName: string, array: number[]): Effect;
  29627. /**
  29628. * 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)
  29629. * @param uniformName Name of the variable.
  29630. * @param array array to be set.
  29631. * @returns this effect.
  29632. */
  29633. setArray3(uniformName: string, array: number[]): Effect;
  29634. /**
  29635. * 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)
  29636. * @param uniformName Name of the variable.
  29637. * @param array array to be set.
  29638. * @returns this effect.
  29639. */
  29640. setArray4(uniformName: string, array: number[]): Effect;
  29641. /**
  29642. * Sets matrices on a uniform variable.
  29643. * @param uniformName Name of the variable.
  29644. * @param matrices matrices to be set.
  29645. * @returns this effect.
  29646. */
  29647. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  29648. /**
  29649. * Sets matrix on a uniform variable.
  29650. * @param uniformName Name of the variable.
  29651. * @param matrix matrix to be set.
  29652. * @returns this effect.
  29653. */
  29654. setMatrix(uniformName: string, matrix: Matrix): Effect;
  29655. /**
  29656. * 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)
  29657. * @param uniformName Name of the variable.
  29658. * @param matrix matrix to be set.
  29659. * @returns this effect.
  29660. */
  29661. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  29662. /**
  29663. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  29664. * @param uniformName Name of the variable.
  29665. * @param matrix matrix to be set.
  29666. * @returns this effect.
  29667. */
  29668. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  29669. /**
  29670. * Sets a float on a uniform variable.
  29671. * @param uniformName Name of the variable.
  29672. * @param value value to be set.
  29673. * @returns this effect.
  29674. */
  29675. setFloat(uniformName: string, value: number): Effect;
  29676. /**
  29677. * Sets a boolean on a uniform variable.
  29678. * @param uniformName Name of the variable.
  29679. * @param bool value to be set.
  29680. * @returns this effect.
  29681. */
  29682. setBool(uniformName: string, bool: boolean): Effect;
  29683. /**
  29684. * Sets a Vector2 on a uniform variable.
  29685. * @param uniformName Name of the variable.
  29686. * @param vector2 vector2 to be set.
  29687. * @returns this effect.
  29688. */
  29689. setVector2(uniformName: string, vector2: Vector2): Effect;
  29690. /**
  29691. * Sets a float2 on a uniform variable.
  29692. * @param uniformName Name of the variable.
  29693. * @param x First float in float2.
  29694. * @param y Second float in float2.
  29695. * @returns this effect.
  29696. */
  29697. setFloat2(uniformName: string, x: number, y: number): Effect;
  29698. /**
  29699. * Sets a Vector3 on a uniform variable.
  29700. * @param uniformName Name of the variable.
  29701. * @param vector3 Value to be set.
  29702. * @returns this effect.
  29703. */
  29704. setVector3(uniformName: string, vector3: Vector3): Effect;
  29705. /**
  29706. * Sets a float3 on a uniform variable.
  29707. * @param uniformName Name of the variable.
  29708. * @param x First float in float3.
  29709. * @param y Second float in float3.
  29710. * @param z Third float in float3.
  29711. * @returns this effect.
  29712. */
  29713. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  29714. /**
  29715. * Sets a Vector4 on a uniform variable.
  29716. * @param uniformName Name of the variable.
  29717. * @param vector4 Value to be set.
  29718. * @returns this effect.
  29719. */
  29720. setVector4(uniformName: string, vector4: Vector4): Effect;
  29721. /**
  29722. * Sets a float4 on a uniform variable.
  29723. * @param uniformName Name of the variable.
  29724. * @param x First float in float4.
  29725. * @param y Second float in float4.
  29726. * @param z Third float in float4.
  29727. * @param w Fourth float in float4.
  29728. * @returns this effect.
  29729. */
  29730. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  29731. /**
  29732. * Sets a Color3 on a uniform variable.
  29733. * @param uniformName Name of the variable.
  29734. * @param color3 Value to be set.
  29735. * @returns this effect.
  29736. */
  29737. setColor3(uniformName: string, color3: Color3): Effect;
  29738. /**
  29739. * Sets a Color4 on a uniform variable.
  29740. * @param uniformName Name of the variable.
  29741. * @param color3 Value to be set.
  29742. * @param alpha Alpha value to be set.
  29743. * @returns this effect.
  29744. */
  29745. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  29746. /**
  29747. * Sets a Color4 on a uniform variable
  29748. * @param uniformName defines the name of the variable
  29749. * @param color4 defines the value to be set
  29750. * @returns this effect.
  29751. */
  29752. setDirectColor4(uniformName: string, color4: Color4): Effect;
  29753. /** Release all associated resources */
  29754. dispose(): void;
  29755. /**
  29756. * This function will add a new shader to the shader store
  29757. * @param name the name of the shader
  29758. * @param pixelShader optional pixel shader content
  29759. * @param vertexShader optional vertex shader content
  29760. */
  29761. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  29762. /**
  29763. * Store of each shader (The can be looked up using effect.key)
  29764. */
  29765. static ShadersStore: {
  29766. [key: string]: string;
  29767. };
  29768. /**
  29769. * Store of each included file for a shader (The can be looked up using effect.key)
  29770. */
  29771. static IncludesShadersStore: {
  29772. [key: string]: string;
  29773. };
  29774. /**
  29775. * Resets the cache of effects.
  29776. */
  29777. static ResetCache(): void;
  29778. }
  29779. }
  29780. declare module BABYLON {
  29781. /**
  29782. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  29783. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  29784. * 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;
  29785. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  29786. */
  29787. export class ColorCurves {
  29788. private _dirty;
  29789. private _tempColor;
  29790. private _globalCurve;
  29791. private _highlightsCurve;
  29792. private _midtonesCurve;
  29793. private _shadowsCurve;
  29794. private _positiveCurve;
  29795. private _negativeCurve;
  29796. private _globalHue;
  29797. private _globalDensity;
  29798. private _globalSaturation;
  29799. private _globalExposure;
  29800. /**
  29801. * Gets the global Hue value.
  29802. * 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).
  29803. */
  29804. /**
  29805. * Sets the global Hue value.
  29806. * 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).
  29807. */
  29808. globalHue: number;
  29809. /**
  29810. * Gets the global Density value.
  29811. * 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.
  29812. * Values less than zero provide a filter of opposite hue.
  29813. */
  29814. /**
  29815. * Sets the global Density value.
  29816. * 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.
  29817. * Values less than zero provide a filter of opposite hue.
  29818. */
  29819. globalDensity: number;
  29820. /**
  29821. * Gets the global Saturation value.
  29822. * 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.
  29823. */
  29824. /**
  29825. * Sets the global Saturation value.
  29826. * 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.
  29827. */
  29828. globalSaturation: number;
  29829. /**
  29830. * Gets the global Exposure value.
  29831. * 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.
  29832. */
  29833. /**
  29834. * Sets the global Exposure value.
  29835. * 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.
  29836. */
  29837. globalExposure: number;
  29838. private _highlightsHue;
  29839. private _highlightsDensity;
  29840. private _highlightsSaturation;
  29841. private _highlightsExposure;
  29842. /**
  29843. * Gets the highlights Hue value.
  29844. * 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).
  29845. */
  29846. /**
  29847. * Sets the highlights Hue value.
  29848. * 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).
  29849. */
  29850. highlightsHue: number;
  29851. /**
  29852. * Gets the highlights Density value.
  29853. * 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.
  29854. * Values less than zero provide a filter of opposite hue.
  29855. */
  29856. /**
  29857. * Sets the highlights Density value.
  29858. * 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.
  29859. * Values less than zero provide a filter of opposite hue.
  29860. */
  29861. highlightsDensity: number;
  29862. /**
  29863. * Gets the highlights Saturation value.
  29864. * 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.
  29865. */
  29866. /**
  29867. * Sets the highlights Saturation value.
  29868. * 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.
  29869. */
  29870. highlightsSaturation: number;
  29871. /**
  29872. * Gets the highlights Exposure value.
  29873. * 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.
  29874. */
  29875. /**
  29876. * Sets the highlights Exposure value.
  29877. * 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.
  29878. */
  29879. highlightsExposure: number;
  29880. private _midtonesHue;
  29881. private _midtonesDensity;
  29882. private _midtonesSaturation;
  29883. private _midtonesExposure;
  29884. /**
  29885. * Gets the midtones Hue value.
  29886. * 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).
  29887. */
  29888. /**
  29889. * Sets the midtones Hue value.
  29890. * 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).
  29891. */
  29892. midtonesHue: number;
  29893. /**
  29894. * Gets the midtones Density value.
  29895. * 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.
  29896. * Values less than zero provide a filter of opposite hue.
  29897. */
  29898. /**
  29899. * Sets the midtones Density value.
  29900. * 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.
  29901. * Values less than zero provide a filter of opposite hue.
  29902. */
  29903. midtonesDensity: number;
  29904. /**
  29905. * Gets the midtones Saturation value.
  29906. * 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.
  29907. */
  29908. /**
  29909. * Sets the midtones Saturation value.
  29910. * 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.
  29911. */
  29912. midtonesSaturation: number;
  29913. /**
  29914. * Gets the midtones Exposure value.
  29915. * 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.
  29916. */
  29917. /**
  29918. * Sets the midtones Exposure value.
  29919. * 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.
  29920. */
  29921. midtonesExposure: number;
  29922. private _shadowsHue;
  29923. private _shadowsDensity;
  29924. private _shadowsSaturation;
  29925. private _shadowsExposure;
  29926. /**
  29927. * Gets the shadows Hue value.
  29928. * 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).
  29929. */
  29930. /**
  29931. * Sets the shadows Hue value.
  29932. * 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).
  29933. */
  29934. shadowsHue: number;
  29935. /**
  29936. * Gets the shadows Density value.
  29937. * 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.
  29938. * Values less than zero provide a filter of opposite hue.
  29939. */
  29940. /**
  29941. * Sets the shadows Density value.
  29942. * 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.
  29943. * Values less than zero provide a filter of opposite hue.
  29944. */
  29945. shadowsDensity: number;
  29946. /**
  29947. * Gets the shadows Saturation value.
  29948. * 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.
  29949. */
  29950. /**
  29951. * Sets the shadows Saturation value.
  29952. * 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.
  29953. */
  29954. shadowsSaturation: number;
  29955. /**
  29956. * Gets the shadows Exposure value.
  29957. * 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.
  29958. */
  29959. /**
  29960. * Sets the shadows Exposure value.
  29961. * 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.
  29962. */
  29963. shadowsExposure: number;
  29964. /**
  29965. * Returns the class name
  29966. * @returns The class name
  29967. */
  29968. getClassName(): string;
  29969. /**
  29970. * Binds the color curves to the shader.
  29971. * @param colorCurves The color curve to bind
  29972. * @param effect The effect to bind to
  29973. * @param positiveUniform The positive uniform shader parameter
  29974. * @param neutralUniform The neutral uniform shader parameter
  29975. * @param negativeUniform The negative uniform shader parameter
  29976. */
  29977. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  29978. /**
  29979. * Prepare the list of uniforms associated with the ColorCurves effects.
  29980. * @param uniformsList The list of uniforms used in the effect
  29981. */
  29982. static PrepareUniforms(uniformsList: string[]): void;
  29983. /**
  29984. * Returns color grading data based on a hue, density, saturation and exposure value.
  29985. * @param filterHue The hue of the color filter.
  29986. * @param filterDensity The density of the color filter.
  29987. * @param saturation The saturation.
  29988. * @param exposure The exposure.
  29989. * @param result The result data container.
  29990. */
  29991. private getColorGradingDataToRef;
  29992. /**
  29993. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  29994. * @param value The input slider value in range [-100,100].
  29995. * @returns Adjusted value.
  29996. */
  29997. private static applyColorGradingSliderNonlinear;
  29998. /**
  29999. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  30000. * @param hue The hue (H) input.
  30001. * @param saturation The saturation (S) input.
  30002. * @param brightness The brightness (B) input.
  30003. * @result An RGBA color represented as Vector4.
  30004. */
  30005. private static fromHSBToRef;
  30006. /**
  30007. * Returns a value clamped between min and max
  30008. * @param value The value to clamp
  30009. * @param min The minimum of value
  30010. * @param max The maximum of value
  30011. * @returns The clamped value.
  30012. */
  30013. private static clamp;
  30014. /**
  30015. * Clones the current color curve instance.
  30016. * @return The cloned curves
  30017. */
  30018. clone(): ColorCurves;
  30019. /**
  30020. * Serializes the current color curve instance to a json representation.
  30021. * @return a JSON representation
  30022. */
  30023. serialize(): any;
  30024. /**
  30025. * Parses the color curve from a json representation.
  30026. * @param source the JSON source to parse
  30027. * @return The parsed curves
  30028. */
  30029. static Parse(source: any): ColorCurves;
  30030. }
  30031. }
  30032. declare module BABYLON {
  30033. /**
  30034. * Interface to follow in your material defines to integrate easily the
  30035. * Image proccessing functions.
  30036. * @hidden
  30037. */
  30038. export interface IImageProcessingConfigurationDefines {
  30039. IMAGEPROCESSING: boolean;
  30040. VIGNETTE: boolean;
  30041. VIGNETTEBLENDMODEMULTIPLY: boolean;
  30042. VIGNETTEBLENDMODEOPAQUE: boolean;
  30043. TONEMAPPING: boolean;
  30044. TONEMAPPING_ACES: boolean;
  30045. CONTRAST: boolean;
  30046. EXPOSURE: boolean;
  30047. COLORCURVES: boolean;
  30048. COLORGRADING: boolean;
  30049. COLORGRADING3D: boolean;
  30050. SAMPLER3DGREENDEPTH: boolean;
  30051. SAMPLER3DBGRMAP: boolean;
  30052. IMAGEPROCESSINGPOSTPROCESS: boolean;
  30053. }
  30054. /**
  30055. * @hidden
  30056. */
  30057. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  30058. IMAGEPROCESSING: boolean;
  30059. VIGNETTE: boolean;
  30060. VIGNETTEBLENDMODEMULTIPLY: boolean;
  30061. VIGNETTEBLENDMODEOPAQUE: boolean;
  30062. TONEMAPPING: boolean;
  30063. TONEMAPPING_ACES: boolean;
  30064. CONTRAST: boolean;
  30065. COLORCURVES: boolean;
  30066. COLORGRADING: boolean;
  30067. COLORGRADING3D: boolean;
  30068. SAMPLER3DGREENDEPTH: boolean;
  30069. SAMPLER3DBGRMAP: boolean;
  30070. IMAGEPROCESSINGPOSTPROCESS: boolean;
  30071. EXPOSURE: boolean;
  30072. constructor();
  30073. }
  30074. /**
  30075. * This groups together the common properties used for image processing either in direct forward pass
  30076. * or through post processing effect depending on the use of the image processing pipeline in your scene
  30077. * or not.
  30078. */
  30079. export class ImageProcessingConfiguration {
  30080. /**
  30081. * Default tone mapping applied in BabylonJS.
  30082. */
  30083. static readonly TONEMAPPING_STANDARD: number;
  30084. /**
  30085. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  30086. * to other engines rendering to increase portability.
  30087. */
  30088. static readonly TONEMAPPING_ACES: number;
  30089. /**
  30090. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  30091. */
  30092. colorCurves: Nullable<ColorCurves>;
  30093. private _colorCurvesEnabled;
  30094. /**
  30095. * Gets wether the color curves effect is enabled.
  30096. */
  30097. /**
  30098. * Sets wether the color curves effect is enabled.
  30099. */
  30100. colorCurvesEnabled: boolean;
  30101. private _colorGradingTexture;
  30102. /**
  30103. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  30104. */
  30105. /**
  30106. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  30107. */
  30108. colorGradingTexture: Nullable<BaseTexture>;
  30109. private _colorGradingEnabled;
  30110. /**
  30111. * Gets wether the color grading effect is enabled.
  30112. */
  30113. /**
  30114. * Sets wether the color grading effect is enabled.
  30115. */
  30116. colorGradingEnabled: boolean;
  30117. private _colorGradingWithGreenDepth;
  30118. /**
  30119. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  30120. */
  30121. /**
  30122. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  30123. */
  30124. colorGradingWithGreenDepth: boolean;
  30125. private _colorGradingBGR;
  30126. /**
  30127. * Gets wether the color grading texture contains BGR values.
  30128. */
  30129. /**
  30130. * Sets wether the color grading texture contains BGR values.
  30131. */
  30132. colorGradingBGR: boolean;
  30133. /** @hidden */
  30134. _exposure: number;
  30135. /**
  30136. * Gets the Exposure used in the effect.
  30137. */
  30138. /**
  30139. * Sets the Exposure used in the effect.
  30140. */
  30141. exposure: number;
  30142. private _toneMappingEnabled;
  30143. /**
  30144. * Gets wether the tone mapping effect is enabled.
  30145. */
  30146. /**
  30147. * Sets wether the tone mapping effect is enabled.
  30148. */
  30149. toneMappingEnabled: boolean;
  30150. private _toneMappingType;
  30151. /**
  30152. * Gets the type of tone mapping effect.
  30153. */
  30154. /**
  30155. * Sets the type of tone mapping effect used in BabylonJS.
  30156. */
  30157. toneMappingType: number;
  30158. protected _contrast: number;
  30159. /**
  30160. * Gets the contrast used in the effect.
  30161. */
  30162. /**
  30163. * Sets the contrast used in the effect.
  30164. */
  30165. contrast: number;
  30166. /**
  30167. * Vignette stretch size.
  30168. */
  30169. vignetteStretch: number;
  30170. /**
  30171. * Vignette centre X Offset.
  30172. */
  30173. vignetteCentreX: number;
  30174. /**
  30175. * Vignette centre Y Offset.
  30176. */
  30177. vignetteCentreY: number;
  30178. /**
  30179. * Vignette weight or intensity of the vignette effect.
  30180. */
  30181. vignetteWeight: number;
  30182. /**
  30183. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  30184. * if vignetteEnabled is set to true.
  30185. */
  30186. vignetteColor: Color4;
  30187. /**
  30188. * Camera field of view used by the Vignette effect.
  30189. */
  30190. vignetteCameraFov: number;
  30191. private _vignetteBlendMode;
  30192. /**
  30193. * Gets the vignette blend mode allowing different kind of effect.
  30194. */
  30195. /**
  30196. * Sets the vignette blend mode allowing different kind of effect.
  30197. */
  30198. vignetteBlendMode: number;
  30199. private _vignetteEnabled;
  30200. /**
  30201. * Gets wether the vignette effect is enabled.
  30202. */
  30203. /**
  30204. * Sets wether the vignette effect is enabled.
  30205. */
  30206. vignetteEnabled: boolean;
  30207. private _applyByPostProcess;
  30208. /**
  30209. * Gets wether the image processing is applied through a post process or not.
  30210. */
  30211. /**
  30212. * Sets wether the image processing is applied through a post process or not.
  30213. */
  30214. applyByPostProcess: boolean;
  30215. private _isEnabled;
  30216. /**
  30217. * Gets wether the image processing is enabled or not.
  30218. */
  30219. /**
  30220. * Sets wether the image processing is enabled or not.
  30221. */
  30222. isEnabled: boolean;
  30223. /**
  30224. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  30225. */
  30226. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  30227. /**
  30228. * Method called each time the image processing information changes requires to recompile the effect.
  30229. */
  30230. protected _updateParameters(): void;
  30231. /**
  30232. * Gets the current class name.
  30233. * @return "ImageProcessingConfiguration"
  30234. */
  30235. getClassName(): string;
  30236. /**
  30237. * Prepare the list of uniforms associated with the Image Processing effects.
  30238. * @param uniforms The list of uniforms used in the effect
  30239. * @param defines the list of defines currently in use
  30240. */
  30241. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  30242. /**
  30243. * Prepare the list of samplers associated with the Image Processing effects.
  30244. * @param samplersList The list of uniforms used in the effect
  30245. * @param defines the list of defines currently in use
  30246. */
  30247. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  30248. /**
  30249. * Prepare the list of defines associated to the shader.
  30250. * @param defines the list of defines to complete
  30251. * @param forPostProcess Define if we are currently in post process mode or not
  30252. */
  30253. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  30254. /**
  30255. * Returns true if all the image processing information are ready.
  30256. * @returns True if ready, otherwise, false
  30257. */
  30258. isReady(): boolean;
  30259. /**
  30260. * Binds the image processing to the shader.
  30261. * @param effect The effect to bind to
  30262. * @param aspectRatio Define the current aspect ratio of the effect
  30263. */
  30264. bind(effect: Effect, aspectRatio?: number): void;
  30265. /**
  30266. * Clones the current image processing instance.
  30267. * @return The cloned image processing
  30268. */
  30269. clone(): ImageProcessingConfiguration;
  30270. /**
  30271. * Serializes the current image processing instance to a json representation.
  30272. * @return a JSON representation
  30273. */
  30274. serialize(): any;
  30275. /**
  30276. * Parses the image processing from a json representation.
  30277. * @param source the JSON source to parse
  30278. * @return The parsed image processing
  30279. */
  30280. static Parse(source: any): ImageProcessingConfiguration;
  30281. private static _VIGNETTEMODE_MULTIPLY;
  30282. private static _VIGNETTEMODE_OPAQUE;
  30283. /**
  30284. * Used to apply the vignette as a mix with the pixel color.
  30285. */
  30286. static readonly VIGNETTEMODE_MULTIPLY: number;
  30287. /**
  30288. * Used to apply the vignette as a replacement of the pixel color.
  30289. */
  30290. static readonly VIGNETTEMODE_OPAQUE: number;
  30291. }
  30292. }
  30293. declare module BABYLON {
  30294. /**
  30295. * This represents all the required information to add a fresnel effect on a material:
  30296. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30297. */
  30298. export class FresnelParameters {
  30299. private _isEnabled;
  30300. /**
  30301. * Define if the fresnel effect is enable or not.
  30302. */
  30303. isEnabled: boolean;
  30304. /**
  30305. * Define the color used on edges (grazing angle)
  30306. */
  30307. leftColor: Color3;
  30308. /**
  30309. * Define the color used on center
  30310. */
  30311. rightColor: Color3;
  30312. /**
  30313. * Define bias applied to computed fresnel term
  30314. */
  30315. bias: number;
  30316. /**
  30317. * Defined the power exponent applied to fresnel term
  30318. */
  30319. power: number;
  30320. /**
  30321. * Clones the current fresnel and its valuues
  30322. * @returns a clone fresnel configuration
  30323. */
  30324. clone(): FresnelParameters;
  30325. /**
  30326. * Serializes the current fresnel parameters to a JSON representation.
  30327. * @return the JSON serialization
  30328. */
  30329. serialize(): any;
  30330. /**
  30331. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  30332. * @param parsedFresnelParameters Define the JSON representation
  30333. * @returns the parsed parameters
  30334. */
  30335. static Parse(parsedFresnelParameters: any): FresnelParameters;
  30336. }
  30337. }
  30338. declare module BABYLON {
  30339. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  30340. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30341. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30342. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30343. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30344. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30345. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30346. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30347. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30348. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30349. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30350. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30351. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30352. /**
  30353. * Decorator used to define property that can be serialized as reference to a camera
  30354. * @param sourceName defines the name of the property to decorate
  30355. */
  30356. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30357. /**
  30358. * Class used to help serialization objects
  30359. */
  30360. export class SerializationHelper {
  30361. /** @hidden */
  30362. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  30363. /** @hidden */
  30364. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  30365. /** @hidden */
  30366. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  30367. /** @hidden */
  30368. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  30369. /**
  30370. * Appends the serialized animations from the source animations
  30371. * @param source Source containing the animations
  30372. * @param destination Target to store the animations
  30373. */
  30374. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  30375. /**
  30376. * Static function used to serialized a specific entity
  30377. * @param entity defines the entity to serialize
  30378. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  30379. * @returns a JSON compatible object representing the serialization of the entity
  30380. */
  30381. static Serialize<T>(entity: T, serializationObject?: any): any;
  30382. /**
  30383. * Creates a new entity from a serialization data object
  30384. * @param creationFunction defines a function used to instanciated the new entity
  30385. * @param source defines the source serialization data
  30386. * @param scene defines the hosting scene
  30387. * @param rootUrl defines the root url for resources
  30388. * @returns a new entity
  30389. */
  30390. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  30391. /**
  30392. * Clones an object
  30393. * @param creationFunction defines the function used to instanciate the new object
  30394. * @param source defines the source object
  30395. * @returns the cloned object
  30396. */
  30397. static Clone<T>(creationFunction: () => T, source: T): T;
  30398. /**
  30399. * Instanciates a new object based on a source one (some data will be shared between both object)
  30400. * @param creationFunction defines the function used to instanciate the new object
  30401. * @param source defines the source object
  30402. * @returns the new object
  30403. */
  30404. static Instanciate<T>(creationFunction: () => T, source: T): T;
  30405. }
  30406. }
  30407. declare module BABYLON {
  30408. /**
  30409. * This is the base class of all the camera used in the application.
  30410. * @see http://doc.babylonjs.com/features/cameras
  30411. */
  30412. export class Camera extends Node {
  30413. /** @hidden */
  30414. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  30415. /**
  30416. * This is the default projection mode used by the cameras.
  30417. * It helps recreating a feeling of perspective and better appreciate depth.
  30418. * This is the best way to simulate real life cameras.
  30419. */
  30420. static readonly PERSPECTIVE_CAMERA: number;
  30421. /**
  30422. * This helps creating camera with an orthographic mode.
  30423. * 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.
  30424. */
  30425. static readonly ORTHOGRAPHIC_CAMERA: number;
  30426. /**
  30427. * This is the default FOV mode for perspective cameras.
  30428. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  30429. */
  30430. static readonly FOVMODE_VERTICAL_FIXED: number;
  30431. /**
  30432. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  30433. */
  30434. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  30435. /**
  30436. * This specifies ther is no need for a camera rig.
  30437. * Basically only one eye is rendered corresponding to the camera.
  30438. */
  30439. static readonly RIG_MODE_NONE: number;
  30440. /**
  30441. * Simulates a camera Rig with one blue eye and one red eye.
  30442. * This can be use with 3d blue and red glasses.
  30443. */
  30444. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  30445. /**
  30446. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  30447. */
  30448. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  30449. /**
  30450. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  30451. */
  30452. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  30453. /**
  30454. * Defines that both eyes of the camera will be rendered over under each other.
  30455. */
  30456. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  30457. /**
  30458. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  30459. */
  30460. static readonly RIG_MODE_VR: number;
  30461. /**
  30462. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  30463. */
  30464. static readonly RIG_MODE_WEBVR: number;
  30465. /**
  30466. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  30467. */
  30468. static readonly RIG_MODE_CUSTOM: number;
  30469. /**
  30470. * Defines if by default attaching controls should prevent the default javascript event to continue.
  30471. */
  30472. static ForceAttachControlToAlwaysPreventDefault: boolean;
  30473. /**
  30474. * Define the input manager associated with the camera.
  30475. */
  30476. inputs: CameraInputsManager<Camera>;
  30477. /** @hidden */
  30478. _position: Vector3;
  30479. /**
  30480. * Define the current local position of the camera in the scene
  30481. */
  30482. position: Vector3;
  30483. /**
  30484. * The vector the camera should consider as up.
  30485. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  30486. */
  30487. upVector: Vector3;
  30488. /**
  30489. * Define the current limit on the left side for an orthographic camera
  30490. * In scene unit
  30491. */
  30492. orthoLeft: Nullable<number>;
  30493. /**
  30494. * Define the current limit on the right side for an orthographic camera
  30495. * In scene unit
  30496. */
  30497. orthoRight: Nullable<number>;
  30498. /**
  30499. * Define the current limit on the bottom side for an orthographic camera
  30500. * In scene unit
  30501. */
  30502. orthoBottom: Nullable<number>;
  30503. /**
  30504. * Define the current limit on the top side for an orthographic camera
  30505. * In scene unit
  30506. */
  30507. orthoTop: Nullable<number>;
  30508. /**
  30509. * Field Of View is set in Radians. (default is 0.8)
  30510. */
  30511. fov: number;
  30512. /**
  30513. * Define the minimum distance the camera can see from.
  30514. * This is important to note that the depth buffer are not infinite and the closer it starts
  30515. * the more your scene might encounter depth fighting issue.
  30516. */
  30517. minZ: number;
  30518. /**
  30519. * Define the maximum distance the camera can see to.
  30520. * This is important to note that the depth buffer are not infinite and the further it end
  30521. * the more your scene might encounter depth fighting issue.
  30522. */
  30523. maxZ: number;
  30524. /**
  30525. * Define the default inertia of the camera.
  30526. * This helps giving a smooth feeling to the camera movement.
  30527. */
  30528. inertia: number;
  30529. /**
  30530. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.PERSPECTIVE_ORTHOGRAPHIC)
  30531. */
  30532. mode: number;
  30533. /**
  30534. * Define wether the camera is intermediate.
  30535. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  30536. */
  30537. isIntermediate: boolean;
  30538. /**
  30539. * Define the viewport of the camera.
  30540. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  30541. */
  30542. viewport: Viewport;
  30543. /**
  30544. * Restricts the camera to viewing objects with the same layerMask.
  30545. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  30546. */
  30547. layerMask: number;
  30548. /**
  30549. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  30550. */
  30551. fovMode: number;
  30552. /**
  30553. * Rig mode of the camera.
  30554. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  30555. * This is normally controlled byt the camera themselves as internal use.
  30556. */
  30557. cameraRigMode: number;
  30558. /**
  30559. * Defines the distance between both "eyes" in case of a RIG
  30560. */
  30561. interaxialDistance: number;
  30562. /**
  30563. * Defines if stereoscopic rendering is done side by side or over under.
  30564. */
  30565. isStereoscopicSideBySide: boolean;
  30566. /**
  30567. * 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
  30568. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  30569. * else in the scene.
  30570. */
  30571. customRenderTargets: RenderTargetTexture[];
  30572. /**
  30573. * When set, the camera will render to this render target instead of the default canvas
  30574. */
  30575. outputRenderTarget: Nullable<RenderTargetTexture>;
  30576. /**
  30577. * Observable triggered when the camera view matrix has changed.
  30578. */
  30579. onViewMatrixChangedObservable: Observable<Camera>;
  30580. /**
  30581. * Observable triggered when the camera Projection matrix has changed.
  30582. */
  30583. onProjectionMatrixChangedObservable: Observable<Camera>;
  30584. /**
  30585. * Observable triggered when the inputs have been processed.
  30586. */
  30587. onAfterCheckInputsObservable: Observable<Camera>;
  30588. /**
  30589. * Observable triggered when reset has been called and applied to the camera.
  30590. */
  30591. onRestoreStateObservable: Observable<Camera>;
  30592. /** @hidden */
  30593. _cameraRigParams: any;
  30594. /** @hidden */
  30595. _rigCameras: Camera[];
  30596. /** @hidden */
  30597. _rigPostProcess: Nullable<PostProcess>;
  30598. protected _webvrViewMatrix: Matrix;
  30599. /** @hidden */
  30600. _skipRendering: boolean;
  30601. /** @hidden */
  30602. _projectionMatrix: Matrix;
  30603. /** @hidden */
  30604. _postProcesses: Nullable<PostProcess>[];
  30605. /** @hidden */
  30606. _activeMeshes: SmartArray<AbstractMesh>;
  30607. protected _globalPosition: Vector3;
  30608. /** @hidden */
  30609. _computedViewMatrix: Matrix;
  30610. private _doNotComputeProjectionMatrix;
  30611. private _transformMatrix;
  30612. private _frustumPlanes;
  30613. private _refreshFrustumPlanes;
  30614. private _storedFov;
  30615. private _stateStored;
  30616. /**
  30617. * Instantiates a new camera object.
  30618. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  30619. * @see http://doc.babylonjs.com/features/cameras
  30620. * @param name Defines the name of the camera in the scene
  30621. * @param position Defines the position of the camera
  30622. * @param scene Defines the scene the camera belongs too
  30623. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  30624. */
  30625. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  30626. /**
  30627. * Store current camera state (fov, position, etc..)
  30628. * @returns the camera
  30629. */
  30630. storeState(): Camera;
  30631. /**
  30632. * Restores the camera state values if it has been stored. You must call storeState() first
  30633. */
  30634. protected _restoreStateValues(): boolean;
  30635. /**
  30636. * Restored camera state. You must call storeState() first.
  30637. * @returns true if restored and false otherwise
  30638. */
  30639. restoreState(): boolean;
  30640. /**
  30641. * Gets the class name of the camera.
  30642. * @returns the class name
  30643. */
  30644. getClassName(): string;
  30645. /** @hidden */
  30646. readonly _isCamera: boolean;
  30647. /**
  30648. * Gets a string representation of the camera useful for debug purpose.
  30649. * @param fullDetails Defines that a more verboe level of logging is required
  30650. * @returns the string representation
  30651. */
  30652. toString(fullDetails?: boolean): string;
  30653. /**
  30654. * Gets the current world space position of the camera.
  30655. */
  30656. readonly globalPosition: Vector3;
  30657. /**
  30658. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  30659. * @returns the active meshe list
  30660. */
  30661. getActiveMeshes(): SmartArray<AbstractMesh>;
  30662. /**
  30663. * Check wether a mesh is part of the current active mesh list of the camera
  30664. * @param mesh Defines the mesh to check
  30665. * @returns true if active, false otherwise
  30666. */
  30667. isActiveMesh(mesh: Mesh): boolean;
  30668. /**
  30669. * Is this camera ready to be used/rendered
  30670. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  30671. * @return true if the camera is ready
  30672. */
  30673. isReady(completeCheck?: boolean): boolean;
  30674. /** @hidden */
  30675. _initCache(): void;
  30676. /** @hidden */
  30677. _updateCache(ignoreParentClass?: boolean): void;
  30678. /** @hidden */
  30679. _isSynchronized(): boolean;
  30680. /** @hidden */
  30681. _isSynchronizedViewMatrix(): boolean;
  30682. /** @hidden */
  30683. _isSynchronizedProjectionMatrix(): boolean;
  30684. /**
  30685. * Attach the input controls to a specific dom element to get the input from.
  30686. * @param element Defines the element the controls should be listened from
  30687. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  30688. */
  30689. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  30690. /**
  30691. * Detach the current controls from the specified dom element.
  30692. * @param element Defines the element to stop listening the inputs from
  30693. */
  30694. detachControl(element: HTMLElement): void;
  30695. /**
  30696. * Update the camera state according to the different inputs gathered during the frame.
  30697. */
  30698. update(): void;
  30699. /** @hidden */
  30700. _checkInputs(): void;
  30701. /** @hidden */
  30702. readonly rigCameras: Camera[];
  30703. /**
  30704. * Gets the post process used by the rig cameras
  30705. */
  30706. readonly rigPostProcess: Nullable<PostProcess>;
  30707. /**
  30708. * Internal, gets the first post proces.
  30709. * @returns the first post process to be run on this camera.
  30710. */
  30711. _getFirstPostProcess(): Nullable<PostProcess>;
  30712. private _cascadePostProcessesToRigCams;
  30713. /**
  30714. * Attach a post process to the camera.
  30715. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  30716. * @param postProcess The post process to attach to the camera
  30717. * @param insertAt The position of the post process in case several of them are in use in the scene
  30718. * @returns the position the post process has been inserted at
  30719. */
  30720. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  30721. /**
  30722. * Detach a post process to the camera.
  30723. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  30724. * @param postProcess The post process to detach from the camera
  30725. */
  30726. detachPostProcess(postProcess: PostProcess): void;
  30727. /**
  30728. * Gets the current world matrix of the camera
  30729. */
  30730. getWorldMatrix(): Matrix;
  30731. /** @hidden */
  30732. _getViewMatrix(): Matrix;
  30733. /**
  30734. * Gets the current view matrix of the camera.
  30735. * @param force forces the camera to recompute the matrix without looking at the cached state
  30736. * @returns the view matrix
  30737. */
  30738. getViewMatrix(force?: boolean): Matrix;
  30739. /**
  30740. * Freeze the projection matrix.
  30741. * It will prevent the cache check of the camera projection compute and can speed up perf
  30742. * if no parameter of the camera are meant to change
  30743. * @param projection Defines manually a projection if necessary
  30744. */
  30745. freezeProjectionMatrix(projection?: Matrix): void;
  30746. /**
  30747. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  30748. */
  30749. unfreezeProjectionMatrix(): void;
  30750. /**
  30751. * Gets the current projection matrix of the camera.
  30752. * @param force forces the camera to recompute the matrix without looking at the cached state
  30753. * @returns the projection matrix
  30754. */
  30755. getProjectionMatrix(force?: boolean): Matrix;
  30756. /**
  30757. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  30758. * @returns a Matrix
  30759. */
  30760. getTransformationMatrix(): Matrix;
  30761. private _updateFrustumPlanes;
  30762. /**
  30763. * Checks if a cullable object (mesh...) is in the camera frustum
  30764. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  30765. * @param target The object to check
  30766. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  30767. * @returns true if the object is in frustum otherwise false
  30768. */
  30769. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  30770. /**
  30771. * Checks if a cullable object (mesh...) is in the camera frustum
  30772. * Unlike isInFrustum this cheks the full bounding box
  30773. * @param target The object to check
  30774. * @returns true if the object is in frustum otherwise false
  30775. */
  30776. isCompletelyInFrustum(target: ICullable): boolean;
  30777. /**
  30778. * Gets a ray in the forward direction from the camera.
  30779. * @param length Defines the length of the ray to create
  30780. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  30781. * @param origin Defines the start point of the ray which defaults to the camera position
  30782. * @returns the forward ray
  30783. */
  30784. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  30785. /**
  30786. * Releases resources associated with this node.
  30787. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  30788. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  30789. */
  30790. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  30791. /** @hidden */
  30792. _isLeftCamera: boolean;
  30793. /**
  30794. * Gets the left camera of a rig setup in case of Rigged Camera
  30795. */
  30796. readonly isLeftCamera: boolean;
  30797. /** @hidden */
  30798. _isRightCamera: boolean;
  30799. /**
  30800. * Gets the right camera of a rig setup in case of Rigged Camera
  30801. */
  30802. readonly isRightCamera: boolean;
  30803. /**
  30804. * Gets the left camera of a rig setup in case of Rigged Camera
  30805. */
  30806. readonly leftCamera: Nullable<FreeCamera>;
  30807. /**
  30808. * Gets the right camera of a rig setup in case of Rigged Camera
  30809. */
  30810. readonly rightCamera: Nullable<FreeCamera>;
  30811. /**
  30812. * Gets the left camera target of a rig setup in case of Rigged Camera
  30813. * @returns the target position
  30814. */
  30815. getLeftTarget(): Nullable<Vector3>;
  30816. /**
  30817. * Gets the right camera target of a rig setup in case of Rigged Camera
  30818. * @returns the target position
  30819. */
  30820. getRightTarget(): Nullable<Vector3>;
  30821. /**
  30822. * @hidden
  30823. */
  30824. setCameraRigMode(mode: number, rigParams: any): void;
  30825. /** @hidden */
  30826. static _setStereoscopicRigMode(camera: Camera): void;
  30827. /** @hidden */
  30828. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  30829. /** @hidden */
  30830. static _setVRRigMode(camera: Camera, rigParams: any): void;
  30831. /** @hidden */
  30832. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  30833. /** @hidden */
  30834. _getVRProjectionMatrix(): Matrix;
  30835. protected _updateCameraRotationMatrix(): void;
  30836. protected _updateWebVRCameraRotationMatrix(): void;
  30837. /**
  30838. * This function MUST be overwritten by the different WebVR cameras available.
  30839. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  30840. * @hidden
  30841. */
  30842. _getWebVRProjectionMatrix(): Matrix;
  30843. /**
  30844. * This function MUST be overwritten by the different WebVR cameras available.
  30845. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  30846. * @hidden
  30847. */
  30848. _getWebVRViewMatrix(): Matrix;
  30849. /** @hidden */
  30850. setCameraRigParameter(name: string, value: any): void;
  30851. /**
  30852. * needs to be overridden by children so sub has required properties to be copied
  30853. * @hidden
  30854. */
  30855. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  30856. /**
  30857. * May need to be overridden by children
  30858. * @hidden
  30859. */
  30860. _updateRigCameras(): void;
  30861. /** @hidden */
  30862. _setupInputs(): void;
  30863. /**
  30864. * Serialiaze the camera setup to a json represention
  30865. * @returns the JSON representation
  30866. */
  30867. serialize(): any;
  30868. /**
  30869. * Clones the current camera.
  30870. * @param name The cloned camera name
  30871. * @returns the cloned camera
  30872. */
  30873. clone(name: string): Camera;
  30874. /**
  30875. * Gets the direction of the camera relative to a given local axis.
  30876. * @param localAxis Defines the reference axis to provide a relative direction.
  30877. * @return the direction
  30878. */
  30879. getDirection(localAxis: Vector3): Vector3;
  30880. /**
  30881. * Gets the direction of the camera relative to a given local axis into a passed vector.
  30882. * @param localAxis Defines the reference axis to provide a relative direction.
  30883. * @param result Defines the vector to store the result in
  30884. */
  30885. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  30886. /**
  30887. * Gets a camera constructor for a given camera type
  30888. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  30889. * @param name The name of the camera the result will be able to instantiate
  30890. * @param scene The scene the result will construct the camera in
  30891. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  30892. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  30893. * @returns a factory method to construc the camera
  30894. */
  30895. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  30896. /**
  30897. * Compute the world matrix of the camera.
  30898. * @returns the camera workd matrix
  30899. */
  30900. computeWorldMatrix(): Matrix;
  30901. /**
  30902. * Parse a JSON and creates the camera from the parsed information
  30903. * @param parsedCamera The JSON to parse
  30904. * @param scene The scene to instantiate the camera in
  30905. * @returns the newly constructed camera
  30906. */
  30907. static Parse(parsedCamera: any, scene: Scene): Camera;
  30908. }
  30909. }
  30910. declare module BABYLON {
  30911. /**
  30912. * Interface for any object that can request an animation frame
  30913. */
  30914. export interface ICustomAnimationFrameRequester {
  30915. /**
  30916. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  30917. */
  30918. renderFunction?: Function;
  30919. /**
  30920. * Called to request the next frame to render to
  30921. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  30922. */
  30923. requestAnimationFrame: Function;
  30924. /**
  30925. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  30926. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  30927. */
  30928. requestID?: number;
  30929. }
  30930. /**
  30931. * Interface containing an array of animations
  30932. */
  30933. export interface IAnimatable {
  30934. /**
  30935. * Array of animations
  30936. */
  30937. animations: Nullable<Array<Animation>>;
  30938. }
  30939. /** Interface used by value gradients (color, factor, ...) */
  30940. export interface IValueGradient {
  30941. /**
  30942. * Gets or sets the gradient value (between 0 and 1)
  30943. */
  30944. gradient: number;
  30945. }
  30946. /** Class used to store color4 gradient */
  30947. export class ColorGradient implements IValueGradient {
  30948. /**
  30949. * Gets or sets the gradient value (between 0 and 1)
  30950. */
  30951. gradient: number;
  30952. /**
  30953. * Gets or sets first associated color
  30954. */
  30955. color1: Color4;
  30956. /**
  30957. * Gets or sets second associated color
  30958. */
  30959. color2?: Color4;
  30960. /**
  30961. * Will get a color picked randomly between color1 and color2.
  30962. * If color2 is undefined then color1 will be used
  30963. * @param result defines the target Color4 to store the result in
  30964. */
  30965. getColorToRef(result: Color4): void;
  30966. }
  30967. /** Class used to store color 3 gradient */
  30968. export class Color3Gradient implements IValueGradient {
  30969. /**
  30970. * Gets or sets the gradient value (between 0 and 1)
  30971. */
  30972. gradient: number;
  30973. /**
  30974. * Gets or sets the associated color
  30975. */
  30976. color: Color3;
  30977. }
  30978. /** Class used to store factor gradient */
  30979. export class FactorGradient implements IValueGradient {
  30980. /**
  30981. * Gets or sets the gradient value (between 0 and 1)
  30982. */
  30983. gradient: number;
  30984. /**
  30985. * Gets or sets first associated factor
  30986. */
  30987. factor1: number;
  30988. /**
  30989. * Gets or sets second associated factor
  30990. */
  30991. factor2?: number;
  30992. /**
  30993. * Will get a number picked randomly between factor1 and factor2.
  30994. * If factor2 is undefined then factor1 will be used
  30995. * @returns the picked number
  30996. */
  30997. getFactor(): number;
  30998. }
  30999. /**
  31000. * @ignore
  31001. * Application error to support additional information when loading a file
  31002. */
  31003. export class LoadFileError extends Error {
  31004. /** defines the optional web request */
  31005. request?: WebRequest | undefined;
  31006. private static _setPrototypeOf;
  31007. /**
  31008. * Creates a new LoadFileError
  31009. * @param message defines the message of the error
  31010. * @param request defines the optional web request
  31011. */
  31012. constructor(message: string,
  31013. /** defines the optional web request */
  31014. request?: WebRequest | undefined);
  31015. }
  31016. /**
  31017. * Class used to define a retry strategy when error happens while loading assets
  31018. */
  31019. export class RetryStrategy {
  31020. /**
  31021. * Function used to defines an exponential back off strategy
  31022. * @param maxRetries defines the maximum number of retries (3 by default)
  31023. * @param baseInterval defines the interval between retries
  31024. * @returns the strategy function to use
  31025. */
  31026. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  31027. }
  31028. /**
  31029. * File request interface
  31030. */
  31031. export interface IFileRequest {
  31032. /**
  31033. * Raised when the request is complete (success or error).
  31034. */
  31035. onCompleteObservable: Observable<IFileRequest>;
  31036. /**
  31037. * Aborts the request for a file.
  31038. */
  31039. abort: () => void;
  31040. }
  31041. /**
  31042. * Class containing a set of static utilities functions
  31043. */
  31044. export class Tools {
  31045. /**
  31046. * Gets or sets the base URL to use to load assets
  31047. */
  31048. static BaseUrl: string;
  31049. /**
  31050. * Enable/Disable Custom HTTP Request Headers globally.
  31051. * default = false
  31052. * @see CustomRequestHeaders
  31053. */
  31054. static UseCustomRequestHeaders: boolean;
  31055. /**
  31056. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  31057. * i.e. when loading files, where the server/service expects an Authorization header
  31058. */
  31059. static CustomRequestHeaders: {
  31060. [key: string]: string;
  31061. };
  31062. /**
  31063. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  31064. */
  31065. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  31066. /**
  31067. * Default behaviour for cors in the application.
  31068. * It can be a string if the expected behavior is identical in the entire app.
  31069. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  31070. */
  31071. static CorsBehavior: string | ((url: string | string[]) => string);
  31072. /**
  31073. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  31074. * @ignorenaming
  31075. */
  31076. static UseFallbackTexture: boolean;
  31077. /**
  31078. * Use this object to register external classes like custom textures or material
  31079. * to allow the laoders to instantiate them
  31080. */
  31081. static RegisteredExternalClasses: {
  31082. [key: string]: Object;
  31083. };
  31084. /**
  31085. * Texture content used if a texture cannot loaded
  31086. * @ignorenaming
  31087. */
  31088. static fallbackTexture: string;
  31089. /**
  31090. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  31091. * @param u defines the coordinate on X axis
  31092. * @param v defines the coordinate on Y axis
  31093. * @param width defines the width of the source data
  31094. * @param height defines the height of the source data
  31095. * @param pixels defines the source byte array
  31096. * @param color defines the output color
  31097. */
  31098. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  31099. /**
  31100. * Interpolates between a and b via alpha
  31101. * @param a The lower value (returned when alpha = 0)
  31102. * @param b The upper value (returned when alpha = 1)
  31103. * @param alpha The interpolation-factor
  31104. * @return The mixed value
  31105. */
  31106. static Mix(a: number, b: number, alpha: number): number;
  31107. /**
  31108. * Tries to instantiate a new object from a given class name
  31109. * @param className defines the class name to instantiate
  31110. * @returns the new object or null if the system was not able to do the instantiation
  31111. */
  31112. static Instantiate(className: string): any;
  31113. /**
  31114. * Provides a slice function that will work even on IE
  31115. * @param data defines the array to slice
  31116. * @param start defines the start of the data (optional)
  31117. * @param end defines the end of the data (optional)
  31118. * @returns the new sliced array
  31119. */
  31120. static Slice<T>(data: T, start?: number, end?: number): T;
  31121. /**
  31122. * Polyfill for setImmediate
  31123. * @param action defines the action to execute after the current execution block
  31124. */
  31125. static SetImmediate(action: () => void): void;
  31126. /**
  31127. * Function indicating if a number is an exponent of 2
  31128. * @param value defines the value to test
  31129. * @returns true if the value is an exponent of 2
  31130. */
  31131. static IsExponentOfTwo(value: number): boolean;
  31132. private static _tmpFloatArray;
  31133. /**
  31134. * Returns the nearest 32-bit single precision float representation of a Number
  31135. * @param value A Number. If the parameter is of a different type, it will get converted
  31136. * to a number or to NaN if it cannot be converted
  31137. * @returns number
  31138. */
  31139. static FloatRound(value: number): number;
  31140. /**
  31141. * Find the next highest power of two.
  31142. * @param x Number to start search from.
  31143. * @return Next highest power of two.
  31144. */
  31145. static CeilingPOT(x: number): number;
  31146. /**
  31147. * Find the next lowest power of two.
  31148. * @param x Number to start search from.
  31149. * @return Next lowest power of two.
  31150. */
  31151. static FloorPOT(x: number): number;
  31152. /**
  31153. * Find the nearest power of two.
  31154. * @param x Number to start search from.
  31155. * @return Next nearest power of two.
  31156. */
  31157. static NearestPOT(x: number): number;
  31158. /**
  31159. * Get the closest exponent of two
  31160. * @param value defines the value to approximate
  31161. * @param max defines the maximum value to return
  31162. * @param mode defines how to define the closest value
  31163. * @returns closest exponent of two of the given value
  31164. */
  31165. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  31166. /**
  31167. * Extracts the filename from a path
  31168. * @param path defines the path to use
  31169. * @returns the filename
  31170. */
  31171. static GetFilename(path: string): string;
  31172. /**
  31173. * Extracts the "folder" part of a path (everything before the filename).
  31174. * @param uri The URI to extract the info from
  31175. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  31176. * @returns The "folder" part of the path
  31177. */
  31178. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  31179. /**
  31180. * Extracts text content from a DOM element hierarchy
  31181. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  31182. */
  31183. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  31184. /**
  31185. * Convert an angle in radians to degrees
  31186. * @param angle defines the angle to convert
  31187. * @returns the angle in degrees
  31188. */
  31189. static ToDegrees(angle: number): number;
  31190. /**
  31191. * Convert an angle in degrees to radians
  31192. * @param angle defines the angle to convert
  31193. * @returns the angle in radians
  31194. */
  31195. static ToRadians(angle: number): number;
  31196. /**
  31197. * Encode a buffer to a base64 string
  31198. * @param buffer defines the buffer to encode
  31199. * @returns the encoded string
  31200. */
  31201. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  31202. /**
  31203. * Extracts minimum and maximum values from a list of indexed positions
  31204. * @param positions defines the positions to use
  31205. * @param indices defines the indices to the positions
  31206. * @param indexStart defines the start index
  31207. * @param indexCount defines the end index
  31208. * @param bias defines bias value to add to the result
  31209. * @return minimum and maximum values
  31210. */
  31211. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  31212. minimum: Vector3;
  31213. maximum: Vector3;
  31214. };
  31215. /**
  31216. * Extracts minimum and maximum values from a list of positions
  31217. * @param positions defines the positions to use
  31218. * @param start defines the start index in the positions array
  31219. * @param count defines the number of positions to handle
  31220. * @param bias defines bias value to add to the result
  31221. * @param stride defines the stride size to use (distance between two positions in the positions array)
  31222. * @return minimum and maximum values
  31223. */
  31224. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  31225. minimum: Vector3;
  31226. maximum: Vector3;
  31227. };
  31228. /**
  31229. * Returns an array if obj is not an array
  31230. * @param obj defines the object to evaluate as an array
  31231. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  31232. * @returns either obj directly if obj is an array or a new array containing obj
  31233. */
  31234. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  31235. /**
  31236. * Gets the pointer prefix to use
  31237. * @returns "pointer" if touch is enabled. Else returns "mouse"
  31238. */
  31239. static GetPointerPrefix(): string;
  31240. /**
  31241. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  31242. * @param func - the function to be called
  31243. * @param requester - the object that will request the next frame. Falls back to window.
  31244. * @returns frame number
  31245. */
  31246. static QueueNewFrame(func: () => void, requester?: any): number;
  31247. /**
  31248. * Ask the browser to promote the current element to fullscreen rendering mode
  31249. * @param element defines the DOM element to promote
  31250. */
  31251. static RequestFullscreen(element: HTMLElement): void;
  31252. /**
  31253. * Asks the browser to exit fullscreen mode
  31254. */
  31255. static ExitFullscreen(): void;
  31256. /**
  31257. * Ask the browser to promote the current element to pointerlock mode
  31258. * @param element defines the DOM element to promote
  31259. */
  31260. static RequestPointerlock(element: HTMLElement): void;
  31261. /**
  31262. * Asks the browser to exit pointerlock mode
  31263. */
  31264. static ExitPointerlock(): void;
  31265. /**
  31266. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  31267. * @param url define the url we are trying
  31268. * @param element define the dom element where to configure the cors policy
  31269. */
  31270. static SetCorsBehavior(url: string | string[], element: {
  31271. crossOrigin: string | null;
  31272. }): void;
  31273. /**
  31274. * Removes unwanted characters from an url
  31275. * @param url defines the url to clean
  31276. * @returns the cleaned url
  31277. */
  31278. static CleanUrl(url: string): string;
  31279. /**
  31280. * Gets or sets a function used to pre-process url before using them to load assets
  31281. */
  31282. static PreprocessUrl: (url: string) => string;
  31283. /**
  31284. * Loads an image as an HTMLImageElement.
  31285. * @param input url string, ArrayBuffer, or Blob to load
  31286. * @param onLoad callback called when the image successfully loads
  31287. * @param onError callback called when the image fails to load
  31288. * @param offlineProvider offline provider for caching
  31289. * @returns the HTMLImageElement of the loaded image
  31290. */
  31291. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  31292. /**
  31293. * Loads a file
  31294. * @param url url string, ArrayBuffer, or Blob to load
  31295. * @param onSuccess callback called when the file successfully loads
  31296. * @param onProgress callback called while file is loading (if the server supports this mode)
  31297. * @param offlineProvider defines the offline provider for caching
  31298. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  31299. * @param onError callback called when the file fails to load
  31300. * @returns a file request object
  31301. */
  31302. 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;
  31303. /**
  31304. * Load a script (identified by an url). When the url returns, the
  31305. * content of this file is added into a new script element, attached to the DOM (body element)
  31306. * @param scriptUrl defines the url of the script to laod
  31307. * @param onSuccess defines the callback called when the script is loaded
  31308. * @param onError defines the callback to call if an error occurs
  31309. * @param scriptId defines the id of the script element
  31310. */
  31311. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  31312. /**
  31313. * Load an asynchronous script (identified by an url). When the url returns, the
  31314. * content of this file is added into a new script element, attached to the DOM (body element)
  31315. * @param scriptUrl defines the url of the script to laod
  31316. * @param scriptId defines the id of the script element
  31317. * @returns a promise request object
  31318. */
  31319. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  31320. /**
  31321. * Loads a file from a blob
  31322. * @param fileToLoad defines the blob to use
  31323. * @param callback defines the callback to call when data is loaded
  31324. * @param progressCallback defines the callback to call during loading process
  31325. * @returns a file request object
  31326. */
  31327. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  31328. /**
  31329. * Loads a file
  31330. * @param fileToLoad defines the file to load
  31331. * @param callback defines the callback to call when data is loaded
  31332. * @param progressCallBack defines the callback to call during loading process
  31333. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  31334. * @returns a file request object
  31335. */
  31336. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  31337. /**
  31338. * Creates a data url from a given string content
  31339. * @param content defines the content to convert
  31340. * @returns the new data url link
  31341. */
  31342. static FileAsURL(content: string): string;
  31343. /**
  31344. * Format the given number to a specific decimal format
  31345. * @param value defines the number to format
  31346. * @param decimals defines the number of decimals to use
  31347. * @returns the formatted string
  31348. */
  31349. static Format(value: number, decimals?: number): string;
  31350. /**
  31351. * Checks if a given vector is inside a specific range
  31352. * @param v defines the vector to test
  31353. * @param min defines the minimum range
  31354. * @param max defines the maximum range
  31355. */
  31356. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  31357. /**
  31358. * Tries to copy an object by duplicating every property
  31359. * @param source defines the source object
  31360. * @param destination defines the target object
  31361. * @param doNotCopyList defines a list of properties to avoid
  31362. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  31363. */
  31364. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  31365. /**
  31366. * Gets a boolean indicating if the given object has no own property
  31367. * @param obj defines the object to test
  31368. * @returns true if object has no own property
  31369. */
  31370. static IsEmpty(obj: any): boolean;
  31371. /**
  31372. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  31373. * @param str Source string
  31374. * @param suffix Suffix to search for in the source string
  31375. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  31376. */
  31377. static EndsWith(str: string, suffix: string): boolean;
  31378. /**
  31379. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  31380. * @param str Source string
  31381. * @param suffix Suffix to search for in the source string
  31382. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  31383. */
  31384. static StartsWith(str: string, suffix: string): boolean;
  31385. /**
  31386. * Function used to register events at window level
  31387. * @param events defines the events to register
  31388. */
  31389. static RegisterTopRootEvents(events: {
  31390. name: string;
  31391. handler: Nullable<(e: FocusEvent) => any>;
  31392. }[]): void;
  31393. /**
  31394. * Function used to unregister events from window level
  31395. * @param events defines the events to unregister
  31396. */
  31397. static UnregisterTopRootEvents(events: {
  31398. name: string;
  31399. handler: Nullable<(e: FocusEvent) => any>;
  31400. }[]): void;
  31401. /**
  31402. * @ignore
  31403. */
  31404. static _ScreenshotCanvas: HTMLCanvasElement;
  31405. /**
  31406. * Dumps the current bound framebuffer
  31407. * @param width defines the rendering width
  31408. * @param height defines the rendering height
  31409. * @param engine defines the hosting engine
  31410. * @param successCallback defines the callback triggered once the data are available
  31411. * @param mimeType defines the mime type of the result
  31412. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  31413. */
  31414. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  31415. /**
  31416. * Converts the canvas data to blob.
  31417. * This acts as a polyfill for browsers not supporting the to blob function.
  31418. * @param canvas Defines the canvas to extract the data from
  31419. * @param successCallback Defines the callback triggered once the data are available
  31420. * @param mimeType Defines the mime type of the result
  31421. */
  31422. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  31423. /**
  31424. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  31425. * @param successCallback defines the callback triggered once the data are available
  31426. * @param mimeType defines the mime type of the result
  31427. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  31428. */
  31429. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  31430. /**
  31431. * Downloads a blob in the browser
  31432. * @param blob defines the blob to download
  31433. * @param fileName defines the name of the downloaded file
  31434. */
  31435. static Download(blob: Blob, fileName: string): void;
  31436. /**
  31437. * Captures a screenshot of the current rendering
  31438. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  31439. * @param engine defines the rendering engine
  31440. * @param camera defines the source camera
  31441. * @param size This parameter can be set to a single number or to an object with the
  31442. * following (optional) properties: precision, width, height. If a single number is passed,
  31443. * it will be used for both width and height. If an object is passed, the screenshot size
  31444. * will be derived from the parameters. The precision property is a multiplier allowing
  31445. * rendering at a higher or lower resolution
  31446. * @param successCallback defines the callback receives a single parameter which contains the
  31447. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  31448. * src parameter of an <img> to display it
  31449. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  31450. * Check your browser for supported MIME types
  31451. */
  31452. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  31453. /**
  31454. * Generates an image screenshot from the specified camera.
  31455. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  31456. * @param engine The engine to use for rendering
  31457. * @param camera The camera to use for rendering
  31458. * @param size This parameter can be set to a single number or to an object with the
  31459. * following (optional) properties: precision, width, height. If a single number is passed,
  31460. * it will be used for both width and height. If an object is passed, the screenshot size
  31461. * will be derived from the parameters. The precision property is a multiplier allowing
  31462. * rendering at a higher or lower resolution
  31463. * @param successCallback The callback receives a single parameter which contains the
  31464. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  31465. * src parameter of an <img> to display it
  31466. * @param mimeType The MIME type of the screenshot image (default: image/png).
  31467. * Check your browser for supported MIME types
  31468. * @param samples Texture samples (default: 1)
  31469. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  31470. * @param fileName A name for for the downloaded file.
  31471. */
  31472. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  31473. /**
  31474. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  31475. * Be aware Math.random() could cause collisions, but:
  31476. * "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"
  31477. * @returns a pseudo random id
  31478. */
  31479. static RandomId(): string;
  31480. /**
  31481. * Test if the given uri is a base64 string
  31482. * @param uri The uri to test
  31483. * @return True if the uri is a base64 string or false otherwise
  31484. */
  31485. static IsBase64(uri: string): boolean;
  31486. /**
  31487. * Decode the given base64 uri.
  31488. * @param uri The uri to decode
  31489. * @return The decoded base64 data.
  31490. */
  31491. static DecodeBase64(uri: string): ArrayBuffer;
  31492. /**
  31493. * Gets the absolute url.
  31494. * @param url the input url
  31495. * @return the absolute url
  31496. */
  31497. static GetAbsoluteUrl(url: string): string;
  31498. /**
  31499. * No log
  31500. */
  31501. static readonly NoneLogLevel: number;
  31502. /**
  31503. * Only message logs
  31504. */
  31505. static readonly MessageLogLevel: number;
  31506. /**
  31507. * Only warning logs
  31508. */
  31509. static readonly WarningLogLevel: number;
  31510. /**
  31511. * Only error logs
  31512. */
  31513. static readonly ErrorLogLevel: number;
  31514. /**
  31515. * All logs
  31516. */
  31517. static readonly AllLogLevel: number;
  31518. /**
  31519. * Gets a value indicating the number of loading errors
  31520. * @ignorenaming
  31521. */
  31522. static readonly errorsCount: number;
  31523. /**
  31524. * Callback called when a new log is added
  31525. */
  31526. static OnNewCacheEntry: (entry: string) => void;
  31527. /**
  31528. * Log a message to the console
  31529. * @param message defines the message to log
  31530. */
  31531. static Log(message: string): void;
  31532. /**
  31533. * Write a warning message to the console
  31534. * @param message defines the message to log
  31535. */
  31536. static Warn(message: string): void;
  31537. /**
  31538. * Write an error message to the console
  31539. * @param message defines the message to log
  31540. */
  31541. static Error(message: string): void;
  31542. /**
  31543. * Gets current log cache (list of logs)
  31544. */
  31545. static readonly LogCache: string;
  31546. /**
  31547. * Clears the log cache
  31548. */
  31549. static ClearLogCache(): void;
  31550. /**
  31551. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  31552. */
  31553. static LogLevels: number;
  31554. /**
  31555. * Checks if the loaded document was accessed via `file:`-Protocol.
  31556. * @returns boolean
  31557. */
  31558. static IsFileURL(): boolean;
  31559. /**
  31560. * Checks if the window object exists
  31561. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  31562. */
  31563. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  31564. /**
  31565. * No performance log
  31566. */
  31567. static readonly PerformanceNoneLogLevel: number;
  31568. /**
  31569. * Use user marks to log performance
  31570. */
  31571. static readonly PerformanceUserMarkLogLevel: number;
  31572. /**
  31573. * Log performance to the console
  31574. */
  31575. static readonly PerformanceConsoleLogLevel: number;
  31576. private static _performance;
  31577. /**
  31578. * Sets the current performance log level
  31579. */
  31580. static PerformanceLogLevel: number;
  31581. private static _StartPerformanceCounterDisabled;
  31582. private static _EndPerformanceCounterDisabled;
  31583. private static _StartUserMark;
  31584. private static _EndUserMark;
  31585. private static _StartPerformanceConsole;
  31586. private static _EndPerformanceConsole;
  31587. /**
  31588. * Starts a performance counter
  31589. */
  31590. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  31591. /**
  31592. * Ends a specific performance coutner
  31593. */
  31594. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  31595. /**
  31596. * Gets either window.performance.now() if supported or Date.now() else
  31597. */
  31598. static readonly Now: number;
  31599. /**
  31600. * This method will return the name of the class used to create the instance of the given object.
  31601. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  31602. * @param object the object to get the class name from
  31603. * @param isType defines if the object is actually a type
  31604. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  31605. */
  31606. static GetClassName(object: any, isType?: boolean): string;
  31607. /**
  31608. * Gets the first element of an array satisfying a given predicate
  31609. * @param array defines the array to browse
  31610. * @param predicate defines the predicate to use
  31611. * @returns null if not found or the element
  31612. */
  31613. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  31614. /**
  31615. * This method will return the name of the full name of the class, including its owning module (if any).
  31616. * 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).
  31617. * @param object the object to get the class name from
  31618. * @param isType defines if the object is actually a type
  31619. * @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.
  31620. * @ignorenaming
  31621. */
  31622. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  31623. /**
  31624. * Returns a promise that resolves after the given amount of time.
  31625. * @param delay Number of milliseconds to delay
  31626. * @returns Promise that resolves after the given amount of time
  31627. */
  31628. static DelayAsync(delay: number): Promise<void>;
  31629. /**
  31630. * Gets the current gradient from an array of IValueGradient
  31631. * @param ratio defines the current ratio to get
  31632. * @param gradients defines the array of IValueGradient
  31633. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  31634. */
  31635. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  31636. }
  31637. /**
  31638. * This class is used to track a performance counter which is number based.
  31639. * The user has access to many properties which give statistics of different nature.
  31640. *
  31641. * The implementer can track two kinds of Performance Counter: time and count.
  31642. * 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.
  31643. * 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.
  31644. */
  31645. export class PerfCounter {
  31646. /**
  31647. * Gets or sets a global boolean to turn on and off all the counters
  31648. */
  31649. static Enabled: boolean;
  31650. /**
  31651. * Returns the smallest value ever
  31652. */
  31653. readonly min: number;
  31654. /**
  31655. * Returns the biggest value ever
  31656. */
  31657. readonly max: number;
  31658. /**
  31659. * Returns the average value since the performance counter is running
  31660. */
  31661. readonly average: number;
  31662. /**
  31663. * Returns the average value of the last second the counter was monitored
  31664. */
  31665. readonly lastSecAverage: number;
  31666. /**
  31667. * Returns the current value
  31668. */
  31669. readonly current: number;
  31670. /**
  31671. * Gets the accumulated total
  31672. */
  31673. readonly total: number;
  31674. /**
  31675. * Gets the total value count
  31676. */
  31677. readonly count: number;
  31678. /**
  31679. * Creates a new counter
  31680. */
  31681. constructor();
  31682. /**
  31683. * Call this method to start monitoring a new frame.
  31684. * 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.
  31685. */
  31686. fetchNewFrame(): void;
  31687. /**
  31688. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  31689. * @param newCount the count value to add to the monitored count
  31690. * @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.
  31691. */
  31692. addCount(newCount: number, fetchResult: boolean): void;
  31693. /**
  31694. * Start monitoring this performance counter
  31695. */
  31696. beginMonitoring(): void;
  31697. /**
  31698. * Compute the time lapsed since the previous beginMonitoring() call.
  31699. * @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
  31700. */
  31701. endMonitoring(newFrame?: boolean): void;
  31702. private _fetchResult;
  31703. private _startMonitoringTime;
  31704. private _min;
  31705. private _max;
  31706. private _average;
  31707. private _current;
  31708. private _totalValueCount;
  31709. private _totalAccumulated;
  31710. private _lastSecAverage;
  31711. private _lastSecAccumulated;
  31712. private _lastSecTime;
  31713. private _lastSecValueCount;
  31714. }
  31715. /**
  31716. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  31717. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  31718. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  31719. * @param name The name of the class, case should be preserved
  31720. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  31721. */
  31722. export function className(name: string, module?: string): (target: Object) => void;
  31723. /**
  31724. * An implementation of a loop for asynchronous functions.
  31725. */
  31726. export class AsyncLoop {
  31727. /**
  31728. * Defines the number of iterations for the loop
  31729. */
  31730. iterations: number;
  31731. /**
  31732. * Defines the current index of the loop.
  31733. */
  31734. index: number;
  31735. private _done;
  31736. private _fn;
  31737. private _successCallback;
  31738. /**
  31739. * Constructor.
  31740. * @param iterations the number of iterations.
  31741. * @param func the function to run each iteration
  31742. * @param successCallback the callback that will be called upon succesful execution
  31743. * @param offset starting offset.
  31744. */
  31745. constructor(
  31746. /**
  31747. * Defines the number of iterations for the loop
  31748. */
  31749. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  31750. /**
  31751. * Execute the next iteration. Must be called after the last iteration was finished.
  31752. */
  31753. executeNext(): void;
  31754. /**
  31755. * Break the loop and run the success callback.
  31756. */
  31757. breakLoop(): void;
  31758. /**
  31759. * Create and run an async loop.
  31760. * @param iterations the number of iterations.
  31761. * @param fn the function to run each iteration
  31762. * @param successCallback the callback that will be called upon succesful execution
  31763. * @param offset starting offset.
  31764. * @returns the created async loop object
  31765. */
  31766. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  31767. /**
  31768. * A for-loop that will run a given number of iterations synchronous and the rest async.
  31769. * @param iterations total number of iterations
  31770. * @param syncedIterations number of synchronous iterations in each async iteration.
  31771. * @param fn the function to call each iteration.
  31772. * @param callback a success call back that will be called when iterating stops.
  31773. * @param breakFunction a break condition (optional)
  31774. * @param timeout timeout settings for the setTimeout function. default - 0.
  31775. * @returns the created async loop object
  31776. */
  31777. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  31778. }
  31779. }
  31780. declare module BABYLON {
  31781. /** @hidden */
  31782. export interface ICollisionCoordinator {
  31783. createCollider(): Collider;
  31784. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  31785. init(scene: Scene): void;
  31786. }
  31787. /** @hidden */
  31788. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  31789. private _scene;
  31790. private _scaledPosition;
  31791. private _scaledVelocity;
  31792. private _finalPosition;
  31793. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  31794. createCollider(): Collider;
  31795. init(scene: Scene): void;
  31796. private _collideWithWorld;
  31797. }
  31798. }
  31799. declare module BABYLON {
  31800. /**
  31801. * Class used to manage all inputs for the scene.
  31802. */
  31803. export class InputManager {
  31804. /** The distance in pixel that you have to move to prevent some events */
  31805. static DragMovementThreshold: number;
  31806. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  31807. static LongPressDelay: number;
  31808. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  31809. static DoubleClickDelay: number;
  31810. /** If you need to check double click without raising a single click at first click, enable this flag */
  31811. static ExclusiveDoubleClickMode: boolean;
  31812. private _wheelEventName;
  31813. private _onPointerMove;
  31814. private _onPointerDown;
  31815. private _onPointerUp;
  31816. private _initClickEvent;
  31817. private _initActionManager;
  31818. private _delayedSimpleClick;
  31819. private _delayedSimpleClickTimeout;
  31820. private _previousDelayedSimpleClickTimeout;
  31821. private _meshPickProceed;
  31822. private _previousButtonPressed;
  31823. private _currentPickResult;
  31824. private _previousPickResult;
  31825. private _totalPointersPressed;
  31826. private _doubleClickOccured;
  31827. private _pointerOverMesh;
  31828. private _pickedDownMesh;
  31829. private _pickedUpMesh;
  31830. private _pointerX;
  31831. private _pointerY;
  31832. private _unTranslatedPointerX;
  31833. private _unTranslatedPointerY;
  31834. private _startingPointerPosition;
  31835. private _previousStartingPointerPosition;
  31836. private _startingPointerTime;
  31837. private _previousStartingPointerTime;
  31838. private _pointerCaptures;
  31839. private _onKeyDown;
  31840. private _onKeyUp;
  31841. private _onCanvasFocusObserver;
  31842. private _onCanvasBlurObserver;
  31843. private _scene;
  31844. /**
  31845. * Creates a new InputManager
  31846. * @param scene defines the hosting scene
  31847. */
  31848. constructor(scene: Scene);
  31849. /**
  31850. * Gets the mesh that is currently under the pointer
  31851. */
  31852. readonly meshUnderPointer: Nullable<AbstractMesh>;
  31853. /**
  31854. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  31855. */
  31856. readonly unTranslatedPointer: Vector2;
  31857. /**
  31858. * Gets or sets the current on-screen X position of the pointer
  31859. */
  31860. pointerX: number;
  31861. /**
  31862. * Gets or sets the current on-screen Y position of the pointer
  31863. */
  31864. pointerY: number;
  31865. private _updatePointerPosition;
  31866. private _processPointerMove;
  31867. private _setRayOnPointerInfo;
  31868. private _checkPrePointerObservable;
  31869. /**
  31870. * Use this method to simulate a pointer move on a mesh
  31871. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  31872. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  31873. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  31874. */
  31875. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  31876. /**
  31877. * Use this method to simulate a pointer down on a mesh
  31878. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  31879. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  31880. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  31881. */
  31882. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  31883. private _processPointerDown;
  31884. /** @hidden */
  31885. _isPointerSwiping(): boolean;
  31886. /**
  31887. * Use this method to simulate a pointer up on a mesh
  31888. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  31889. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  31890. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  31891. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  31892. */
  31893. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  31894. private _processPointerUp;
  31895. /**
  31896. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  31897. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  31898. * @returns true if the pointer was captured
  31899. */
  31900. isPointerCaptured(pointerId?: number): boolean;
  31901. /**
  31902. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  31903. * @param attachUp defines if you want to attach events to pointerup
  31904. * @param attachDown defines if you want to attach events to pointerdown
  31905. * @param attachMove defines if you want to attach events to pointermove
  31906. */
  31907. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  31908. /**
  31909. * Detaches all event handlers
  31910. */
  31911. detachControl(): void;
  31912. /**
  31913. * Force the value of meshUnderPointer
  31914. * @param mesh defines the mesh to use
  31915. */
  31916. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  31917. /**
  31918. * Gets the mesh under the pointer
  31919. * @returns a Mesh or null if no mesh is under the pointer
  31920. */
  31921. getPointerOverMesh(): Nullable<AbstractMesh>;
  31922. }
  31923. }
  31924. declare module BABYLON {
  31925. /**
  31926. * This class defines the direct association between an animation and a target
  31927. */
  31928. export class TargetedAnimation {
  31929. /**
  31930. * Animation to perform
  31931. */
  31932. animation: Animation;
  31933. /**
  31934. * Target to animate
  31935. */
  31936. target: any;
  31937. /**
  31938. * Serialize the object
  31939. * @returns the JSON object representing the current entity
  31940. */
  31941. serialize(): any;
  31942. }
  31943. /**
  31944. * Use this class to create coordinated animations on multiple targets
  31945. */
  31946. export class AnimationGroup implements IDisposable {
  31947. /** The name of the animation group */
  31948. name: string;
  31949. private _scene;
  31950. private _targetedAnimations;
  31951. private _animatables;
  31952. private _from;
  31953. private _to;
  31954. private _isStarted;
  31955. private _isPaused;
  31956. private _speedRatio;
  31957. private _loopAnimation;
  31958. /**
  31959. * Gets or sets the unique id of the node
  31960. */
  31961. uniqueId: number;
  31962. /**
  31963. * This observable will notify when one animation have ended
  31964. */
  31965. onAnimationEndObservable: Observable<TargetedAnimation>;
  31966. /**
  31967. * Observer raised when one animation loops
  31968. */
  31969. onAnimationLoopObservable: Observable<TargetedAnimation>;
  31970. /**
  31971. * This observable will notify when all animations have ended.
  31972. */
  31973. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  31974. /**
  31975. * This observable will notify when all animations have paused.
  31976. */
  31977. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  31978. /**
  31979. * This observable will notify when all animations are playing.
  31980. */
  31981. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  31982. /**
  31983. * Gets the first frame
  31984. */
  31985. readonly from: number;
  31986. /**
  31987. * Gets the last frame
  31988. */
  31989. readonly to: number;
  31990. /**
  31991. * Define if the animations are started
  31992. */
  31993. readonly isStarted: boolean;
  31994. /**
  31995. * Gets a value indicating that the current group is playing
  31996. */
  31997. readonly isPlaying: boolean;
  31998. /**
  31999. * Gets or sets the speed ratio to use for all animations
  32000. */
  32001. /**
  32002. * Gets or sets the speed ratio to use for all animations
  32003. */
  32004. speedRatio: number;
  32005. /**
  32006. * Gets or sets if all animations should loop or not
  32007. */
  32008. loopAnimation: boolean;
  32009. /**
  32010. * Gets the targeted animations for this animation group
  32011. */
  32012. readonly targetedAnimations: Array<TargetedAnimation>;
  32013. /**
  32014. * returning the list of animatables controlled by this animation group.
  32015. */
  32016. readonly animatables: Array<Animatable>;
  32017. /**
  32018. * Instantiates a new Animation Group.
  32019. * This helps managing several animations at once.
  32020. * @see http://doc.babylonjs.com/how_to/group
  32021. * @param name Defines the name of the group
  32022. * @param scene Defines the scene the group belongs to
  32023. */
  32024. constructor(
  32025. /** The name of the animation group */
  32026. name: string, scene?: Nullable<Scene>);
  32027. /**
  32028. * Add an animation (with its target) in the group
  32029. * @param animation defines the animation we want to add
  32030. * @param target defines the target of the animation
  32031. * @returns the TargetedAnimation object
  32032. */
  32033. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  32034. /**
  32035. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  32036. * It can add constant keys at begin or end
  32037. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  32038. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  32039. * @returns the animation group
  32040. */
  32041. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  32042. /**
  32043. * Start all animations on given targets
  32044. * @param loop defines if animations must loop
  32045. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  32046. * @param from defines the from key (optional)
  32047. * @param to defines the to key (optional)
  32048. * @returns the current animation group
  32049. */
  32050. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  32051. /**
  32052. * Pause all animations
  32053. * @returns the animation group
  32054. */
  32055. pause(): AnimationGroup;
  32056. /**
  32057. * Play all animations to initial state
  32058. * This function will start() the animations if they were not started or will restart() them if they were paused
  32059. * @param loop defines if animations must loop
  32060. * @returns the animation group
  32061. */
  32062. play(loop?: boolean): AnimationGroup;
  32063. /**
  32064. * Reset all animations to initial state
  32065. * @returns the animation group
  32066. */
  32067. reset(): AnimationGroup;
  32068. /**
  32069. * Restart animations from key 0
  32070. * @returns the animation group
  32071. */
  32072. restart(): AnimationGroup;
  32073. /**
  32074. * Stop all animations
  32075. * @returns the animation group
  32076. */
  32077. stop(): AnimationGroup;
  32078. /**
  32079. * Set animation weight for all animatables
  32080. * @param weight defines the weight to use
  32081. * @return the animationGroup
  32082. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  32083. */
  32084. setWeightForAllAnimatables(weight: number): AnimationGroup;
  32085. /**
  32086. * Synchronize and normalize all animatables with a source animatable
  32087. * @param root defines the root animatable to synchronize with
  32088. * @return the animationGroup
  32089. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  32090. */
  32091. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  32092. /**
  32093. * Goes to a specific frame in this animation group
  32094. * @param frame the frame number to go to
  32095. * @return the animationGroup
  32096. */
  32097. goToFrame(frame: number): AnimationGroup;
  32098. /**
  32099. * Dispose all associated resources
  32100. */
  32101. dispose(): void;
  32102. private _checkAnimationGroupEnded;
  32103. /**
  32104. * Clone the current animation group and returns a copy
  32105. * @param newName defines the name of the new group
  32106. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  32107. * @returns the new aniamtion group
  32108. */
  32109. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  32110. /**
  32111. * Serializes the animationGroup to an object
  32112. * @returns Serialized object
  32113. */
  32114. serialize(): any;
  32115. /**
  32116. * Returns a new AnimationGroup object parsed from the source provided.
  32117. * @param parsedAnimationGroup defines the source
  32118. * @param scene defines the scene that will receive the animationGroup
  32119. * @returns a new AnimationGroup
  32120. */
  32121. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  32122. /**
  32123. * Returns the string "AnimationGroup"
  32124. * @returns "AnimationGroup"
  32125. */
  32126. getClassName(): string;
  32127. /**
  32128. * Creates a detailled string about the object
  32129. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  32130. * @returns a string representing the object
  32131. */
  32132. toString(fullDetails?: boolean): string;
  32133. }
  32134. }
  32135. declare module BABYLON {
  32136. /**
  32137. * Define an interface for all classes that will hold resources
  32138. */
  32139. export interface IDisposable {
  32140. /**
  32141. * Releases all held resources
  32142. */
  32143. dispose(): void;
  32144. }
  32145. /** Interface defining initialization parameters for Scene class */
  32146. export interface SceneOptions {
  32147. /**
  32148. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  32149. * It will improve performance when the number of geometries becomes important.
  32150. */
  32151. useGeometryUniqueIdsMap?: boolean;
  32152. /**
  32153. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  32154. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  32155. */
  32156. useMaterialMeshMap?: boolean;
  32157. /**
  32158. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  32159. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  32160. */
  32161. useClonedMeshhMap?: boolean;
  32162. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  32163. virtual?: boolean;
  32164. }
  32165. /**
  32166. * Represents a scene to be rendered by the engine.
  32167. * @see http://doc.babylonjs.com/features/scene
  32168. */
  32169. export class Scene extends AbstractScene implements IAnimatable {
  32170. private static _uniqueIdCounter;
  32171. /** The fog is deactivated */
  32172. static readonly FOGMODE_NONE: number;
  32173. /** The fog density is following an exponential function */
  32174. static readonly FOGMODE_EXP: number;
  32175. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  32176. static readonly FOGMODE_EXP2: number;
  32177. /** The fog density is following a linear function. */
  32178. static readonly FOGMODE_LINEAR: number;
  32179. /**
  32180. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  32181. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32182. */
  32183. static MinDeltaTime: number;
  32184. /**
  32185. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  32186. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32187. */
  32188. static MaxDeltaTime: number;
  32189. /**
  32190. * Factory used to create the default material.
  32191. * @param name The name of the material to create
  32192. * @param scene The scene to create the material for
  32193. * @returns The default material
  32194. */
  32195. static DefaultMaterialFactory(scene: Scene): Material;
  32196. /**
  32197. * Factory used to create the a collision coordinator.
  32198. * @returns The collision coordinator
  32199. */
  32200. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  32201. /** @hidden */
  32202. _inputManager: InputManager;
  32203. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  32204. cameraToUseForPointers: Nullable<Camera>;
  32205. /** @hidden */
  32206. readonly _isScene: boolean;
  32207. /**
  32208. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  32209. */
  32210. autoClear: boolean;
  32211. /**
  32212. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  32213. */
  32214. autoClearDepthAndStencil: boolean;
  32215. /**
  32216. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  32217. */
  32218. clearColor: Color4;
  32219. /**
  32220. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  32221. */
  32222. ambientColor: Color3;
  32223. /**
  32224. * This is use to store the default BRDF lookup for PBR materials in your scene.
  32225. * It should only be one of the following (if not the default embedded one):
  32226. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  32227. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  32228. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  32229. * The material properties need to be setup according to the type of texture in use.
  32230. */
  32231. environmentBRDFTexture: BaseTexture;
  32232. /** @hidden */
  32233. protected _environmentTexture: Nullable<BaseTexture>;
  32234. /**
  32235. * Texture used in all pbr material as the reflection texture.
  32236. * As in the majority of the scene they are the same (exception for multi room and so on),
  32237. * this is easier to reference from here than from all the materials.
  32238. */
  32239. /**
  32240. * Texture used in all pbr material as the reflection texture.
  32241. * As in the majority of the scene they are the same (exception for multi room and so on),
  32242. * this is easier to set here than in all the materials.
  32243. */
  32244. environmentTexture: Nullable<BaseTexture>;
  32245. /** @hidden */
  32246. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  32247. /**
  32248. * Default image processing configuration used either in the rendering
  32249. * Forward main pass or through the imageProcessingPostProcess if present.
  32250. * As in the majority of the scene they are the same (exception for multi camera),
  32251. * this is easier to reference from here than from all the materials and post process.
  32252. *
  32253. * No setter as we it is a shared configuration, you can set the values instead.
  32254. */
  32255. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  32256. private _forceWireframe;
  32257. /**
  32258. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  32259. */
  32260. forceWireframe: boolean;
  32261. private _forcePointsCloud;
  32262. /**
  32263. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  32264. */
  32265. forcePointsCloud: boolean;
  32266. /**
  32267. * Gets or sets the active clipplane 1
  32268. */
  32269. clipPlane: Nullable<Plane>;
  32270. /**
  32271. * Gets or sets the active clipplane 2
  32272. */
  32273. clipPlane2: Nullable<Plane>;
  32274. /**
  32275. * Gets or sets the active clipplane 3
  32276. */
  32277. clipPlane3: Nullable<Plane>;
  32278. /**
  32279. * Gets or sets the active clipplane 4
  32280. */
  32281. clipPlane4: Nullable<Plane>;
  32282. /**
  32283. * Gets or sets a boolean indicating if animations are enabled
  32284. */
  32285. animationsEnabled: boolean;
  32286. private _animationPropertiesOverride;
  32287. /**
  32288. * Gets or sets the animation properties override
  32289. */
  32290. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  32291. /**
  32292. * Gets or sets a boolean indicating if a constant deltatime has to be used
  32293. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  32294. */
  32295. useConstantAnimationDeltaTime: boolean;
  32296. /**
  32297. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  32298. * Please note that it requires to run a ray cast through the scene on every frame
  32299. */
  32300. constantlyUpdateMeshUnderPointer: boolean;
  32301. /**
  32302. * Defines the HTML cursor to use when hovering over interactive elements
  32303. */
  32304. hoverCursor: string;
  32305. /**
  32306. * Defines the HTML default cursor to use (empty by default)
  32307. */
  32308. defaultCursor: string;
  32309. /**
  32310. * This is used to call preventDefault() on pointer down
  32311. * in order to block unwanted artifacts like system double clicks
  32312. */
  32313. preventDefaultOnPointerDown: boolean;
  32314. /**
  32315. * This is used to call preventDefault() on pointer up
  32316. * in order to block unwanted artifacts like system double clicks
  32317. */
  32318. preventDefaultOnPointerUp: boolean;
  32319. /**
  32320. * Gets or sets user defined metadata
  32321. */
  32322. metadata: any;
  32323. /**
  32324. * For internal use only. Please do not use.
  32325. */
  32326. reservedDataStore: any;
  32327. /**
  32328. * Gets the name of the plugin used to load this scene (null by default)
  32329. */
  32330. loadingPluginName: string;
  32331. /**
  32332. * Use this array to add regular expressions used to disable offline support for specific urls
  32333. */
  32334. disableOfflineSupportExceptionRules: RegExp[];
  32335. /**
  32336. * An event triggered when the scene is disposed.
  32337. */
  32338. onDisposeObservable: Observable<Scene>;
  32339. private _onDisposeObserver;
  32340. /** Sets a function to be executed when this scene is disposed. */
  32341. onDispose: () => void;
  32342. /**
  32343. * An event triggered before rendering the scene (right after animations and physics)
  32344. */
  32345. onBeforeRenderObservable: Observable<Scene>;
  32346. private _onBeforeRenderObserver;
  32347. /** Sets a function to be executed before rendering this scene */
  32348. beforeRender: Nullable<() => void>;
  32349. /**
  32350. * An event triggered after rendering the scene
  32351. */
  32352. onAfterRenderObservable: Observable<Scene>;
  32353. /**
  32354. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  32355. */
  32356. onAfterRenderCameraObservable: Observable<Camera>;
  32357. private _onAfterRenderObserver;
  32358. /** Sets a function to be executed after rendering this scene */
  32359. afterRender: Nullable<() => void>;
  32360. /**
  32361. * An event triggered before animating the scene
  32362. */
  32363. onBeforeAnimationsObservable: Observable<Scene>;
  32364. /**
  32365. * An event triggered after animations processing
  32366. */
  32367. onAfterAnimationsObservable: Observable<Scene>;
  32368. /**
  32369. * An event triggered before draw calls are ready to be sent
  32370. */
  32371. onBeforeDrawPhaseObservable: Observable<Scene>;
  32372. /**
  32373. * An event triggered after draw calls have been sent
  32374. */
  32375. onAfterDrawPhaseObservable: Observable<Scene>;
  32376. /**
  32377. * An event triggered when the scene is ready
  32378. */
  32379. onReadyObservable: Observable<Scene>;
  32380. /**
  32381. * An event triggered before rendering a camera
  32382. */
  32383. onBeforeCameraRenderObservable: Observable<Camera>;
  32384. private _onBeforeCameraRenderObserver;
  32385. /** Sets a function to be executed before rendering a camera*/
  32386. beforeCameraRender: () => void;
  32387. /**
  32388. * An event triggered after rendering a camera
  32389. */
  32390. onAfterCameraRenderObservable: Observable<Camera>;
  32391. private _onAfterCameraRenderObserver;
  32392. /** Sets a function to be executed after rendering a camera*/
  32393. afterCameraRender: () => void;
  32394. /**
  32395. * An event triggered when active meshes evaluation is about to start
  32396. */
  32397. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  32398. /**
  32399. * An event triggered when active meshes evaluation is done
  32400. */
  32401. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  32402. /**
  32403. * An event triggered when particles rendering is about to start
  32404. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  32405. */
  32406. onBeforeParticlesRenderingObservable: Observable<Scene>;
  32407. /**
  32408. * An event triggered when particles rendering is done
  32409. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  32410. */
  32411. onAfterParticlesRenderingObservable: Observable<Scene>;
  32412. /**
  32413. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  32414. */
  32415. onDataLoadedObservable: Observable<Scene>;
  32416. /**
  32417. * An event triggered when a camera is created
  32418. */
  32419. onNewCameraAddedObservable: Observable<Camera>;
  32420. /**
  32421. * An event triggered when a camera is removed
  32422. */
  32423. onCameraRemovedObservable: Observable<Camera>;
  32424. /**
  32425. * An event triggered when a light is created
  32426. */
  32427. onNewLightAddedObservable: Observable<Light>;
  32428. /**
  32429. * An event triggered when a light is removed
  32430. */
  32431. onLightRemovedObservable: Observable<Light>;
  32432. /**
  32433. * An event triggered when a geometry is created
  32434. */
  32435. onNewGeometryAddedObservable: Observable<Geometry>;
  32436. /**
  32437. * An event triggered when a geometry is removed
  32438. */
  32439. onGeometryRemovedObservable: Observable<Geometry>;
  32440. /**
  32441. * An event triggered when a transform node is created
  32442. */
  32443. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  32444. /**
  32445. * An event triggered when a transform node is removed
  32446. */
  32447. onTransformNodeRemovedObservable: Observable<TransformNode>;
  32448. /**
  32449. * An event triggered when a mesh is created
  32450. */
  32451. onNewMeshAddedObservable: Observable<AbstractMesh>;
  32452. /**
  32453. * An event triggered when a mesh is removed
  32454. */
  32455. onMeshRemovedObservable: Observable<AbstractMesh>;
  32456. /**
  32457. * An event triggered when a skeleton is created
  32458. */
  32459. onNewSkeletonAddedObservable: Observable<Skeleton>;
  32460. /**
  32461. * An event triggered when a skeleton is removed
  32462. */
  32463. onSkeletonRemovedObservable: Observable<Skeleton>;
  32464. /**
  32465. * An event triggered when a material is created
  32466. */
  32467. onNewMaterialAddedObservable: Observable<Material>;
  32468. /**
  32469. * An event triggered when a material is removed
  32470. */
  32471. onMaterialRemovedObservable: Observable<Material>;
  32472. /**
  32473. * An event triggered when a texture is created
  32474. */
  32475. onNewTextureAddedObservable: Observable<BaseTexture>;
  32476. /**
  32477. * An event triggered when a texture is removed
  32478. */
  32479. onTextureRemovedObservable: Observable<BaseTexture>;
  32480. /**
  32481. * An event triggered when render targets are about to be rendered
  32482. * Can happen multiple times per frame.
  32483. */
  32484. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  32485. /**
  32486. * An event triggered when render targets were rendered.
  32487. * Can happen multiple times per frame.
  32488. */
  32489. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  32490. /**
  32491. * An event triggered before calculating deterministic simulation step
  32492. */
  32493. onBeforeStepObservable: Observable<Scene>;
  32494. /**
  32495. * An event triggered after calculating deterministic simulation step
  32496. */
  32497. onAfterStepObservable: Observable<Scene>;
  32498. /**
  32499. * An event triggered when the activeCamera property is updated
  32500. */
  32501. onActiveCameraChanged: Observable<Scene>;
  32502. /**
  32503. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  32504. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  32505. * 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)
  32506. */
  32507. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  32508. /**
  32509. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  32510. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  32511. * 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)
  32512. */
  32513. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  32514. /**
  32515. * This Observable will when a mesh has been imported into the scene.
  32516. */
  32517. onMeshImportedObservable: Observable<AbstractMesh>;
  32518. /**
  32519. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  32520. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  32521. */
  32522. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  32523. /** @hidden */
  32524. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  32525. /**
  32526. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  32527. */
  32528. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  32529. /**
  32530. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  32531. */
  32532. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  32533. /**
  32534. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  32535. */
  32536. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  32537. /** Callback called when a pointer move is detected */
  32538. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  32539. /** Callback called when a pointer down is detected */
  32540. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  32541. /** Callback called when a pointer up is detected */
  32542. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  32543. /** Callback called when a pointer pick is detected */
  32544. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  32545. /**
  32546. * 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).
  32547. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  32548. */
  32549. onPrePointerObservable: Observable<PointerInfoPre>;
  32550. /**
  32551. * Observable event triggered each time an input event is received from the rendering canvas
  32552. */
  32553. onPointerObservable: Observable<PointerInfo>;
  32554. /**
  32555. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  32556. */
  32557. readonly unTranslatedPointer: Vector2;
  32558. /**
  32559. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  32560. */
  32561. static DragMovementThreshold: number;
  32562. /**
  32563. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  32564. */
  32565. static LongPressDelay: number;
  32566. /**
  32567. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  32568. */
  32569. static DoubleClickDelay: number;
  32570. /** If you need to check double click without raising a single click at first click, enable this flag */
  32571. static ExclusiveDoubleClickMode: boolean;
  32572. /** @hidden */
  32573. _mirroredCameraPosition: Nullable<Vector3>;
  32574. /**
  32575. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  32576. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  32577. */
  32578. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  32579. /**
  32580. * Observable event triggered each time an keyboard event is received from the hosting window
  32581. */
  32582. onKeyboardObservable: Observable<KeyboardInfo>;
  32583. private _useRightHandedSystem;
  32584. /**
  32585. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  32586. */
  32587. useRightHandedSystem: boolean;
  32588. private _timeAccumulator;
  32589. private _currentStepId;
  32590. private _currentInternalStep;
  32591. /**
  32592. * Sets the step Id used by deterministic lock step
  32593. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32594. * @param newStepId defines the step Id
  32595. */
  32596. setStepId(newStepId: number): void;
  32597. /**
  32598. * Gets the step Id used by deterministic lock step
  32599. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32600. * @returns the step Id
  32601. */
  32602. getStepId(): number;
  32603. /**
  32604. * Gets the internal step used by deterministic lock step
  32605. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32606. * @returns the internal step
  32607. */
  32608. getInternalStep(): number;
  32609. private _fogEnabled;
  32610. /**
  32611. * Gets or sets a boolean indicating if fog is enabled on this scene
  32612. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32613. * (Default is true)
  32614. */
  32615. fogEnabled: boolean;
  32616. private _fogMode;
  32617. /**
  32618. * Gets or sets the fog mode to use
  32619. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32620. * | mode | value |
  32621. * | --- | --- |
  32622. * | FOGMODE_NONE | 0 |
  32623. * | FOGMODE_EXP | 1 |
  32624. * | FOGMODE_EXP2 | 2 |
  32625. * | FOGMODE_LINEAR | 3 |
  32626. */
  32627. fogMode: number;
  32628. /**
  32629. * Gets or sets the fog color to use
  32630. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32631. * (Default is Color3(0.2, 0.2, 0.3))
  32632. */
  32633. fogColor: Color3;
  32634. /**
  32635. * Gets or sets the fog density to use
  32636. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32637. * (Default is 0.1)
  32638. */
  32639. fogDensity: number;
  32640. /**
  32641. * Gets or sets the fog start distance to use
  32642. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32643. * (Default is 0)
  32644. */
  32645. fogStart: number;
  32646. /**
  32647. * Gets or sets the fog end distance to use
  32648. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32649. * (Default is 1000)
  32650. */
  32651. fogEnd: number;
  32652. private _shadowsEnabled;
  32653. /**
  32654. * Gets or sets a boolean indicating if shadows are enabled on this scene
  32655. */
  32656. shadowsEnabled: boolean;
  32657. private _lightsEnabled;
  32658. /**
  32659. * Gets or sets a boolean indicating if lights are enabled on this scene
  32660. */
  32661. lightsEnabled: boolean;
  32662. /** All of the active cameras added to this scene. */
  32663. activeCameras: Camera[];
  32664. /** @hidden */
  32665. _activeCamera: Nullable<Camera>;
  32666. /** Gets or sets the current active camera */
  32667. activeCamera: Nullable<Camera>;
  32668. private _defaultMaterial;
  32669. /** The default material used on meshes when no material is affected */
  32670. /** The default material used on meshes when no material is affected */
  32671. defaultMaterial: Material;
  32672. private _texturesEnabled;
  32673. /**
  32674. * Gets or sets a boolean indicating if textures are enabled on this scene
  32675. */
  32676. texturesEnabled: boolean;
  32677. /**
  32678. * Gets or sets a boolean indicating if particles are enabled on this scene
  32679. */
  32680. particlesEnabled: boolean;
  32681. /**
  32682. * Gets or sets a boolean indicating if sprites are enabled on this scene
  32683. */
  32684. spritesEnabled: boolean;
  32685. private _skeletonsEnabled;
  32686. /**
  32687. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  32688. */
  32689. skeletonsEnabled: boolean;
  32690. /**
  32691. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  32692. */
  32693. lensFlaresEnabled: boolean;
  32694. /**
  32695. * Gets or sets a boolean indicating if collisions are enabled on this scene
  32696. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32697. */
  32698. collisionsEnabled: boolean;
  32699. private _collisionCoordinator;
  32700. /** @hidden */
  32701. readonly collisionCoordinator: ICollisionCoordinator;
  32702. /**
  32703. * Defines the gravity applied to this scene (used only for collisions)
  32704. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32705. */
  32706. gravity: Vector3;
  32707. /**
  32708. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  32709. */
  32710. postProcessesEnabled: boolean;
  32711. /**
  32712. * The list of postprocesses added to the scene
  32713. */
  32714. postProcesses: PostProcess[];
  32715. /**
  32716. * Gets the current postprocess manager
  32717. */
  32718. postProcessManager: PostProcessManager;
  32719. /**
  32720. * Gets or sets a boolean indicating if render targets are enabled on this scene
  32721. */
  32722. renderTargetsEnabled: boolean;
  32723. /**
  32724. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  32725. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  32726. */
  32727. dumpNextRenderTargets: boolean;
  32728. /**
  32729. * The list of user defined render targets added to the scene
  32730. */
  32731. customRenderTargets: RenderTargetTexture[];
  32732. /**
  32733. * Defines if texture loading must be delayed
  32734. * If true, textures will only be loaded when they need to be rendered
  32735. */
  32736. useDelayedTextureLoading: boolean;
  32737. /**
  32738. * Gets the list of meshes imported to the scene through SceneLoader
  32739. */
  32740. importedMeshesFiles: String[];
  32741. /**
  32742. * Gets or sets a boolean indicating if probes are enabled on this scene
  32743. */
  32744. probesEnabled: boolean;
  32745. /**
  32746. * Gets or sets the current offline provider to use to store scene data
  32747. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  32748. */
  32749. offlineProvider: IOfflineProvider;
  32750. /**
  32751. * Gets or sets the action manager associated with the scene
  32752. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  32753. */
  32754. actionManager: AbstractActionManager;
  32755. private _meshesForIntersections;
  32756. /**
  32757. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  32758. */
  32759. proceduralTexturesEnabled: boolean;
  32760. private _engine;
  32761. private _totalVertices;
  32762. /** @hidden */
  32763. _activeIndices: PerfCounter;
  32764. /** @hidden */
  32765. _activeParticles: PerfCounter;
  32766. /** @hidden */
  32767. _activeBones: PerfCounter;
  32768. private _animationRatio;
  32769. /** @hidden */
  32770. _animationTimeLast: number;
  32771. /** @hidden */
  32772. _animationTime: number;
  32773. /**
  32774. * Gets or sets a general scale for animation speed
  32775. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  32776. */
  32777. animationTimeScale: number;
  32778. /** @hidden */
  32779. _cachedMaterial: Nullable<Material>;
  32780. /** @hidden */
  32781. _cachedEffect: Nullable<Effect>;
  32782. /** @hidden */
  32783. _cachedVisibility: Nullable<number>;
  32784. private _renderId;
  32785. private _frameId;
  32786. private _executeWhenReadyTimeoutId;
  32787. private _intermediateRendering;
  32788. private _viewUpdateFlag;
  32789. private _projectionUpdateFlag;
  32790. /** @hidden */
  32791. _toBeDisposed: Nullable<IDisposable>[];
  32792. private _activeRequests;
  32793. /** @hidden */
  32794. _pendingData: any[];
  32795. private _isDisposed;
  32796. /**
  32797. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  32798. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  32799. */
  32800. dispatchAllSubMeshesOfActiveMeshes: boolean;
  32801. private _activeMeshes;
  32802. private _processedMaterials;
  32803. private _renderTargets;
  32804. /** @hidden */
  32805. _activeParticleSystems: SmartArray<IParticleSystem>;
  32806. private _activeSkeletons;
  32807. private _softwareSkinnedMeshes;
  32808. private _renderingManager;
  32809. /** @hidden */
  32810. _activeAnimatables: Animatable[];
  32811. private _transformMatrix;
  32812. private _sceneUbo;
  32813. /** @hidden */
  32814. _viewMatrix: Matrix;
  32815. private _projectionMatrix;
  32816. /** @hidden */
  32817. _forcedViewPosition: Nullable<Vector3>;
  32818. /** @hidden */
  32819. _frustumPlanes: Plane[];
  32820. /**
  32821. * Gets the list of frustum planes (built from the active camera)
  32822. */
  32823. readonly frustumPlanes: Plane[];
  32824. /**
  32825. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  32826. * This is useful if there are more lights that the maximum simulteanous authorized
  32827. */
  32828. requireLightSorting: boolean;
  32829. /** @hidden */
  32830. readonly useMaterialMeshMap: boolean;
  32831. /** @hidden */
  32832. readonly useClonedMeshhMap: boolean;
  32833. private _externalData;
  32834. private _uid;
  32835. /**
  32836. * @hidden
  32837. * Backing store of defined scene components.
  32838. */
  32839. _components: ISceneComponent[];
  32840. /**
  32841. * @hidden
  32842. * Backing store of defined scene components.
  32843. */
  32844. _serializableComponents: ISceneSerializableComponent[];
  32845. /**
  32846. * List of components to register on the next registration step.
  32847. */
  32848. private _transientComponents;
  32849. /**
  32850. * Registers the transient components if needed.
  32851. */
  32852. private _registerTransientComponents;
  32853. /**
  32854. * @hidden
  32855. * Add a component to the scene.
  32856. * Note that the ccomponent could be registered on th next frame if this is called after
  32857. * the register component stage.
  32858. * @param component Defines the component to add to the scene
  32859. */
  32860. _addComponent(component: ISceneComponent): void;
  32861. /**
  32862. * @hidden
  32863. * Gets a component from the scene.
  32864. * @param name defines the name of the component to retrieve
  32865. * @returns the component or null if not present
  32866. */
  32867. _getComponent(name: string): Nullable<ISceneComponent>;
  32868. /**
  32869. * @hidden
  32870. * Defines the actions happening before camera updates.
  32871. */
  32872. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  32873. /**
  32874. * @hidden
  32875. * Defines the actions happening before clear the canvas.
  32876. */
  32877. _beforeClearStage: Stage<SimpleStageAction>;
  32878. /**
  32879. * @hidden
  32880. * Defines the actions when collecting render targets for the frame.
  32881. */
  32882. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  32883. /**
  32884. * @hidden
  32885. * Defines the actions happening for one camera in the frame.
  32886. */
  32887. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  32888. /**
  32889. * @hidden
  32890. * Defines the actions happening during the per mesh ready checks.
  32891. */
  32892. _isReadyForMeshStage: Stage<MeshStageAction>;
  32893. /**
  32894. * @hidden
  32895. * Defines the actions happening before evaluate active mesh checks.
  32896. */
  32897. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  32898. /**
  32899. * @hidden
  32900. * Defines the actions happening during the evaluate sub mesh checks.
  32901. */
  32902. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  32903. /**
  32904. * @hidden
  32905. * Defines the actions happening during the active mesh stage.
  32906. */
  32907. _activeMeshStage: Stage<ActiveMeshStageAction>;
  32908. /**
  32909. * @hidden
  32910. * Defines the actions happening during the per camera render target step.
  32911. */
  32912. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  32913. /**
  32914. * @hidden
  32915. * Defines the actions happening just before the active camera is drawing.
  32916. */
  32917. _beforeCameraDrawStage: Stage<CameraStageAction>;
  32918. /**
  32919. * @hidden
  32920. * Defines the actions happening just before a render target is drawing.
  32921. */
  32922. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  32923. /**
  32924. * @hidden
  32925. * Defines the actions happening just before a rendering group is drawing.
  32926. */
  32927. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  32928. /**
  32929. * @hidden
  32930. * Defines the actions happening just before a mesh is drawing.
  32931. */
  32932. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  32933. /**
  32934. * @hidden
  32935. * Defines the actions happening just after a mesh has been drawn.
  32936. */
  32937. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  32938. /**
  32939. * @hidden
  32940. * Defines the actions happening just after a rendering group has been drawn.
  32941. */
  32942. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  32943. /**
  32944. * @hidden
  32945. * Defines the actions happening just after the active camera has been drawn.
  32946. */
  32947. _afterCameraDrawStage: Stage<CameraStageAction>;
  32948. /**
  32949. * @hidden
  32950. * Defines the actions happening just after a render target has been drawn.
  32951. */
  32952. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  32953. /**
  32954. * @hidden
  32955. * Defines the actions happening just after rendering all cameras and computing intersections.
  32956. */
  32957. _afterRenderStage: Stage<SimpleStageAction>;
  32958. /**
  32959. * @hidden
  32960. * Defines the actions happening when a pointer move event happens.
  32961. */
  32962. _pointerMoveStage: Stage<PointerMoveStageAction>;
  32963. /**
  32964. * @hidden
  32965. * Defines the actions happening when a pointer down event happens.
  32966. */
  32967. _pointerDownStage: Stage<PointerUpDownStageAction>;
  32968. /**
  32969. * @hidden
  32970. * Defines the actions happening when a pointer up event happens.
  32971. */
  32972. _pointerUpStage: Stage<PointerUpDownStageAction>;
  32973. /**
  32974. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  32975. */
  32976. private geometriesByUniqueId;
  32977. /**
  32978. * Creates a new Scene
  32979. * @param engine defines the engine to use to render this scene
  32980. * @param options defines the scene options
  32981. */
  32982. constructor(engine: Engine, options?: SceneOptions);
  32983. /**
  32984. * Gets a string idenfifying the name of the class
  32985. * @returns "Scene" string
  32986. */
  32987. getClassName(): string;
  32988. private _defaultMeshCandidates;
  32989. /**
  32990. * @hidden
  32991. */
  32992. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  32993. private _defaultSubMeshCandidates;
  32994. /**
  32995. * @hidden
  32996. */
  32997. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  32998. /**
  32999. * Sets the default candidate providers for the scene.
  33000. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  33001. * and getCollidingSubMeshCandidates to their default function
  33002. */
  33003. setDefaultCandidateProviders(): void;
  33004. /**
  33005. * Gets the mesh that is currently under the pointer
  33006. */
  33007. readonly meshUnderPointer: Nullable<AbstractMesh>;
  33008. /**
  33009. * Gets or sets the current on-screen X position of the pointer
  33010. */
  33011. pointerX: number;
  33012. /**
  33013. * Gets or sets the current on-screen Y position of the pointer
  33014. */
  33015. pointerY: number;
  33016. /**
  33017. * Gets the cached material (ie. the latest rendered one)
  33018. * @returns the cached material
  33019. */
  33020. getCachedMaterial(): Nullable<Material>;
  33021. /**
  33022. * Gets the cached effect (ie. the latest rendered one)
  33023. * @returns the cached effect
  33024. */
  33025. getCachedEffect(): Nullable<Effect>;
  33026. /**
  33027. * Gets the cached visibility state (ie. the latest rendered one)
  33028. * @returns the cached visibility state
  33029. */
  33030. getCachedVisibility(): Nullable<number>;
  33031. /**
  33032. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  33033. * @param material defines the current material
  33034. * @param effect defines the current effect
  33035. * @param visibility defines the current visibility state
  33036. * @returns true if one parameter is not cached
  33037. */
  33038. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  33039. /**
  33040. * Gets the engine associated with the scene
  33041. * @returns an Engine
  33042. */
  33043. getEngine(): Engine;
  33044. /**
  33045. * Gets the total number of vertices rendered per frame
  33046. * @returns the total number of vertices rendered per frame
  33047. */
  33048. getTotalVertices(): number;
  33049. /**
  33050. * Gets the performance counter for total vertices
  33051. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33052. */
  33053. readonly totalVerticesPerfCounter: PerfCounter;
  33054. /**
  33055. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  33056. * @returns the total number of active indices rendered per frame
  33057. */
  33058. getActiveIndices(): number;
  33059. /**
  33060. * Gets the performance counter for active indices
  33061. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33062. */
  33063. readonly totalActiveIndicesPerfCounter: PerfCounter;
  33064. /**
  33065. * Gets the total number of active particles rendered per frame
  33066. * @returns the total number of active particles rendered per frame
  33067. */
  33068. getActiveParticles(): number;
  33069. /**
  33070. * Gets the performance counter for active particles
  33071. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33072. */
  33073. readonly activeParticlesPerfCounter: PerfCounter;
  33074. /**
  33075. * Gets the total number of active bones rendered per frame
  33076. * @returns the total number of active bones rendered per frame
  33077. */
  33078. getActiveBones(): number;
  33079. /**
  33080. * Gets the performance counter for active bones
  33081. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33082. */
  33083. readonly activeBonesPerfCounter: PerfCounter;
  33084. /**
  33085. * Gets the array of active meshes
  33086. * @returns an array of AbstractMesh
  33087. */
  33088. getActiveMeshes(): SmartArray<AbstractMesh>;
  33089. /**
  33090. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  33091. * @returns a number
  33092. */
  33093. getAnimationRatio(): number;
  33094. /**
  33095. * Gets an unique Id for the current render phase
  33096. * @returns a number
  33097. */
  33098. getRenderId(): number;
  33099. /**
  33100. * Gets an unique Id for the current frame
  33101. * @returns a number
  33102. */
  33103. getFrameId(): number;
  33104. /** Call this function if you want to manually increment the render Id*/
  33105. incrementRenderId(): void;
  33106. private _createUbo;
  33107. /**
  33108. * Use this method to simulate a pointer move on a mesh
  33109. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33110. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33111. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33112. * @returns the current scene
  33113. */
  33114. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  33115. /**
  33116. * Use this method to simulate a pointer down on a mesh
  33117. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33118. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33119. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33120. * @returns the current scene
  33121. */
  33122. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  33123. /**
  33124. * Use this method to simulate a pointer up on a mesh
  33125. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33126. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33127. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33128. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  33129. * @returns the current scene
  33130. */
  33131. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  33132. /**
  33133. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  33134. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  33135. * @returns true if the pointer was captured
  33136. */
  33137. isPointerCaptured(pointerId?: number): boolean;
  33138. /**
  33139. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  33140. * @param attachUp defines if you want to attach events to pointerup
  33141. * @param attachDown defines if you want to attach events to pointerdown
  33142. * @param attachMove defines if you want to attach events to pointermove
  33143. */
  33144. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  33145. /** Detaches all event handlers*/
  33146. detachControl(): void;
  33147. /**
  33148. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  33149. * Delay loaded resources are not taking in account
  33150. * @return true if all required resources are ready
  33151. */
  33152. isReady(): boolean;
  33153. /** Resets all cached information relative to material (including effect and visibility) */
  33154. resetCachedMaterial(): void;
  33155. /**
  33156. * Registers a function to be called before every frame render
  33157. * @param func defines the function to register
  33158. */
  33159. registerBeforeRender(func: () => void): void;
  33160. /**
  33161. * Unregisters a function called before every frame render
  33162. * @param func defines the function to unregister
  33163. */
  33164. unregisterBeforeRender(func: () => void): void;
  33165. /**
  33166. * Registers a function to be called after every frame render
  33167. * @param func defines the function to register
  33168. */
  33169. registerAfterRender(func: () => void): void;
  33170. /**
  33171. * Unregisters a function called after every frame render
  33172. * @param func defines the function to unregister
  33173. */
  33174. unregisterAfterRender(func: () => void): void;
  33175. private _executeOnceBeforeRender;
  33176. /**
  33177. * The provided function will run before render once and will be disposed afterwards.
  33178. * A timeout delay can be provided so that the function will be executed in N ms.
  33179. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  33180. * @param func The function to be executed.
  33181. * @param timeout optional delay in ms
  33182. */
  33183. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  33184. /** @hidden */
  33185. _addPendingData(data: any): void;
  33186. /** @hidden */
  33187. _removePendingData(data: any): void;
  33188. /**
  33189. * Returns the number of items waiting to be loaded
  33190. * @returns the number of items waiting to be loaded
  33191. */
  33192. getWaitingItemsCount(): number;
  33193. /**
  33194. * Returns a boolean indicating if the scene is still loading data
  33195. */
  33196. readonly isLoading: boolean;
  33197. /**
  33198. * Registers a function to be executed when the scene is ready
  33199. * @param {Function} func - the function to be executed
  33200. */
  33201. executeWhenReady(func: () => void): void;
  33202. /**
  33203. * Returns a promise that resolves when the scene is ready
  33204. * @returns A promise that resolves when the scene is ready
  33205. */
  33206. whenReadyAsync(): Promise<void>;
  33207. /** @hidden */
  33208. _checkIsReady(): void;
  33209. /**
  33210. * Gets all animatable attached to the scene
  33211. */
  33212. readonly animatables: Animatable[];
  33213. /**
  33214. * Resets the last animation time frame.
  33215. * Useful to override when animations start running when loading a scene for the first time.
  33216. */
  33217. resetLastAnimationTimeFrame(): void;
  33218. /**
  33219. * Gets the current view matrix
  33220. * @returns a Matrix
  33221. */
  33222. getViewMatrix(): Matrix;
  33223. /**
  33224. * Gets the current projection matrix
  33225. * @returns a Matrix
  33226. */
  33227. getProjectionMatrix(): Matrix;
  33228. /**
  33229. * Gets the current transform matrix
  33230. * @returns a Matrix made of View * Projection
  33231. */
  33232. getTransformMatrix(): Matrix;
  33233. /**
  33234. * Sets the current transform matrix
  33235. * @param viewL defines the View matrix to use
  33236. * @param projectionL defines the Projection matrix to use
  33237. * @param viewR defines the right View matrix to use (if provided)
  33238. * @param projectionR defines the right Projection matrix to use (if provided)
  33239. */
  33240. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  33241. /**
  33242. * Gets the uniform buffer used to store scene data
  33243. * @returns a UniformBuffer
  33244. */
  33245. getSceneUniformBuffer(): UniformBuffer;
  33246. /**
  33247. * Gets an unique (relatively to the current scene) Id
  33248. * @returns an unique number for the scene
  33249. */
  33250. getUniqueId(): number;
  33251. /**
  33252. * Add a mesh to the list of scene's meshes
  33253. * @param newMesh defines the mesh to add
  33254. * @param recursive if all child meshes should also be added to the scene
  33255. */
  33256. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  33257. /**
  33258. * Remove a mesh for the list of scene's meshes
  33259. * @param toRemove defines the mesh to remove
  33260. * @param recursive if all child meshes should also be removed from the scene
  33261. * @returns the index where the mesh was in the mesh list
  33262. */
  33263. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  33264. /**
  33265. * Add a transform node to the list of scene's transform nodes
  33266. * @param newTransformNode defines the transform node to add
  33267. */
  33268. addTransformNode(newTransformNode: TransformNode): void;
  33269. /**
  33270. * Remove a transform node for the list of scene's transform nodes
  33271. * @param toRemove defines the transform node to remove
  33272. * @returns the index where the transform node was in the transform node list
  33273. */
  33274. removeTransformNode(toRemove: TransformNode): number;
  33275. /**
  33276. * Remove a skeleton for the list of scene's skeletons
  33277. * @param toRemove defines the skeleton to remove
  33278. * @returns the index where the skeleton was in the skeleton list
  33279. */
  33280. removeSkeleton(toRemove: Skeleton): number;
  33281. /**
  33282. * Remove a morph target for the list of scene's morph targets
  33283. * @param toRemove defines the morph target to remove
  33284. * @returns the index where the morph target was in the morph target list
  33285. */
  33286. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  33287. /**
  33288. * Remove a light for the list of scene's lights
  33289. * @param toRemove defines the light to remove
  33290. * @returns the index where the light was in the light list
  33291. */
  33292. removeLight(toRemove: Light): number;
  33293. /**
  33294. * Remove a camera for the list of scene's cameras
  33295. * @param toRemove defines the camera to remove
  33296. * @returns the index where the camera was in the camera list
  33297. */
  33298. removeCamera(toRemove: Camera): number;
  33299. /**
  33300. * Remove a particle system for the list of scene's particle systems
  33301. * @param toRemove defines the particle system to remove
  33302. * @returns the index where the particle system was in the particle system list
  33303. */
  33304. removeParticleSystem(toRemove: IParticleSystem): number;
  33305. /**
  33306. * Remove a animation for the list of scene's animations
  33307. * @param toRemove defines the animation to remove
  33308. * @returns the index where the animation was in the animation list
  33309. */
  33310. removeAnimation(toRemove: Animation): number;
  33311. /**
  33312. * Will stop the animation of the given target
  33313. * @param target - the target
  33314. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  33315. * @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)
  33316. */
  33317. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  33318. /**
  33319. * Removes the given animation group from this scene.
  33320. * @param toRemove The animation group to remove
  33321. * @returns The index of the removed animation group
  33322. */
  33323. removeAnimationGroup(toRemove: AnimationGroup): number;
  33324. /**
  33325. * Removes the given multi-material from this scene.
  33326. * @param toRemove The multi-material to remove
  33327. * @returns The index of the removed multi-material
  33328. */
  33329. removeMultiMaterial(toRemove: MultiMaterial): number;
  33330. /**
  33331. * Removes the given material from this scene.
  33332. * @param toRemove The material to remove
  33333. * @returns The index of the removed material
  33334. */
  33335. removeMaterial(toRemove: Material): number;
  33336. /**
  33337. * Removes the given action manager from this scene.
  33338. * @param toRemove The action manager to remove
  33339. * @returns The index of the removed action manager
  33340. */
  33341. removeActionManager(toRemove: AbstractActionManager): number;
  33342. /**
  33343. * Removes the given texture from this scene.
  33344. * @param toRemove The texture to remove
  33345. * @returns The index of the removed texture
  33346. */
  33347. removeTexture(toRemove: BaseTexture): number;
  33348. /**
  33349. * Adds the given light to this scene
  33350. * @param newLight The light to add
  33351. */
  33352. addLight(newLight: Light): void;
  33353. /**
  33354. * Sorts the list list based on light priorities
  33355. */
  33356. sortLightsByPriority(): void;
  33357. /**
  33358. * Adds the given camera to this scene
  33359. * @param newCamera The camera to add
  33360. */
  33361. addCamera(newCamera: Camera): void;
  33362. /**
  33363. * Adds the given skeleton to this scene
  33364. * @param newSkeleton The skeleton to add
  33365. */
  33366. addSkeleton(newSkeleton: Skeleton): void;
  33367. /**
  33368. * Adds the given particle system to this scene
  33369. * @param newParticleSystem The particle system to add
  33370. */
  33371. addParticleSystem(newParticleSystem: IParticleSystem): void;
  33372. /**
  33373. * Adds the given animation to this scene
  33374. * @param newAnimation The animation to add
  33375. */
  33376. addAnimation(newAnimation: Animation): void;
  33377. /**
  33378. * Adds the given animation group to this scene.
  33379. * @param newAnimationGroup The animation group to add
  33380. */
  33381. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  33382. /**
  33383. * Adds the given multi-material to this scene
  33384. * @param newMultiMaterial The multi-material to add
  33385. */
  33386. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  33387. /**
  33388. * Adds the given material to this scene
  33389. * @param newMaterial The material to add
  33390. */
  33391. addMaterial(newMaterial: Material): void;
  33392. /**
  33393. * Adds the given morph target to this scene
  33394. * @param newMorphTargetManager The morph target to add
  33395. */
  33396. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  33397. /**
  33398. * Adds the given geometry to this scene
  33399. * @param newGeometry The geometry to add
  33400. */
  33401. addGeometry(newGeometry: Geometry): void;
  33402. /**
  33403. * Adds the given action manager to this scene
  33404. * @param newActionManager The action manager to add
  33405. */
  33406. addActionManager(newActionManager: AbstractActionManager): void;
  33407. /**
  33408. * Adds the given texture to this scene.
  33409. * @param newTexture The texture to add
  33410. */
  33411. addTexture(newTexture: BaseTexture): void;
  33412. /**
  33413. * Switch active camera
  33414. * @param newCamera defines the new active camera
  33415. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  33416. */
  33417. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  33418. /**
  33419. * sets the active camera of the scene using its ID
  33420. * @param id defines the camera's ID
  33421. * @return the new active camera or null if none found.
  33422. */
  33423. setActiveCameraByID(id: string): Nullable<Camera>;
  33424. /**
  33425. * sets the active camera of the scene using its name
  33426. * @param name defines the camera's name
  33427. * @returns the new active camera or null if none found.
  33428. */
  33429. setActiveCameraByName(name: string): Nullable<Camera>;
  33430. /**
  33431. * get an animation group using its name
  33432. * @param name defines the material's name
  33433. * @return the animation group or null if none found.
  33434. */
  33435. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  33436. /**
  33437. * Get a material using its unique id
  33438. * @param uniqueId defines the material's unique id
  33439. * @return the material or null if none found.
  33440. */
  33441. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  33442. /**
  33443. * get a material using its id
  33444. * @param id defines the material's ID
  33445. * @return the material or null if none found.
  33446. */
  33447. getMaterialByID(id: string): Nullable<Material>;
  33448. /**
  33449. * Gets a material using its name
  33450. * @param name defines the material's name
  33451. * @return the material or null if none found.
  33452. */
  33453. getMaterialByName(name: string): Nullable<Material>;
  33454. /**
  33455. * Gets a camera using its id
  33456. * @param id defines the id to look for
  33457. * @returns the camera or null if not found
  33458. */
  33459. getCameraByID(id: string): Nullable<Camera>;
  33460. /**
  33461. * Gets a camera using its unique id
  33462. * @param uniqueId defines the unique id to look for
  33463. * @returns the camera or null if not found
  33464. */
  33465. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  33466. /**
  33467. * Gets a camera using its name
  33468. * @param name defines the camera's name
  33469. * @return the camera or null if none found.
  33470. */
  33471. getCameraByName(name: string): Nullable<Camera>;
  33472. /**
  33473. * Gets a bone using its id
  33474. * @param id defines the bone's id
  33475. * @return the bone or null if not found
  33476. */
  33477. getBoneByID(id: string): Nullable<Bone>;
  33478. /**
  33479. * Gets a bone using its id
  33480. * @param name defines the bone's name
  33481. * @return the bone or null if not found
  33482. */
  33483. getBoneByName(name: string): Nullable<Bone>;
  33484. /**
  33485. * Gets a light node using its name
  33486. * @param name defines the the light's name
  33487. * @return the light or null if none found.
  33488. */
  33489. getLightByName(name: string): Nullable<Light>;
  33490. /**
  33491. * Gets a light node using its id
  33492. * @param id defines the light's id
  33493. * @return the light or null if none found.
  33494. */
  33495. getLightByID(id: string): Nullable<Light>;
  33496. /**
  33497. * Gets a light node using its scene-generated unique ID
  33498. * @param uniqueId defines the light's unique id
  33499. * @return the light or null if none found.
  33500. */
  33501. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  33502. /**
  33503. * Gets a particle system by id
  33504. * @param id defines the particle system id
  33505. * @return the corresponding system or null if none found
  33506. */
  33507. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  33508. /**
  33509. * Gets a geometry using its ID
  33510. * @param id defines the geometry's id
  33511. * @return the geometry or null if none found.
  33512. */
  33513. getGeometryByID(id: string): Nullable<Geometry>;
  33514. private _getGeometryByUniqueID;
  33515. /**
  33516. * Add a new geometry to this scene
  33517. * @param geometry defines the geometry to be added to the scene.
  33518. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  33519. * @return a boolean defining if the geometry was added or not
  33520. */
  33521. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  33522. /**
  33523. * Removes an existing geometry
  33524. * @param geometry defines the geometry to be removed from the scene
  33525. * @return a boolean defining if the geometry was removed or not
  33526. */
  33527. removeGeometry(geometry: Geometry): boolean;
  33528. /**
  33529. * Gets the list of geometries attached to the scene
  33530. * @returns an array of Geometry
  33531. */
  33532. getGeometries(): Geometry[];
  33533. /**
  33534. * Gets the first added mesh found of a given ID
  33535. * @param id defines the id to search for
  33536. * @return the mesh found or null if not found at all
  33537. */
  33538. getMeshByID(id: string): Nullable<AbstractMesh>;
  33539. /**
  33540. * Gets a list of meshes using their id
  33541. * @param id defines the id to search for
  33542. * @returns a list of meshes
  33543. */
  33544. getMeshesByID(id: string): Array<AbstractMesh>;
  33545. /**
  33546. * Gets the first added transform node found of a given ID
  33547. * @param id defines the id to search for
  33548. * @return the found transform node or null if not found at all.
  33549. */
  33550. getTransformNodeByID(id: string): Nullable<TransformNode>;
  33551. /**
  33552. * Gets a transform node with its auto-generated unique id
  33553. * @param uniqueId efines the unique id to search for
  33554. * @return the found transform node or null if not found at all.
  33555. */
  33556. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  33557. /**
  33558. * Gets a list of transform nodes using their id
  33559. * @param id defines the id to search for
  33560. * @returns a list of transform nodes
  33561. */
  33562. getTransformNodesByID(id: string): Array<TransformNode>;
  33563. /**
  33564. * Gets a mesh with its auto-generated unique id
  33565. * @param uniqueId defines the unique id to search for
  33566. * @return the found mesh or null if not found at all.
  33567. */
  33568. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  33569. /**
  33570. * Gets a the last added mesh using a given id
  33571. * @param id defines the id to search for
  33572. * @return the found mesh or null if not found at all.
  33573. */
  33574. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  33575. /**
  33576. * Gets a the last added node (Mesh, Camera, Light) using a given id
  33577. * @param id defines the id to search for
  33578. * @return the found node or null if not found at all
  33579. */
  33580. getLastEntryByID(id: string): Nullable<Node>;
  33581. /**
  33582. * Gets a node (Mesh, Camera, Light) using a given id
  33583. * @param id defines the id to search for
  33584. * @return the found node or null if not found at all
  33585. */
  33586. getNodeByID(id: string): Nullable<Node>;
  33587. /**
  33588. * Gets a node (Mesh, Camera, Light) using a given name
  33589. * @param name defines the name to search for
  33590. * @return the found node or null if not found at all.
  33591. */
  33592. getNodeByName(name: string): Nullable<Node>;
  33593. /**
  33594. * Gets a mesh using a given name
  33595. * @param name defines the name to search for
  33596. * @return the found mesh or null if not found at all.
  33597. */
  33598. getMeshByName(name: string): Nullable<AbstractMesh>;
  33599. /**
  33600. * Gets a transform node using a given name
  33601. * @param name defines the name to search for
  33602. * @return the found transform node or null if not found at all.
  33603. */
  33604. getTransformNodeByName(name: string): Nullable<TransformNode>;
  33605. /**
  33606. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  33607. * @param id defines the id to search for
  33608. * @return the found skeleton or null if not found at all.
  33609. */
  33610. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  33611. /**
  33612. * Gets a skeleton using a given auto generated unique id
  33613. * @param uniqueId defines the unique id to search for
  33614. * @return the found skeleton or null if not found at all.
  33615. */
  33616. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  33617. /**
  33618. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  33619. * @param id defines the id to search for
  33620. * @return the found skeleton or null if not found at all.
  33621. */
  33622. getSkeletonById(id: string): Nullable<Skeleton>;
  33623. /**
  33624. * Gets a skeleton using a given name
  33625. * @param name defines the name to search for
  33626. * @return the found skeleton or null if not found at all.
  33627. */
  33628. getSkeletonByName(name: string): Nullable<Skeleton>;
  33629. /**
  33630. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  33631. * @param id defines the id to search for
  33632. * @return the found morph target manager or null if not found at all.
  33633. */
  33634. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  33635. /**
  33636. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  33637. * @param id defines the id to search for
  33638. * @return the found morph target or null if not found at all.
  33639. */
  33640. getMorphTargetById(id: string): Nullable<MorphTarget>;
  33641. /**
  33642. * Gets a boolean indicating if the given mesh is active
  33643. * @param mesh defines the mesh to look for
  33644. * @returns true if the mesh is in the active list
  33645. */
  33646. isActiveMesh(mesh: AbstractMesh): boolean;
  33647. /**
  33648. * Return a unique id as a string which can serve as an identifier for the scene
  33649. */
  33650. readonly uid: string;
  33651. /**
  33652. * Add an externaly attached data from its key.
  33653. * This method call will fail and return false, if such key already exists.
  33654. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  33655. * @param key the unique key that identifies the data
  33656. * @param data the data object to associate to the key for this Engine instance
  33657. * @return true if no such key were already present and the data was added successfully, false otherwise
  33658. */
  33659. addExternalData<T>(key: string, data: T): boolean;
  33660. /**
  33661. * Get an externaly attached data from its key
  33662. * @param key the unique key that identifies the data
  33663. * @return the associated data, if present (can be null), or undefined if not present
  33664. */
  33665. getExternalData<T>(key: string): Nullable<T>;
  33666. /**
  33667. * Get an externaly attached data from its key, create it using a factory if it's not already present
  33668. * @param key the unique key that identifies the data
  33669. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  33670. * @return the associated data, can be null if the factory returned null.
  33671. */
  33672. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  33673. /**
  33674. * Remove an externaly attached data from the Engine instance
  33675. * @param key the unique key that identifies the data
  33676. * @return true if the data was successfully removed, false if it doesn't exist
  33677. */
  33678. removeExternalData(key: string): boolean;
  33679. private _evaluateSubMesh;
  33680. /**
  33681. * Clear the processed materials smart array preventing retention point in material dispose.
  33682. */
  33683. freeProcessedMaterials(): void;
  33684. private _preventFreeActiveMeshesAndRenderingGroups;
  33685. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  33686. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  33687. * when disposing several meshes in a row or a hierarchy of meshes.
  33688. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  33689. */
  33690. blockfreeActiveMeshesAndRenderingGroups: boolean;
  33691. /**
  33692. * Clear the active meshes smart array preventing retention point in mesh dispose.
  33693. */
  33694. freeActiveMeshes(): void;
  33695. /**
  33696. * Clear the info related to rendering groups preventing retention points during dispose.
  33697. */
  33698. freeRenderingGroups(): void;
  33699. /** @hidden */
  33700. _isInIntermediateRendering(): boolean;
  33701. /**
  33702. * Lambda returning the list of potentially active meshes.
  33703. */
  33704. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  33705. /**
  33706. * Lambda returning the list of potentially active sub meshes.
  33707. */
  33708. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  33709. /**
  33710. * Lambda returning the list of potentially intersecting sub meshes.
  33711. */
  33712. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  33713. /**
  33714. * Lambda returning the list of potentially colliding sub meshes.
  33715. */
  33716. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  33717. private _activeMeshesFrozen;
  33718. /**
  33719. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  33720. * @returns the current scene
  33721. */
  33722. freezeActiveMeshes(): Scene;
  33723. /**
  33724. * Use this function to restart evaluating active meshes on every frame
  33725. * @returns the current scene
  33726. */
  33727. unfreezeActiveMeshes(): Scene;
  33728. private _evaluateActiveMeshes;
  33729. private _activeMesh;
  33730. /**
  33731. * Update the transform matrix to update from the current active camera
  33732. * @param force defines a boolean used to force the update even if cache is up to date
  33733. */
  33734. updateTransformMatrix(force?: boolean): void;
  33735. private _bindFrameBuffer;
  33736. /** @hidden */
  33737. _allowPostProcessClearColor: boolean;
  33738. /** @hidden */
  33739. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  33740. private _processSubCameras;
  33741. private _checkIntersections;
  33742. /** @hidden */
  33743. _advancePhysicsEngineStep(step: number): void;
  33744. /**
  33745. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  33746. */
  33747. getDeterministicFrameTime: () => number;
  33748. /** @hidden */
  33749. _animate(): void;
  33750. /** Execute all animations (for a frame) */
  33751. animate(): void;
  33752. /**
  33753. * Render the scene
  33754. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  33755. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  33756. */
  33757. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  33758. /**
  33759. * Freeze all materials
  33760. * A frozen material will not be updatable but should be faster to render
  33761. */
  33762. freezeMaterials(): void;
  33763. /**
  33764. * Unfreeze all materials
  33765. * A frozen material will not be updatable but should be faster to render
  33766. */
  33767. unfreezeMaterials(): void;
  33768. /**
  33769. * Releases all held ressources
  33770. */
  33771. dispose(): void;
  33772. /**
  33773. * Gets if the scene is already disposed
  33774. */
  33775. readonly isDisposed: boolean;
  33776. /**
  33777. * Call this function to reduce memory footprint of the scene.
  33778. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  33779. */
  33780. clearCachedVertexData(): void;
  33781. /**
  33782. * This function will remove the local cached buffer data from texture.
  33783. * It will save memory but will prevent the texture from being rebuilt
  33784. */
  33785. cleanCachedTextureBuffer(): void;
  33786. /**
  33787. * Get the world extend vectors with an optional filter
  33788. *
  33789. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  33790. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  33791. */
  33792. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  33793. min: Vector3;
  33794. max: Vector3;
  33795. };
  33796. /**
  33797. * Creates a ray that can be used to pick in the scene
  33798. * @param x defines the x coordinate of the origin (on-screen)
  33799. * @param y defines the y coordinate of the origin (on-screen)
  33800. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  33801. * @param camera defines the camera to use for the picking
  33802. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  33803. * @returns a Ray
  33804. */
  33805. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  33806. /**
  33807. * Creates a ray that can be used to pick in the scene
  33808. * @param x defines the x coordinate of the origin (on-screen)
  33809. * @param y defines the y coordinate of the origin (on-screen)
  33810. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  33811. * @param result defines the ray where to store the picking ray
  33812. * @param camera defines the camera to use for the picking
  33813. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  33814. * @returns the current scene
  33815. */
  33816. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  33817. /**
  33818. * Creates a ray that can be used to pick in the scene
  33819. * @param x defines the x coordinate of the origin (on-screen)
  33820. * @param y defines the y coordinate of the origin (on-screen)
  33821. * @param camera defines the camera to use for the picking
  33822. * @returns a Ray
  33823. */
  33824. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  33825. /**
  33826. * Creates a ray that can be used to pick in the scene
  33827. * @param x defines the x coordinate of the origin (on-screen)
  33828. * @param y defines the y coordinate of the origin (on-screen)
  33829. * @param result defines the ray where to store the picking ray
  33830. * @param camera defines the camera to use for the picking
  33831. * @returns the current scene
  33832. */
  33833. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  33834. /** Launch a ray to try to pick a mesh in the scene
  33835. * @param x position on screen
  33836. * @param y position on screen
  33837. * @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
  33838. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  33839. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  33840. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33841. * @returns a PickingInfo
  33842. */
  33843. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: (p0: Vector3, p1: Vector3, p2: Vector3) => boolean): Nullable<PickingInfo>;
  33844. /** Use the given ray to pick a mesh in the scene
  33845. * @param ray The ray to use to pick meshes
  33846. * @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
  33847. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  33848. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33849. * @returns a PickingInfo
  33850. */
  33851. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  33852. /**
  33853. * Launch a ray to try to pick a mesh in the scene
  33854. * @param x X position on screen
  33855. * @param y Y position on screen
  33856. * @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
  33857. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  33858. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33859. * @returns an array of PickingInfo
  33860. */
  33861. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  33862. /**
  33863. * Launch a ray to try to pick a mesh in the scene
  33864. * @param ray Ray to use
  33865. * @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
  33866. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33867. * @returns an array of PickingInfo
  33868. */
  33869. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  33870. /**
  33871. * Force the value of meshUnderPointer
  33872. * @param mesh defines the mesh to use
  33873. */
  33874. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  33875. /**
  33876. * Gets the mesh under the pointer
  33877. * @returns a Mesh or null if no mesh is under the pointer
  33878. */
  33879. getPointerOverMesh(): Nullable<AbstractMesh>;
  33880. /** @hidden */
  33881. _rebuildGeometries(): void;
  33882. /** @hidden */
  33883. _rebuildTextures(): void;
  33884. private _getByTags;
  33885. /**
  33886. * Get a list of meshes by tags
  33887. * @param tagsQuery defines the tags query to use
  33888. * @param forEach defines a predicate used to filter results
  33889. * @returns an array of Mesh
  33890. */
  33891. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  33892. /**
  33893. * Get a list of cameras by tags
  33894. * @param tagsQuery defines the tags query to use
  33895. * @param forEach defines a predicate used to filter results
  33896. * @returns an array of Camera
  33897. */
  33898. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  33899. /**
  33900. * Get a list of lights by tags
  33901. * @param tagsQuery defines the tags query to use
  33902. * @param forEach defines a predicate used to filter results
  33903. * @returns an array of Light
  33904. */
  33905. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  33906. /**
  33907. * Get a list of materials by tags
  33908. * @param tagsQuery defines the tags query to use
  33909. * @param forEach defines a predicate used to filter results
  33910. * @returns an array of Material
  33911. */
  33912. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  33913. /**
  33914. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  33915. * This allowed control for front to back rendering or reversly depending of the special needs.
  33916. *
  33917. * @param renderingGroupId The rendering group id corresponding to its index
  33918. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  33919. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  33920. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  33921. */
  33922. 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;
  33923. /**
  33924. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  33925. *
  33926. * @param renderingGroupId The rendering group id corresponding to its index
  33927. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  33928. * @param depth Automatically clears depth between groups if true and autoClear is true.
  33929. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  33930. */
  33931. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  33932. /**
  33933. * Gets the current auto clear configuration for one rendering group of the rendering
  33934. * manager.
  33935. * @param index the rendering group index to get the information for
  33936. * @returns The auto clear setup for the requested rendering group
  33937. */
  33938. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  33939. private _blockMaterialDirtyMechanism;
  33940. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  33941. blockMaterialDirtyMechanism: boolean;
  33942. /**
  33943. * Will flag all materials as dirty to trigger new shader compilation
  33944. * @param flag defines the flag used to specify which material part must be marked as dirty
  33945. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  33946. */
  33947. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  33948. /** @hidden */
  33949. _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;
  33950. /** @hidden */
  33951. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  33952. }
  33953. }
  33954. declare module BABYLON {
  33955. /**
  33956. * Set of assets to keep when moving a scene into an asset container.
  33957. */
  33958. export class KeepAssets extends AbstractScene {
  33959. }
  33960. /**
  33961. * Container with a set of assets that can be added or removed from a scene.
  33962. */
  33963. export class AssetContainer extends AbstractScene {
  33964. /**
  33965. * The scene the AssetContainer belongs to.
  33966. */
  33967. scene: Scene;
  33968. /**
  33969. * Instantiates an AssetContainer.
  33970. * @param scene The scene the AssetContainer belongs to.
  33971. */
  33972. constructor(scene: Scene);
  33973. /**
  33974. * Adds all the assets from the container to the scene.
  33975. */
  33976. addAllToScene(): void;
  33977. /**
  33978. * Removes all the assets in the container from the scene
  33979. */
  33980. removeAllFromScene(): void;
  33981. /**
  33982. * Disposes all the assets in the container
  33983. */
  33984. dispose(): void;
  33985. private _moveAssets;
  33986. /**
  33987. * Removes all the assets contained in the scene and adds them to the container.
  33988. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  33989. */
  33990. moveAllFromScene(keepAssets?: KeepAssets): void;
  33991. /**
  33992. * 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.
  33993. * @returns the root mesh
  33994. */
  33995. createRootMesh(): Mesh;
  33996. }
  33997. }
  33998. declare module BABYLON {
  33999. /**
  34000. * Defines how the parser contract is defined.
  34001. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  34002. */
  34003. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  34004. /**
  34005. * Defines how the individual parser contract is defined.
  34006. * These parser can parse an individual asset
  34007. */
  34008. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  34009. /**
  34010. * Base class of the scene acting as a container for the different elements composing a scene.
  34011. * This class is dynamically extended by the different components of the scene increasing
  34012. * flexibility and reducing coupling
  34013. */
  34014. export abstract class AbstractScene {
  34015. /**
  34016. * Stores the list of available parsers in the application.
  34017. */
  34018. private static _BabylonFileParsers;
  34019. /**
  34020. * Stores the list of available individual parsers in the application.
  34021. */
  34022. private static _IndividualBabylonFileParsers;
  34023. /**
  34024. * Adds a parser in the list of available ones
  34025. * @param name Defines the name of the parser
  34026. * @param parser Defines the parser to add
  34027. */
  34028. static AddParser(name: string, parser: BabylonFileParser): void;
  34029. /**
  34030. * Gets a general parser from the list of avaialble ones
  34031. * @param name Defines the name of the parser
  34032. * @returns the requested parser or null
  34033. */
  34034. static GetParser(name: string): Nullable<BabylonFileParser>;
  34035. /**
  34036. * Adds n individual parser in the list of available ones
  34037. * @param name Defines the name of the parser
  34038. * @param parser Defines the parser to add
  34039. */
  34040. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  34041. /**
  34042. * Gets an individual parser from the list of avaialble ones
  34043. * @param name Defines the name of the parser
  34044. * @returns the requested parser or null
  34045. */
  34046. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  34047. /**
  34048. * Parser json data and populate both a scene and its associated container object
  34049. * @param jsonData Defines the data to parse
  34050. * @param scene Defines the scene to parse the data for
  34051. * @param container Defines the container attached to the parsing sequence
  34052. * @param rootUrl Defines the root url of the data
  34053. */
  34054. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  34055. /**
  34056. * Gets the list of root nodes (ie. nodes with no parent)
  34057. */
  34058. rootNodes: Node[];
  34059. /** All of the cameras added to this scene
  34060. * @see http://doc.babylonjs.com/babylon101/cameras
  34061. */
  34062. cameras: Camera[];
  34063. /**
  34064. * All of the lights added to this scene
  34065. * @see http://doc.babylonjs.com/babylon101/lights
  34066. */
  34067. lights: Light[];
  34068. /**
  34069. * All of the (abstract) meshes added to this scene
  34070. */
  34071. meshes: AbstractMesh[];
  34072. /**
  34073. * The list of skeletons added to the scene
  34074. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  34075. */
  34076. skeletons: Skeleton[];
  34077. /**
  34078. * All of the particle systems added to this scene
  34079. * @see http://doc.babylonjs.com/babylon101/particles
  34080. */
  34081. particleSystems: IParticleSystem[];
  34082. /**
  34083. * Gets a list of Animations associated with the scene
  34084. */
  34085. animations: Animation[];
  34086. /**
  34087. * All of the animation groups added to this scene
  34088. * @see http://doc.babylonjs.com/how_to/group
  34089. */
  34090. animationGroups: AnimationGroup[];
  34091. /**
  34092. * All of the multi-materials added to this scene
  34093. * @see http://doc.babylonjs.com/how_to/multi_materials
  34094. */
  34095. multiMaterials: MultiMaterial[];
  34096. /**
  34097. * All of the materials added to this scene
  34098. * In the context of a Scene, it is not supposed to be modified manually.
  34099. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  34100. * Note also that the order of the Material wihin the array is not significant and might change.
  34101. * @see http://doc.babylonjs.com/babylon101/materials
  34102. */
  34103. materials: Material[];
  34104. /**
  34105. * The list of morph target managers added to the scene
  34106. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  34107. */
  34108. morphTargetManagers: MorphTargetManager[];
  34109. /**
  34110. * The list of geometries used in the scene.
  34111. */
  34112. geometries: Geometry[];
  34113. /**
  34114. * All of the tranform nodes added to this scene
  34115. * In the context of a Scene, it is not supposed to be modified manually.
  34116. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  34117. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  34118. * @see http://doc.babylonjs.com/how_to/transformnode
  34119. */
  34120. transformNodes: TransformNode[];
  34121. /**
  34122. * ActionManagers available on the scene.
  34123. */
  34124. actionManagers: AbstractActionManager[];
  34125. /**
  34126. * Textures to keep.
  34127. */
  34128. textures: BaseTexture[];
  34129. /**
  34130. * Environment texture for the scene
  34131. */
  34132. environmentTexture: Nullable<BaseTexture>;
  34133. }
  34134. }
  34135. declare module BABYLON {
  34136. /**
  34137. * Defines a sound that can be played in the application.
  34138. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  34139. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34140. */
  34141. export class Sound {
  34142. /**
  34143. * The name of the sound in the scene.
  34144. */
  34145. name: string;
  34146. /**
  34147. * Does the sound autoplay once loaded.
  34148. */
  34149. autoplay: boolean;
  34150. /**
  34151. * Does the sound loop after it finishes playing once.
  34152. */
  34153. loop: boolean;
  34154. /**
  34155. * Does the sound use a custom attenuation curve to simulate the falloff
  34156. * happening when the source gets further away from the camera.
  34157. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  34158. */
  34159. useCustomAttenuation: boolean;
  34160. /**
  34161. * The sound track id this sound belongs to.
  34162. */
  34163. soundTrackId: number;
  34164. /**
  34165. * Is this sound currently played.
  34166. */
  34167. isPlaying: boolean;
  34168. /**
  34169. * Is this sound currently paused.
  34170. */
  34171. isPaused: boolean;
  34172. /**
  34173. * Does this sound enables spatial sound.
  34174. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34175. */
  34176. spatialSound: boolean;
  34177. /**
  34178. * Define the reference distance the sound should be heard perfectly.
  34179. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34180. */
  34181. refDistance: number;
  34182. /**
  34183. * Define the roll off factor of spatial sounds.
  34184. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34185. */
  34186. rolloffFactor: number;
  34187. /**
  34188. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  34189. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34190. */
  34191. maxDistance: number;
  34192. /**
  34193. * Define the distance attenuation model the sound will follow.
  34194. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34195. */
  34196. distanceModel: string;
  34197. /**
  34198. * @hidden
  34199. * Back Compat
  34200. **/
  34201. onended: () => any;
  34202. /**
  34203. * Observable event when the current playing sound finishes.
  34204. */
  34205. onEndedObservable: Observable<Sound>;
  34206. private _panningModel;
  34207. private _playbackRate;
  34208. private _streaming;
  34209. private _startTime;
  34210. private _startOffset;
  34211. private _position;
  34212. /** @hidden */
  34213. _positionInEmitterSpace: boolean;
  34214. private _localDirection;
  34215. private _volume;
  34216. private _isReadyToPlay;
  34217. private _isDirectional;
  34218. private _readyToPlayCallback;
  34219. private _audioBuffer;
  34220. private _soundSource;
  34221. private _streamingSource;
  34222. private _soundPanner;
  34223. private _soundGain;
  34224. private _inputAudioNode;
  34225. private _outputAudioNode;
  34226. private _coneInnerAngle;
  34227. private _coneOuterAngle;
  34228. private _coneOuterGain;
  34229. private _scene;
  34230. private _connectedTransformNode;
  34231. private _customAttenuationFunction;
  34232. private _registerFunc;
  34233. private _isOutputConnected;
  34234. private _htmlAudioElement;
  34235. private _urlType;
  34236. /** @hidden */
  34237. static _SceneComponentInitialization: (scene: Scene) => void;
  34238. /**
  34239. * Create a sound and attach it to a scene
  34240. * @param name Name of your sound
  34241. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  34242. * @param scene defines the scene the sound belongs to
  34243. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  34244. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  34245. */
  34246. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  34247. /**
  34248. * Release the sound and its associated resources
  34249. */
  34250. dispose(): void;
  34251. /**
  34252. * Gets if the sounds is ready to be played or not.
  34253. * @returns true if ready, otherwise false
  34254. */
  34255. isReady(): boolean;
  34256. private _soundLoaded;
  34257. /**
  34258. * Sets the data of the sound from an audiobuffer
  34259. * @param audioBuffer The audioBuffer containing the data
  34260. */
  34261. setAudioBuffer(audioBuffer: AudioBuffer): void;
  34262. /**
  34263. * Updates the current sounds options such as maxdistance, loop...
  34264. * @param options A JSON object containing values named as the object properties
  34265. */
  34266. updateOptions(options: any): void;
  34267. private _createSpatialParameters;
  34268. private _updateSpatialParameters;
  34269. /**
  34270. * Switch the panning model to HRTF:
  34271. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  34272. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34273. */
  34274. switchPanningModelToHRTF(): void;
  34275. /**
  34276. * Switch the panning model to Equal Power:
  34277. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  34278. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34279. */
  34280. switchPanningModelToEqualPower(): void;
  34281. private _switchPanningModel;
  34282. /**
  34283. * Connect this sound to a sound track audio node like gain...
  34284. * @param soundTrackAudioNode the sound track audio node to connect to
  34285. */
  34286. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  34287. /**
  34288. * Transform this sound into a directional source
  34289. * @param coneInnerAngle Size of the inner cone in degree
  34290. * @param coneOuterAngle Size of the outer cone in degree
  34291. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  34292. */
  34293. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  34294. /**
  34295. * Gets or sets the inner angle for the directional cone.
  34296. */
  34297. /**
  34298. * Gets or sets the inner angle for the directional cone.
  34299. */
  34300. directionalConeInnerAngle: number;
  34301. /**
  34302. * Gets or sets the outer angle for the directional cone.
  34303. */
  34304. /**
  34305. * Gets or sets the outer angle for the directional cone.
  34306. */
  34307. directionalConeOuterAngle: number;
  34308. /**
  34309. * Sets the position of the emitter if spatial sound is enabled
  34310. * @param newPosition Defines the new posisiton
  34311. */
  34312. setPosition(newPosition: Vector3): void;
  34313. /**
  34314. * Sets the local direction of the emitter if spatial sound is enabled
  34315. * @param newLocalDirection Defines the new local direction
  34316. */
  34317. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  34318. private _updateDirection;
  34319. /** @hidden */
  34320. updateDistanceFromListener(): void;
  34321. /**
  34322. * Sets a new custom attenuation function for the sound.
  34323. * @param callback Defines the function used for the attenuation
  34324. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  34325. */
  34326. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  34327. /**
  34328. * Play the sound
  34329. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  34330. * @param offset (optional) Start the sound setting it at a specific time
  34331. */
  34332. play(time?: number, offset?: number): void;
  34333. private _onended;
  34334. /**
  34335. * Stop the sound
  34336. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  34337. */
  34338. stop(time?: number): void;
  34339. /**
  34340. * Put the sound in pause
  34341. */
  34342. pause(): void;
  34343. /**
  34344. * Sets a dedicated volume for this sounds
  34345. * @param newVolume Define the new volume of the sound
  34346. * @param time Define in how long the sound should be at this value
  34347. */
  34348. setVolume(newVolume: number, time?: number): void;
  34349. /**
  34350. * Set the sound play back rate
  34351. * @param newPlaybackRate Define the playback rate the sound should be played at
  34352. */
  34353. setPlaybackRate(newPlaybackRate: number): void;
  34354. /**
  34355. * Gets the volume of the sound.
  34356. * @returns the volume of the sound
  34357. */
  34358. getVolume(): number;
  34359. /**
  34360. * Attach the sound to a dedicated mesh
  34361. * @param transformNode The transform node to connect the sound with
  34362. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  34363. */
  34364. attachToMesh(transformNode: TransformNode): void;
  34365. /**
  34366. * Detach the sound from the previously attached mesh
  34367. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  34368. */
  34369. detachFromMesh(): void;
  34370. private _onRegisterAfterWorldMatrixUpdate;
  34371. /**
  34372. * Clone the current sound in the scene.
  34373. * @returns the new sound clone
  34374. */
  34375. clone(): Nullable<Sound>;
  34376. /**
  34377. * Gets the current underlying audio buffer containing the data
  34378. * @returns the audio buffer
  34379. */
  34380. getAudioBuffer(): Nullable<AudioBuffer>;
  34381. /**
  34382. * Serializes the Sound in a JSON representation
  34383. * @returns the JSON representation of the sound
  34384. */
  34385. serialize(): any;
  34386. /**
  34387. * Parse a JSON representation of a sound to innstantiate in a given scene
  34388. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  34389. * @param scene Define the scene the new parsed sound should be created in
  34390. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  34391. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  34392. * @returns the newly parsed sound
  34393. */
  34394. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  34395. }
  34396. }
  34397. declare module BABYLON {
  34398. /**
  34399. * This defines an action helpful to play a defined sound on a triggered action.
  34400. */
  34401. export class PlaySoundAction extends Action {
  34402. private _sound;
  34403. /**
  34404. * Instantiate the action
  34405. * @param triggerOptions defines the trigger options
  34406. * @param sound defines the sound to play
  34407. * @param condition defines the trigger related conditions
  34408. */
  34409. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  34410. /** @hidden */
  34411. _prepare(): void;
  34412. /**
  34413. * Execute the action and play the sound.
  34414. */
  34415. execute(): void;
  34416. /**
  34417. * Serializes the actions and its related information.
  34418. * @param parent defines the object to serialize in
  34419. * @returns the serialized object
  34420. */
  34421. serialize(parent: any): any;
  34422. }
  34423. /**
  34424. * This defines an action helpful to stop a defined sound on a triggered action.
  34425. */
  34426. export class StopSoundAction extends Action {
  34427. private _sound;
  34428. /**
  34429. * Instantiate the action
  34430. * @param triggerOptions defines the trigger options
  34431. * @param sound defines the sound to stop
  34432. * @param condition defines the trigger related conditions
  34433. */
  34434. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  34435. /** @hidden */
  34436. _prepare(): void;
  34437. /**
  34438. * Execute the action and stop the sound.
  34439. */
  34440. execute(): void;
  34441. /**
  34442. * Serializes the actions and its related information.
  34443. * @param parent defines the object to serialize in
  34444. * @returns the serialized object
  34445. */
  34446. serialize(parent: any): any;
  34447. }
  34448. }
  34449. declare module BABYLON {
  34450. /**
  34451. * This defines an action responsible to change the value of a property
  34452. * by interpolating between its current value and the newly set one once triggered.
  34453. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  34454. */
  34455. export class InterpolateValueAction extends Action {
  34456. /**
  34457. * Defines the path of the property where the value should be interpolated
  34458. */
  34459. propertyPath: string;
  34460. /**
  34461. * Defines the target value at the end of the interpolation.
  34462. */
  34463. value: any;
  34464. /**
  34465. * Defines the time it will take for the property to interpolate to the value.
  34466. */
  34467. duration: number;
  34468. /**
  34469. * Defines if the other scene animations should be stopped when the action has been triggered
  34470. */
  34471. stopOtherAnimations?: boolean;
  34472. /**
  34473. * Defines a callback raised once the interpolation animation has been done.
  34474. */
  34475. onInterpolationDone?: () => void;
  34476. /**
  34477. * Observable triggered once the interpolation animation has been done.
  34478. */
  34479. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  34480. private _target;
  34481. private _effectiveTarget;
  34482. private _property;
  34483. /**
  34484. * Instantiate the action
  34485. * @param triggerOptions defines the trigger options
  34486. * @param target defines the object containing the value to interpolate
  34487. * @param propertyPath defines the path to the property in the target object
  34488. * @param value defines the target value at the end of the interpolation
  34489. * @param duration deines the time it will take for the property to interpolate to the value.
  34490. * @param condition defines the trigger related conditions
  34491. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  34492. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  34493. */
  34494. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  34495. /** @hidden */
  34496. _prepare(): void;
  34497. /**
  34498. * Execute the action starts the value interpolation.
  34499. */
  34500. execute(): void;
  34501. /**
  34502. * Serializes the actions and its related information.
  34503. * @param parent defines the object to serialize in
  34504. * @returns the serialized object
  34505. */
  34506. serialize(parent: any): any;
  34507. }
  34508. }
  34509. declare module BABYLON {
  34510. /**
  34511. * Options allowed during the creation of a sound track.
  34512. */
  34513. export interface ISoundTrackOptions {
  34514. /**
  34515. * The volume the sound track should take during creation
  34516. */
  34517. volume?: number;
  34518. /**
  34519. * Define if the sound track is the main sound track of the scene
  34520. */
  34521. mainTrack?: boolean;
  34522. }
  34523. /**
  34524. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  34525. * It will be also used in a future release to apply effects on a specific track.
  34526. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  34527. */
  34528. export class SoundTrack {
  34529. /**
  34530. * The unique identifier of the sound track in the scene.
  34531. */
  34532. id: number;
  34533. /**
  34534. * The list of sounds included in the sound track.
  34535. */
  34536. soundCollection: Array<Sound>;
  34537. private _outputAudioNode;
  34538. private _scene;
  34539. private _isMainTrack;
  34540. private _connectedAnalyser;
  34541. private _options;
  34542. private _isInitialized;
  34543. /**
  34544. * Creates a new sound track.
  34545. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  34546. * @param scene Define the scene the sound track belongs to
  34547. * @param options
  34548. */
  34549. constructor(scene: Scene, options?: ISoundTrackOptions);
  34550. private _initializeSoundTrackAudioGraph;
  34551. /**
  34552. * Release the sound track and its associated resources
  34553. */
  34554. dispose(): void;
  34555. /**
  34556. * Adds a sound to this sound track
  34557. * @param sound define the cound to add
  34558. * @ignoreNaming
  34559. */
  34560. AddSound(sound: Sound): void;
  34561. /**
  34562. * Removes a sound to this sound track
  34563. * @param sound define the cound to remove
  34564. * @ignoreNaming
  34565. */
  34566. RemoveSound(sound: Sound): void;
  34567. /**
  34568. * Set a global volume for the full sound track.
  34569. * @param newVolume Define the new volume of the sound track
  34570. */
  34571. setVolume(newVolume: number): void;
  34572. /**
  34573. * Switch the panning model to HRTF:
  34574. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  34575. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34576. */
  34577. switchPanningModelToHRTF(): void;
  34578. /**
  34579. * Switch the panning model to Equal Power:
  34580. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  34581. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34582. */
  34583. switchPanningModelToEqualPower(): void;
  34584. /**
  34585. * Connect the sound track to an audio analyser allowing some amazing
  34586. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  34587. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  34588. * @param analyser The analyser to connect to the engine
  34589. */
  34590. connectToAnalyser(analyser: Analyser): void;
  34591. }
  34592. }
  34593. declare module BABYLON {
  34594. interface AbstractScene {
  34595. /**
  34596. * The list of sounds used in the scene.
  34597. */
  34598. sounds: Nullable<Array<Sound>>;
  34599. }
  34600. interface Scene {
  34601. /**
  34602. * @hidden
  34603. * Backing field
  34604. */
  34605. _mainSoundTrack: SoundTrack;
  34606. /**
  34607. * The main sound track played by the scene.
  34608. * It cotains your primary collection of sounds.
  34609. */
  34610. mainSoundTrack: SoundTrack;
  34611. /**
  34612. * The list of sound tracks added to the scene
  34613. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34614. */
  34615. soundTracks: Nullable<Array<SoundTrack>>;
  34616. /**
  34617. * Gets a sound using a given name
  34618. * @param name defines the name to search for
  34619. * @return the found sound or null if not found at all.
  34620. */
  34621. getSoundByName(name: string): Nullable<Sound>;
  34622. /**
  34623. * Gets or sets if audio support is enabled
  34624. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34625. */
  34626. audioEnabled: boolean;
  34627. /**
  34628. * Gets or sets if audio will be output to headphones
  34629. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34630. */
  34631. headphone: boolean;
  34632. }
  34633. /**
  34634. * Defines the sound scene component responsible to manage any sounds
  34635. * in a given scene.
  34636. */
  34637. export class AudioSceneComponent implements ISceneSerializableComponent {
  34638. /**
  34639. * The component name helpfull to identify the component in the list of scene components.
  34640. */
  34641. readonly name: string;
  34642. /**
  34643. * The scene the component belongs to.
  34644. */
  34645. scene: Scene;
  34646. private _audioEnabled;
  34647. /**
  34648. * Gets whether audio is enabled or not.
  34649. * Please use related enable/disable method to switch state.
  34650. */
  34651. readonly audioEnabled: boolean;
  34652. private _headphone;
  34653. /**
  34654. * Gets whether audio is outputing to headphone or not.
  34655. * Please use the according Switch methods to change output.
  34656. */
  34657. readonly headphone: boolean;
  34658. /**
  34659. * Creates a new instance of the component for the given scene
  34660. * @param scene Defines the scene to register the component in
  34661. */
  34662. constructor(scene: Scene);
  34663. /**
  34664. * Registers the component in a given scene
  34665. */
  34666. register(): void;
  34667. /**
  34668. * Rebuilds the elements related to this component in case of
  34669. * context lost for instance.
  34670. */
  34671. rebuild(): void;
  34672. /**
  34673. * Serializes the component data to the specified json object
  34674. * @param serializationObject The object to serialize to
  34675. */
  34676. serialize(serializationObject: any): void;
  34677. /**
  34678. * Adds all the elements from the container to the scene
  34679. * @param container the container holding the elements
  34680. */
  34681. addFromContainer(container: AbstractScene): void;
  34682. /**
  34683. * Removes all the elements in the container from the scene
  34684. * @param container contains the elements to remove
  34685. * @param dispose if the removed element should be disposed (default: false)
  34686. */
  34687. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  34688. /**
  34689. * Disposes the component and the associated ressources.
  34690. */
  34691. dispose(): void;
  34692. /**
  34693. * Disables audio in the associated scene.
  34694. */
  34695. disableAudio(): void;
  34696. /**
  34697. * Enables audio in the associated scene.
  34698. */
  34699. enableAudio(): void;
  34700. /**
  34701. * Switch audio to headphone output.
  34702. */
  34703. switchAudioModeForHeadphones(): void;
  34704. /**
  34705. * Switch audio to normal speakers.
  34706. */
  34707. switchAudioModeForNormalSpeakers(): void;
  34708. private _afterRender;
  34709. }
  34710. }
  34711. declare module BABYLON {
  34712. /**
  34713. * Wraps one or more Sound objects and selects one with random weight for playback.
  34714. */
  34715. export class WeightedSound {
  34716. /** When true a Sound will be selected and played when the current playing Sound completes. */
  34717. loop: boolean;
  34718. private _coneInnerAngle;
  34719. private _coneOuterAngle;
  34720. private _volume;
  34721. /** A Sound is currently playing. */
  34722. isPlaying: boolean;
  34723. /** A Sound is currently paused. */
  34724. isPaused: boolean;
  34725. private _sounds;
  34726. private _weights;
  34727. private _currentIndex?;
  34728. /**
  34729. * Creates a new WeightedSound from the list of sounds given.
  34730. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  34731. * @param sounds Array of Sounds that will be selected from.
  34732. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  34733. */
  34734. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  34735. /**
  34736. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  34737. */
  34738. /**
  34739. * The size of cone in degress for a directional sound in which there will be no attenuation.
  34740. */
  34741. directionalConeInnerAngle: number;
  34742. /**
  34743. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  34744. * Listener angles between innerAngle and outerAngle will falloff linearly.
  34745. */
  34746. /**
  34747. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  34748. * Listener angles between innerAngle and outerAngle will falloff linearly.
  34749. */
  34750. directionalConeOuterAngle: number;
  34751. /**
  34752. * Playback volume.
  34753. */
  34754. /**
  34755. * Playback volume.
  34756. */
  34757. volume: number;
  34758. private _onended;
  34759. /**
  34760. * Suspend playback
  34761. */
  34762. pause(): void;
  34763. /**
  34764. * Stop playback
  34765. */
  34766. stop(): void;
  34767. /**
  34768. * Start playback.
  34769. * @param startOffset Position the clip head at a specific time in seconds.
  34770. */
  34771. play(startOffset?: number): void;
  34772. }
  34773. }
  34774. declare module BABYLON {
  34775. /**
  34776. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  34777. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  34778. */
  34779. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  34780. /**
  34781. * Gets the name of the behavior.
  34782. */
  34783. readonly name: string;
  34784. /**
  34785. * The easing function used by animations
  34786. */
  34787. static EasingFunction: BackEase;
  34788. /**
  34789. * The easing mode used by animations
  34790. */
  34791. static EasingMode: number;
  34792. /**
  34793. * The duration of the animation, in milliseconds
  34794. */
  34795. transitionDuration: number;
  34796. /**
  34797. * Length of the distance animated by the transition when lower radius is reached
  34798. */
  34799. lowerRadiusTransitionRange: number;
  34800. /**
  34801. * Length of the distance animated by the transition when upper radius is reached
  34802. */
  34803. upperRadiusTransitionRange: number;
  34804. private _autoTransitionRange;
  34805. /**
  34806. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  34807. */
  34808. /**
  34809. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  34810. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  34811. */
  34812. autoTransitionRange: boolean;
  34813. private _attachedCamera;
  34814. private _onAfterCheckInputsObserver;
  34815. private _onMeshTargetChangedObserver;
  34816. /**
  34817. * Initializes the behavior.
  34818. */
  34819. init(): void;
  34820. /**
  34821. * Attaches the behavior to its arc rotate camera.
  34822. * @param camera Defines the camera to attach the behavior to
  34823. */
  34824. attach(camera: ArcRotateCamera): void;
  34825. /**
  34826. * Detaches the behavior from its current arc rotate camera.
  34827. */
  34828. detach(): void;
  34829. private _radiusIsAnimating;
  34830. private _radiusBounceTransition;
  34831. private _animatables;
  34832. private _cachedWheelPrecision;
  34833. /**
  34834. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  34835. * @param radiusLimit The limit to check against.
  34836. * @return Bool to indicate if at limit.
  34837. */
  34838. private _isRadiusAtLimit;
  34839. /**
  34840. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  34841. * @param radiusDelta The delta by which to animate to. Can be negative.
  34842. */
  34843. private _applyBoundRadiusAnimation;
  34844. /**
  34845. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  34846. */
  34847. protected _clearAnimationLocks(): void;
  34848. /**
  34849. * Stops and removes all animations that have been applied to the camera
  34850. */
  34851. stopAllAnimations(): void;
  34852. }
  34853. }
  34854. declare module BABYLON {
  34855. /**
  34856. * 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.
  34857. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  34858. */
  34859. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  34860. /**
  34861. * Gets the name of the behavior.
  34862. */
  34863. readonly name: string;
  34864. private _mode;
  34865. private _radiusScale;
  34866. private _positionScale;
  34867. private _defaultElevation;
  34868. private _elevationReturnTime;
  34869. private _elevationReturnWaitTime;
  34870. private _zoomStopsAnimation;
  34871. private _framingTime;
  34872. /**
  34873. * The easing function used by animations
  34874. */
  34875. static EasingFunction: ExponentialEase;
  34876. /**
  34877. * The easing mode used by animations
  34878. */
  34879. static EasingMode: number;
  34880. /**
  34881. * Sets the current mode used by the behavior
  34882. */
  34883. /**
  34884. * Gets current mode used by the behavior.
  34885. */
  34886. mode: number;
  34887. /**
  34888. * Sets the scale applied to the radius (1 by default)
  34889. */
  34890. /**
  34891. * Gets the scale applied to the radius
  34892. */
  34893. radiusScale: number;
  34894. /**
  34895. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  34896. */
  34897. /**
  34898. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  34899. */
  34900. positionScale: number;
  34901. /**
  34902. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  34903. * behaviour is triggered, in radians.
  34904. */
  34905. /**
  34906. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  34907. * behaviour is triggered, in radians.
  34908. */
  34909. defaultElevation: number;
  34910. /**
  34911. * Sets the time (in milliseconds) taken to return to the default beta position.
  34912. * Negative value indicates camera should not return to default.
  34913. */
  34914. /**
  34915. * Gets the time (in milliseconds) taken to return to the default beta position.
  34916. * Negative value indicates camera should not return to default.
  34917. */
  34918. elevationReturnTime: number;
  34919. /**
  34920. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  34921. */
  34922. /**
  34923. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  34924. */
  34925. elevationReturnWaitTime: number;
  34926. /**
  34927. * Sets the flag that indicates if user zooming should stop animation.
  34928. */
  34929. /**
  34930. * Gets the flag that indicates if user zooming should stop animation.
  34931. */
  34932. zoomStopsAnimation: boolean;
  34933. /**
  34934. * Sets the transition time when framing the mesh, in milliseconds
  34935. */
  34936. /**
  34937. * Gets the transition time when framing the mesh, in milliseconds
  34938. */
  34939. framingTime: number;
  34940. /**
  34941. * Define if the behavior should automatically change the configured
  34942. * camera limits and sensibilities.
  34943. */
  34944. autoCorrectCameraLimitsAndSensibility: boolean;
  34945. private _onPrePointerObservableObserver;
  34946. private _onAfterCheckInputsObserver;
  34947. private _onMeshTargetChangedObserver;
  34948. private _attachedCamera;
  34949. private _isPointerDown;
  34950. private _lastInteractionTime;
  34951. /**
  34952. * Initializes the behavior.
  34953. */
  34954. init(): void;
  34955. /**
  34956. * Attaches the behavior to its arc rotate camera.
  34957. * @param camera Defines the camera to attach the behavior to
  34958. */
  34959. attach(camera: ArcRotateCamera): void;
  34960. /**
  34961. * Detaches the behavior from its current arc rotate camera.
  34962. */
  34963. detach(): void;
  34964. private _animatables;
  34965. private _betaIsAnimating;
  34966. private _betaTransition;
  34967. private _radiusTransition;
  34968. private _vectorTransition;
  34969. /**
  34970. * Targets the given mesh and updates zoom level accordingly.
  34971. * @param mesh The mesh to target.
  34972. * @param radius Optional. If a cached radius position already exists, overrides default.
  34973. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  34974. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34975. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34976. */
  34977. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34978. /**
  34979. * Targets the given mesh with its children and updates zoom level accordingly.
  34980. * @param mesh The mesh to target.
  34981. * @param radius Optional. If a cached radius position already exists, overrides default.
  34982. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  34983. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34984. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34985. */
  34986. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34987. /**
  34988. * Targets the given meshes with their children and updates zoom level accordingly.
  34989. * @param meshes The mesh to target.
  34990. * @param radius Optional. If a cached radius position already exists, overrides default.
  34991. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  34992. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34993. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34994. */
  34995. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34996. /**
  34997. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  34998. * @param minimumWorld Determines the smaller position of the bounding box extend
  34999. * @param maximumWorld Determines the bigger position of the bounding box extend
  35000. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35001. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35002. */
  35003. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35004. /**
  35005. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  35006. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  35007. * frustum width.
  35008. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  35009. * to fully enclose the mesh in the viewing frustum.
  35010. */
  35011. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  35012. /**
  35013. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  35014. * is automatically returned to its default position (expected to be above ground plane).
  35015. */
  35016. private _maintainCameraAboveGround;
  35017. /**
  35018. * Returns the frustum slope based on the canvas ratio and camera FOV
  35019. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  35020. */
  35021. private _getFrustumSlope;
  35022. /**
  35023. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  35024. */
  35025. private _clearAnimationLocks;
  35026. /**
  35027. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  35028. */
  35029. private _applyUserInteraction;
  35030. /**
  35031. * Stops and removes all animations that have been applied to the camera
  35032. */
  35033. stopAllAnimations(): void;
  35034. /**
  35035. * Gets a value indicating if the user is moving the camera
  35036. */
  35037. readonly isUserIsMoving: boolean;
  35038. /**
  35039. * The camera can move all the way towards the mesh.
  35040. */
  35041. static IgnoreBoundsSizeMode: number;
  35042. /**
  35043. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  35044. */
  35045. static FitFrustumSidesMode: number;
  35046. }
  35047. }
  35048. declare module BABYLON {
  35049. /**
  35050. * Base class for Camera Pointer Inputs.
  35051. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  35052. * for example usage.
  35053. */
  35054. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  35055. /**
  35056. * Defines the camera the input is attached to.
  35057. */
  35058. abstract camera: Camera;
  35059. /**
  35060. * Whether keyboard modifier keys are pressed at time of last mouse event.
  35061. */
  35062. protected _altKey: boolean;
  35063. protected _ctrlKey: boolean;
  35064. protected _metaKey: boolean;
  35065. protected _shiftKey: boolean;
  35066. /**
  35067. * Which mouse buttons were pressed at time of last mouse event.
  35068. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  35069. */
  35070. protected _buttonsPressed: number;
  35071. /**
  35072. * Defines the buttons associated with the input to handle camera move.
  35073. */
  35074. buttons: number[];
  35075. /**
  35076. * Attach the input controls to a specific dom element to get the input from.
  35077. * @param element Defines the element the controls should be listened from
  35078. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35079. */
  35080. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35081. /**
  35082. * Detach the current controls from the specified dom element.
  35083. * @param element Defines the element to stop listening the inputs from
  35084. */
  35085. detachControl(element: Nullable<HTMLElement>): void;
  35086. /**
  35087. * Gets the class name of the current input.
  35088. * @returns the class name
  35089. */
  35090. getClassName(): string;
  35091. /**
  35092. * Get the friendly name associated with the input class.
  35093. * @returns the input friendly name
  35094. */
  35095. getSimpleName(): string;
  35096. /**
  35097. * Called on pointer POINTERDOUBLETAP event.
  35098. * Override this method to provide functionality on POINTERDOUBLETAP event.
  35099. */
  35100. protected onDoubleTap(type: string): void;
  35101. /**
  35102. * Called on pointer POINTERMOVE event if only a single touch is active.
  35103. * Override this method to provide functionality.
  35104. */
  35105. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  35106. /**
  35107. * Called on pointer POINTERMOVE event if multiple touches are active.
  35108. * Override this method to provide functionality.
  35109. */
  35110. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  35111. /**
  35112. * Called on JS contextmenu event.
  35113. * Override this method to provide functionality.
  35114. */
  35115. protected onContextMenu(evt: PointerEvent): void;
  35116. /**
  35117. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  35118. * press.
  35119. * Override this method to provide functionality.
  35120. */
  35121. protected onButtonDown(evt: PointerEvent): void;
  35122. /**
  35123. * Called each time a new POINTERUP event occurs. Ie, for each button
  35124. * release.
  35125. * Override this method to provide functionality.
  35126. */
  35127. protected onButtonUp(evt: PointerEvent): void;
  35128. /**
  35129. * Called when window becomes inactive.
  35130. * Override this method to provide functionality.
  35131. */
  35132. protected onLostFocus(): void;
  35133. private _pointerInput;
  35134. private _observer;
  35135. private _onLostFocus;
  35136. private pointA;
  35137. private pointB;
  35138. }
  35139. }
  35140. declare module BABYLON {
  35141. /**
  35142. * Manage the pointers inputs to control an arc rotate camera.
  35143. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35144. */
  35145. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  35146. /**
  35147. * Defines the camera the input is attached to.
  35148. */
  35149. camera: ArcRotateCamera;
  35150. /**
  35151. * Gets the class name of the current input.
  35152. * @returns the class name
  35153. */
  35154. getClassName(): string;
  35155. /**
  35156. * Defines the buttons associated with the input to handle camera move.
  35157. */
  35158. buttons: number[];
  35159. /**
  35160. * Defines the pointer angular sensibility along the X axis or how fast is
  35161. * the camera rotating.
  35162. */
  35163. angularSensibilityX: number;
  35164. /**
  35165. * Defines the pointer angular sensibility along the Y axis or how fast is
  35166. * the camera rotating.
  35167. */
  35168. angularSensibilityY: number;
  35169. /**
  35170. * Defines the pointer pinch precision or how fast is the camera zooming.
  35171. */
  35172. pinchPrecision: number;
  35173. /**
  35174. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  35175. * from 0.
  35176. * It defines the percentage of current camera.radius to use as delta when
  35177. * pinch zoom is used.
  35178. */
  35179. pinchDeltaPercentage: number;
  35180. /**
  35181. * Defines the pointer panning sensibility or how fast is the camera moving.
  35182. */
  35183. panningSensibility: number;
  35184. /**
  35185. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  35186. */
  35187. multiTouchPanning: boolean;
  35188. /**
  35189. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  35190. * zoom (pinch) through multitouch.
  35191. */
  35192. multiTouchPanAndZoom: boolean;
  35193. /**
  35194. * Revers pinch action direction.
  35195. */
  35196. pinchInwards: boolean;
  35197. private _isPanClick;
  35198. private _twoFingerActivityCount;
  35199. private _isPinching;
  35200. /**
  35201. * Called on pointer POINTERMOVE event if only a single touch is active.
  35202. */
  35203. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  35204. /**
  35205. * Called on pointer POINTERDOUBLETAP event.
  35206. */
  35207. protected onDoubleTap(type: string): void;
  35208. /**
  35209. * Called on pointer POINTERMOVE event if multiple touches are active.
  35210. */
  35211. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  35212. /**
  35213. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  35214. * press.
  35215. */
  35216. protected onButtonDown(evt: PointerEvent): void;
  35217. /**
  35218. * Called each time a new POINTERUP event occurs. Ie, for each button
  35219. * release.
  35220. */
  35221. protected onButtonUp(evt: PointerEvent): void;
  35222. /**
  35223. * Called when window becomes inactive.
  35224. */
  35225. protected onLostFocus(): void;
  35226. }
  35227. }
  35228. declare module BABYLON {
  35229. /**
  35230. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  35231. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35232. */
  35233. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  35234. /**
  35235. * Defines the camera the input is attached to.
  35236. */
  35237. camera: ArcRotateCamera;
  35238. /**
  35239. * Defines the list of key codes associated with the up action (increase alpha)
  35240. */
  35241. keysUp: number[];
  35242. /**
  35243. * Defines the list of key codes associated with the down action (decrease alpha)
  35244. */
  35245. keysDown: number[];
  35246. /**
  35247. * Defines the list of key codes associated with the left action (increase beta)
  35248. */
  35249. keysLeft: number[];
  35250. /**
  35251. * Defines the list of key codes associated with the right action (decrease beta)
  35252. */
  35253. keysRight: number[];
  35254. /**
  35255. * Defines the list of key codes associated with the reset action.
  35256. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  35257. */
  35258. keysReset: number[];
  35259. /**
  35260. * Defines the panning sensibility of the inputs.
  35261. * (How fast is the camera paning)
  35262. */
  35263. panningSensibility: number;
  35264. /**
  35265. * Defines the zooming sensibility of the inputs.
  35266. * (How fast is the camera zooming)
  35267. */
  35268. zoomingSensibility: number;
  35269. /**
  35270. * Defines wether maintaining the alt key down switch the movement mode from
  35271. * orientation to zoom.
  35272. */
  35273. useAltToZoom: boolean;
  35274. /**
  35275. * Rotation speed of the camera
  35276. */
  35277. angularSpeed: number;
  35278. private _keys;
  35279. private _ctrlPressed;
  35280. private _altPressed;
  35281. private _onCanvasBlurObserver;
  35282. private _onKeyboardObserver;
  35283. private _engine;
  35284. private _scene;
  35285. /**
  35286. * Attach the input controls to a specific dom element to get the input from.
  35287. * @param element Defines the element the controls should be listened from
  35288. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35289. */
  35290. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35291. /**
  35292. * Detach the current controls from the specified dom element.
  35293. * @param element Defines the element to stop listening the inputs from
  35294. */
  35295. detachControl(element: Nullable<HTMLElement>): void;
  35296. /**
  35297. * Update the current camera state depending on the inputs that have been used this frame.
  35298. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  35299. */
  35300. checkInputs(): void;
  35301. /**
  35302. * Gets the class name of the current intput.
  35303. * @returns the class name
  35304. */
  35305. getClassName(): string;
  35306. /**
  35307. * Get the friendly name associated with the input class.
  35308. * @returns the input friendly name
  35309. */
  35310. getSimpleName(): string;
  35311. }
  35312. }
  35313. declare module BABYLON {
  35314. /**
  35315. * Manage the mouse wheel inputs to control an arc rotate camera.
  35316. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35317. */
  35318. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  35319. /**
  35320. * Defines the camera the input is attached to.
  35321. */
  35322. camera: ArcRotateCamera;
  35323. /**
  35324. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  35325. */
  35326. wheelPrecision: number;
  35327. /**
  35328. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  35329. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  35330. */
  35331. wheelDeltaPercentage: number;
  35332. private _wheel;
  35333. private _observer;
  35334. private computeDeltaFromMouseWheelLegacyEvent;
  35335. /**
  35336. * Attach the input controls to a specific dom element to get the input from.
  35337. * @param element Defines the element the controls should be listened from
  35338. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35339. */
  35340. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35341. /**
  35342. * Detach the current controls from the specified dom element.
  35343. * @param element Defines the element to stop listening the inputs from
  35344. */
  35345. detachControl(element: Nullable<HTMLElement>): void;
  35346. /**
  35347. * Gets the class name of the current intput.
  35348. * @returns the class name
  35349. */
  35350. getClassName(): string;
  35351. /**
  35352. * Get the friendly name associated with the input class.
  35353. * @returns the input friendly name
  35354. */
  35355. getSimpleName(): string;
  35356. }
  35357. }
  35358. declare module BABYLON {
  35359. /**
  35360. * Default Inputs manager for the ArcRotateCamera.
  35361. * It groups all the default supported inputs for ease of use.
  35362. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35363. */
  35364. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  35365. /**
  35366. * Instantiates a new ArcRotateCameraInputsManager.
  35367. * @param camera Defines the camera the inputs belong to
  35368. */
  35369. constructor(camera: ArcRotateCamera);
  35370. /**
  35371. * Add mouse wheel input support to the input manager.
  35372. * @returns the current input manager
  35373. */
  35374. addMouseWheel(): ArcRotateCameraInputsManager;
  35375. /**
  35376. * Add pointers input support to the input manager.
  35377. * @returns the current input manager
  35378. */
  35379. addPointers(): ArcRotateCameraInputsManager;
  35380. /**
  35381. * Add keyboard input support to the input manager.
  35382. * @returns the current input manager
  35383. */
  35384. addKeyboard(): ArcRotateCameraInputsManager;
  35385. }
  35386. }
  35387. declare module BABYLON {
  35388. /**
  35389. * This represents an orbital type of camera.
  35390. *
  35391. * 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.
  35392. * 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.
  35393. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  35394. */
  35395. export class ArcRotateCamera extends TargetCamera {
  35396. /**
  35397. * Defines the rotation angle of the camera along the longitudinal axis.
  35398. */
  35399. alpha: number;
  35400. /**
  35401. * Defines the rotation angle of the camera along the latitudinal axis.
  35402. */
  35403. beta: number;
  35404. /**
  35405. * Defines the radius of the camera from it s target point.
  35406. */
  35407. radius: number;
  35408. protected _target: Vector3;
  35409. protected _targetHost: Nullable<AbstractMesh>;
  35410. /**
  35411. * Defines the target point of the camera.
  35412. * The camera looks towards it form the radius distance.
  35413. */
  35414. target: Vector3;
  35415. /**
  35416. * Define the current local position of the camera in the scene
  35417. */
  35418. position: Vector3;
  35419. protected _upVector: Vector3;
  35420. protected _upToYMatrix: Matrix;
  35421. protected _YToUpMatrix: Matrix;
  35422. /**
  35423. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  35424. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  35425. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  35426. */
  35427. upVector: Vector3;
  35428. /**
  35429. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  35430. */
  35431. setMatUp(): void;
  35432. /**
  35433. * Current inertia value on the longitudinal axis.
  35434. * The bigger this number the longer it will take for the camera to stop.
  35435. */
  35436. inertialAlphaOffset: number;
  35437. /**
  35438. * Current inertia value on the latitudinal axis.
  35439. * The bigger this number the longer it will take for the camera to stop.
  35440. */
  35441. inertialBetaOffset: number;
  35442. /**
  35443. * Current inertia value on the radius axis.
  35444. * The bigger this number the longer it will take for the camera to stop.
  35445. */
  35446. inertialRadiusOffset: number;
  35447. /**
  35448. * Minimum allowed angle on the longitudinal axis.
  35449. * This can help limiting how the Camera is able to move in the scene.
  35450. */
  35451. lowerAlphaLimit: Nullable<number>;
  35452. /**
  35453. * Maximum allowed angle on the longitudinal axis.
  35454. * This can help limiting how the Camera is able to move in the scene.
  35455. */
  35456. upperAlphaLimit: Nullable<number>;
  35457. /**
  35458. * Minimum allowed angle on the latitudinal axis.
  35459. * This can help limiting how the Camera is able to move in the scene.
  35460. */
  35461. lowerBetaLimit: number;
  35462. /**
  35463. * Maximum allowed angle on the latitudinal axis.
  35464. * This can help limiting how the Camera is able to move in the scene.
  35465. */
  35466. upperBetaLimit: number;
  35467. /**
  35468. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  35469. * This can help limiting how the Camera is able to move in the scene.
  35470. */
  35471. lowerRadiusLimit: Nullable<number>;
  35472. /**
  35473. * Maximum allowed distance of the camera to the target (The camera can not get further).
  35474. * This can help limiting how the Camera is able to move in the scene.
  35475. */
  35476. upperRadiusLimit: Nullable<number>;
  35477. /**
  35478. * Defines the current inertia value used during panning of the camera along the X axis.
  35479. */
  35480. inertialPanningX: number;
  35481. /**
  35482. * Defines the current inertia value used during panning of the camera along the Y axis.
  35483. */
  35484. inertialPanningY: number;
  35485. /**
  35486. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  35487. * Basically if your fingers moves away from more than this distance you will be considered
  35488. * in pinch mode.
  35489. */
  35490. pinchToPanMaxDistance: number;
  35491. /**
  35492. * Defines the maximum distance the camera can pan.
  35493. * This could help keeping the cammera always in your scene.
  35494. */
  35495. panningDistanceLimit: Nullable<number>;
  35496. /**
  35497. * Defines the target of the camera before paning.
  35498. */
  35499. panningOriginTarget: Vector3;
  35500. /**
  35501. * Defines the value of the inertia used during panning.
  35502. * 0 would mean stop inertia and one would mean no decelleration at all.
  35503. */
  35504. panningInertia: number;
  35505. /**
  35506. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  35507. */
  35508. angularSensibilityX: number;
  35509. /**
  35510. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  35511. */
  35512. angularSensibilityY: number;
  35513. /**
  35514. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  35515. */
  35516. pinchPrecision: number;
  35517. /**
  35518. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  35519. * It will be used instead of pinchDeltaPrecision if different from 0.
  35520. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  35521. */
  35522. pinchDeltaPercentage: number;
  35523. /**
  35524. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  35525. */
  35526. panningSensibility: number;
  35527. /**
  35528. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  35529. */
  35530. keysUp: number[];
  35531. /**
  35532. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  35533. */
  35534. keysDown: number[];
  35535. /**
  35536. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  35537. */
  35538. keysLeft: number[];
  35539. /**
  35540. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  35541. */
  35542. keysRight: number[];
  35543. /**
  35544. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  35545. */
  35546. wheelPrecision: number;
  35547. /**
  35548. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  35549. * It will be used instead of pinchDeltaPrecision if different from 0.
  35550. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  35551. */
  35552. wheelDeltaPercentage: number;
  35553. /**
  35554. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  35555. */
  35556. zoomOnFactor: number;
  35557. /**
  35558. * Defines a screen offset for the camera position.
  35559. */
  35560. targetScreenOffset: Vector2;
  35561. /**
  35562. * Allows the camera to be completely reversed.
  35563. * If false the camera can not arrive upside down.
  35564. */
  35565. allowUpsideDown: boolean;
  35566. /**
  35567. * Define if double tap/click is used to restore the previously saved state of the camera.
  35568. */
  35569. useInputToRestoreState: boolean;
  35570. /** @hidden */
  35571. _viewMatrix: Matrix;
  35572. /** @hidden */
  35573. _useCtrlForPanning: boolean;
  35574. /** @hidden */
  35575. _panningMouseButton: number;
  35576. /**
  35577. * Defines the input associated to the camera.
  35578. */
  35579. inputs: ArcRotateCameraInputsManager;
  35580. /** @hidden */
  35581. _reset: () => void;
  35582. /**
  35583. * Defines the allowed panning axis.
  35584. */
  35585. panningAxis: Vector3;
  35586. protected _localDirection: Vector3;
  35587. protected _transformedDirection: Vector3;
  35588. private _bouncingBehavior;
  35589. /**
  35590. * Gets the bouncing behavior of the camera if it has been enabled.
  35591. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35592. */
  35593. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  35594. /**
  35595. * Defines if the bouncing behavior of the camera is enabled on the camera.
  35596. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35597. */
  35598. useBouncingBehavior: boolean;
  35599. private _framingBehavior;
  35600. /**
  35601. * Gets the framing behavior of the camera if it has been enabled.
  35602. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35603. */
  35604. readonly framingBehavior: Nullable<FramingBehavior>;
  35605. /**
  35606. * Defines if the framing behavior of the camera is enabled on the camera.
  35607. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35608. */
  35609. useFramingBehavior: boolean;
  35610. private _autoRotationBehavior;
  35611. /**
  35612. * Gets the auto rotation behavior of the camera if it has been enabled.
  35613. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  35614. */
  35615. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  35616. /**
  35617. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  35618. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  35619. */
  35620. useAutoRotationBehavior: boolean;
  35621. /**
  35622. * Observable triggered when the mesh target has been changed on the camera.
  35623. */
  35624. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  35625. /**
  35626. * Event raised when the camera is colliding with a mesh.
  35627. */
  35628. onCollide: (collidedMesh: AbstractMesh) => void;
  35629. /**
  35630. * Defines whether the camera should check collision with the objects oh the scene.
  35631. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  35632. */
  35633. checkCollisions: boolean;
  35634. /**
  35635. * Defines the collision radius of the camera.
  35636. * This simulates a sphere around the camera.
  35637. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  35638. */
  35639. collisionRadius: Vector3;
  35640. protected _collider: Collider;
  35641. protected _previousPosition: Vector3;
  35642. protected _collisionVelocity: Vector3;
  35643. protected _newPosition: Vector3;
  35644. protected _previousAlpha: number;
  35645. protected _previousBeta: number;
  35646. protected _previousRadius: number;
  35647. protected _collisionTriggered: boolean;
  35648. protected _targetBoundingCenter: Nullable<Vector3>;
  35649. private _computationVector;
  35650. /**
  35651. * Instantiates a new ArcRotateCamera in a given scene
  35652. * @param name Defines the name of the camera
  35653. * @param alpha Defines the camera rotation along the logitudinal axis
  35654. * @param beta Defines the camera rotation along the latitudinal axis
  35655. * @param radius Defines the camera distance from its target
  35656. * @param target Defines the camera target
  35657. * @param scene Defines the scene the camera belongs to
  35658. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  35659. */
  35660. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  35661. /** @hidden */
  35662. _initCache(): void;
  35663. /** @hidden */
  35664. _updateCache(ignoreParentClass?: boolean): void;
  35665. protected _getTargetPosition(): Vector3;
  35666. private _storedAlpha;
  35667. private _storedBeta;
  35668. private _storedRadius;
  35669. private _storedTarget;
  35670. /**
  35671. * Stores the current state of the camera (alpha, beta, radius and target)
  35672. * @returns the camera itself
  35673. */
  35674. storeState(): Camera;
  35675. /**
  35676. * @hidden
  35677. * Restored camera state. You must call storeState() first
  35678. */
  35679. _restoreStateValues(): boolean;
  35680. /** @hidden */
  35681. _isSynchronizedViewMatrix(): boolean;
  35682. /**
  35683. * Attached controls to the current camera.
  35684. * @param element Defines the element the controls should be listened from
  35685. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35686. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  35687. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  35688. */
  35689. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  35690. /**
  35691. * Detach the current controls from the camera.
  35692. * The camera will stop reacting to inputs.
  35693. * @param element Defines the element to stop listening the inputs from
  35694. */
  35695. detachControl(element: HTMLElement): void;
  35696. /** @hidden */
  35697. _checkInputs(): void;
  35698. protected _checkLimits(): void;
  35699. /**
  35700. * Rebuilds angles (alpha, beta) and radius from the give position and target
  35701. */
  35702. rebuildAnglesAndRadius(): void;
  35703. /**
  35704. * Use a position to define the current camera related information like aplha, beta and radius
  35705. * @param position Defines the position to set the camera at
  35706. */
  35707. setPosition(position: Vector3): void;
  35708. /**
  35709. * Defines the target the camera should look at.
  35710. * This will automatically adapt alpha beta and radius to fit within the new target.
  35711. * @param target Defines the new target as a Vector or a mesh
  35712. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  35713. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  35714. */
  35715. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  35716. /** @hidden */
  35717. _getViewMatrix(): Matrix;
  35718. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  35719. /**
  35720. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  35721. * @param meshes Defines the mesh to zoom on
  35722. * @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)
  35723. */
  35724. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  35725. /**
  35726. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  35727. * The target will be changed but the radius
  35728. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  35729. * @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)
  35730. */
  35731. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  35732. min: Vector3;
  35733. max: Vector3;
  35734. distance: number;
  35735. }, doNotUpdateMaxZ?: boolean): void;
  35736. /**
  35737. * @override
  35738. * Override Camera.createRigCamera
  35739. */
  35740. createRigCamera(name: string, cameraIndex: number): Camera;
  35741. /**
  35742. * @hidden
  35743. * @override
  35744. * Override Camera._updateRigCameras
  35745. */
  35746. _updateRigCameras(): void;
  35747. /**
  35748. * Destroy the camera and release the current resources hold by it.
  35749. */
  35750. dispose(): void;
  35751. /**
  35752. * Gets the current object class name.
  35753. * @return the class name
  35754. */
  35755. getClassName(): string;
  35756. }
  35757. }
  35758. declare module BABYLON {
  35759. /**
  35760. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  35761. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  35762. */
  35763. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  35764. /**
  35765. * Gets the name of the behavior.
  35766. */
  35767. readonly name: string;
  35768. private _zoomStopsAnimation;
  35769. private _idleRotationSpeed;
  35770. private _idleRotationWaitTime;
  35771. private _idleRotationSpinupTime;
  35772. /**
  35773. * Sets the flag that indicates if user zooming should stop animation.
  35774. */
  35775. /**
  35776. * Gets the flag that indicates if user zooming should stop animation.
  35777. */
  35778. zoomStopsAnimation: boolean;
  35779. /**
  35780. * Sets the default speed at which the camera rotates around the model.
  35781. */
  35782. /**
  35783. * Gets the default speed at which the camera rotates around the model.
  35784. */
  35785. idleRotationSpeed: number;
  35786. /**
  35787. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  35788. */
  35789. /**
  35790. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  35791. */
  35792. idleRotationWaitTime: number;
  35793. /**
  35794. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  35795. */
  35796. /**
  35797. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  35798. */
  35799. idleRotationSpinupTime: number;
  35800. /**
  35801. * Gets a value indicating if the camera is currently rotating because of this behavior
  35802. */
  35803. readonly rotationInProgress: boolean;
  35804. private _onPrePointerObservableObserver;
  35805. private _onAfterCheckInputsObserver;
  35806. private _attachedCamera;
  35807. private _isPointerDown;
  35808. private _lastFrameTime;
  35809. private _lastInteractionTime;
  35810. private _cameraRotationSpeed;
  35811. /**
  35812. * Initializes the behavior.
  35813. */
  35814. init(): void;
  35815. /**
  35816. * Attaches the behavior to its arc rotate camera.
  35817. * @param camera Defines the camera to attach the behavior to
  35818. */
  35819. attach(camera: ArcRotateCamera): void;
  35820. /**
  35821. * Detaches the behavior from its current arc rotate camera.
  35822. */
  35823. detach(): void;
  35824. /**
  35825. * Returns true if user is scrolling.
  35826. * @return true if user is scrolling.
  35827. */
  35828. private _userIsZooming;
  35829. private _lastFrameRadius;
  35830. private _shouldAnimationStopForInteraction;
  35831. /**
  35832. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  35833. */
  35834. private _applyUserInteraction;
  35835. private _userIsMoving;
  35836. }
  35837. }
  35838. declare module BABYLON {
  35839. /**
  35840. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  35841. */
  35842. export class AttachToBoxBehavior implements Behavior<Mesh> {
  35843. private ui;
  35844. /**
  35845. * The name of the behavior
  35846. */
  35847. name: string;
  35848. /**
  35849. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  35850. */
  35851. distanceAwayFromFace: number;
  35852. /**
  35853. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  35854. */
  35855. distanceAwayFromBottomOfFace: number;
  35856. private _faceVectors;
  35857. private _target;
  35858. private _scene;
  35859. private _onRenderObserver;
  35860. private _tmpMatrix;
  35861. private _tmpVector;
  35862. /**
  35863. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  35864. * @param ui The transform node that should be attched to the mesh
  35865. */
  35866. constructor(ui: TransformNode);
  35867. /**
  35868. * Initializes the behavior
  35869. */
  35870. init(): void;
  35871. private _closestFace;
  35872. private _zeroVector;
  35873. private _lookAtTmpMatrix;
  35874. private _lookAtToRef;
  35875. /**
  35876. * Attaches the AttachToBoxBehavior to the passed in mesh
  35877. * @param target The mesh that the specified node will be attached to
  35878. */
  35879. attach(target: Mesh): void;
  35880. /**
  35881. * Detaches the behavior from the mesh
  35882. */
  35883. detach(): void;
  35884. }
  35885. }
  35886. declare module BABYLON {
  35887. /**
  35888. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  35889. */
  35890. export class FadeInOutBehavior implements Behavior<Mesh> {
  35891. /**
  35892. * Time in milliseconds to delay before fading in (Default: 0)
  35893. */
  35894. delay: number;
  35895. /**
  35896. * Time in milliseconds for the mesh to fade in (Default: 300)
  35897. */
  35898. fadeInTime: number;
  35899. private _millisecondsPerFrame;
  35900. private _hovered;
  35901. private _hoverValue;
  35902. private _ownerNode;
  35903. /**
  35904. * Instatiates the FadeInOutBehavior
  35905. */
  35906. constructor();
  35907. /**
  35908. * The name of the behavior
  35909. */
  35910. readonly name: string;
  35911. /**
  35912. * Initializes the behavior
  35913. */
  35914. init(): void;
  35915. /**
  35916. * Attaches the fade behavior on the passed in mesh
  35917. * @param ownerNode The mesh that will be faded in/out once attached
  35918. */
  35919. attach(ownerNode: Mesh): void;
  35920. /**
  35921. * Detaches the behavior from the mesh
  35922. */
  35923. detach(): void;
  35924. /**
  35925. * Triggers the mesh to begin fading in or out
  35926. * @param value if the object should fade in or out (true to fade in)
  35927. */
  35928. fadeIn(value: boolean): void;
  35929. private _update;
  35930. private _setAllVisibility;
  35931. }
  35932. }
  35933. declare module BABYLON {
  35934. /**
  35935. * Class containing a set of static utilities functions for managing Pivots
  35936. * @hidden
  35937. */
  35938. export class PivotTools {
  35939. private static _PivotCached;
  35940. private static _OldPivotPoint;
  35941. private static _PivotTranslation;
  35942. private static _PivotTmpVector;
  35943. /** @hidden */
  35944. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  35945. /** @hidden */
  35946. static _RestorePivotPoint(mesh: AbstractMesh): void;
  35947. }
  35948. }
  35949. declare module BABYLON {
  35950. /**
  35951. * Class containing static functions to help procedurally build meshes
  35952. */
  35953. export class PlaneBuilder {
  35954. /**
  35955. * Creates a plane mesh
  35956. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  35957. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  35958. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  35959. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  35960. * * 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
  35961. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  35962. * @param name defines the name of the mesh
  35963. * @param options defines the options used to create the mesh
  35964. * @param scene defines the hosting scene
  35965. * @returns the plane mesh
  35966. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  35967. */
  35968. static CreatePlane(name: string, options: {
  35969. size?: number;
  35970. width?: number;
  35971. height?: number;
  35972. sideOrientation?: number;
  35973. frontUVs?: Vector4;
  35974. backUVs?: Vector4;
  35975. updatable?: boolean;
  35976. sourcePlane?: Plane;
  35977. }, scene?: Nullable<Scene>): Mesh;
  35978. }
  35979. }
  35980. declare module BABYLON {
  35981. /**
  35982. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  35983. */
  35984. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  35985. private static _AnyMouseID;
  35986. /**
  35987. * Abstract mesh the behavior is set on
  35988. */
  35989. attachedNode: AbstractMesh;
  35990. private _dragPlane;
  35991. private _scene;
  35992. private _pointerObserver;
  35993. private _beforeRenderObserver;
  35994. private static _planeScene;
  35995. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  35996. /**
  35997. * 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)
  35998. */
  35999. maxDragAngle: number;
  36000. /**
  36001. * @hidden
  36002. */
  36003. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  36004. /**
  36005. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  36006. */
  36007. currentDraggingPointerID: number;
  36008. /**
  36009. * The last position where the pointer hit the drag plane in world space
  36010. */
  36011. lastDragPosition: Vector3;
  36012. /**
  36013. * If the behavior is currently in a dragging state
  36014. */
  36015. dragging: boolean;
  36016. /**
  36017. * 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)
  36018. */
  36019. dragDeltaRatio: number;
  36020. /**
  36021. * If the drag plane orientation should be updated during the dragging (Default: true)
  36022. */
  36023. updateDragPlane: boolean;
  36024. private _debugMode;
  36025. private _moving;
  36026. /**
  36027. * Fires each time the attached mesh is dragged with the pointer
  36028. * * delta between last drag position and current drag position in world space
  36029. * * dragDistance along the drag axis
  36030. * * dragPlaneNormal normal of the current drag plane used during the drag
  36031. * * dragPlanePoint in world space where the drag intersects the drag plane
  36032. */
  36033. onDragObservable: Observable<{
  36034. delta: Vector3;
  36035. dragPlanePoint: Vector3;
  36036. dragPlaneNormal: Vector3;
  36037. dragDistance: number;
  36038. pointerId: number;
  36039. }>;
  36040. /**
  36041. * Fires each time a drag begins (eg. mouse down on mesh)
  36042. */
  36043. onDragStartObservable: Observable<{
  36044. dragPlanePoint: Vector3;
  36045. pointerId: number;
  36046. }>;
  36047. /**
  36048. * Fires each time a drag ends (eg. mouse release after drag)
  36049. */
  36050. onDragEndObservable: Observable<{
  36051. dragPlanePoint: Vector3;
  36052. pointerId: number;
  36053. }>;
  36054. /**
  36055. * If the attached mesh should be moved when dragged
  36056. */
  36057. moveAttached: boolean;
  36058. /**
  36059. * If the drag behavior will react to drag events (Default: true)
  36060. */
  36061. enabled: boolean;
  36062. /**
  36063. * If camera controls should be detached during the drag
  36064. */
  36065. detachCameraControls: boolean;
  36066. /**
  36067. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  36068. */
  36069. useObjectOrienationForDragging: boolean;
  36070. private _options;
  36071. /**
  36072. * Creates a pointer drag behavior that can be attached to a mesh
  36073. * @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)
  36074. */
  36075. constructor(options?: {
  36076. dragAxis?: Vector3;
  36077. dragPlaneNormal?: Vector3;
  36078. });
  36079. /**
  36080. * Predicate to determine if it is valid to move the object to a new position when it is moved
  36081. */
  36082. validateDrag: (targetPosition: Vector3) => boolean;
  36083. /**
  36084. * The name of the behavior
  36085. */
  36086. readonly name: string;
  36087. /**
  36088. * Initializes the behavior
  36089. */
  36090. init(): void;
  36091. private _tmpVector;
  36092. private _alternatePickedPoint;
  36093. private _worldDragAxis;
  36094. private _targetPosition;
  36095. private _attachedElement;
  36096. /**
  36097. * Attaches the drag behavior the passed in mesh
  36098. * @param ownerNode The mesh that will be dragged around once attached
  36099. */
  36100. attach(ownerNode: AbstractMesh): void;
  36101. /**
  36102. * Force relase the drag action by code.
  36103. */
  36104. releaseDrag(): void;
  36105. private _startDragRay;
  36106. private _lastPointerRay;
  36107. /**
  36108. * Simulates the start of a pointer drag event on the behavior
  36109. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  36110. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  36111. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  36112. */
  36113. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  36114. private _startDrag;
  36115. private _dragDelta;
  36116. private _moveDrag;
  36117. private _pickWithRayOnDragPlane;
  36118. private _pointA;
  36119. private _pointB;
  36120. private _pointC;
  36121. private _lineA;
  36122. private _lineB;
  36123. private _localAxis;
  36124. private _lookAt;
  36125. private _updateDragPlanePosition;
  36126. /**
  36127. * Detaches the behavior from the mesh
  36128. */
  36129. detach(): void;
  36130. }
  36131. }
  36132. declare module BABYLON {
  36133. /**
  36134. * A behavior that when attached to a mesh will allow the mesh to be scaled
  36135. */
  36136. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  36137. private _dragBehaviorA;
  36138. private _dragBehaviorB;
  36139. private _startDistance;
  36140. private _initialScale;
  36141. private _targetScale;
  36142. private _ownerNode;
  36143. private _sceneRenderObserver;
  36144. /**
  36145. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  36146. */
  36147. constructor();
  36148. /**
  36149. * The name of the behavior
  36150. */
  36151. readonly name: string;
  36152. /**
  36153. * Initializes the behavior
  36154. */
  36155. init(): void;
  36156. private _getCurrentDistance;
  36157. /**
  36158. * Attaches the scale behavior the passed in mesh
  36159. * @param ownerNode The mesh that will be scaled around once attached
  36160. */
  36161. attach(ownerNode: Mesh): void;
  36162. /**
  36163. * Detaches the behavior from the mesh
  36164. */
  36165. detach(): void;
  36166. }
  36167. }
  36168. declare module BABYLON {
  36169. /**
  36170. * 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
  36171. */
  36172. export class SixDofDragBehavior implements Behavior<Mesh> {
  36173. private static _virtualScene;
  36174. private _ownerNode;
  36175. private _sceneRenderObserver;
  36176. private _scene;
  36177. private _targetPosition;
  36178. private _virtualOriginMesh;
  36179. private _virtualDragMesh;
  36180. private _pointerObserver;
  36181. private _moving;
  36182. private _startingOrientation;
  36183. /**
  36184. * 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)
  36185. */
  36186. private zDragFactor;
  36187. /**
  36188. * If the object should rotate to face the drag origin
  36189. */
  36190. rotateDraggedObject: boolean;
  36191. /**
  36192. * If the behavior is currently in a dragging state
  36193. */
  36194. dragging: boolean;
  36195. /**
  36196. * 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)
  36197. */
  36198. dragDeltaRatio: number;
  36199. /**
  36200. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  36201. */
  36202. currentDraggingPointerID: number;
  36203. /**
  36204. * If camera controls should be detached during the drag
  36205. */
  36206. detachCameraControls: boolean;
  36207. /**
  36208. * Fires each time a drag starts
  36209. */
  36210. onDragStartObservable: Observable<{}>;
  36211. /**
  36212. * Fires each time a drag ends (eg. mouse release after drag)
  36213. */
  36214. onDragEndObservable: Observable<{}>;
  36215. /**
  36216. * 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
  36217. */
  36218. constructor();
  36219. /**
  36220. * The name of the behavior
  36221. */
  36222. readonly name: string;
  36223. /**
  36224. * Initializes the behavior
  36225. */
  36226. init(): void;
  36227. /**
  36228. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  36229. */
  36230. private readonly _pointerCamera;
  36231. /**
  36232. * Attaches the scale behavior the passed in mesh
  36233. * @param ownerNode The mesh that will be scaled around once attached
  36234. */
  36235. attach(ownerNode: Mesh): void;
  36236. /**
  36237. * Detaches the behavior from the mesh
  36238. */
  36239. detach(): void;
  36240. }
  36241. }
  36242. declare module BABYLON {
  36243. /**
  36244. * Class used to apply inverse kinematics to bones
  36245. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  36246. */
  36247. export class BoneIKController {
  36248. private static _tmpVecs;
  36249. private static _tmpQuat;
  36250. private static _tmpMats;
  36251. /**
  36252. * Gets or sets the target mesh
  36253. */
  36254. targetMesh: AbstractMesh;
  36255. /** Gets or sets the mesh used as pole */
  36256. poleTargetMesh: AbstractMesh;
  36257. /**
  36258. * Gets or sets the bone used as pole
  36259. */
  36260. poleTargetBone: Nullable<Bone>;
  36261. /**
  36262. * Gets or sets the target position
  36263. */
  36264. targetPosition: Vector3;
  36265. /**
  36266. * Gets or sets the pole target position
  36267. */
  36268. poleTargetPosition: Vector3;
  36269. /**
  36270. * Gets or sets the pole target local offset
  36271. */
  36272. poleTargetLocalOffset: Vector3;
  36273. /**
  36274. * Gets or sets the pole angle
  36275. */
  36276. poleAngle: number;
  36277. /**
  36278. * Gets or sets the mesh associated with the controller
  36279. */
  36280. mesh: AbstractMesh;
  36281. /**
  36282. * 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)
  36283. */
  36284. slerpAmount: number;
  36285. private _bone1Quat;
  36286. private _bone1Mat;
  36287. private _bone2Ang;
  36288. private _bone1;
  36289. private _bone2;
  36290. private _bone1Length;
  36291. private _bone2Length;
  36292. private _maxAngle;
  36293. private _maxReach;
  36294. private _rightHandedSystem;
  36295. private _bendAxis;
  36296. private _slerping;
  36297. private _adjustRoll;
  36298. /**
  36299. * Gets or sets maximum allowed angle
  36300. */
  36301. maxAngle: number;
  36302. /**
  36303. * Creates a new BoneIKController
  36304. * @param mesh defines the mesh to control
  36305. * @param bone defines the bone to control
  36306. * @param options defines options to set up the controller
  36307. */
  36308. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  36309. targetMesh?: AbstractMesh;
  36310. poleTargetMesh?: AbstractMesh;
  36311. poleTargetBone?: Bone;
  36312. poleTargetLocalOffset?: Vector3;
  36313. poleAngle?: number;
  36314. bendAxis?: Vector3;
  36315. maxAngle?: number;
  36316. slerpAmount?: number;
  36317. });
  36318. private _setMaxAngle;
  36319. /**
  36320. * Force the controller to update the bones
  36321. */
  36322. update(): void;
  36323. }
  36324. }
  36325. declare module BABYLON {
  36326. /**
  36327. * Class used to make a bone look toward a point in space
  36328. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  36329. */
  36330. export class BoneLookController {
  36331. private static _tmpVecs;
  36332. private static _tmpQuat;
  36333. private static _tmpMats;
  36334. /**
  36335. * The target Vector3 that the bone will look at
  36336. */
  36337. target: Vector3;
  36338. /**
  36339. * The mesh that the bone is attached to
  36340. */
  36341. mesh: AbstractMesh;
  36342. /**
  36343. * The bone that will be looking to the target
  36344. */
  36345. bone: Bone;
  36346. /**
  36347. * The up axis of the coordinate system that is used when the bone is rotated
  36348. */
  36349. upAxis: Vector3;
  36350. /**
  36351. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  36352. */
  36353. upAxisSpace: Space;
  36354. /**
  36355. * Used to make an adjustment to the yaw of the bone
  36356. */
  36357. adjustYaw: number;
  36358. /**
  36359. * Used to make an adjustment to the pitch of the bone
  36360. */
  36361. adjustPitch: number;
  36362. /**
  36363. * Used to make an adjustment to the roll of the bone
  36364. */
  36365. adjustRoll: number;
  36366. /**
  36367. * 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)
  36368. */
  36369. slerpAmount: number;
  36370. private _minYaw;
  36371. private _maxYaw;
  36372. private _minPitch;
  36373. private _maxPitch;
  36374. private _minYawSin;
  36375. private _minYawCos;
  36376. private _maxYawSin;
  36377. private _maxYawCos;
  36378. private _midYawConstraint;
  36379. private _minPitchTan;
  36380. private _maxPitchTan;
  36381. private _boneQuat;
  36382. private _slerping;
  36383. private _transformYawPitch;
  36384. private _transformYawPitchInv;
  36385. private _firstFrameSkipped;
  36386. private _yawRange;
  36387. private _fowardAxis;
  36388. /**
  36389. * Gets or sets the minimum yaw angle that the bone can look to
  36390. */
  36391. minYaw: number;
  36392. /**
  36393. * Gets or sets the maximum yaw angle that the bone can look to
  36394. */
  36395. maxYaw: number;
  36396. /**
  36397. * Gets or sets the minimum pitch angle that the bone can look to
  36398. */
  36399. minPitch: number;
  36400. /**
  36401. * Gets or sets the maximum pitch angle that the bone can look to
  36402. */
  36403. maxPitch: number;
  36404. /**
  36405. * Create a BoneLookController
  36406. * @param mesh the mesh that the bone belongs to
  36407. * @param bone the bone that will be looking to the target
  36408. * @param target the target Vector3 to look at
  36409. * @param options optional settings:
  36410. * * maxYaw: the maximum angle the bone will yaw to
  36411. * * minYaw: the minimum angle the bone will yaw to
  36412. * * maxPitch: the maximum angle the bone will pitch to
  36413. * * minPitch: the minimum angle the bone will yaw to
  36414. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  36415. * * upAxis: the up axis of the coordinate system
  36416. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  36417. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  36418. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  36419. * * adjustYaw: used to make an adjustment to the yaw of the bone
  36420. * * adjustPitch: used to make an adjustment to the pitch of the bone
  36421. * * adjustRoll: used to make an adjustment to the roll of the bone
  36422. **/
  36423. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  36424. maxYaw?: number;
  36425. minYaw?: number;
  36426. maxPitch?: number;
  36427. minPitch?: number;
  36428. slerpAmount?: number;
  36429. upAxis?: Vector3;
  36430. upAxisSpace?: Space;
  36431. yawAxis?: Vector3;
  36432. pitchAxis?: Vector3;
  36433. adjustYaw?: number;
  36434. adjustPitch?: number;
  36435. adjustRoll?: number;
  36436. });
  36437. /**
  36438. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  36439. */
  36440. update(): void;
  36441. private _getAngleDiff;
  36442. private _getAngleBetween;
  36443. private _isAngleBetween;
  36444. }
  36445. }
  36446. declare module BABYLON {
  36447. /**
  36448. * Manage the gamepad inputs to control an arc rotate camera.
  36449. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36450. */
  36451. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  36452. /**
  36453. * Defines the camera the input is attached to.
  36454. */
  36455. camera: ArcRotateCamera;
  36456. /**
  36457. * Defines the gamepad the input is gathering event from.
  36458. */
  36459. gamepad: Nullable<Gamepad>;
  36460. /**
  36461. * Defines the gamepad rotation sensiblity.
  36462. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  36463. */
  36464. gamepadRotationSensibility: number;
  36465. /**
  36466. * Defines the gamepad move sensiblity.
  36467. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  36468. */
  36469. gamepadMoveSensibility: number;
  36470. private _onGamepadConnectedObserver;
  36471. private _onGamepadDisconnectedObserver;
  36472. /**
  36473. * Attach the input controls to a specific dom element to get the input from.
  36474. * @param element Defines the element the controls should be listened from
  36475. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36476. */
  36477. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36478. /**
  36479. * Detach the current controls from the specified dom element.
  36480. * @param element Defines the element to stop listening the inputs from
  36481. */
  36482. detachControl(element: Nullable<HTMLElement>): void;
  36483. /**
  36484. * Update the current camera state depending on the inputs that have been used this frame.
  36485. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36486. */
  36487. checkInputs(): void;
  36488. /**
  36489. * Gets the class name of the current intput.
  36490. * @returns the class name
  36491. */
  36492. getClassName(): string;
  36493. /**
  36494. * Get the friendly name associated with the input class.
  36495. * @returns the input friendly name
  36496. */
  36497. getSimpleName(): string;
  36498. }
  36499. }
  36500. declare module BABYLON {
  36501. interface ArcRotateCameraInputsManager {
  36502. /**
  36503. * Add orientation input support to the input manager.
  36504. * @returns the current input manager
  36505. */
  36506. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  36507. }
  36508. /**
  36509. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  36510. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36511. */
  36512. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  36513. /**
  36514. * Defines the camera the input is attached to.
  36515. */
  36516. camera: ArcRotateCamera;
  36517. /**
  36518. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  36519. */
  36520. alphaCorrection: number;
  36521. /**
  36522. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  36523. */
  36524. gammaCorrection: number;
  36525. private _alpha;
  36526. private _gamma;
  36527. private _dirty;
  36528. private _deviceOrientationHandler;
  36529. /**
  36530. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  36531. */
  36532. constructor();
  36533. /**
  36534. * Attach the input controls to a specific dom element to get the input from.
  36535. * @param element Defines the element the controls should be listened from
  36536. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36537. */
  36538. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36539. /** @hidden */
  36540. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  36541. /**
  36542. * Update the current camera state depending on the inputs that have been used this frame.
  36543. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36544. */
  36545. checkInputs(): void;
  36546. /**
  36547. * Detach the current controls from the specified dom element.
  36548. * @param element Defines the element to stop listening the inputs from
  36549. */
  36550. detachControl(element: Nullable<HTMLElement>): void;
  36551. /**
  36552. * Gets the class name of the current intput.
  36553. * @returns the class name
  36554. */
  36555. getClassName(): string;
  36556. /**
  36557. * Get the friendly name associated with the input class.
  36558. * @returns the input friendly name
  36559. */
  36560. getSimpleName(): string;
  36561. }
  36562. }
  36563. declare module BABYLON {
  36564. /**
  36565. * Listen to mouse events to control the camera.
  36566. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36567. */
  36568. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  36569. /**
  36570. * Defines the camera the input is attached to.
  36571. */
  36572. camera: FlyCamera;
  36573. /**
  36574. * Defines if touch is enabled. (Default is true.)
  36575. */
  36576. touchEnabled: boolean;
  36577. /**
  36578. * Defines the buttons associated with the input to handle camera rotation.
  36579. */
  36580. buttons: number[];
  36581. /**
  36582. * Assign buttons for Yaw control.
  36583. */
  36584. buttonsYaw: number[];
  36585. /**
  36586. * Assign buttons for Pitch control.
  36587. */
  36588. buttonsPitch: number[];
  36589. /**
  36590. * Assign buttons for Roll control.
  36591. */
  36592. buttonsRoll: number[];
  36593. /**
  36594. * Detect if any button is being pressed while mouse is moved.
  36595. * -1 = Mouse locked.
  36596. * 0 = Left button.
  36597. * 1 = Middle Button.
  36598. * 2 = Right Button.
  36599. */
  36600. activeButton: number;
  36601. /**
  36602. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  36603. * Higher values reduce its sensitivity.
  36604. */
  36605. angularSensibility: number;
  36606. private _mousemoveCallback;
  36607. private _observer;
  36608. private _rollObserver;
  36609. private previousPosition;
  36610. private noPreventDefault;
  36611. private element;
  36612. /**
  36613. * Listen to mouse events to control the camera.
  36614. * @param touchEnabled Define if touch is enabled. (Default is true.)
  36615. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36616. */
  36617. constructor(touchEnabled?: boolean);
  36618. /**
  36619. * Attach the mouse control to the HTML DOM element.
  36620. * @param element Defines the element that listens to the input events.
  36621. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  36622. */
  36623. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36624. /**
  36625. * Detach the current controls from the specified dom element.
  36626. * @param element Defines the element to stop listening the inputs from
  36627. */
  36628. detachControl(element: Nullable<HTMLElement>): void;
  36629. /**
  36630. * Gets the class name of the current input.
  36631. * @returns the class name.
  36632. */
  36633. getClassName(): string;
  36634. /**
  36635. * Get the friendly name associated with the input class.
  36636. * @returns the input's friendly name.
  36637. */
  36638. getSimpleName(): string;
  36639. private _pointerInput;
  36640. private _onMouseMove;
  36641. /**
  36642. * Rotate camera by mouse offset.
  36643. */
  36644. private rotateCamera;
  36645. }
  36646. }
  36647. declare module BABYLON {
  36648. /**
  36649. * Default Inputs manager for the FlyCamera.
  36650. * It groups all the default supported inputs for ease of use.
  36651. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36652. */
  36653. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  36654. /**
  36655. * Instantiates a new FlyCameraInputsManager.
  36656. * @param camera Defines the camera the inputs belong to.
  36657. */
  36658. constructor(camera: FlyCamera);
  36659. /**
  36660. * Add keyboard input support to the input manager.
  36661. * @returns the new FlyCameraKeyboardMoveInput().
  36662. */
  36663. addKeyboard(): FlyCameraInputsManager;
  36664. /**
  36665. * Add mouse input support to the input manager.
  36666. * @param touchEnabled Enable touch screen support.
  36667. * @returns the new FlyCameraMouseInput().
  36668. */
  36669. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  36670. }
  36671. }
  36672. declare module BABYLON {
  36673. /**
  36674. * This is a flying camera, designed for 3D movement and rotation in all directions,
  36675. * such as in a 3D Space Shooter or a Flight Simulator.
  36676. */
  36677. export class FlyCamera extends TargetCamera {
  36678. /**
  36679. * Define the collision ellipsoid of the camera.
  36680. * This is helpful for simulating a camera body, like a player's body.
  36681. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  36682. */
  36683. ellipsoid: Vector3;
  36684. /**
  36685. * Define an offset for the position of the ellipsoid around the camera.
  36686. * This can be helpful if the camera is attached away from the player's body center,
  36687. * such as at its head.
  36688. */
  36689. ellipsoidOffset: Vector3;
  36690. /**
  36691. * Enable or disable collisions of the camera with the rest of the scene objects.
  36692. */
  36693. checkCollisions: boolean;
  36694. /**
  36695. * Enable or disable gravity on the camera.
  36696. */
  36697. applyGravity: boolean;
  36698. /**
  36699. * Define the current direction the camera is moving to.
  36700. */
  36701. cameraDirection: Vector3;
  36702. /**
  36703. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  36704. * This overrides and empties cameraRotation.
  36705. */
  36706. rotationQuaternion: Quaternion;
  36707. /**
  36708. * Track Roll to maintain the wanted Rolling when looking around.
  36709. */
  36710. _trackRoll: number;
  36711. /**
  36712. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  36713. */
  36714. rollCorrect: number;
  36715. /**
  36716. * Mimic a banked turn, Rolling the camera when Yawing.
  36717. * It's recommended to use rollCorrect = 10 for faster banking correction.
  36718. */
  36719. bankedTurn: boolean;
  36720. /**
  36721. * Limit in radians for how much Roll banking will add. (Default: 90°)
  36722. */
  36723. bankedTurnLimit: number;
  36724. /**
  36725. * Value of 0 disables the banked Roll.
  36726. * Value of 1 is equal to the Yaw angle in radians.
  36727. */
  36728. bankedTurnMultiplier: number;
  36729. /**
  36730. * The inputs manager loads all the input sources, such as keyboard and mouse.
  36731. */
  36732. inputs: FlyCameraInputsManager;
  36733. /**
  36734. * Gets the input sensibility for mouse input.
  36735. * Higher values reduce sensitivity.
  36736. */
  36737. /**
  36738. * Sets the input sensibility for a mouse input.
  36739. * Higher values reduce sensitivity.
  36740. */
  36741. angularSensibility: number;
  36742. /**
  36743. * Get the keys for camera movement forward.
  36744. */
  36745. /**
  36746. * Set the keys for camera movement forward.
  36747. */
  36748. keysForward: number[];
  36749. /**
  36750. * Get the keys for camera movement backward.
  36751. */
  36752. keysBackward: number[];
  36753. /**
  36754. * Get the keys for camera movement up.
  36755. */
  36756. /**
  36757. * Set the keys for camera movement up.
  36758. */
  36759. keysUp: number[];
  36760. /**
  36761. * Get the keys for camera movement down.
  36762. */
  36763. /**
  36764. * Set the keys for camera movement down.
  36765. */
  36766. keysDown: number[];
  36767. /**
  36768. * Get the keys for camera movement left.
  36769. */
  36770. /**
  36771. * Set the keys for camera movement left.
  36772. */
  36773. keysLeft: number[];
  36774. /**
  36775. * Set the keys for camera movement right.
  36776. */
  36777. /**
  36778. * Set the keys for camera movement right.
  36779. */
  36780. keysRight: number[];
  36781. /**
  36782. * Event raised when the camera collides with a mesh in the scene.
  36783. */
  36784. onCollide: (collidedMesh: AbstractMesh) => void;
  36785. private _collider;
  36786. private _needMoveForGravity;
  36787. private _oldPosition;
  36788. private _diffPosition;
  36789. private _newPosition;
  36790. /** @hidden */
  36791. _localDirection: Vector3;
  36792. /** @hidden */
  36793. _transformedDirection: Vector3;
  36794. /**
  36795. * Instantiates a FlyCamera.
  36796. * This is a flying camera, designed for 3D movement and rotation in all directions,
  36797. * such as in a 3D Space Shooter or a Flight Simulator.
  36798. * @param name Define the name of the camera in the scene.
  36799. * @param position Define the starting position of the camera in the scene.
  36800. * @param scene Define the scene the camera belongs to.
  36801. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  36802. */
  36803. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  36804. /**
  36805. * Attach a control to the HTML DOM element.
  36806. * @param element Defines the element that listens to the input events.
  36807. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  36808. */
  36809. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36810. /**
  36811. * Detach a control from the HTML DOM element.
  36812. * The camera will stop reacting to that input.
  36813. * @param element Defines the element that listens to the input events.
  36814. */
  36815. detachControl(element: HTMLElement): void;
  36816. private _collisionMask;
  36817. /**
  36818. * Get the mask that the camera ignores in collision events.
  36819. */
  36820. /**
  36821. * Set the mask that the camera ignores in collision events.
  36822. */
  36823. collisionMask: number;
  36824. /** @hidden */
  36825. _collideWithWorld(displacement: Vector3): void;
  36826. /** @hidden */
  36827. private _onCollisionPositionChange;
  36828. /** @hidden */
  36829. _checkInputs(): void;
  36830. /** @hidden */
  36831. _decideIfNeedsToMove(): boolean;
  36832. /** @hidden */
  36833. _updatePosition(): void;
  36834. /**
  36835. * Restore the Roll to its target value at the rate specified.
  36836. * @param rate - Higher means slower restoring.
  36837. * @hidden
  36838. */
  36839. restoreRoll(rate: number): void;
  36840. /**
  36841. * Destroy the camera and release the current resources held by it.
  36842. */
  36843. dispose(): void;
  36844. /**
  36845. * Get the current object class name.
  36846. * @returns the class name.
  36847. */
  36848. getClassName(): string;
  36849. }
  36850. }
  36851. declare module BABYLON {
  36852. /**
  36853. * Listen to keyboard events to control the camera.
  36854. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36855. */
  36856. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  36857. /**
  36858. * Defines the camera the input is attached to.
  36859. */
  36860. camera: FlyCamera;
  36861. /**
  36862. * The list of keyboard keys used to control the forward move of the camera.
  36863. */
  36864. keysForward: number[];
  36865. /**
  36866. * The list of keyboard keys used to control the backward move of the camera.
  36867. */
  36868. keysBackward: number[];
  36869. /**
  36870. * The list of keyboard keys used to control the forward move of the camera.
  36871. */
  36872. keysUp: number[];
  36873. /**
  36874. * The list of keyboard keys used to control the backward move of the camera.
  36875. */
  36876. keysDown: number[];
  36877. /**
  36878. * The list of keyboard keys used to control the right strafe move of the camera.
  36879. */
  36880. keysRight: number[];
  36881. /**
  36882. * The list of keyboard keys used to control the left strafe move of the camera.
  36883. */
  36884. keysLeft: number[];
  36885. private _keys;
  36886. private _onCanvasBlurObserver;
  36887. private _onKeyboardObserver;
  36888. private _engine;
  36889. private _scene;
  36890. /**
  36891. * Attach the input controls to a specific dom element to get the input from.
  36892. * @param element Defines the element the controls should be listened from
  36893. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36894. */
  36895. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36896. /**
  36897. * Detach the current controls from the specified dom element.
  36898. * @param element Defines the element to stop listening the inputs from
  36899. */
  36900. detachControl(element: Nullable<HTMLElement>): void;
  36901. /**
  36902. * Gets the class name of the current intput.
  36903. * @returns the class name
  36904. */
  36905. getClassName(): string;
  36906. /** @hidden */
  36907. _onLostFocus(e: FocusEvent): void;
  36908. /**
  36909. * Get the friendly name associated with the input class.
  36910. * @returns the input friendly name
  36911. */
  36912. getSimpleName(): string;
  36913. /**
  36914. * Update the current camera state depending on the inputs that have been used this frame.
  36915. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36916. */
  36917. checkInputs(): void;
  36918. }
  36919. }
  36920. declare module BABYLON {
  36921. /**
  36922. * Manage the mouse wheel inputs to control a follow camera.
  36923. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36924. */
  36925. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  36926. /**
  36927. * Defines the camera the input is attached to.
  36928. */
  36929. camera: FollowCamera;
  36930. /**
  36931. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  36932. */
  36933. axisControlRadius: boolean;
  36934. /**
  36935. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  36936. */
  36937. axisControlHeight: boolean;
  36938. /**
  36939. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  36940. */
  36941. axisControlRotation: boolean;
  36942. /**
  36943. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  36944. * relation to mouseWheel events.
  36945. */
  36946. wheelPrecision: number;
  36947. /**
  36948. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  36949. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  36950. */
  36951. wheelDeltaPercentage: number;
  36952. private _wheel;
  36953. private _observer;
  36954. /**
  36955. * Attach the input controls to a specific dom element to get the input from.
  36956. * @param element Defines the element the controls should be listened from
  36957. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36958. */
  36959. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36960. /**
  36961. * Detach the current controls from the specified dom element.
  36962. * @param element Defines the element to stop listening the inputs from
  36963. */
  36964. detachControl(element: Nullable<HTMLElement>): void;
  36965. /**
  36966. * Gets the class name of the current intput.
  36967. * @returns the class name
  36968. */
  36969. getClassName(): string;
  36970. /**
  36971. * Get the friendly name associated with the input class.
  36972. * @returns the input friendly name
  36973. */
  36974. getSimpleName(): string;
  36975. }
  36976. }
  36977. declare module BABYLON {
  36978. /**
  36979. * Manage the pointers inputs to control an follow camera.
  36980. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36981. */
  36982. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  36983. /**
  36984. * Defines the camera the input is attached to.
  36985. */
  36986. camera: FollowCamera;
  36987. /**
  36988. * Gets the class name of the current input.
  36989. * @returns the class name
  36990. */
  36991. getClassName(): string;
  36992. /**
  36993. * Defines the pointer angular sensibility along the X axis or how fast is
  36994. * the camera rotating.
  36995. * A negative number will reverse the axis direction.
  36996. */
  36997. angularSensibilityX: number;
  36998. /**
  36999. * Defines the pointer angular sensibility along the Y axis or how fast is
  37000. * the camera rotating.
  37001. * A negative number will reverse the axis direction.
  37002. */
  37003. angularSensibilityY: number;
  37004. /**
  37005. * Defines the pointer pinch precision or how fast is the camera zooming.
  37006. * A negative number will reverse the axis direction.
  37007. */
  37008. pinchPrecision: number;
  37009. /**
  37010. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  37011. * from 0.
  37012. * It defines the percentage of current camera.radius to use as delta when
  37013. * pinch zoom is used.
  37014. */
  37015. pinchDeltaPercentage: number;
  37016. /**
  37017. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  37018. */
  37019. axisXControlRadius: boolean;
  37020. /**
  37021. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  37022. */
  37023. axisXControlHeight: boolean;
  37024. /**
  37025. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  37026. */
  37027. axisXControlRotation: boolean;
  37028. /**
  37029. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  37030. */
  37031. axisYControlRadius: boolean;
  37032. /**
  37033. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  37034. */
  37035. axisYControlHeight: boolean;
  37036. /**
  37037. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  37038. */
  37039. axisYControlRotation: boolean;
  37040. /**
  37041. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  37042. */
  37043. axisPinchControlRadius: boolean;
  37044. /**
  37045. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  37046. */
  37047. axisPinchControlHeight: boolean;
  37048. /**
  37049. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  37050. */
  37051. axisPinchControlRotation: boolean;
  37052. /**
  37053. * Log error messages if basic misconfiguration has occurred.
  37054. */
  37055. warningEnable: boolean;
  37056. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  37057. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  37058. private _warningCounter;
  37059. private _warning;
  37060. }
  37061. }
  37062. declare module BABYLON {
  37063. /**
  37064. * Default Inputs manager for the FollowCamera.
  37065. * It groups all the default supported inputs for ease of use.
  37066. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37067. */
  37068. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  37069. /**
  37070. * Instantiates a new FollowCameraInputsManager.
  37071. * @param camera Defines the camera the inputs belong to
  37072. */
  37073. constructor(camera: FollowCamera);
  37074. /**
  37075. * Add keyboard input support to the input manager.
  37076. * @returns the current input manager
  37077. */
  37078. addKeyboard(): FollowCameraInputsManager;
  37079. /**
  37080. * Add mouse wheel input support to the input manager.
  37081. * @returns the current input manager
  37082. */
  37083. addMouseWheel(): FollowCameraInputsManager;
  37084. /**
  37085. * Add pointers input support to the input manager.
  37086. * @returns the current input manager
  37087. */
  37088. addPointers(): FollowCameraInputsManager;
  37089. /**
  37090. * Add orientation input support to the input manager.
  37091. * @returns the current input manager
  37092. */
  37093. addVRDeviceOrientation(): FollowCameraInputsManager;
  37094. }
  37095. }
  37096. declare module BABYLON {
  37097. /**
  37098. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  37099. * an arc rotate version arcFollowCamera are available.
  37100. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37101. */
  37102. export class FollowCamera extends TargetCamera {
  37103. /**
  37104. * Distance the follow camera should follow an object at
  37105. */
  37106. radius: number;
  37107. /**
  37108. * Minimum allowed distance of the camera to the axis of rotation
  37109. * (The camera can not get closer).
  37110. * This can help limiting how the Camera is able to move in the scene.
  37111. */
  37112. lowerRadiusLimit: Nullable<number>;
  37113. /**
  37114. * Maximum allowed distance of the camera to the axis of rotation
  37115. * (The camera can not get further).
  37116. * This can help limiting how the Camera is able to move in the scene.
  37117. */
  37118. upperRadiusLimit: Nullable<number>;
  37119. /**
  37120. * Define a rotation offset between the camera and the object it follows
  37121. */
  37122. rotationOffset: number;
  37123. /**
  37124. * Minimum allowed angle to camera position relative to target object.
  37125. * This can help limiting how the Camera is able to move in the scene.
  37126. */
  37127. lowerRotationOffsetLimit: Nullable<number>;
  37128. /**
  37129. * Maximum allowed angle to camera position relative to target object.
  37130. * This can help limiting how the Camera is able to move in the scene.
  37131. */
  37132. upperRotationOffsetLimit: Nullable<number>;
  37133. /**
  37134. * Define a height offset between the camera and the object it follows.
  37135. * It can help following an object from the top (like a car chaing a plane)
  37136. */
  37137. heightOffset: number;
  37138. /**
  37139. * Minimum allowed height of camera position relative to target object.
  37140. * This can help limiting how the Camera is able to move in the scene.
  37141. */
  37142. lowerHeightOffsetLimit: Nullable<number>;
  37143. /**
  37144. * Maximum allowed height of camera position relative to target object.
  37145. * This can help limiting how the Camera is able to move in the scene.
  37146. */
  37147. upperHeightOffsetLimit: Nullable<number>;
  37148. /**
  37149. * Define how fast the camera can accelerate to follow it s target.
  37150. */
  37151. cameraAcceleration: number;
  37152. /**
  37153. * Define the speed limit of the camera following an object.
  37154. */
  37155. maxCameraSpeed: number;
  37156. /**
  37157. * Define the target of the camera.
  37158. */
  37159. lockedTarget: Nullable<AbstractMesh>;
  37160. /**
  37161. * Defines the input associated with the camera.
  37162. */
  37163. inputs: FollowCameraInputsManager;
  37164. /**
  37165. * Instantiates the follow camera.
  37166. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37167. * @param name Define the name of the camera in the scene
  37168. * @param position Define the position of the camera
  37169. * @param scene Define the scene the camera belong to
  37170. * @param lockedTarget Define the target of the camera
  37171. */
  37172. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  37173. private _follow;
  37174. /**
  37175. * Attached controls to the current camera.
  37176. * @param element Defines the element the controls should be listened from
  37177. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37178. */
  37179. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37180. /**
  37181. * Detach the current controls from the camera.
  37182. * The camera will stop reacting to inputs.
  37183. * @param element Defines the element to stop listening the inputs from
  37184. */
  37185. detachControl(element: HTMLElement): void;
  37186. /** @hidden */
  37187. _checkInputs(): void;
  37188. private _checkLimits;
  37189. /**
  37190. * Gets the camera class name.
  37191. * @returns the class name
  37192. */
  37193. getClassName(): string;
  37194. }
  37195. /**
  37196. * Arc Rotate version of the follow camera.
  37197. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  37198. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37199. */
  37200. export class ArcFollowCamera extends TargetCamera {
  37201. /** The longitudinal angle of the camera */
  37202. alpha: number;
  37203. /** The latitudinal angle of the camera */
  37204. beta: number;
  37205. /** The radius of the camera from its target */
  37206. radius: number;
  37207. /** Define the camera target (the messh it should follow) */
  37208. target: Nullable<AbstractMesh>;
  37209. private _cartesianCoordinates;
  37210. /**
  37211. * Instantiates a new ArcFollowCamera
  37212. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37213. * @param name Define the name of the camera
  37214. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  37215. * @param beta Define the rotation angle of the camera around the elevation axis
  37216. * @param radius Define the radius of the camera from its target point
  37217. * @param target Define the target of the camera
  37218. * @param scene Define the scene the camera belongs to
  37219. */
  37220. constructor(name: string,
  37221. /** The longitudinal angle of the camera */
  37222. alpha: number,
  37223. /** The latitudinal angle of the camera */
  37224. beta: number,
  37225. /** The radius of the camera from its target */
  37226. radius: number,
  37227. /** Define the camera target (the messh it should follow) */
  37228. target: Nullable<AbstractMesh>, scene: Scene);
  37229. private _follow;
  37230. /** @hidden */
  37231. _checkInputs(): void;
  37232. /**
  37233. * Returns the class name of the object.
  37234. * It is mostly used internally for serialization purposes.
  37235. */
  37236. getClassName(): string;
  37237. }
  37238. }
  37239. declare module BABYLON {
  37240. /**
  37241. * Manage the keyboard inputs to control the movement of a follow camera.
  37242. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37243. */
  37244. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  37245. /**
  37246. * Defines the camera the input is attached to.
  37247. */
  37248. camera: FollowCamera;
  37249. /**
  37250. * Defines the list of key codes associated with the up action (increase heightOffset)
  37251. */
  37252. keysHeightOffsetIncr: number[];
  37253. /**
  37254. * Defines the list of key codes associated with the down action (decrease heightOffset)
  37255. */
  37256. keysHeightOffsetDecr: number[];
  37257. /**
  37258. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  37259. */
  37260. keysHeightOffsetModifierAlt: boolean;
  37261. /**
  37262. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  37263. */
  37264. keysHeightOffsetModifierCtrl: boolean;
  37265. /**
  37266. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  37267. */
  37268. keysHeightOffsetModifierShift: boolean;
  37269. /**
  37270. * Defines the list of key codes associated with the left action (increase rotationOffset)
  37271. */
  37272. keysRotationOffsetIncr: number[];
  37273. /**
  37274. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  37275. */
  37276. keysRotationOffsetDecr: number[];
  37277. /**
  37278. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  37279. */
  37280. keysRotationOffsetModifierAlt: boolean;
  37281. /**
  37282. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  37283. */
  37284. keysRotationOffsetModifierCtrl: boolean;
  37285. /**
  37286. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  37287. */
  37288. keysRotationOffsetModifierShift: boolean;
  37289. /**
  37290. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  37291. */
  37292. keysRadiusIncr: number[];
  37293. /**
  37294. * Defines the list of key codes associated with the zoom-out action (increase radius)
  37295. */
  37296. keysRadiusDecr: number[];
  37297. /**
  37298. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  37299. */
  37300. keysRadiusModifierAlt: boolean;
  37301. /**
  37302. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  37303. */
  37304. keysRadiusModifierCtrl: boolean;
  37305. /**
  37306. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  37307. */
  37308. keysRadiusModifierShift: boolean;
  37309. /**
  37310. * Defines the rate of change of heightOffset.
  37311. */
  37312. heightSensibility: number;
  37313. /**
  37314. * Defines the rate of change of rotationOffset.
  37315. */
  37316. rotationSensibility: number;
  37317. /**
  37318. * Defines the rate of change of radius.
  37319. */
  37320. radiusSensibility: number;
  37321. private _keys;
  37322. private _ctrlPressed;
  37323. private _altPressed;
  37324. private _shiftPressed;
  37325. private _onCanvasBlurObserver;
  37326. private _onKeyboardObserver;
  37327. private _engine;
  37328. private _scene;
  37329. /**
  37330. * Attach the input controls to a specific dom element to get the input from.
  37331. * @param element Defines the element the controls should be listened from
  37332. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37333. */
  37334. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37335. /**
  37336. * Detach the current controls from the specified dom element.
  37337. * @param element Defines the element to stop listening the inputs from
  37338. */
  37339. detachControl(element: Nullable<HTMLElement>): void;
  37340. /**
  37341. * Update the current camera state depending on the inputs that have been used this frame.
  37342. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37343. */
  37344. checkInputs(): void;
  37345. /**
  37346. * Gets the class name of the current input.
  37347. * @returns the class name
  37348. */
  37349. getClassName(): string;
  37350. /**
  37351. * Get the friendly name associated with the input class.
  37352. * @returns the input friendly name
  37353. */
  37354. getSimpleName(): string;
  37355. /**
  37356. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  37357. * allow modification of the heightOffset value.
  37358. */
  37359. private _modifierHeightOffset;
  37360. /**
  37361. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  37362. * allow modification of the rotationOffset value.
  37363. */
  37364. private _modifierRotationOffset;
  37365. /**
  37366. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  37367. * allow modification of the radius value.
  37368. */
  37369. private _modifierRadius;
  37370. }
  37371. }
  37372. declare module BABYLON {
  37373. interface FreeCameraInputsManager {
  37374. /**
  37375. * @hidden
  37376. */
  37377. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  37378. /**
  37379. * Add orientation input support to the input manager.
  37380. * @returns the current input manager
  37381. */
  37382. addDeviceOrientation(): FreeCameraInputsManager;
  37383. }
  37384. /**
  37385. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  37386. * Screen rotation is taken into account.
  37387. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37388. */
  37389. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  37390. private _camera;
  37391. private _screenOrientationAngle;
  37392. private _constantTranform;
  37393. private _screenQuaternion;
  37394. private _alpha;
  37395. private _beta;
  37396. private _gamma;
  37397. /**
  37398. * @hidden
  37399. */
  37400. _onDeviceOrientationChangedObservable: Observable<void>;
  37401. /**
  37402. * Instantiates a new input
  37403. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37404. */
  37405. constructor();
  37406. /**
  37407. * Define the camera controlled by the input.
  37408. */
  37409. camera: FreeCamera;
  37410. /**
  37411. * Attach the input controls to a specific dom element to get the input from.
  37412. * @param element Defines the element the controls should be listened from
  37413. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37414. */
  37415. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37416. private _orientationChanged;
  37417. private _deviceOrientation;
  37418. /**
  37419. * Detach the current controls from the specified dom element.
  37420. * @param element Defines the element to stop listening the inputs from
  37421. */
  37422. detachControl(element: Nullable<HTMLElement>): void;
  37423. /**
  37424. * Update the current camera state depending on the inputs that have been used this frame.
  37425. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37426. */
  37427. checkInputs(): void;
  37428. /**
  37429. * Gets the class name of the current intput.
  37430. * @returns the class name
  37431. */
  37432. getClassName(): string;
  37433. /**
  37434. * Get the friendly name associated with the input class.
  37435. * @returns the input friendly name
  37436. */
  37437. getSimpleName(): string;
  37438. }
  37439. }
  37440. declare module BABYLON {
  37441. /**
  37442. * Manage the gamepad inputs to control a free camera.
  37443. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37444. */
  37445. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  37446. /**
  37447. * Define the camera the input is attached to.
  37448. */
  37449. camera: FreeCamera;
  37450. /**
  37451. * Define the Gamepad controlling the input
  37452. */
  37453. gamepad: Nullable<Gamepad>;
  37454. /**
  37455. * Defines the gamepad rotation sensiblity.
  37456. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  37457. */
  37458. gamepadAngularSensibility: number;
  37459. /**
  37460. * Defines the gamepad move sensiblity.
  37461. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  37462. */
  37463. gamepadMoveSensibility: number;
  37464. private _onGamepadConnectedObserver;
  37465. private _onGamepadDisconnectedObserver;
  37466. private _cameraTransform;
  37467. private _deltaTransform;
  37468. private _vector3;
  37469. private _vector2;
  37470. /**
  37471. * Attach the input controls to a specific dom element to get the input from.
  37472. * @param element Defines the element the controls should be listened from
  37473. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37474. */
  37475. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37476. /**
  37477. * Detach the current controls from the specified dom element.
  37478. * @param element Defines the element to stop listening the inputs from
  37479. */
  37480. detachControl(element: Nullable<HTMLElement>): void;
  37481. /**
  37482. * Update the current camera state depending on the inputs that have been used this frame.
  37483. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37484. */
  37485. checkInputs(): void;
  37486. /**
  37487. * Gets the class name of the current intput.
  37488. * @returns the class name
  37489. */
  37490. getClassName(): string;
  37491. /**
  37492. * Get the friendly name associated with the input class.
  37493. * @returns the input friendly name
  37494. */
  37495. getSimpleName(): string;
  37496. }
  37497. }
  37498. declare module BABYLON {
  37499. /**
  37500. * Defines the potential axis of a Joystick
  37501. */
  37502. export enum JoystickAxis {
  37503. /** X axis */
  37504. X = 0,
  37505. /** Y axis */
  37506. Y = 1,
  37507. /** Z axis */
  37508. Z = 2
  37509. }
  37510. /**
  37511. * Class used to define virtual joystick (used in touch mode)
  37512. */
  37513. export class VirtualJoystick {
  37514. /**
  37515. * Gets or sets a boolean indicating that left and right values must be inverted
  37516. */
  37517. reverseLeftRight: boolean;
  37518. /**
  37519. * Gets or sets a boolean indicating that up and down values must be inverted
  37520. */
  37521. reverseUpDown: boolean;
  37522. /**
  37523. * Gets the offset value for the position (ie. the change of the position value)
  37524. */
  37525. deltaPosition: Vector3;
  37526. /**
  37527. * Gets a boolean indicating if the virtual joystick was pressed
  37528. */
  37529. pressed: boolean;
  37530. /**
  37531. * Canvas the virtual joystick will render onto, default z-index of this is 5
  37532. */
  37533. static Canvas: Nullable<HTMLCanvasElement>;
  37534. private static _globalJoystickIndex;
  37535. private static vjCanvasContext;
  37536. private static vjCanvasWidth;
  37537. private static vjCanvasHeight;
  37538. private static halfWidth;
  37539. private _action;
  37540. private _axisTargetedByLeftAndRight;
  37541. private _axisTargetedByUpAndDown;
  37542. private _joystickSensibility;
  37543. private _inversedSensibility;
  37544. private _joystickPointerID;
  37545. private _joystickColor;
  37546. private _joystickPointerPos;
  37547. private _joystickPreviousPointerPos;
  37548. private _joystickPointerStartPos;
  37549. private _deltaJoystickVector;
  37550. private _leftJoystick;
  37551. private _touches;
  37552. private _onPointerDownHandlerRef;
  37553. private _onPointerMoveHandlerRef;
  37554. private _onPointerUpHandlerRef;
  37555. private _onResize;
  37556. /**
  37557. * Creates a new virtual joystick
  37558. * @param leftJoystick defines that the joystick is for left hand (false by default)
  37559. */
  37560. constructor(leftJoystick?: boolean);
  37561. /**
  37562. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  37563. * @param newJoystickSensibility defines the new sensibility
  37564. */
  37565. setJoystickSensibility(newJoystickSensibility: number): void;
  37566. private _onPointerDown;
  37567. private _onPointerMove;
  37568. private _onPointerUp;
  37569. /**
  37570. * Change the color of the virtual joystick
  37571. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  37572. */
  37573. setJoystickColor(newColor: string): void;
  37574. /**
  37575. * Defines a callback to call when the joystick is touched
  37576. * @param action defines the callback
  37577. */
  37578. setActionOnTouch(action: () => any): void;
  37579. /**
  37580. * Defines which axis you'd like to control for left & right
  37581. * @param axis defines the axis to use
  37582. */
  37583. setAxisForLeftRight(axis: JoystickAxis): void;
  37584. /**
  37585. * Defines which axis you'd like to control for up & down
  37586. * @param axis defines the axis to use
  37587. */
  37588. setAxisForUpDown(axis: JoystickAxis): void;
  37589. private _drawVirtualJoystick;
  37590. /**
  37591. * Release internal HTML canvas
  37592. */
  37593. releaseCanvas(): void;
  37594. }
  37595. }
  37596. declare module BABYLON {
  37597. interface FreeCameraInputsManager {
  37598. /**
  37599. * Add virtual joystick input support to the input manager.
  37600. * @returns the current input manager
  37601. */
  37602. addVirtualJoystick(): FreeCameraInputsManager;
  37603. }
  37604. /**
  37605. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  37606. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37607. */
  37608. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  37609. /**
  37610. * Defines the camera the input is attached to.
  37611. */
  37612. camera: FreeCamera;
  37613. private _leftjoystick;
  37614. private _rightjoystick;
  37615. /**
  37616. * Gets the left stick of the virtual joystick.
  37617. * @returns The virtual Joystick
  37618. */
  37619. getLeftJoystick(): VirtualJoystick;
  37620. /**
  37621. * Gets the right stick of the virtual joystick.
  37622. * @returns The virtual Joystick
  37623. */
  37624. getRightJoystick(): VirtualJoystick;
  37625. /**
  37626. * Update the current camera state depending on the inputs that have been used this frame.
  37627. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37628. */
  37629. checkInputs(): void;
  37630. /**
  37631. * Attach the input controls to a specific dom element to get the input from.
  37632. * @param element Defines the element the controls should be listened from
  37633. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37634. */
  37635. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37636. /**
  37637. * Detach the current controls from the specified dom element.
  37638. * @param element Defines the element to stop listening the inputs from
  37639. */
  37640. detachControl(element: Nullable<HTMLElement>): void;
  37641. /**
  37642. * Gets the class name of the current intput.
  37643. * @returns the class name
  37644. */
  37645. getClassName(): string;
  37646. /**
  37647. * Get the friendly name associated with the input class.
  37648. * @returns the input friendly name
  37649. */
  37650. getSimpleName(): string;
  37651. }
  37652. }
  37653. declare module BABYLON {
  37654. /**
  37655. * This represents a FPS type of camera controlled by touch.
  37656. * This is like a universal camera minus the Gamepad controls.
  37657. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37658. */
  37659. export class TouchCamera extends FreeCamera {
  37660. /**
  37661. * Defines the touch sensibility for rotation.
  37662. * The higher the faster.
  37663. */
  37664. touchAngularSensibility: number;
  37665. /**
  37666. * Defines the touch sensibility for move.
  37667. * The higher the faster.
  37668. */
  37669. touchMoveSensibility: number;
  37670. /**
  37671. * Instantiates a new touch camera.
  37672. * This represents a FPS type of camera controlled by touch.
  37673. * This is like a universal camera minus the Gamepad controls.
  37674. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37675. * @param name Define the name of the camera in the scene
  37676. * @param position Define the start position of the camera in the scene
  37677. * @param scene Define the scene the camera belongs to
  37678. */
  37679. constructor(name: string, position: Vector3, scene: Scene);
  37680. /**
  37681. * Gets the current object class name.
  37682. * @return the class name
  37683. */
  37684. getClassName(): string;
  37685. /** @hidden */
  37686. _setupInputs(): void;
  37687. }
  37688. }
  37689. declare module BABYLON {
  37690. /**
  37691. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  37692. * being tilted forward or back and left or right.
  37693. */
  37694. export class DeviceOrientationCamera extends FreeCamera {
  37695. private _initialQuaternion;
  37696. private _quaternionCache;
  37697. private _tmpDragQuaternion;
  37698. /**
  37699. * Creates a new device orientation camera
  37700. * @param name The name of the camera
  37701. * @param position The start position camera
  37702. * @param scene The scene the camera belongs to
  37703. */
  37704. constructor(name: string, position: Vector3, scene: Scene);
  37705. /**
  37706. * @hidden
  37707. * Disabled pointer input on first orientation sensor update (Default: true)
  37708. */
  37709. _disablePointerInputWhenUsingDeviceOrientation: boolean;
  37710. private _dragFactor;
  37711. /**
  37712. * Enabled turning on the y axis when the orientation sensor is active
  37713. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  37714. */
  37715. enableHorizontalDragging(dragFactor?: number): void;
  37716. /**
  37717. * Gets the current instance class name ("DeviceOrientationCamera").
  37718. * This helps avoiding instanceof at run time.
  37719. * @returns the class name
  37720. */
  37721. getClassName(): string;
  37722. /**
  37723. * @hidden
  37724. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  37725. */
  37726. _checkInputs(): void;
  37727. /**
  37728. * Reset the camera to its default orientation on the specified axis only.
  37729. * @param axis The axis to reset
  37730. */
  37731. resetToCurrentRotation(axis?: Axis): void;
  37732. }
  37733. }
  37734. declare module BABYLON {
  37735. /**
  37736. * Defines supported buttons for XBox360 compatible gamepads
  37737. */
  37738. export enum Xbox360Button {
  37739. /** A */
  37740. A = 0,
  37741. /** B */
  37742. B = 1,
  37743. /** X */
  37744. X = 2,
  37745. /** Y */
  37746. Y = 3,
  37747. /** Start */
  37748. Start = 4,
  37749. /** Back */
  37750. Back = 5,
  37751. /** Left button */
  37752. LB = 6,
  37753. /** Right button */
  37754. RB = 7,
  37755. /** Left stick */
  37756. LeftStick = 8,
  37757. /** Right stick */
  37758. RightStick = 9
  37759. }
  37760. /** Defines values for XBox360 DPad */
  37761. export enum Xbox360Dpad {
  37762. /** Up */
  37763. Up = 0,
  37764. /** Down */
  37765. Down = 1,
  37766. /** Left */
  37767. Left = 2,
  37768. /** Right */
  37769. Right = 3
  37770. }
  37771. /**
  37772. * Defines a XBox360 gamepad
  37773. */
  37774. export class Xbox360Pad extends Gamepad {
  37775. private _leftTrigger;
  37776. private _rightTrigger;
  37777. private _onlefttriggerchanged;
  37778. private _onrighttriggerchanged;
  37779. private _onbuttondown;
  37780. private _onbuttonup;
  37781. private _ondpaddown;
  37782. private _ondpadup;
  37783. /** Observable raised when a button is pressed */
  37784. onButtonDownObservable: Observable<Xbox360Button>;
  37785. /** Observable raised when a button is released */
  37786. onButtonUpObservable: Observable<Xbox360Button>;
  37787. /** Observable raised when a pad is pressed */
  37788. onPadDownObservable: Observable<Xbox360Dpad>;
  37789. /** Observable raised when a pad is released */
  37790. onPadUpObservable: Observable<Xbox360Dpad>;
  37791. private _buttonA;
  37792. private _buttonB;
  37793. private _buttonX;
  37794. private _buttonY;
  37795. private _buttonBack;
  37796. private _buttonStart;
  37797. private _buttonLB;
  37798. private _buttonRB;
  37799. private _buttonLeftStick;
  37800. private _buttonRightStick;
  37801. private _dPadUp;
  37802. private _dPadDown;
  37803. private _dPadLeft;
  37804. private _dPadRight;
  37805. private _isXboxOnePad;
  37806. /**
  37807. * Creates a new XBox360 gamepad object
  37808. * @param id defines the id of this gamepad
  37809. * @param index defines its index
  37810. * @param gamepad defines the internal HTML gamepad object
  37811. * @param xboxOne defines if it is a XBox One gamepad
  37812. */
  37813. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  37814. /**
  37815. * Defines the callback to call when left trigger is pressed
  37816. * @param callback defines the callback to use
  37817. */
  37818. onlefttriggerchanged(callback: (value: number) => void): void;
  37819. /**
  37820. * Defines the callback to call when right trigger is pressed
  37821. * @param callback defines the callback to use
  37822. */
  37823. onrighttriggerchanged(callback: (value: number) => void): void;
  37824. /**
  37825. * Gets the left trigger value
  37826. */
  37827. /**
  37828. * Sets the left trigger value
  37829. */
  37830. leftTrigger: number;
  37831. /**
  37832. * Gets the right trigger value
  37833. */
  37834. /**
  37835. * Sets the right trigger value
  37836. */
  37837. rightTrigger: number;
  37838. /**
  37839. * Defines the callback to call when a button is pressed
  37840. * @param callback defines the callback to use
  37841. */
  37842. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  37843. /**
  37844. * Defines the callback to call when a button is released
  37845. * @param callback defines the callback to use
  37846. */
  37847. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  37848. /**
  37849. * Defines the callback to call when a pad is pressed
  37850. * @param callback defines the callback to use
  37851. */
  37852. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  37853. /**
  37854. * Defines the callback to call when a pad is released
  37855. * @param callback defines the callback to use
  37856. */
  37857. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  37858. private _setButtonValue;
  37859. private _setDPadValue;
  37860. /**
  37861. * Gets the value of the `A` button
  37862. */
  37863. /**
  37864. * Sets the value of the `A` button
  37865. */
  37866. buttonA: number;
  37867. /**
  37868. * Gets the value of the `B` button
  37869. */
  37870. /**
  37871. * Sets the value of the `B` button
  37872. */
  37873. buttonB: number;
  37874. /**
  37875. * Gets the value of the `X` button
  37876. */
  37877. /**
  37878. * Sets the value of the `X` button
  37879. */
  37880. buttonX: number;
  37881. /**
  37882. * Gets the value of the `Y` button
  37883. */
  37884. /**
  37885. * Sets the value of the `Y` button
  37886. */
  37887. buttonY: number;
  37888. /**
  37889. * Gets the value of the `Start` button
  37890. */
  37891. /**
  37892. * Sets the value of the `Start` button
  37893. */
  37894. buttonStart: number;
  37895. /**
  37896. * Gets the value of the `Back` button
  37897. */
  37898. /**
  37899. * Sets the value of the `Back` button
  37900. */
  37901. buttonBack: number;
  37902. /**
  37903. * Gets the value of the `Left` button
  37904. */
  37905. /**
  37906. * Sets the value of the `Left` button
  37907. */
  37908. buttonLB: number;
  37909. /**
  37910. * Gets the value of the `Right` button
  37911. */
  37912. /**
  37913. * Sets the value of the `Right` button
  37914. */
  37915. buttonRB: number;
  37916. /**
  37917. * Gets the value of the Left joystick
  37918. */
  37919. /**
  37920. * Sets the value of the Left joystick
  37921. */
  37922. buttonLeftStick: number;
  37923. /**
  37924. * Gets the value of the Right joystick
  37925. */
  37926. /**
  37927. * Sets the value of the Right joystick
  37928. */
  37929. buttonRightStick: number;
  37930. /**
  37931. * Gets the value of D-pad up
  37932. */
  37933. /**
  37934. * Sets the value of D-pad up
  37935. */
  37936. dPadUp: number;
  37937. /**
  37938. * Gets the value of D-pad down
  37939. */
  37940. /**
  37941. * Sets the value of D-pad down
  37942. */
  37943. dPadDown: number;
  37944. /**
  37945. * Gets the value of D-pad left
  37946. */
  37947. /**
  37948. * Sets the value of D-pad left
  37949. */
  37950. dPadLeft: number;
  37951. /**
  37952. * Gets the value of D-pad right
  37953. */
  37954. /**
  37955. * Sets the value of D-pad right
  37956. */
  37957. dPadRight: number;
  37958. /**
  37959. * Force the gamepad to synchronize with device values
  37960. */
  37961. update(): void;
  37962. /**
  37963. * Disposes the gamepad
  37964. */
  37965. dispose(): void;
  37966. }
  37967. }
  37968. declare module BABYLON {
  37969. /**
  37970. * Manager for handling gamepads
  37971. */
  37972. export class GamepadManager {
  37973. private _scene?;
  37974. private _babylonGamepads;
  37975. private _oneGamepadConnected;
  37976. /** @hidden */
  37977. _isMonitoring: boolean;
  37978. private _gamepadEventSupported;
  37979. private _gamepadSupport;
  37980. /**
  37981. * observable to be triggered when the gamepad controller has been connected
  37982. */
  37983. onGamepadConnectedObservable: Observable<Gamepad>;
  37984. /**
  37985. * observable to be triggered when the gamepad controller has been disconnected
  37986. */
  37987. onGamepadDisconnectedObservable: Observable<Gamepad>;
  37988. private _onGamepadConnectedEvent;
  37989. private _onGamepadDisconnectedEvent;
  37990. /**
  37991. * Initializes the gamepad manager
  37992. * @param _scene BabylonJS scene
  37993. */
  37994. constructor(_scene?: Scene | undefined);
  37995. /**
  37996. * The gamepads in the game pad manager
  37997. */
  37998. readonly gamepads: Gamepad[];
  37999. /**
  38000. * Get the gamepad controllers based on type
  38001. * @param type The type of gamepad controller
  38002. * @returns Nullable gamepad
  38003. */
  38004. getGamepadByType(type?: number): Nullable<Gamepad>;
  38005. /**
  38006. * Disposes the gamepad manager
  38007. */
  38008. dispose(): void;
  38009. private _addNewGamepad;
  38010. private _startMonitoringGamepads;
  38011. private _stopMonitoringGamepads;
  38012. /** @hidden */
  38013. _checkGamepadsStatus(): void;
  38014. private _updateGamepadObjects;
  38015. }
  38016. }
  38017. declare module BABYLON {
  38018. interface Scene {
  38019. /** @hidden */
  38020. _gamepadManager: Nullable<GamepadManager>;
  38021. /**
  38022. * Gets the gamepad manager associated with the scene
  38023. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  38024. */
  38025. gamepadManager: GamepadManager;
  38026. }
  38027. /**
  38028. * Interface representing a free camera inputs manager
  38029. */
  38030. interface FreeCameraInputsManager {
  38031. /**
  38032. * Adds gamepad input support to the FreeCameraInputsManager.
  38033. * @returns the FreeCameraInputsManager
  38034. */
  38035. addGamepad(): FreeCameraInputsManager;
  38036. }
  38037. /**
  38038. * Interface representing an arc rotate camera inputs manager
  38039. */
  38040. interface ArcRotateCameraInputsManager {
  38041. /**
  38042. * Adds gamepad input support to the ArcRotateCamera InputManager.
  38043. * @returns the camera inputs manager
  38044. */
  38045. addGamepad(): ArcRotateCameraInputsManager;
  38046. }
  38047. /**
  38048. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  38049. */
  38050. export class GamepadSystemSceneComponent implements ISceneComponent {
  38051. /**
  38052. * The component name helpfull to identify the component in the list of scene components.
  38053. */
  38054. readonly name: string;
  38055. /**
  38056. * The scene the component belongs to.
  38057. */
  38058. scene: Scene;
  38059. /**
  38060. * Creates a new instance of the component for the given scene
  38061. * @param scene Defines the scene to register the component in
  38062. */
  38063. constructor(scene: Scene);
  38064. /**
  38065. * Registers the component in a given scene
  38066. */
  38067. register(): void;
  38068. /**
  38069. * Rebuilds the elements related to this component in case of
  38070. * context lost for instance.
  38071. */
  38072. rebuild(): void;
  38073. /**
  38074. * Disposes the component and the associated ressources
  38075. */
  38076. dispose(): void;
  38077. private _beforeCameraUpdate;
  38078. }
  38079. }
  38080. declare module BABYLON {
  38081. /**
  38082. * 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,
  38083. * which still works and will still be found in many Playgrounds.
  38084. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38085. */
  38086. export class UniversalCamera extends TouchCamera {
  38087. /**
  38088. * Defines the gamepad rotation sensiblity.
  38089. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  38090. */
  38091. gamepadAngularSensibility: number;
  38092. /**
  38093. * Defines the gamepad move sensiblity.
  38094. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  38095. */
  38096. gamepadMoveSensibility: number;
  38097. /**
  38098. * 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,
  38099. * which still works and will still be found in many Playgrounds.
  38100. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38101. * @param name Define the name of the camera in the scene
  38102. * @param position Define the start position of the camera in the scene
  38103. * @param scene Define the scene the camera belongs to
  38104. */
  38105. constructor(name: string, position: Vector3, scene: Scene);
  38106. /**
  38107. * Gets the current object class name.
  38108. * @return the class name
  38109. */
  38110. getClassName(): string;
  38111. }
  38112. }
  38113. declare module BABYLON {
  38114. /**
  38115. * This represents a FPS type of camera. This is only here for back compat purpose.
  38116. * Please use the UniversalCamera instead as both are identical.
  38117. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38118. */
  38119. export class GamepadCamera extends UniversalCamera {
  38120. /**
  38121. * Instantiates a new Gamepad Camera
  38122. * This represents a FPS type of camera. This is only here for back compat purpose.
  38123. * Please use the UniversalCamera instead as both are identical.
  38124. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38125. * @param name Define the name of the camera in the scene
  38126. * @param position Define the start position of the camera in the scene
  38127. * @param scene Define the scene the camera belongs to
  38128. */
  38129. constructor(name: string, position: Vector3, scene: Scene);
  38130. /**
  38131. * Gets the current object class name.
  38132. * @return the class name
  38133. */
  38134. getClassName(): string;
  38135. }
  38136. }
  38137. declare module BABYLON {
  38138. /** @hidden */
  38139. export var passPixelShader: {
  38140. name: string;
  38141. shader: string;
  38142. };
  38143. }
  38144. declare module BABYLON {
  38145. /** @hidden */
  38146. export var passCubePixelShader: {
  38147. name: string;
  38148. shader: string;
  38149. };
  38150. }
  38151. declare module BABYLON {
  38152. /**
  38153. * PassPostProcess which produces an output the same as it's input
  38154. */
  38155. export class PassPostProcess extends PostProcess {
  38156. /**
  38157. * Creates the PassPostProcess
  38158. * @param name The name of the effect.
  38159. * @param options The required width/height ratio to downsize to before computing the render pass.
  38160. * @param camera The camera to apply the render pass to.
  38161. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  38162. * @param engine The engine which the post process will be applied. (default: current engine)
  38163. * @param reusable If the post process can be reused on the same frame. (default: false)
  38164. * @param textureType The type of texture to be used when performing the post processing.
  38165. * @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)
  38166. */
  38167. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  38168. }
  38169. /**
  38170. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  38171. */
  38172. export class PassCubePostProcess extends PostProcess {
  38173. private _face;
  38174. /**
  38175. * Gets or sets the cube face to display.
  38176. * * 0 is +X
  38177. * * 1 is -X
  38178. * * 2 is +Y
  38179. * * 3 is -Y
  38180. * * 4 is +Z
  38181. * * 5 is -Z
  38182. */
  38183. face: number;
  38184. /**
  38185. * Creates the PassCubePostProcess
  38186. * @param name The name of the effect.
  38187. * @param options The required width/height ratio to downsize to before computing the render pass.
  38188. * @param camera The camera to apply the render pass to.
  38189. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  38190. * @param engine The engine which the post process will be applied. (default: current engine)
  38191. * @param reusable If the post process can be reused on the same frame. (default: false)
  38192. * @param textureType The type of texture to be used when performing the post processing.
  38193. * @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)
  38194. */
  38195. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  38196. }
  38197. }
  38198. declare module BABYLON {
  38199. /** @hidden */
  38200. export var anaglyphPixelShader: {
  38201. name: string;
  38202. shader: string;
  38203. };
  38204. }
  38205. declare module BABYLON {
  38206. /**
  38207. * Postprocess used to generate anaglyphic rendering
  38208. */
  38209. export class AnaglyphPostProcess extends PostProcess {
  38210. private _passedProcess;
  38211. /**
  38212. * Creates a new AnaglyphPostProcess
  38213. * @param name defines postprocess name
  38214. * @param options defines creation options or target ratio scale
  38215. * @param rigCameras defines cameras using this postprocess
  38216. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  38217. * @param engine defines hosting engine
  38218. * @param reusable defines if the postprocess will be reused multiple times per frame
  38219. */
  38220. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  38221. }
  38222. }
  38223. declare module BABYLON {
  38224. /**
  38225. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  38226. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38227. */
  38228. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  38229. /**
  38230. * Creates a new AnaglyphArcRotateCamera
  38231. * @param name defines camera name
  38232. * @param alpha defines alpha angle (in radians)
  38233. * @param beta defines beta angle (in radians)
  38234. * @param radius defines radius
  38235. * @param target defines camera target
  38236. * @param interaxialDistance defines distance between each color axis
  38237. * @param scene defines the hosting scene
  38238. */
  38239. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  38240. /**
  38241. * Gets camera class name
  38242. * @returns AnaglyphArcRotateCamera
  38243. */
  38244. getClassName(): string;
  38245. }
  38246. }
  38247. declare module BABYLON {
  38248. /**
  38249. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  38250. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38251. */
  38252. export class AnaglyphFreeCamera extends FreeCamera {
  38253. /**
  38254. * Creates a new AnaglyphFreeCamera
  38255. * @param name defines camera name
  38256. * @param position defines initial position
  38257. * @param interaxialDistance defines distance between each color axis
  38258. * @param scene defines the hosting scene
  38259. */
  38260. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  38261. /**
  38262. * Gets camera class name
  38263. * @returns AnaglyphFreeCamera
  38264. */
  38265. getClassName(): string;
  38266. }
  38267. }
  38268. declare module BABYLON {
  38269. /**
  38270. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  38271. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38272. */
  38273. export class AnaglyphGamepadCamera extends GamepadCamera {
  38274. /**
  38275. * Creates a new AnaglyphGamepadCamera
  38276. * @param name defines camera name
  38277. * @param position defines initial position
  38278. * @param interaxialDistance defines distance between each color axis
  38279. * @param scene defines the hosting scene
  38280. */
  38281. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  38282. /**
  38283. * Gets camera class name
  38284. * @returns AnaglyphGamepadCamera
  38285. */
  38286. getClassName(): string;
  38287. }
  38288. }
  38289. declare module BABYLON {
  38290. /**
  38291. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  38292. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38293. */
  38294. export class AnaglyphUniversalCamera extends UniversalCamera {
  38295. /**
  38296. * Creates a new AnaglyphUniversalCamera
  38297. * @param name defines camera name
  38298. * @param position defines initial position
  38299. * @param interaxialDistance defines distance between each color axis
  38300. * @param scene defines the hosting scene
  38301. */
  38302. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  38303. /**
  38304. * Gets camera class name
  38305. * @returns AnaglyphUniversalCamera
  38306. */
  38307. getClassName(): string;
  38308. }
  38309. }
  38310. declare module BABYLON {
  38311. /** @hidden */
  38312. export var stereoscopicInterlacePixelShader: {
  38313. name: string;
  38314. shader: string;
  38315. };
  38316. }
  38317. declare module BABYLON {
  38318. /**
  38319. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  38320. */
  38321. export class StereoscopicInterlacePostProcess extends PostProcess {
  38322. private _stepSize;
  38323. private _passedProcess;
  38324. /**
  38325. * Initializes a StereoscopicInterlacePostProcess
  38326. * @param name The name of the effect.
  38327. * @param rigCameras The rig cameras to be appled to the post process
  38328. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  38329. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  38330. * @param engine The engine which the post process will be applied. (default: current engine)
  38331. * @param reusable If the post process can be reused on the same frame. (default: false)
  38332. */
  38333. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  38334. }
  38335. }
  38336. declare module BABYLON {
  38337. /**
  38338. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  38339. * @see http://doc.babylonjs.com/features/cameras
  38340. */
  38341. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  38342. /**
  38343. * Creates a new StereoscopicArcRotateCamera
  38344. * @param name defines camera name
  38345. * @param alpha defines alpha angle (in radians)
  38346. * @param beta defines beta angle (in radians)
  38347. * @param radius defines radius
  38348. * @param target defines camera target
  38349. * @param interaxialDistance defines distance between each color axis
  38350. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38351. * @param scene defines the hosting scene
  38352. */
  38353. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38354. /**
  38355. * Gets camera class name
  38356. * @returns StereoscopicArcRotateCamera
  38357. */
  38358. getClassName(): string;
  38359. }
  38360. }
  38361. declare module BABYLON {
  38362. /**
  38363. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  38364. * @see http://doc.babylonjs.com/features/cameras
  38365. */
  38366. export class StereoscopicFreeCamera extends FreeCamera {
  38367. /**
  38368. * Creates a new StereoscopicFreeCamera
  38369. * @param name defines camera name
  38370. * @param position defines initial position
  38371. * @param interaxialDistance defines distance between each color axis
  38372. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38373. * @param scene defines the hosting scene
  38374. */
  38375. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38376. /**
  38377. * Gets camera class name
  38378. * @returns StereoscopicFreeCamera
  38379. */
  38380. getClassName(): string;
  38381. }
  38382. }
  38383. declare module BABYLON {
  38384. /**
  38385. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  38386. * @see http://doc.babylonjs.com/features/cameras
  38387. */
  38388. export class StereoscopicGamepadCamera extends GamepadCamera {
  38389. /**
  38390. * Creates a new StereoscopicGamepadCamera
  38391. * @param name defines camera name
  38392. * @param position defines initial position
  38393. * @param interaxialDistance defines distance between each color axis
  38394. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38395. * @param scene defines the hosting scene
  38396. */
  38397. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38398. /**
  38399. * Gets camera class name
  38400. * @returns StereoscopicGamepadCamera
  38401. */
  38402. getClassName(): string;
  38403. }
  38404. }
  38405. declare module BABYLON {
  38406. /**
  38407. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  38408. * @see http://doc.babylonjs.com/features/cameras
  38409. */
  38410. export class StereoscopicUniversalCamera extends UniversalCamera {
  38411. /**
  38412. * Creates a new StereoscopicUniversalCamera
  38413. * @param name defines camera name
  38414. * @param position defines initial position
  38415. * @param interaxialDistance defines distance between each color axis
  38416. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38417. * @param scene defines the hosting scene
  38418. */
  38419. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38420. /**
  38421. * Gets camera class name
  38422. * @returns StereoscopicUniversalCamera
  38423. */
  38424. getClassName(): string;
  38425. }
  38426. }
  38427. declare module BABYLON {
  38428. /**
  38429. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  38430. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  38431. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  38432. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  38433. */
  38434. export class VirtualJoysticksCamera extends FreeCamera {
  38435. /**
  38436. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  38437. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  38438. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  38439. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  38440. * @param name Define the name of the camera in the scene
  38441. * @param position Define the start position of the camera in the scene
  38442. * @param scene Define the scene the camera belongs to
  38443. */
  38444. constructor(name: string, position: Vector3, scene: Scene);
  38445. /**
  38446. * Gets the current object class name.
  38447. * @return the class name
  38448. */
  38449. getClassName(): string;
  38450. }
  38451. }
  38452. declare module BABYLON {
  38453. /**
  38454. * This represents all the required metrics to create a VR camera.
  38455. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  38456. */
  38457. export class VRCameraMetrics {
  38458. /**
  38459. * Define the horizontal resolution off the screen.
  38460. */
  38461. hResolution: number;
  38462. /**
  38463. * Define the vertical resolution off the screen.
  38464. */
  38465. vResolution: number;
  38466. /**
  38467. * Define the horizontal screen size.
  38468. */
  38469. hScreenSize: number;
  38470. /**
  38471. * Define the vertical screen size.
  38472. */
  38473. vScreenSize: number;
  38474. /**
  38475. * Define the vertical screen center position.
  38476. */
  38477. vScreenCenter: number;
  38478. /**
  38479. * Define the distance of the eyes to the screen.
  38480. */
  38481. eyeToScreenDistance: number;
  38482. /**
  38483. * Define the distance between both lenses
  38484. */
  38485. lensSeparationDistance: number;
  38486. /**
  38487. * Define the distance between both viewer's eyes.
  38488. */
  38489. interpupillaryDistance: number;
  38490. /**
  38491. * Define the distortion factor of the VR postprocess.
  38492. * Please, touch with care.
  38493. */
  38494. distortionK: number[];
  38495. /**
  38496. * Define the chromatic aberration correction factors for the VR post process.
  38497. */
  38498. chromaAbCorrection: number[];
  38499. /**
  38500. * Define the scale factor of the post process.
  38501. * The smaller the better but the slower.
  38502. */
  38503. postProcessScaleFactor: number;
  38504. /**
  38505. * Define an offset for the lens center.
  38506. */
  38507. lensCenterOffset: number;
  38508. /**
  38509. * Define if the current vr camera should compensate the distortion of the lense or not.
  38510. */
  38511. compensateDistortion: boolean;
  38512. /**
  38513. * Defines if multiview should be enabled when rendering (Default: false)
  38514. */
  38515. multiviewEnabled: boolean;
  38516. /**
  38517. * Gets the rendering aspect ratio based on the provided resolutions.
  38518. */
  38519. readonly aspectRatio: number;
  38520. /**
  38521. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  38522. */
  38523. readonly aspectRatioFov: number;
  38524. /**
  38525. * @hidden
  38526. */
  38527. readonly leftHMatrix: Matrix;
  38528. /**
  38529. * @hidden
  38530. */
  38531. readonly rightHMatrix: Matrix;
  38532. /**
  38533. * @hidden
  38534. */
  38535. readonly leftPreViewMatrix: Matrix;
  38536. /**
  38537. * @hidden
  38538. */
  38539. readonly rightPreViewMatrix: Matrix;
  38540. /**
  38541. * Get the default VRMetrics based on the most generic setup.
  38542. * @returns the default vr metrics
  38543. */
  38544. static GetDefault(): VRCameraMetrics;
  38545. }
  38546. }
  38547. declare module BABYLON {
  38548. /** @hidden */
  38549. export var vrDistortionCorrectionPixelShader: {
  38550. name: string;
  38551. shader: string;
  38552. };
  38553. }
  38554. declare module BABYLON {
  38555. /**
  38556. * VRDistortionCorrectionPostProcess used for mobile VR
  38557. */
  38558. export class VRDistortionCorrectionPostProcess extends PostProcess {
  38559. private _isRightEye;
  38560. private _distortionFactors;
  38561. private _postProcessScaleFactor;
  38562. private _lensCenterOffset;
  38563. private _scaleIn;
  38564. private _scaleFactor;
  38565. private _lensCenter;
  38566. /**
  38567. * Initializes the VRDistortionCorrectionPostProcess
  38568. * @param name The name of the effect.
  38569. * @param camera The camera to apply the render pass to.
  38570. * @param isRightEye If this is for the right eye distortion
  38571. * @param vrMetrics All the required metrics for the VR camera
  38572. */
  38573. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  38574. }
  38575. }
  38576. declare module BABYLON {
  38577. /**
  38578. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  38579. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  38580. */
  38581. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  38582. /**
  38583. * Creates a new VRDeviceOrientationArcRotateCamera
  38584. * @param name defines camera name
  38585. * @param alpha defines the camera rotation along the logitudinal axis
  38586. * @param beta defines the camera rotation along the latitudinal axis
  38587. * @param radius defines the camera distance from its target
  38588. * @param target defines the camera target
  38589. * @param scene defines the scene the camera belongs to
  38590. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  38591. * @param vrCameraMetrics defines the vr metrics associated to the camera
  38592. */
  38593. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  38594. /**
  38595. * Gets camera class name
  38596. * @returns VRDeviceOrientationArcRotateCamera
  38597. */
  38598. getClassName(): string;
  38599. }
  38600. }
  38601. declare module BABYLON {
  38602. /**
  38603. * Camera used to simulate VR rendering (based on FreeCamera)
  38604. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  38605. */
  38606. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  38607. /**
  38608. * Creates a new VRDeviceOrientationFreeCamera
  38609. * @param name defines camera name
  38610. * @param position defines the start position of the camera
  38611. * @param scene defines the scene the camera belongs to
  38612. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  38613. * @param vrCameraMetrics defines the vr metrics associated to the camera
  38614. */
  38615. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  38616. /**
  38617. * Gets camera class name
  38618. * @returns VRDeviceOrientationFreeCamera
  38619. */
  38620. getClassName(): string;
  38621. }
  38622. }
  38623. declare module BABYLON {
  38624. /**
  38625. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  38626. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  38627. */
  38628. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  38629. /**
  38630. * Creates a new VRDeviceOrientationGamepadCamera
  38631. * @param name defines camera name
  38632. * @param position defines the start position of the camera
  38633. * @param scene defines the scene the camera belongs to
  38634. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  38635. * @param vrCameraMetrics defines the vr metrics associated to the camera
  38636. */
  38637. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  38638. /**
  38639. * Gets camera class name
  38640. * @returns VRDeviceOrientationGamepadCamera
  38641. */
  38642. getClassName(): string;
  38643. }
  38644. }
  38645. declare module BABYLON {
  38646. /**
  38647. * Base class of materials working in push mode in babylon JS
  38648. * @hidden
  38649. */
  38650. export class PushMaterial extends Material {
  38651. protected _activeEffect: Effect;
  38652. protected _normalMatrix: Matrix;
  38653. /**
  38654. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  38655. * This means that the material can keep using a previous shader while a new one is being compiled.
  38656. * This is mostly used when shader parallel compilation is supported (true by default)
  38657. */
  38658. allowShaderHotSwapping: boolean;
  38659. constructor(name: string, scene: Scene);
  38660. getEffect(): Effect;
  38661. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  38662. /**
  38663. * Binds the given world matrix to the active effect
  38664. *
  38665. * @param world the matrix to bind
  38666. */
  38667. bindOnlyWorldMatrix(world: Matrix): void;
  38668. /**
  38669. * Binds the given normal matrix to the active effect
  38670. *
  38671. * @param normalMatrix the matrix to bind
  38672. */
  38673. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  38674. bind(world: Matrix, mesh?: Mesh): void;
  38675. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  38676. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  38677. }
  38678. }
  38679. declare module BABYLON {
  38680. /**
  38681. * This groups all the flags used to control the materials channel.
  38682. */
  38683. export class MaterialFlags {
  38684. private static _DiffuseTextureEnabled;
  38685. /**
  38686. * Are diffuse textures enabled in the application.
  38687. */
  38688. static DiffuseTextureEnabled: boolean;
  38689. private static _AmbientTextureEnabled;
  38690. /**
  38691. * Are ambient textures enabled in the application.
  38692. */
  38693. static AmbientTextureEnabled: boolean;
  38694. private static _OpacityTextureEnabled;
  38695. /**
  38696. * Are opacity textures enabled in the application.
  38697. */
  38698. static OpacityTextureEnabled: boolean;
  38699. private static _ReflectionTextureEnabled;
  38700. /**
  38701. * Are reflection textures enabled in the application.
  38702. */
  38703. static ReflectionTextureEnabled: boolean;
  38704. private static _EmissiveTextureEnabled;
  38705. /**
  38706. * Are emissive textures enabled in the application.
  38707. */
  38708. static EmissiveTextureEnabled: boolean;
  38709. private static _SpecularTextureEnabled;
  38710. /**
  38711. * Are specular textures enabled in the application.
  38712. */
  38713. static SpecularTextureEnabled: boolean;
  38714. private static _BumpTextureEnabled;
  38715. /**
  38716. * Are bump textures enabled in the application.
  38717. */
  38718. static BumpTextureEnabled: boolean;
  38719. private static _LightmapTextureEnabled;
  38720. /**
  38721. * Are lightmap textures enabled in the application.
  38722. */
  38723. static LightmapTextureEnabled: boolean;
  38724. private static _RefractionTextureEnabled;
  38725. /**
  38726. * Are refraction textures enabled in the application.
  38727. */
  38728. static RefractionTextureEnabled: boolean;
  38729. private static _ColorGradingTextureEnabled;
  38730. /**
  38731. * Are color grading textures enabled in the application.
  38732. */
  38733. static ColorGradingTextureEnabled: boolean;
  38734. private static _FresnelEnabled;
  38735. /**
  38736. * Are fresnels enabled in the application.
  38737. */
  38738. static FresnelEnabled: boolean;
  38739. private static _ClearCoatTextureEnabled;
  38740. /**
  38741. * Are clear coat textures enabled in the application.
  38742. */
  38743. static ClearCoatTextureEnabled: boolean;
  38744. private static _ClearCoatBumpTextureEnabled;
  38745. /**
  38746. * Are clear coat bump textures enabled in the application.
  38747. */
  38748. static ClearCoatBumpTextureEnabled: boolean;
  38749. private static _ClearCoatTintTextureEnabled;
  38750. /**
  38751. * Are clear coat tint textures enabled in the application.
  38752. */
  38753. static ClearCoatTintTextureEnabled: boolean;
  38754. private static _SheenTextureEnabled;
  38755. /**
  38756. * Are sheen textures enabled in the application.
  38757. */
  38758. static SheenTextureEnabled: boolean;
  38759. private static _AnisotropicTextureEnabled;
  38760. /**
  38761. * Are anisotropic textures enabled in the application.
  38762. */
  38763. static AnisotropicTextureEnabled: boolean;
  38764. private static _ThicknessTextureEnabled;
  38765. /**
  38766. * Are thickness textures enabled in the application.
  38767. */
  38768. static ThicknessTextureEnabled: boolean;
  38769. }
  38770. }
  38771. declare module BABYLON {
  38772. /** @hidden */
  38773. export var defaultFragmentDeclaration: {
  38774. name: string;
  38775. shader: string;
  38776. };
  38777. }
  38778. declare module BABYLON {
  38779. /** @hidden */
  38780. export var defaultUboDeclaration: {
  38781. name: string;
  38782. shader: string;
  38783. };
  38784. }
  38785. declare module BABYLON {
  38786. /** @hidden */
  38787. export var lightFragmentDeclaration: {
  38788. name: string;
  38789. shader: string;
  38790. };
  38791. }
  38792. declare module BABYLON {
  38793. /** @hidden */
  38794. export var lightUboDeclaration: {
  38795. name: string;
  38796. shader: string;
  38797. };
  38798. }
  38799. declare module BABYLON {
  38800. /** @hidden */
  38801. export var lightsFragmentFunctions: {
  38802. name: string;
  38803. shader: string;
  38804. };
  38805. }
  38806. declare module BABYLON {
  38807. /** @hidden */
  38808. export var shadowsFragmentFunctions: {
  38809. name: string;
  38810. shader: string;
  38811. };
  38812. }
  38813. declare module BABYLON {
  38814. /** @hidden */
  38815. export var fresnelFunction: {
  38816. name: string;
  38817. shader: string;
  38818. };
  38819. }
  38820. declare module BABYLON {
  38821. /** @hidden */
  38822. export var reflectionFunction: {
  38823. name: string;
  38824. shader: string;
  38825. };
  38826. }
  38827. declare module BABYLON {
  38828. /** @hidden */
  38829. export var bumpFragmentFunctions: {
  38830. name: string;
  38831. shader: string;
  38832. };
  38833. }
  38834. declare module BABYLON {
  38835. /** @hidden */
  38836. export var logDepthDeclaration: {
  38837. name: string;
  38838. shader: string;
  38839. };
  38840. }
  38841. declare module BABYLON {
  38842. /** @hidden */
  38843. export var bumpFragment: {
  38844. name: string;
  38845. shader: string;
  38846. };
  38847. }
  38848. declare module BABYLON {
  38849. /** @hidden */
  38850. export var depthPrePass: {
  38851. name: string;
  38852. shader: string;
  38853. };
  38854. }
  38855. declare module BABYLON {
  38856. /** @hidden */
  38857. export var lightFragment: {
  38858. name: string;
  38859. shader: string;
  38860. };
  38861. }
  38862. declare module BABYLON {
  38863. /** @hidden */
  38864. export var logDepthFragment: {
  38865. name: string;
  38866. shader: string;
  38867. };
  38868. }
  38869. declare module BABYLON {
  38870. /** @hidden */
  38871. export var defaultPixelShader: {
  38872. name: string;
  38873. shader: string;
  38874. };
  38875. }
  38876. declare module BABYLON {
  38877. /** @hidden */
  38878. export var defaultVertexDeclaration: {
  38879. name: string;
  38880. shader: string;
  38881. };
  38882. }
  38883. declare module BABYLON {
  38884. /** @hidden */
  38885. export var bumpVertexDeclaration: {
  38886. name: string;
  38887. shader: string;
  38888. };
  38889. }
  38890. declare module BABYLON {
  38891. /** @hidden */
  38892. export var bumpVertex: {
  38893. name: string;
  38894. shader: string;
  38895. };
  38896. }
  38897. declare module BABYLON {
  38898. /** @hidden */
  38899. export var fogVertex: {
  38900. name: string;
  38901. shader: string;
  38902. };
  38903. }
  38904. declare module BABYLON {
  38905. /** @hidden */
  38906. export var shadowsVertex: {
  38907. name: string;
  38908. shader: string;
  38909. };
  38910. }
  38911. declare module BABYLON {
  38912. /** @hidden */
  38913. export var pointCloudVertex: {
  38914. name: string;
  38915. shader: string;
  38916. };
  38917. }
  38918. declare module BABYLON {
  38919. /** @hidden */
  38920. export var logDepthVertex: {
  38921. name: string;
  38922. shader: string;
  38923. };
  38924. }
  38925. declare module BABYLON {
  38926. /** @hidden */
  38927. export var defaultVertexShader: {
  38928. name: string;
  38929. shader: string;
  38930. };
  38931. }
  38932. declare module BABYLON {
  38933. /** @hidden */
  38934. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  38935. MAINUV1: boolean;
  38936. MAINUV2: boolean;
  38937. DIFFUSE: boolean;
  38938. DIFFUSEDIRECTUV: number;
  38939. AMBIENT: boolean;
  38940. AMBIENTDIRECTUV: number;
  38941. OPACITY: boolean;
  38942. OPACITYDIRECTUV: number;
  38943. OPACITYRGB: boolean;
  38944. REFLECTION: boolean;
  38945. EMISSIVE: boolean;
  38946. EMISSIVEDIRECTUV: number;
  38947. SPECULAR: boolean;
  38948. SPECULARDIRECTUV: number;
  38949. BUMP: boolean;
  38950. BUMPDIRECTUV: number;
  38951. PARALLAX: boolean;
  38952. PARALLAXOCCLUSION: boolean;
  38953. SPECULAROVERALPHA: boolean;
  38954. CLIPPLANE: boolean;
  38955. CLIPPLANE2: boolean;
  38956. CLIPPLANE3: boolean;
  38957. CLIPPLANE4: boolean;
  38958. ALPHATEST: boolean;
  38959. DEPTHPREPASS: boolean;
  38960. ALPHAFROMDIFFUSE: boolean;
  38961. POINTSIZE: boolean;
  38962. FOG: boolean;
  38963. SPECULARTERM: boolean;
  38964. DIFFUSEFRESNEL: boolean;
  38965. OPACITYFRESNEL: boolean;
  38966. REFLECTIONFRESNEL: boolean;
  38967. REFRACTIONFRESNEL: boolean;
  38968. EMISSIVEFRESNEL: boolean;
  38969. FRESNEL: boolean;
  38970. NORMAL: boolean;
  38971. UV1: boolean;
  38972. UV2: boolean;
  38973. VERTEXCOLOR: boolean;
  38974. VERTEXALPHA: boolean;
  38975. NUM_BONE_INFLUENCERS: number;
  38976. BonesPerMesh: number;
  38977. BONETEXTURE: boolean;
  38978. INSTANCES: boolean;
  38979. GLOSSINESS: boolean;
  38980. ROUGHNESS: boolean;
  38981. EMISSIVEASILLUMINATION: boolean;
  38982. LINKEMISSIVEWITHDIFFUSE: boolean;
  38983. REFLECTIONFRESNELFROMSPECULAR: boolean;
  38984. LIGHTMAP: boolean;
  38985. LIGHTMAPDIRECTUV: number;
  38986. OBJECTSPACE_NORMALMAP: boolean;
  38987. USELIGHTMAPASSHADOWMAP: boolean;
  38988. REFLECTIONMAP_3D: boolean;
  38989. REFLECTIONMAP_SPHERICAL: boolean;
  38990. REFLECTIONMAP_PLANAR: boolean;
  38991. REFLECTIONMAP_CUBIC: boolean;
  38992. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  38993. REFLECTIONMAP_PROJECTION: boolean;
  38994. REFLECTIONMAP_SKYBOX: boolean;
  38995. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  38996. REFLECTIONMAP_EXPLICIT: boolean;
  38997. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  38998. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  38999. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  39000. INVERTCUBICMAP: boolean;
  39001. LOGARITHMICDEPTH: boolean;
  39002. REFRACTION: boolean;
  39003. REFRACTIONMAP_3D: boolean;
  39004. REFLECTIONOVERALPHA: boolean;
  39005. TWOSIDEDLIGHTING: boolean;
  39006. SHADOWFLOAT: boolean;
  39007. MORPHTARGETS: boolean;
  39008. MORPHTARGETS_NORMAL: boolean;
  39009. MORPHTARGETS_TANGENT: boolean;
  39010. NUM_MORPH_INFLUENCERS: number;
  39011. NONUNIFORMSCALING: boolean;
  39012. PREMULTIPLYALPHA: boolean;
  39013. IMAGEPROCESSING: boolean;
  39014. VIGNETTE: boolean;
  39015. VIGNETTEBLENDMODEMULTIPLY: boolean;
  39016. VIGNETTEBLENDMODEOPAQUE: boolean;
  39017. TONEMAPPING: boolean;
  39018. TONEMAPPING_ACES: boolean;
  39019. CONTRAST: boolean;
  39020. COLORCURVES: boolean;
  39021. COLORGRADING: boolean;
  39022. COLORGRADING3D: boolean;
  39023. SAMPLER3DGREENDEPTH: boolean;
  39024. SAMPLER3DBGRMAP: boolean;
  39025. IMAGEPROCESSINGPOSTPROCESS: boolean;
  39026. MULTIVIEW: boolean;
  39027. /**
  39028. * If the reflection texture on this material is in linear color space
  39029. * @hidden
  39030. */
  39031. IS_REFLECTION_LINEAR: boolean;
  39032. /**
  39033. * If the refraction texture on this material is in linear color space
  39034. * @hidden
  39035. */
  39036. IS_REFRACTION_LINEAR: boolean;
  39037. EXPOSURE: boolean;
  39038. constructor();
  39039. setReflectionMode(modeToEnable: string): void;
  39040. }
  39041. /**
  39042. * This is the default material used in Babylon. It is the best trade off between quality
  39043. * and performances.
  39044. * @see http://doc.babylonjs.com/babylon101/materials
  39045. */
  39046. export class StandardMaterial extends PushMaterial {
  39047. private _diffuseTexture;
  39048. /**
  39049. * The basic texture of the material as viewed under a light.
  39050. */
  39051. diffuseTexture: Nullable<BaseTexture>;
  39052. private _ambientTexture;
  39053. /**
  39054. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  39055. */
  39056. ambientTexture: Nullable<BaseTexture>;
  39057. private _opacityTexture;
  39058. /**
  39059. * Define the transparency of the material from a texture.
  39060. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  39061. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  39062. */
  39063. opacityTexture: Nullable<BaseTexture>;
  39064. private _reflectionTexture;
  39065. /**
  39066. * Define the texture used to display the reflection.
  39067. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39068. */
  39069. reflectionTexture: Nullable<BaseTexture>;
  39070. private _emissiveTexture;
  39071. /**
  39072. * Define texture of the material as if self lit.
  39073. * This will be mixed in the final result even in the absence of light.
  39074. */
  39075. emissiveTexture: Nullable<BaseTexture>;
  39076. private _specularTexture;
  39077. /**
  39078. * Define how the color and intensity of the highlight given by the light in the material.
  39079. */
  39080. specularTexture: Nullable<BaseTexture>;
  39081. private _bumpTexture;
  39082. /**
  39083. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  39084. * 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.
  39085. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  39086. */
  39087. bumpTexture: Nullable<BaseTexture>;
  39088. private _lightmapTexture;
  39089. /**
  39090. * Complex lighting can be computationally expensive to compute at runtime.
  39091. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  39092. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  39093. */
  39094. lightmapTexture: Nullable<BaseTexture>;
  39095. private _refractionTexture;
  39096. /**
  39097. * Define the texture used to display the refraction.
  39098. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39099. */
  39100. refractionTexture: Nullable<BaseTexture>;
  39101. /**
  39102. * The color of the material lit by the environmental background lighting.
  39103. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  39104. */
  39105. ambientColor: Color3;
  39106. /**
  39107. * The basic color of the material as viewed under a light.
  39108. */
  39109. diffuseColor: Color3;
  39110. /**
  39111. * Define how the color and intensity of the highlight given by the light in the material.
  39112. */
  39113. specularColor: Color3;
  39114. /**
  39115. * Define the color of the material as if self lit.
  39116. * This will be mixed in the final result even in the absence of light.
  39117. */
  39118. emissiveColor: Color3;
  39119. /**
  39120. * Defines how sharp are the highlights in the material.
  39121. * The bigger the value the sharper giving a more glossy feeling to the result.
  39122. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  39123. */
  39124. specularPower: number;
  39125. private _useAlphaFromDiffuseTexture;
  39126. /**
  39127. * Does the transparency come from the diffuse texture alpha channel.
  39128. */
  39129. useAlphaFromDiffuseTexture: boolean;
  39130. private _useEmissiveAsIllumination;
  39131. /**
  39132. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  39133. */
  39134. useEmissiveAsIllumination: boolean;
  39135. private _linkEmissiveWithDiffuse;
  39136. /**
  39137. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  39138. * the emissive level when the final color is close to one.
  39139. */
  39140. linkEmissiveWithDiffuse: boolean;
  39141. private _useSpecularOverAlpha;
  39142. /**
  39143. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  39144. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  39145. */
  39146. useSpecularOverAlpha: boolean;
  39147. private _useReflectionOverAlpha;
  39148. /**
  39149. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  39150. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  39151. */
  39152. useReflectionOverAlpha: boolean;
  39153. private _disableLighting;
  39154. /**
  39155. * Does lights from the scene impacts this material.
  39156. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  39157. */
  39158. disableLighting: boolean;
  39159. private _useObjectSpaceNormalMap;
  39160. /**
  39161. * Allows using an object space normal map (instead of tangent space).
  39162. */
  39163. useObjectSpaceNormalMap: boolean;
  39164. private _useParallax;
  39165. /**
  39166. * Is parallax enabled or not.
  39167. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  39168. */
  39169. useParallax: boolean;
  39170. private _useParallaxOcclusion;
  39171. /**
  39172. * Is parallax occlusion enabled or not.
  39173. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  39174. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  39175. */
  39176. useParallaxOcclusion: boolean;
  39177. /**
  39178. * 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.
  39179. */
  39180. parallaxScaleBias: number;
  39181. private _roughness;
  39182. /**
  39183. * Helps to define how blurry the reflections should appears in the material.
  39184. */
  39185. roughness: number;
  39186. /**
  39187. * In case of refraction, define the value of the index of refraction.
  39188. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39189. */
  39190. indexOfRefraction: number;
  39191. /**
  39192. * Invert the refraction texture alongside the y axis.
  39193. * It can be useful with procedural textures or probe for instance.
  39194. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39195. */
  39196. invertRefractionY: boolean;
  39197. /**
  39198. * Defines the alpha limits in alpha test mode.
  39199. */
  39200. alphaCutOff: number;
  39201. private _useLightmapAsShadowmap;
  39202. /**
  39203. * In case of light mapping, define whether the map contains light or shadow informations.
  39204. */
  39205. useLightmapAsShadowmap: boolean;
  39206. private _diffuseFresnelParameters;
  39207. /**
  39208. * Define the diffuse fresnel parameters of the material.
  39209. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39210. */
  39211. diffuseFresnelParameters: FresnelParameters;
  39212. private _opacityFresnelParameters;
  39213. /**
  39214. * Define the opacity fresnel parameters of the material.
  39215. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39216. */
  39217. opacityFresnelParameters: FresnelParameters;
  39218. private _reflectionFresnelParameters;
  39219. /**
  39220. * Define the reflection fresnel parameters of the material.
  39221. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39222. */
  39223. reflectionFresnelParameters: FresnelParameters;
  39224. private _refractionFresnelParameters;
  39225. /**
  39226. * Define the refraction fresnel parameters of the material.
  39227. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39228. */
  39229. refractionFresnelParameters: FresnelParameters;
  39230. private _emissiveFresnelParameters;
  39231. /**
  39232. * Define the emissive fresnel parameters of the material.
  39233. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39234. */
  39235. emissiveFresnelParameters: FresnelParameters;
  39236. private _useReflectionFresnelFromSpecular;
  39237. /**
  39238. * If true automatically deducts the fresnels values from the material specularity.
  39239. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39240. */
  39241. useReflectionFresnelFromSpecular: boolean;
  39242. private _useGlossinessFromSpecularMapAlpha;
  39243. /**
  39244. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  39245. */
  39246. useGlossinessFromSpecularMapAlpha: boolean;
  39247. private _maxSimultaneousLights;
  39248. /**
  39249. * Defines the maximum number of lights that can be used in the material
  39250. */
  39251. maxSimultaneousLights: number;
  39252. private _invertNormalMapX;
  39253. /**
  39254. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  39255. */
  39256. invertNormalMapX: boolean;
  39257. private _invertNormalMapY;
  39258. /**
  39259. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  39260. */
  39261. invertNormalMapY: boolean;
  39262. private _twoSidedLighting;
  39263. /**
  39264. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  39265. */
  39266. twoSidedLighting: boolean;
  39267. /**
  39268. * Default configuration related to image processing available in the standard Material.
  39269. */
  39270. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  39271. /**
  39272. * Gets the image processing configuration used either in this material.
  39273. */
  39274. /**
  39275. * Sets the Default image processing configuration used either in the this material.
  39276. *
  39277. * If sets to null, the scene one is in use.
  39278. */
  39279. imageProcessingConfiguration: ImageProcessingConfiguration;
  39280. /**
  39281. * Keep track of the image processing observer to allow dispose and replace.
  39282. */
  39283. private _imageProcessingObserver;
  39284. /**
  39285. * Attaches a new image processing configuration to the Standard Material.
  39286. * @param configuration
  39287. */
  39288. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  39289. /**
  39290. * Gets wether the color curves effect is enabled.
  39291. */
  39292. /**
  39293. * Sets wether the color curves effect is enabled.
  39294. */
  39295. cameraColorCurvesEnabled: boolean;
  39296. /**
  39297. * Gets wether the color grading effect is enabled.
  39298. */
  39299. /**
  39300. * Gets wether the color grading effect is enabled.
  39301. */
  39302. cameraColorGradingEnabled: boolean;
  39303. /**
  39304. * Gets wether tonemapping is enabled or not.
  39305. */
  39306. /**
  39307. * Sets wether tonemapping is enabled or not
  39308. */
  39309. cameraToneMappingEnabled: boolean;
  39310. /**
  39311. * The camera exposure used on this material.
  39312. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  39313. * This corresponds to a photographic exposure.
  39314. */
  39315. /**
  39316. * The camera exposure used on this material.
  39317. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  39318. * This corresponds to a photographic exposure.
  39319. */
  39320. cameraExposure: number;
  39321. /**
  39322. * Gets The camera contrast used on this material.
  39323. */
  39324. /**
  39325. * Sets The camera contrast used on this material.
  39326. */
  39327. cameraContrast: number;
  39328. /**
  39329. * Gets the Color Grading 2D Lookup Texture.
  39330. */
  39331. /**
  39332. * Sets the Color Grading 2D Lookup Texture.
  39333. */
  39334. cameraColorGradingTexture: Nullable<BaseTexture>;
  39335. /**
  39336. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  39337. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  39338. * 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;
  39339. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  39340. */
  39341. /**
  39342. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  39343. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  39344. * 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;
  39345. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  39346. */
  39347. cameraColorCurves: Nullable<ColorCurves>;
  39348. /**
  39349. * Custom callback helping to override the default shader used in the material.
  39350. */
  39351. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  39352. protected _renderTargets: SmartArray<RenderTargetTexture>;
  39353. protected _worldViewProjectionMatrix: Matrix;
  39354. protected _globalAmbientColor: Color3;
  39355. protected _useLogarithmicDepth: boolean;
  39356. /**
  39357. * Instantiates a new standard material.
  39358. * This is the default material used in Babylon. It is the best trade off between quality
  39359. * and performances.
  39360. * @see http://doc.babylonjs.com/babylon101/materials
  39361. * @param name Define the name of the material in the scene
  39362. * @param scene Define the scene the material belong to
  39363. */
  39364. constructor(name: string, scene: Scene);
  39365. /**
  39366. * Gets a boolean indicating that current material needs to register RTT
  39367. */
  39368. readonly hasRenderTargetTextures: boolean;
  39369. /**
  39370. * Gets the current class name of the material e.g. "StandardMaterial"
  39371. * Mainly use in serialization.
  39372. * @returns the class name
  39373. */
  39374. getClassName(): string;
  39375. /**
  39376. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  39377. * You can try switching to logarithmic depth.
  39378. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  39379. */
  39380. useLogarithmicDepth: boolean;
  39381. /**
  39382. * Specifies if the material will require alpha blending
  39383. * @returns a boolean specifying if alpha blending is needed
  39384. */
  39385. needAlphaBlending(): boolean;
  39386. /**
  39387. * Specifies if this material should be rendered in alpha test mode
  39388. * @returns a boolean specifying if an alpha test is needed.
  39389. */
  39390. needAlphaTesting(): boolean;
  39391. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  39392. /**
  39393. * Get the texture used for alpha test purpose.
  39394. * @returns the diffuse texture in case of the standard material.
  39395. */
  39396. getAlphaTestTexture(): Nullable<BaseTexture>;
  39397. /**
  39398. * Get if the submesh is ready to be used and all its information available.
  39399. * Child classes can use it to update shaders
  39400. * @param mesh defines the mesh to check
  39401. * @param subMesh defines which submesh to check
  39402. * @param useInstances specifies that instances should be used
  39403. * @returns a boolean indicating that the submesh is ready or not
  39404. */
  39405. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  39406. /**
  39407. * Builds the material UBO layouts.
  39408. * Used internally during the effect preparation.
  39409. */
  39410. buildUniformLayout(): void;
  39411. /**
  39412. * Unbinds the material from the mesh
  39413. */
  39414. unbind(): void;
  39415. /**
  39416. * Binds the submesh to this material by preparing the effect and shader to draw
  39417. * @param world defines the world transformation matrix
  39418. * @param mesh defines the mesh containing the submesh
  39419. * @param subMesh defines the submesh to bind the material to
  39420. */
  39421. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  39422. /**
  39423. * Get the list of animatables in the material.
  39424. * @returns the list of animatables object used in the material
  39425. */
  39426. getAnimatables(): IAnimatable[];
  39427. /**
  39428. * Gets the active textures from the material
  39429. * @returns an array of textures
  39430. */
  39431. getActiveTextures(): BaseTexture[];
  39432. /**
  39433. * Specifies if the material uses a texture
  39434. * @param texture defines the texture to check against the material
  39435. * @returns a boolean specifying if the material uses the texture
  39436. */
  39437. hasTexture(texture: BaseTexture): boolean;
  39438. /**
  39439. * Disposes the material
  39440. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  39441. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  39442. */
  39443. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  39444. /**
  39445. * Makes a duplicate of the material, and gives it a new name
  39446. * @param name defines the new name for the duplicated material
  39447. * @returns the cloned material
  39448. */
  39449. clone(name: string): StandardMaterial;
  39450. /**
  39451. * Serializes this material in a JSON representation
  39452. * @returns the serialized material object
  39453. */
  39454. serialize(): any;
  39455. /**
  39456. * Creates a standard material from parsed material data
  39457. * @param source defines the JSON representation of the material
  39458. * @param scene defines the hosting scene
  39459. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  39460. * @returns a new standard material
  39461. */
  39462. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  39463. /**
  39464. * Are diffuse textures enabled in the application.
  39465. */
  39466. static DiffuseTextureEnabled: boolean;
  39467. /**
  39468. * Are ambient textures enabled in the application.
  39469. */
  39470. static AmbientTextureEnabled: boolean;
  39471. /**
  39472. * Are opacity textures enabled in the application.
  39473. */
  39474. static OpacityTextureEnabled: boolean;
  39475. /**
  39476. * Are reflection textures enabled in the application.
  39477. */
  39478. static ReflectionTextureEnabled: boolean;
  39479. /**
  39480. * Are emissive textures enabled in the application.
  39481. */
  39482. static EmissiveTextureEnabled: boolean;
  39483. /**
  39484. * Are specular textures enabled in the application.
  39485. */
  39486. static SpecularTextureEnabled: boolean;
  39487. /**
  39488. * Are bump textures enabled in the application.
  39489. */
  39490. static BumpTextureEnabled: boolean;
  39491. /**
  39492. * Are lightmap textures enabled in the application.
  39493. */
  39494. static LightmapTextureEnabled: boolean;
  39495. /**
  39496. * Are refraction textures enabled in the application.
  39497. */
  39498. static RefractionTextureEnabled: boolean;
  39499. /**
  39500. * Are color grading textures enabled in the application.
  39501. */
  39502. static ColorGradingTextureEnabled: boolean;
  39503. /**
  39504. * Are fresnels enabled in the application.
  39505. */
  39506. static FresnelEnabled: boolean;
  39507. }
  39508. }
  39509. declare module BABYLON {
  39510. /**
  39511. * A class extending Texture allowing drawing on a texture
  39512. * @see http://doc.babylonjs.com/how_to/dynamictexture
  39513. */
  39514. export class DynamicTexture extends Texture {
  39515. private _generateMipMaps;
  39516. private _canvas;
  39517. private _context;
  39518. private _engine;
  39519. /**
  39520. * Creates a DynamicTexture
  39521. * @param name defines the name of the texture
  39522. * @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
  39523. * @param scene defines the scene where you want the texture
  39524. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  39525. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  39526. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  39527. */
  39528. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  39529. /**
  39530. * Get the current class name of the texture useful for serialization or dynamic coding.
  39531. * @returns "DynamicTexture"
  39532. */
  39533. getClassName(): string;
  39534. /**
  39535. * Gets the current state of canRescale
  39536. */
  39537. readonly canRescale: boolean;
  39538. private _recreate;
  39539. /**
  39540. * Scales the texture
  39541. * @param ratio the scale factor to apply to both width and height
  39542. */
  39543. scale(ratio: number): void;
  39544. /**
  39545. * Resizes the texture
  39546. * @param width the new width
  39547. * @param height the new height
  39548. */
  39549. scaleTo(width: number, height: number): void;
  39550. /**
  39551. * Gets the context of the canvas used by the texture
  39552. * @returns the canvas context of the dynamic texture
  39553. */
  39554. getContext(): CanvasRenderingContext2D;
  39555. /**
  39556. * Clears the texture
  39557. */
  39558. clear(): void;
  39559. /**
  39560. * Updates the texture
  39561. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  39562. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  39563. */
  39564. update(invertY?: boolean, premulAlpha?: boolean): void;
  39565. /**
  39566. * Draws text onto the texture
  39567. * @param text defines the text to be drawn
  39568. * @param x defines the placement of the text from the left
  39569. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  39570. * @param font defines the font to be used with font-style, font-size, font-name
  39571. * @param color defines the color used for the text
  39572. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  39573. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  39574. * @param update defines whether texture is immediately update (default is true)
  39575. */
  39576. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  39577. /**
  39578. * Clones the texture
  39579. * @returns the clone of the texture.
  39580. */
  39581. clone(): DynamicTexture;
  39582. /**
  39583. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  39584. * @returns a serialized dynamic texture object
  39585. */
  39586. serialize(): any;
  39587. /** @hidden */
  39588. _rebuild(): void;
  39589. }
  39590. }
  39591. declare module BABYLON {
  39592. /** @hidden */
  39593. export var imageProcessingPixelShader: {
  39594. name: string;
  39595. shader: string;
  39596. };
  39597. }
  39598. declare module BABYLON {
  39599. /**
  39600. * ImageProcessingPostProcess
  39601. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  39602. */
  39603. export class ImageProcessingPostProcess extends PostProcess {
  39604. /**
  39605. * Default configuration related to image processing available in the PBR Material.
  39606. */
  39607. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  39608. /**
  39609. * Gets the image processing configuration used either in this material.
  39610. */
  39611. /**
  39612. * Sets the Default image processing configuration used either in the this material.
  39613. *
  39614. * If sets to null, the scene one is in use.
  39615. */
  39616. imageProcessingConfiguration: ImageProcessingConfiguration;
  39617. /**
  39618. * Keep track of the image processing observer to allow dispose and replace.
  39619. */
  39620. private _imageProcessingObserver;
  39621. /**
  39622. * Attaches a new image processing configuration to the PBR Material.
  39623. * @param configuration
  39624. */
  39625. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  39626. /**
  39627. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  39628. */
  39629. /**
  39630. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  39631. */
  39632. colorCurves: Nullable<ColorCurves>;
  39633. /**
  39634. * Gets wether the color curves effect is enabled.
  39635. */
  39636. /**
  39637. * Sets wether the color curves effect is enabled.
  39638. */
  39639. colorCurvesEnabled: boolean;
  39640. /**
  39641. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  39642. */
  39643. /**
  39644. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  39645. */
  39646. colorGradingTexture: Nullable<BaseTexture>;
  39647. /**
  39648. * Gets wether the color grading effect is enabled.
  39649. */
  39650. /**
  39651. * Gets wether the color grading effect is enabled.
  39652. */
  39653. colorGradingEnabled: boolean;
  39654. /**
  39655. * Gets exposure used in the effect.
  39656. */
  39657. /**
  39658. * Sets exposure used in the effect.
  39659. */
  39660. exposure: number;
  39661. /**
  39662. * Gets wether tonemapping is enabled or not.
  39663. */
  39664. /**
  39665. * Sets wether tonemapping is enabled or not
  39666. */
  39667. toneMappingEnabled: boolean;
  39668. /**
  39669. * Gets the type of tone mapping effect.
  39670. */
  39671. /**
  39672. * Sets the type of tone mapping effect.
  39673. */
  39674. toneMappingType: number;
  39675. /**
  39676. * Gets contrast used in the effect.
  39677. */
  39678. /**
  39679. * Sets contrast used in the effect.
  39680. */
  39681. contrast: number;
  39682. /**
  39683. * Gets Vignette stretch size.
  39684. */
  39685. /**
  39686. * Sets Vignette stretch size.
  39687. */
  39688. vignetteStretch: number;
  39689. /**
  39690. * Gets Vignette centre X Offset.
  39691. */
  39692. /**
  39693. * Sets Vignette centre X Offset.
  39694. */
  39695. vignetteCentreX: number;
  39696. /**
  39697. * Gets Vignette centre Y Offset.
  39698. */
  39699. /**
  39700. * Sets Vignette centre Y Offset.
  39701. */
  39702. vignetteCentreY: number;
  39703. /**
  39704. * Gets Vignette weight or intensity of the vignette effect.
  39705. */
  39706. /**
  39707. * Sets Vignette weight or intensity of the vignette effect.
  39708. */
  39709. vignetteWeight: number;
  39710. /**
  39711. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  39712. * if vignetteEnabled is set to true.
  39713. */
  39714. /**
  39715. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  39716. * if vignetteEnabled is set to true.
  39717. */
  39718. vignetteColor: Color4;
  39719. /**
  39720. * Gets Camera field of view used by the Vignette effect.
  39721. */
  39722. /**
  39723. * Sets Camera field of view used by the Vignette effect.
  39724. */
  39725. vignetteCameraFov: number;
  39726. /**
  39727. * Gets the vignette blend mode allowing different kind of effect.
  39728. */
  39729. /**
  39730. * Sets the vignette blend mode allowing different kind of effect.
  39731. */
  39732. vignetteBlendMode: number;
  39733. /**
  39734. * Gets wether the vignette effect is enabled.
  39735. */
  39736. /**
  39737. * Sets wether the vignette effect is enabled.
  39738. */
  39739. vignetteEnabled: boolean;
  39740. private _fromLinearSpace;
  39741. /**
  39742. * Gets wether the input of the processing is in Gamma or Linear Space.
  39743. */
  39744. /**
  39745. * Sets wether the input of the processing is in Gamma or Linear Space.
  39746. */
  39747. fromLinearSpace: boolean;
  39748. /**
  39749. * Defines cache preventing GC.
  39750. */
  39751. private _defines;
  39752. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  39753. /**
  39754. * "ImageProcessingPostProcess"
  39755. * @returns "ImageProcessingPostProcess"
  39756. */
  39757. getClassName(): string;
  39758. protected _updateParameters(): void;
  39759. dispose(camera?: Camera): void;
  39760. }
  39761. }
  39762. declare module BABYLON {
  39763. /**
  39764. * Class containing static functions to help procedurally build meshes
  39765. */
  39766. export class GroundBuilder {
  39767. /**
  39768. * Creates a ground mesh
  39769. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  39770. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  39771. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  39772. * @param name defines the name of the mesh
  39773. * @param options defines the options used to create the mesh
  39774. * @param scene defines the hosting scene
  39775. * @returns the ground mesh
  39776. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  39777. */
  39778. static CreateGround(name: string, options: {
  39779. width?: number;
  39780. height?: number;
  39781. subdivisions?: number;
  39782. subdivisionsX?: number;
  39783. subdivisionsY?: number;
  39784. updatable?: boolean;
  39785. }, scene: any): Mesh;
  39786. /**
  39787. * Creates a tiled ground mesh
  39788. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  39789. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  39790. * * 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
  39791. * * 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
  39792. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  39793. * @param name defines the name of the mesh
  39794. * @param options defines the options used to create the mesh
  39795. * @param scene defines the hosting scene
  39796. * @returns the tiled ground mesh
  39797. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  39798. */
  39799. static CreateTiledGround(name: string, options: {
  39800. xmin: number;
  39801. zmin: number;
  39802. xmax: number;
  39803. zmax: number;
  39804. subdivisions?: {
  39805. w: number;
  39806. h: number;
  39807. };
  39808. precision?: {
  39809. w: number;
  39810. h: number;
  39811. };
  39812. updatable?: boolean;
  39813. }, scene?: Nullable<Scene>): Mesh;
  39814. /**
  39815. * Creates a ground mesh from a height map
  39816. * * The parameter `url` sets the URL of the height map image resource.
  39817. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  39818. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  39819. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  39820. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  39821. * * 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.
  39822. * * 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).
  39823. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  39824. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  39825. * @param name defines the name of the mesh
  39826. * @param url defines the url to the height map
  39827. * @param options defines the options used to create the mesh
  39828. * @param scene defines the hosting scene
  39829. * @returns the ground mesh
  39830. * @see https://doc.babylonjs.com/babylon101/height_map
  39831. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  39832. */
  39833. static CreateGroundFromHeightMap(name: string, url: string, options: {
  39834. width?: number;
  39835. height?: number;
  39836. subdivisions?: number;
  39837. minHeight?: number;
  39838. maxHeight?: number;
  39839. colorFilter?: Color3;
  39840. alphaFilter?: number;
  39841. updatable?: boolean;
  39842. onReady?: (mesh: GroundMesh) => void;
  39843. }, scene?: Nullable<Scene>): GroundMesh;
  39844. }
  39845. }
  39846. declare module BABYLON {
  39847. /**
  39848. * Class containing static functions to help procedurally build meshes
  39849. */
  39850. export class TorusBuilder {
  39851. /**
  39852. * Creates a torus mesh
  39853. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  39854. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  39855. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  39856. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  39857. * * 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
  39858. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  39859. * @param name defines the name of the mesh
  39860. * @param options defines the options used to create the mesh
  39861. * @param scene defines the hosting scene
  39862. * @returns the torus mesh
  39863. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  39864. */
  39865. static CreateTorus(name: string, options: {
  39866. diameter?: number;
  39867. thickness?: number;
  39868. tessellation?: number;
  39869. updatable?: boolean;
  39870. sideOrientation?: number;
  39871. frontUVs?: Vector4;
  39872. backUVs?: Vector4;
  39873. }, scene: any): Mesh;
  39874. }
  39875. }
  39876. declare module BABYLON {
  39877. /**
  39878. * Class containing static functions to help procedurally build meshes
  39879. */
  39880. export class CylinderBuilder {
  39881. /**
  39882. * Creates a cylinder or a cone mesh
  39883. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  39884. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  39885. * * 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.
  39886. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  39887. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  39888. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  39889. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  39890. * * 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).
  39891. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  39892. * * 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).
  39893. * * 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
  39894. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  39895. * * 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
  39896. * * 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.
  39897. * * If `enclose` is false, a ring surface is one element.
  39898. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  39899. * * 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
  39900. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  39901. * * 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
  39902. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  39903. * @param name defines the name of the mesh
  39904. * @param options defines the options used to create the mesh
  39905. * @param scene defines the hosting scene
  39906. * @returns the cylinder mesh
  39907. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  39908. */
  39909. static CreateCylinder(name: string, options: {
  39910. height?: number;
  39911. diameterTop?: number;
  39912. diameterBottom?: number;
  39913. diameter?: number;
  39914. tessellation?: number;
  39915. subdivisions?: number;
  39916. arc?: number;
  39917. faceColors?: Color4[];
  39918. faceUV?: Vector4[];
  39919. updatable?: boolean;
  39920. hasRings?: boolean;
  39921. enclose?: boolean;
  39922. cap?: number;
  39923. sideOrientation?: number;
  39924. frontUVs?: Vector4;
  39925. backUVs?: Vector4;
  39926. }, scene: any): Mesh;
  39927. }
  39928. }
  39929. declare module BABYLON {
  39930. /**
  39931. * Options to modify the vr teleportation behavior.
  39932. */
  39933. export interface VRTeleportationOptions {
  39934. /**
  39935. * The name of the mesh which should be used as the teleportation floor. (default: null)
  39936. */
  39937. floorMeshName?: string;
  39938. /**
  39939. * A list of meshes to be used as the teleportation floor. (default: empty)
  39940. */
  39941. floorMeshes?: Mesh[];
  39942. }
  39943. /**
  39944. * Options to modify the vr experience helper's behavior.
  39945. */
  39946. export interface VRExperienceHelperOptions extends WebVROptions {
  39947. /**
  39948. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  39949. */
  39950. createDeviceOrientationCamera?: boolean;
  39951. /**
  39952. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  39953. */
  39954. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  39955. /**
  39956. * Uses the main button on the controller to toggle the laser casted. (default: true)
  39957. */
  39958. laserToggle?: boolean;
  39959. /**
  39960. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  39961. */
  39962. floorMeshes?: Mesh[];
  39963. /**
  39964. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  39965. */
  39966. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  39967. }
  39968. /**
  39969. * Event containing information after VR has been entered
  39970. */
  39971. export class OnAfterEnteringVRObservableEvent {
  39972. /**
  39973. * If entering vr was successful
  39974. */
  39975. success: boolean;
  39976. }
  39977. /**
  39978. * Helps to quickly add VR support to an existing scene.
  39979. * See http://doc.babylonjs.com/how_to/webvr_helper
  39980. */
  39981. export class VRExperienceHelper {
  39982. /** Options to modify the vr experience helper's behavior. */
  39983. webVROptions: VRExperienceHelperOptions;
  39984. private _scene;
  39985. private _position;
  39986. private _btnVR;
  39987. private _btnVRDisplayed;
  39988. private _webVRsupported;
  39989. private _webVRready;
  39990. private _webVRrequesting;
  39991. private _webVRpresenting;
  39992. private _hasEnteredVR;
  39993. private _fullscreenVRpresenting;
  39994. private _canvas;
  39995. private _webVRCamera;
  39996. private _vrDeviceOrientationCamera;
  39997. private _deviceOrientationCamera;
  39998. private _existingCamera;
  39999. private _onKeyDown;
  40000. private _onVrDisplayPresentChange;
  40001. private _onVRDisplayChanged;
  40002. private _onVRRequestPresentStart;
  40003. private _onVRRequestPresentComplete;
  40004. /**
  40005. * Observable raised right before entering VR.
  40006. */
  40007. onEnteringVRObservable: Observable<VRExperienceHelper>;
  40008. /**
  40009. * Observable raised when entering VR has completed.
  40010. */
  40011. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  40012. /**
  40013. * Observable raised when exiting VR.
  40014. */
  40015. onExitingVRObservable: Observable<VRExperienceHelper>;
  40016. /**
  40017. * Observable raised when controller mesh is loaded.
  40018. */
  40019. onControllerMeshLoadedObservable: Observable<WebVRController>;
  40020. /** Return this.onEnteringVRObservable
  40021. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  40022. */
  40023. readonly onEnteringVR: Observable<VRExperienceHelper>;
  40024. /** Return this.onExitingVRObservable
  40025. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  40026. */
  40027. readonly onExitingVR: Observable<VRExperienceHelper>;
  40028. /** Return this.onControllerMeshLoadedObservable
  40029. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  40030. */
  40031. readonly onControllerMeshLoaded: Observable<WebVRController>;
  40032. private _rayLength;
  40033. private _useCustomVRButton;
  40034. private _teleportationRequested;
  40035. private _teleportActive;
  40036. private _floorMeshName;
  40037. private _floorMeshesCollection;
  40038. private _rotationAllowed;
  40039. private _teleportBackwardsVector;
  40040. private _teleportationTarget;
  40041. private _isDefaultTeleportationTarget;
  40042. private _postProcessMove;
  40043. private _teleportationFillColor;
  40044. private _teleportationBorderColor;
  40045. private _rotationAngle;
  40046. private _haloCenter;
  40047. private _cameraGazer;
  40048. private _padSensibilityUp;
  40049. private _padSensibilityDown;
  40050. private _leftController;
  40051. private _rightController;
  40052. /**
  40053. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  40054. */
  40055. onNewMeshSelected: Observable<AbstractMesh>;
  40056. /**
  40057. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  40058. */
  40059. onNewMeshPicked: Observable<PickingInfo>;
  40060. private _circleEase;
  40061. /**
  40062. * Observable raised before camera teleportation
  40063. */
  40064. onBeforeCameraTeleport: Observable<Vector3>;
  40065. /**
  40066. * Observable raised after camera teleportation
  40067. */
  40068. onAfterCameraTeleport: Observable<Vector3>;
  40069. /**
  40070. * Observable raised when current selected mesh gets unselected
  40071. */
  40072. onSelectedMeshUnselected: Observable<AbstractMesh>;
  40073. private _raySelectionPredicate;
  40074. /**
  40075. * To be optionaly changed by user to define custom ray selection
  40076. */
  40077. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  40078. /**
  40079. * To be optionaly changed by user to define custom selection logic (after ray selection)
  40080. */
  40081. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  40082. /**
  40083. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  40084. */
  40085. teleportationEnabled: boolean;
  40086. private _defaultHeight;
  40087. private _teleportationInitialized;
  40088. private _interactionsEnabled;
  40089. private _interactionsRequested;
  40090. private _displayGaze;
  40091. private _displayLaserPointer;
  40092. /**
  40093. * The mesh used to display where the user is going to teleport.
  40094. */
  40095. /**
  40096. * Sets the mesh to be used to display where the user is going to teleport.
  40097. */
  40098. teleportationTarget: Mesh;
  40099. /**
  40100. * 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
  40101. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  40102. * See http://doc.babylonjs.com/resources/baking_transformations
  40103. */
  40104. gazeTrackerMesh: Mesh;
  40105. /**
  40106. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  40107. */
  40108. updateGazeTrackerScale: boolean;
  40109. /**
  40110. * If the gaze trackers color should be updated when selecting meshes
  40111. */
  40112. updateGazeTrackerColor: boolean;
  40113. /**
  40114. * The gaze tracking mesh corresponding to the left controller
  40115. */
  40116. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  40117. /**
  40118. * The gaze tracking mesh corresponding to the right controller
  40119. */
  40120. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  40121. /**
  40122. * If the ray of the gaze should be displayed.
  40123. */
  40124. /**
  40125. * Sets if the ray of the gaze should be displayed.
  40126. */
  40127. displayGaze: boolean;
  40128. /**
  40129. * If the ray of the LaserPointer should be displayed.
  40130. */
  40131. /**
  40132. * Sets if the ray of the LaserPointer should be displayed.
  40133. */
  40134. displayLaserPointer: boolean;
  40135. /**
  40136. * The deviceOrientationCamera used as the camera when not in VR.
  40137. */
  40138. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  40139. /**
  40140. * Based on the current WebVR support, returns the current VR camera used.
  40141. */
  40142. readonly currentVRCamera: Nullable<Camera>;
  40143. /**
  40144. * The webVRCamera which is used when in VR.
  40145. */
  40146. readonly webVRCamera: WebVRFreeCamera;
  40147. /**
  40148. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  40149. */
  40150. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  40151. private readonly _teleportationRequestInitiated;
  40152. /**
  40153. * Defines wether or not Pointer lock should be requested when switching to
  40154. * full screen.
  40155. */
  40156. requestPointerLockOnFullScreen: boolean;
  40157. /**
  40158. * Instantiates a VRExperienceHelper.
  40159. * Helps to quickly add VR support to an existing scene.
  40160. * @param scene The scene the VRExperienceHelper belongs to.
  40161. * @param webVROptions Options to modify the vr experience helper's behavior.
  40162. */
  40163. constructor(scene: Scene,
  40164. /** Options to modify the vr experience helper's behavior. */
  40165. webVROptions?: VRExperienceHelperOptions);
  40166. private _onDefaultMeshLoaded;
  40167. private _onResize;
  40168. private _onFullscreenChange;
  40169. /**
  40170. * Gets a value indicating if we are currently in VR mode.
  40171. */
  40172. readonly isInVRMode: boolean;
  40173. private onVrDisplayPresentChange;
  40174. private onVRDisplayChanged;
  40175. private moveButtonToBottomRight;
  40176. private displayVRButton;
  40177. private updateButtonVisibility;
  40178. private _cachedAngularSensibility;
  40179. /**
  40180. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  40181. * Otherwise, will use the fullscreen API.
  40182. */
  40183. enterVR(): void;
  40184. /**
  40185. * Attempt to exit VR, or fullscreen.
  40186. */
  40187. exitVR(): void;
  40188. /**
  40189. * The position of the vr experience helper.
  40190. */
  40191. /**
  40192. * Sets the position of the vr experience helper.
  40193. */
  40194. position: Vector3;
  40195. /**
  40196. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  40197. */
  40198. enableInteractions(): void;
  40199. private readonly _noControllerIsActive;
  40200. private beforeRender;
  40201. private _isTeleportationFloor;
  40202. /**
  40203. * Adds a floor mesh to be used for teleportation.
  40204. * @param floorMesh the mesh to be used for teleportation.
  40205. */
  40206. addFloorMesh(floorMesh: Mesh): void;
  40207. /**
  40208. * Removes a floor mesh from being used for teleportation.
  40209. * @param floorMesh the mesh to be removed.
  40210. */
  40211. removeFloorMesh(floorMesh: Mesh): void;
  40212. /**
  40213. * Enables interactions and teleportation using the VR controllers and gaze.
  40214. * @param vrTeleportationOptions options to modify teleportation behavior.
  40215. */
  40216. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  40217. private _onNewGamepadConnected;
  40218. private _tryEnableInteractionOnController;
  40219. private _onNewGamepadDisconnected;
  40220. private _enableInteractionOnController;
  40221. private _checkTeleportWithRay;
  40222. private _checkRotate;
  40223. private _checkTeleportBackwards;
  40224. private _enableTeleportationOnController;
  40225. private _createTeleportationCircles;
  40226. private _displayTeleportationTarget;
  40227. private _hideTeleportationTarget;
  40228. private _rotateCamera;
  40229. private _moveTeleportationSelectorTo;
  40230. private _workingVector;
  40231. private _workingQuaternion;
  40232. private _workingMatrix;
  40233. /**
  40234. * Teleports the users feet to the desired location
  40235. * @param location The location where the user's feet should be placed
  40236. */
  40237. teleportCamera(location: Vector3): void;
  40238. private _convertNormalToDirectionOfRay;
  40239. private _castRayAndSelectObject;
  40240. private _notifySelectedMeshUnselected;
  40241. /**
  40242. * Sets the color of the laser ray from the vr controllers.
  40243. * @param color new color for the ray.
  40244. */
  40245. changeLaserColor(color: Color3): void;
  40246. /**
  40247. * Sets the color of the ray from the vr headsets gaze.
  40248. * @param color new color for the ray.
  40249. */
  40250. changeGazeColor(color: Color3): void;
  40251. /**
  40252. * Exits VR and disposes of the vr experience helper
  40253. */
  40254. dispose(): void;
  40255. /**
  40256. * Gets the name of the VRExperienceHelper class
  40257. * @returns "VRExperienceHelper"
  40258. */
  40259. getClassName(): string;
  40260. }
  40261. }
  40262. declare module BABYLON {
  40263. /**
  40264. * Manages an XRSession
  40265. * @see https://doc.babylonjs.com/how_to/webxr
  40266. */
  40267. export class WebXRSessionManager implements IDisposable {
  40268. private scene;
  40269. /**
  40270. * Fires every time a new xrFrame arrives which can be used to update the camera
  40271. */
  40272. onXRFrameObservable: Observable<any>;
  40273. /**
  40274. * Fires when the xr session is ended either by the device or manually done
  40275. */
  40276. onXRSessionEnded: Observable<any>;
  40277. /** @hidden */
  40278. _xrSession: XRSession;
  40279. /** @hidden */
  40280. _frameOfReference: XRFrameOfReference;
  40281. /** @hidden */
  40282. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  40283. /** @hidden */
  40284. _currentXRFrame: Nullable<XRFrame>;
  40285. private _xrNavigator;
  40286. private _xrDevice;
  40287. private _tmpMatrix;
  40288. /**
  40289. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  40290. * @param scene The scene which the session should be created for
  40291. */
  40292. constructor(scene: Scene);
  40293. /**
  40294. * Initializes the manager
  40295. * After initialization enterXR can be called to start an XR session
  40296. * @returns Promise which resolves after it is initialized
  40297. */
  40298. initializeAsync(): Promise<void>;
  40299. /**
  40300. * Enters XR with the desired XR session options, this must be done with a user action (eg. button click event)
  40301. * @param sessionCreationOptions xr options to create the session with
  40302. * @param frameOfReferenceType option to configure how the xr pose is expressed
  40303. * @returns Promise which resolves after it enters XR
  40304. */
  40305. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReferenceType: string): Promise<void>;
  40306. /**
  40307. * Stops the xrSession and restores the renderloop
  40308. * @returns Promise which resolves after it exits XR
  40309. */
  40310. exitXRAsync(): Promise<void>;
  40311. /**
  40312. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  40313. * @param ray ray to cast into the environment
  40314. * @returns Promise which resolves with a collision point in the environment if it exists
  40315. */
  40316. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  40317. /**
  40318. * Checks if a session would be supported for the creation options specified
  40319. * @param options creation options to check if they are supported
  40320. * @returns true if supported
  40321. */
  40322. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  40323. /**
  40324. * @hidden
  40325. * Converts the render layer of xrSession to a render target
  40326. * @param session session to create render target for
  40327. * @param scene scene the new render target should be created for
  40328. */
  40329. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene): RenderTargetTexture;
  40330. /**
  40331. * Disposes of the session manager
  40332. */
  40333. dispose(): void;
  40334. }
  40335. }
  40336. declare module BABYLON {
  40337. /**
  40338. * WebXR Camera which holds the views for the xrSession
  40339. * @see https://doc.babylonjs.com/how_to/webxr
  40340. */
  40341. export class WebXRCamera extends FreeCamera {
  40342. private static _TmpMatrix;
  40343. /**
  40344. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  40345. * @param name the name of the camera
  40346. * @param scene the scene to add the camera to
  40347. */
  40348. constructor(name: string, scene: Scene);
  40349. private _updateNumberOfRigCameras;
  40350. /** @hidden */
  40351. _updateForDualEyeDebugging(pupilDistance?: number): void;
  40352. /**
  40353. * Updates the cameras position from the current pose information of the XR session
  40354. * @param xrSessionManager the session containing pose information
  40355. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  40356. */
  40357. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  40358. }
  40359. }
  40360. declare module BABYLON {
  40361. /**
  40362. * States of the webXR experience
  40363. */
  40364. export enum WebXRState {
  40365. /**
  40366. * Transitioning to being in XR mode
  40367. */
  40368. ENTERING_XR = 0,
  40369. /**
  40370. * Transitioning to non XR mode
  40371. */
  40372. EXITING_XR = 1,
  40373. /**
  40374. * In XR mode and presenting
  40375. */
  40376. IN_XR = 2,
  40377. /**
  40378. * Not entered XR mode
  40379. */
  40380. NOT_IN_XR = 3
  40381. }
  40382. /**
  40383. * Helper class used to enable XR
  40384. * @see https://doc.babylonjs.com/how_to/webxr
  40385. */
  40386. export class WebXRExperienceHelper implements IDisposable {
  40387. private scene;
  40388. /**
  40389. * 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
  40390. */
  40391. container: AbstractMesh;
  40392. /**
  40393. * Camera used to render xr content
  40394. */
  40395. camera: WebXRCamera;
  40396. /**
  40397. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  40398. */
  40399. state: WebXRState;
  40400. private _setState;
  40401. private static _TmpVector;
  40402. /**
  40403. * Fires when the state of the experience helper has changed
  40404. */
  40405. onStateChangedObservable: Observable<WebXRState>;
  40406. /** @hidden */
  40407. _sessionManager: WebXRSessionManager;
  40408. private _nonVRCamera;
  40409. private _originalSceneAutoClear;
  40410. private _supported;
  40411. /**
  40412. * Creates the experience helper
  40413. * @param scene the scene to attach the experience helper to
  40414. * @returns a promise for the experience helper
  40415. */
  40416. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  40417. /**
  40418. * Creates a WebXRExperienceHelper
  40419. * @param scene The scene the helper should be created in
  40420. */
  40421. private constructor();
  40422. /**
  40423. * Exits XR mode and returns the scene to its original state
  40424. * @returns promise that resolves after xr mode has exited
  40425. */
  40426. exitXRAsync(): Promise<void>;
  40427. /**
  40428. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  40429. * @param sessionCreationOptions options for the XR session
  40430. * @param frameOfReference frame of reference of the XR session
  40431. * @returns promise that resolves after xr mode has entered
  40432. */
  40433. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReference: string): Promise<void>;
  40434. /**
  40435. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  40436. * @param ray ray to cast into the environment
  40437. * @returns Promise which resolves with a collision point in the environment if it exists
  40438. */
  40439. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  40440. /**
  40441. * Updates the global position of the camera by moving the camera's container
  40442. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  40443. * @param position The desired global position of the camera
  40444. */
  40445. setPositionOfCameraUsingContainer(position: Vector3): void;
  40446. /**
  40447. * Rotates the xr camera by rotating the camera's container around the camera's position
  40448. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  40449. * @param rotation the desired quaternion rotation to apply to the camera
  40450. */
  40451. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  40452. /**
  40453. * Checks if the creation options are supported by the xr session
  40454. * @param options creation options
  40455. * @returns true if supported
  40456. */
  40457. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  40458. /**
  40459. * Disposes of the experience helper
  40460. */
  40461. dispose(): void;
  40462. }
  40463. }
  40464. declare module BABYLON {
  40465. /**
  40466. * Button which can be used to enter a different mode of XR
  40467. */
  40468. export class WebXREnterExitUIButton {
  40469. /** button element */
  40470. element: HTMLElement;
  40471. /** XR initialization options for the button */
  40472. initializationOptions: XRSessionCreationOptions;
  40473. /**
  40474. * Creates a WebXREnterExitUIButton
  40475. * @param element button element
  40476. * @param initializationOptions XR initialization options for the button
  40477. */
  40478. constructor(
  40479. /** button element */
  40480. element: HTMLElement,
  40481. /** XR initialization options for the button */
  40482. initializationOptions: XRSessionCreationOptions);
  40483. /**
  40484. * Overwritable function which can be used to update the button's visuals when the state changes
  40485. * @param activeButton the current active button in the UI
  40486. */
  40487. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  40488. }
  40489. /**
  40490. * Options to create the webXR UI
  40491. */
  40492. export class WebXREnterExitUIOptions {
  40493. /**
  40494. * Context to enter xr with
  40495. */
  40496. outputCanvasContext?: Nullable<WebGLRenderingContext>;
  40497. /**
  40498. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  40499. */
  40500. customButtons?: Array<WebXREnterExitUIButton>;
  40501. }
  40502. /**
  40503. * UI to allow the user to enter/exit XR mode
  40504. */
  40505. export class WebXREnterExitUI implements IDisposable {
  40506. private scene;
  40507. private _overlay;
  40508. private _buttons;
  40509. private _activeButton;
  40510. /**
  40511. * Fired every time the active button is changed.
  40512. *
  40513. * When xr is entered via a button that launches xr that button will be the callback parameter
  40514. *
  40515. * When exiting xr the callback parameter will be null)
  40516. */
  40517. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  40518. /**
  40519. * Creates UI to allow the user to enter/exit XR mode
  40520. * @param scene the scene to add the ui to
  40521. * @param helper the xr experience helper to enter/exit xr with
  40522. * @param options options to configure the UI
  40523. * @returns the created ui
  40524. */
  40525. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  40526. private constructor();
  40527. private _updateButtons;
  40528. /**
  40529. * Disposes of the object
  40530. */
  40531. dispose(): void;
  40532. }
  40533. }
  40534. declare module BABYLON {
  40535. /**
  40536. * Represents an XR input
  40537. */
  40538. export class WebXRController {
  40539. /**
  40540. * 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
  40541. */
  40542. grip?: AbstractMesh;
  40543. /**
  40544. * Pointer which can be used to select objects or attach a visible laser to
  40545. */
  40546. pointer: AbstractMesh;
  40547. /**
  40548. * Creates the controller
  40549. * @see https://doc.babylonjs.com/how_to/webxr
  40550. * @param scene the scene which the controller should be associated to
  40551. */
  40552. constructor(scene: Scene);
  40553. /**
  40554. * Disposes of the object
  40555. */
  40556. dispose(): void;
  40557. }
  40558. /**
  40559. * XR input used to track XR inputs such as controllers/rays
  40560. */
  40561. export class WebXRInput implements IDisposable {
  40562. private helper;
  40563. /**
  40564. * XR controllers being tracked
  40565. */
  40566. controllers: Array<WebXRController>;
  40567. private _tmpMatrix;
  40568. private _frameObserver;
  40569. /**
  40570. * Initializes the WebXRInput
  40571. * @param helper experience helper which the input should be created for
  40572. */
  40573. constructor(helper: WebXRExperienceHelper);
  40574. /**
  40575. * Disposes of the object
  40576. */
  40577. dispose(): void;
  40578. }
  40579. }
  40580. declare module BABYLON {
  40581. /**
  40582. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  40583. */
  40584. export class WebXRManagedOutputCanvas implements IDisposable {
  40585. private _canvas;
  40586. /**
  40587. * xrpresent context of the canvas which can be used to display/mirror xr content
  40588. */
  40589. canvasContext: Nullable<WebGLRenderingContext>;
  40590. /**
  40591. * Initializes the canvas to be added/removed upon entering/exiting xr
  40592. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  40593. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  40594. */
  40595. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  40596. /**
  40597. * Disposes of the object
  40598. */
  40599. dispose(): void;
  40600. private _setManagedOutputCanvas;
  40601. private _addCanvas;
  40602. private _removeCanvas;
  40603. }
  40604. }
  40605. declare module BABYLON {
  40606. /**
  40607. * Contains an array of blocks representing the octree
  40608. */
  40609. export interface IOctreeContainer<T> {
  40610. /**
  40611. * Blocks within the octree
  40612. */
  40613. blocks: Array<OctreeBlock<T>>;
  40614. }
  40615. /**
  40616. * Class used to store a cell in an octree
  40617. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40618. */
  40619. export class OctreeBlock<T> {
  40620. /**
  40621. * Gets the content of the current block
  40622. */
  40623. entries: T[];
  40624. /**
  40625. * Gets the list of block children
  40626. */
  40627. blocks: Array<OctreeBlock<T>>;
  40628. private _depth;
  40629. private _maxDepth;
  40630. private _capacity;
  40631. private _minPoint;
  40632. private _maxPoint;
  40633. private _boundingVectors;
  40634. private _creationFunc;
  40635. /**
  40636. * Creates a new block
  40637. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  40638. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  40639. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  40640. * @param depth defines the current depth of this block in the octree
  40641. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  40642. * @param creationFunc defines a callback to call when an element is added to the block
  40643. */
  40644. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  40645. /**
  40646. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  40647. */
  40648. readonly capacity: number;
  40649. /**
  40650. * Gets the minimum vector (in world space) of the block's bounding box
  40651. */
  40652. readonly minPoint: Vector3;
  40653. /**
  40654. * Gets the maximum vector (in world space) of the block's bounding box
  40655. */
  40656. readonly maxPoint: Vector3;
  40657. /**
  40658. * Add a new element to this block
  40659. * @param entry defines the element to add
  40660. */
  40661. addEntry(entry: T): void;
  40662. /**
  40663. * Remove an element from this block
  40664. * @param entry defines the element to remove
  40665. */
  40666. removeEntry(entry: T): void;
  40667. /**
  40668. * Add an array of elements to this block
  40669. * @param entries defines the array of elements to add
  40670. */
  40671. addEntries(entries: T[]): void;
  40672. /**
  40673. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  40674. * @param frustumPlanes defines the frustum planes to test
  40675. * @param selection defines the array to store current content if selection is positive
  40676. * @param allowDuplicate defines if the selection array can contains duplicated entries
  40677. */
  40678. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  40679. /**
  40680. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  40681. * @param sphereCenter defines the bounding sphere center
  40682. * @param sphereRadius defines the bounding sphere radius
  40683. * @param selection defines the array to store current content if selection is positive
  40684. * @param allowDuplicate defines if the selection array can contains duplicated entries
  40685. */
  40686. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  40687. /**
  40688. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  40689. * @param ray defines the ray to test with
  40690. * @param selection defines the array to store current content if selection is positive
  40691. */
  40692. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  40693. /**
  40694. * Subdivide the content into child blocks (this block will then be empty)
  40695. */
  40696. createInnerBlocks(): void;
  40697. /**
  40698. * @hidden
  40699. */
  40700. 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;
  40701. }
  40702. }
  40703. declare module BABYLON {
  40704. /**
  40705. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  40706. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40707. */
  40708. export class Octree<T> {
  40709. /** 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.) */
  40710. maxDepth: number;
  40711. /**
  40712. * Blocks within the octree containing objects
  40713. */
  40714. blocks: Array<OctreeBlock<T>>;
  40715. /**
  40716. * Content stored in the octree
  40717. */
  40718. dynamicContent: T[];
  40719. private _maxBlockCapacity;
  40720. private _selectionContent;
  40721. private _creationFunc;
  40722. /**
  40723. * Creates a octree
  40724. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40725. * @param creationFunc function to be used to instatiate the octree
  40726. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  40727. * @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.)
  40728. */
  40729. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  40730. /** 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.) */
  40731. maxDepth?: number);
  40732. /**
  40733. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  40734. * @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);
  40735. * @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);
  40736. * @param entries meshes to be added to the octree blocks
  40737. */
  40738. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  40739. /**
  40740. * Adds a mesh to the octree
  40741. * @param entry Mesh to add to the octree
  40742. */
  40743. addMesh(entry: T): void;
  40744. /**
  40745. * Remove an element from the octree
  40746. * @param entry defines the element to remove
  40747. */
  40748. removeMesh(entry: T): void;
  40749. /**
  40750. * Selects an array of meshes within the frustum
  40751. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  40752. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  40753. * @returns array of meshes within the frustum
  40754. */
  40755. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  40756. /**
  40757. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  40758. * @param sphereCenter defines the bounding sphere center
  40759. * @param sphereRadius defines the bounding sphere radius
  40760. * @param allowDuplicate defines if the selection array can contains duplicated entries
  40761. * @returns an array of objects that intersect the sphere
  40762. */
  40763. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  40764. /**
  40765. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  40766. * @param ray defines the ray to test with
  40767. * @returns array of intersected objects
  40768. */
  40769. intersectsRay(ray: Ray): SmartArray<T>;
  40770. /**
  40771. * Adds a mesh into the octree block if it intersects the block
  40772. */
  40773. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  40774. /**
  40775. * Adds a submesh into the octree block if it intersects the block
  40776. */
  40777. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  40778. }
  40779. }
  40780. declare module BABYLON {
  40781. interface Scene {
  40782. /**
  40783. * @hidden
  40784. * Backing Filed
  40785. */
  40786. _selectionOctree: Octree<AbstractMesh>;
  40787. /**
  40788. * Gets the octree used to boost mesh selection (picking)
  40789. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40790. */
  40791. selectionOctree: Octree<AbstractMesh>;
  40792. /**
  40793. * Creates or updates the octree used to boost selection (picking)
  40794. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40795. * @param maxCapacity defines the maximum capacity per leaf
  40796. * @param maxDepth defines the maximum depth of the octree
  40797. * @returns an octree of AbstractMesh
  40798. */
  40799. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  40800. }
  40801. interface AbstractMesh {
  40802. /**
  40803. * @hidden
  40804. * Backing Field
  40805. */
  40806. _submeshesOctree: Octree<SubMesh>;
  40807. /**
  40808. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  40809. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  40810. * @param maxCapacity defines the maximum size of each block (64 by default)
  40811. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  40812. * @returns the new octree
  40813. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  40814. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40815. */
  40816. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  40817. }
  40818. /**
  40819. * Defines the octree scene component responsible to manage any octrees
  40820. * in a given scene.
  40821. */
  40822. export class OctreeSceneComponent {
  40823. /**
  40824. * The component name help to identify the component in the list of scene components.
  40825. */
  40826. readonly name: string;
  40827. /**
  40828. * The scene the component belongs to.
  40829. */
  40830. scene: Scene;
  40831. /**
  40832. * Indicates if the meshes have been checked to make sure they are isEnabled()
  40833. */
  40834. readonly checksIsEnabled: boolean;
  40835. /**
  40836. * Creates a new instance of the component for the given scene
  40837. * @param scene Defines the scene to register the component in
  40838. */
  40839. constructor(scene: Scene);
  40840. /**
  40841. * Registers the component in a given scene
  40842. */
  40843. register(): void;
  40844. /**
  40845. * Return the list of active meshes
  40846. * @returns the list of active meshes
  40847. */
  40848. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  40849. /**
  40850. * Return the list of active sub meshes
  40851. * @param mesh The mesh to get the candidates sub meshes from
  40852. * @returns the list of active sub meshes
  40853. */
  40854. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  40855. private _tempRay;
  40856. /**
  40857. * Return the list of sub meshes intersecting with a given local ray
  40858. * @param mesh defines the mesh to find the submesh for
  40859. * @param localRay defines the ray in local space
  40860. * @returns the list of intersecting sub meshes
  40861. */
  40862. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  40863. /**
  40864. * Return the list of sub meshes colliding with a collider
  40865. * @param mesh defines the mesh to find the submesh for
  40866. * @param collider defines the collider to evaluate the collision against
  40867. * @returns the list of colliding sub meshes
  40868. */
  40869. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  40870. /**
  40871. * Rebuilds the elements related to this component in case of
  40872. * context lost for instance.
  40873. */
  40874. rebuild(): void;
  40875. /**
  40876. * Disposes the component and the associated ressources.
  40877. */
  40878. dispose(): void;
  40879. }
  40880. }
  40881. declare module BABYLON {
  40882. /**
  40883. * Renders a layer on top of an existing scene
  40884. */
  40885. export class UtilityLayerRenderer implements IDisposable {
  40886. /** the original scene that will be rendered on top of */
  40887. originalScene: Scene;
  40888. private _pointerCaptures;
  40889. private _lastPointerEvents;
  40890. private static _DefaultUtilityLayer;
  40891. private static _DefaultKeepDepthUtilityLayer;
  40892. private _sharedGizmoLight;
  40893. private _renderCamera;
  40894. /**
  40895. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  40896. * @returns the camera that is used when rendering the utility layer
  40897. */
  40898. getRenderCamera(): Nullable<Camera>;
  40899. /**
  40900. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  40901. * @param cam the camera that should be used when rendering the utility layer
  40902. */
  40903. setRenderCamera(cam: Nullable<Camera>): void;
  40904. /**
  40905. * @hidden
  40906. * Light which used by gizmos to get light shading
  40907. */
  40908. _getSharedGizmoLight(): HemisphericLight;
  40909. /**
  40910. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  40911. */
  40912. pickUtilitySceneFirst: boolean;
  40913. /**
  40914. * 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)
  40915. */
  40916. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  40917. /**
  40918. * 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)
  40919. */
  40920. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  40921. /**
  40922. * The scene that is rendered on top of the original scene
  40923. */
  40924. utilityLayerScene: Scene;
  40925. /**
  40926. * If the utility layer should automatically be rendered on top of existing scene
  40927. */
  40928. shouldRender: boolean;
  40929. /**
  40930. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  40931. */
  40932. onlyCheckPointerDownEvents: boolean;
  40933. /**
  40934. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  40935. */
  40936. processAllEvents: boolean;
  40937. /**
  40938. * Observable raised when the pointer move from the utility layer scene to the main scene
  40939. */
  40940. onPointerOutObservable: Observable<number>;
  40941. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  40942. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  40943. private _afterRenderObserver;
  40944. private _sceneDisposeObserver;
  40945. private _originalPointerObserver;
  40946. /**
  40947. * Instantiates a UtilityLayerRenderer
  40948. * @param originalScene the original scene that will be rendered on top of
  40949. * @param handleEvents boolean indicating if the utility layer should handle events
  40950. */
  40951. constructor(
  40952. /** the original scene that will be rendered on top of */
  40953. originalScene: Scene, handleEvents?: boolean);
  40954. private _notifyObservers;
  40955. /**
  40956. * Renders the utility layers scene on top of the original scene
  40957. */
  40958. render(): void;
  40959. /**
  40960. * Disposes of the renderer
  40961. */
  40962. dispose(): void;
  40963. private _updateCamera;
  40964. }
  40965. }
  40966. declare module BABYLON {
  40967. /**
  40968. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  40969. */
  40970. export class Gizmo implements IDisposable {
  40971. /** The utility layer the gizmo will be added to */
  40972. gizmoLayer: UtilityLayerRenderer;
  40973. /**
  40974. * The root mesh of the gizmo
  40975. */
  40976. _rootMesh: Mesh;
  40977. private _attachedMesh;
  40978. /**
  40979. * Ratio for the scale of the gizmo (Default: 1)
  40980. */
  40981. scaleRatio: number;
  40982. /**
  40983. * If a custom mesh has been set (Default: false)
  40984. */
  40985. protected _customMeshSet: boolean;
  40986. /**
  40987. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  40988. * * When set, interactions will be enabled
  40989. */
  40990. attachedMesh: Nullable<AbstractMesh>;
  40991. /**
  40992. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  40993. * @param mesh The mesh to replace the default mesh of the gizmo
  40994. */
  40995. setCustomMesh(mesh: Mesh): void;
  40996. /**
  40997. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  40998. */
  40999. updateGizmoRotationToMatchAttachedMesh: boolean;
  41000. /**
  41001. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  41002. */
  41003. updateGizmoPositionToMatchAttachedMesh: boolean;
  41004. /**
  41005. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  41006. */
  41007. protected _updateScale: boolean;
  41008. protected _interactionsEnabled: boolean;
  41009. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  41010. private _beforeRenderObserver;
  41011. private _tempVector;
  41012. /**
  41013. * Creates a gizmo
  41014. * @param gizmoLayer The utility layer the gizmo will be added to
  41015. */
  41016. constructor(
  41017. /** The utility layer the gizmo will be added to */
  41018. gizmoLayer?: UtilityLayerRenderer);
  41019. /**
  41020. * Updates the gizmo to match the attached mesh's position/rotation
  41021. */
  41022. protected _update(): void;
  41023. /**
  41024. * Disposes of the gizmo
  41025. */
  41026. dispose(): void;
  41027. }
  41028. }
  41029. declare module BABYLON {
  41030. /**
  41031. * Single plane drag gizmo
  41032. */
  41033. export class PlaneDragGizmo extends Gizmo {
  41034. /**
  41035. * Drag behavior responsible for the gizmos dragging interactions
  41036. */
  41037. dragBehavior: PointerDragBehavior;
  41038. private _pointerObserver;
  41039. /**
  41040. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  41041. */
  41042. snapDistance: number;
  41043. /**
  41044. * Event that fires each time the gizmo snaps to a new location.
  41045. * * snapDistance is the the change in distance
  41046. */
  41047. onSnapObservable: Observable<{
  41048. snapDistance: number;
  41049. }>;
  41050. private _plane;
  41051. private _coloredMaterial;
  41052. private _hoverMaterial;
  41053. private _isEnabled;
  41054. private _parent;
  41055. /** @hidden */
  41056. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  41057. /** @hidden */
  41058. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  41059. /**
  41060. * Creates a PlaneDragGizmo
  41061. * @param gizmoLayer The utility layer the gizmo will be added to
  41062. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  41063. * @param color The color of the gizmo
  41064. */
  41065. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  41066. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  41067. /**
  41068. * If the gizmo is enabled
  41069. */
  41070. isEnabled: boolean;
  41071. /**
  41072. * Disposes of the gizmo
  41073. */
  41074. dispose(): void;
  41075. }
  41076. }
  41077. declare module BABYLON {
  41078. /**
  41079. * Gizmo that enables dragging a mesh along 3 axis
  41080. */
  41081. export class PositionGizmo extends Gizmo {
  41082. /**
  41083. * Internal gizmo used for interactions on the x axis
  41084. */
  41085. xGizmo: AxisDragGizmo;
  41086. /**
  41087. * Internal gizmo used for interactions on the y axis
  41088. */
  41089. yGizmo: AxisDragGizmo;
  41090. /**
  41091. * Internal gizmo used for interactions on the z axis
  41092. */
  41093. zGizmo: AxisDragGizmo;
  41094. /**
  41095. * Internal gizmo used for interactions on the yz plane
  41096. */
  41097. xPlaneGizmo: PlaneDragGizmo;
  41098. /**
  41099. * Internal gizmo used for interactions on the xz plane
  41100. */
  41101. yPlaneGizmo: PlaneDragGizmo;
  41102. /**
  41103. * Internal gizmo used for interactions on the xy plane
  41104. */
  41105. zPlaneGizmo: PlaneDragGizmo;
  41106. /**
  41107. * private variables
  41108. */
  41109. private _meshAttached;
  41110. private _updateGizmoRotationToMatchAttachedMesh;
  41111. private _snapDistance;
  41112. private _scaleRatio;
  41113. /** Fires an event when any of it's sub gizmos are dragged */
  41114. onDragStartObservable: Observable<{}>;
  41115. /** Fires an event when any of it's sub gizmos are released from dragging */
  41116. onDragEndObservable: Observable<{}>;
  41117. /**
  41118. * If set to true, planar drag is enabled
  41119. */
  41120. private _planarGizmoEnabled;
  41121. attachedMesh: Nullable<AbstractMesh>;
  41122. /**
  41123. * Creates a PositionGizmo
  41124. * @param gizmoLayer The utility layer the gizmo will be added to
  41125. */
  41126. constructor(gizmoLayer?: UtilityLayerRenderer);
  41127. /**
  41128. * If the planar drag gizmo is enabled
  41129. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  41130. */
  41131. planarGizmoEnabled: boolean;
  41132. updateGizmoRotationToMatchAttachedMesh: boolean;
  41133. /**
  41134. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  41135. */
  41136. snapDistance: number;
  41137. /**
  41138. * Ratio for the scale of the gizmo (Default: 1)
  41139. */
  41140. scaleRatio: number;
  41141. /**
  41142. * Disposes of the gizmo
  41143. */
  41144. dispose(): void;
  41145. /**
  41146. * CustomMeshes are not supported by this gizmo
  41147. * @param mesh The mesh to replace the default mesh of the gizmo
  41148. */
  41149. setCustomMesh(mesh: Mesh): void;
  41150. }
  41151. }
  41152. declare module BABYLON {
  41153. /**
  41154. * Single axis drag gizmo
  41155. */
  41156. export class AxisDragGizmo extends Gizmo {
  41157. /**
  41158. * Drag behavior responsible for the gizmos dragging interactions
  41159. */
  41160. dragBehavior: PointerDragBehavior;
  41161. private _pointerObserver;
  41162. /**
  41163. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  41164. */
  41165. snapDistance: number;
  41166. /**
  41167. * Event that fires each time the gizmo snaps to a new location.
  41168. * * snapDistance is the the change in distance
  41169. */
  41170. onSnapObservable: Observable<{
  41171. snapDistance: number;
  41172. }>;
  41173. private _isEnabled;
  41174. private _parent;
  41175. private _arrow;
  41176. private _coloredMaterial;
  41177. private _hoverMaterial;
  41178. /** @hidden */
  41179. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  41180. /** @hidden */
  41181. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  41182. /**
  41183. * Creates an AxisDragGizmo
  41184. * @param gizmoLayer The utility layer the gizmo will be added to
  41185. * @param dragAxis The axis which the gizmo will be able to drag on
  41186. * @param color The color of the gizmo
  41187. */
  41188. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  41189. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  41190. /**
  41191. * If the gizmo is enabled
  41192. */
  41193. isEnabled: boolean;
  41194. /**
  41195. * Disposes of the gizmo
  41196. */
  41197. dispose(): void;
  41198. }
  41199. }
  41200. declare module BABYLON.Debug {
  41201. /**
  41202. * The Axes viewer will show 3 axes in a specific point in space
  41203. */
  41204. export class AxesViewer {
  41205. private _xAxis;
  41206. private _yAxis;
  41207. private _zAxis;
  41208. private _scaleLinesFactor;
  41209. private _instanced;
  41210. /**
  41211. * Gets the hosting scene
  41212. */
  41213. scene: Scene;
  41214. /**
  41215. * Gets or sets a number used to scale line length
  41216. */
  41217. scaleLines: number;
  41218. /** Gets the node hierarchy used to render x-axis */
  41219. readonly xAxis: TransformNode;
  41220. /** Gets the node hierarchy used to render y-axis */
  41221. readonly yAxis: TransformNode;
  41222. /** Gets the node hierarchy used to render z-axis */
  41223. readonly zAxis: TransformNode;
  41224. /**
  41225. * Creates a new AxesViewer
  41226. * @param scene defines the hosting scene
  41227. * @param scaleLines defines a number used to scale line length (1 by default)
  41228. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  41229. * @param xAxis defines the node hierarchy used to render the x-axis
  41230. * @param yAxis defines the node hierarchy used to render the y-axis
  41231. * @param zAxis defines the node hierarchy used to render the z-axis
  41232. */
  41233. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  41234. /**
  41235. * Force the viewer to update
  41236. * @param position defines the position of the viewer
  41237. * @param xaxis defines the x axis of the viewer
  41238. * @param yaxis defines the y axis of the viewer
  41239. * @param zaxis defines the z axis of the viewer
  41240. */
  41241. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  41242. /**
  41243. * Creates an instance of this axes viewer.
  41244. * @returns a new axes viewer with instanced meshes
  41245. */
  41246. createInstance(): AxesViewer;
  41247. /** Releases resources */
  41248. dispose(): void;
  41249. private static _SetRenderingGroupId;
  41250. }
  41251. }
  41252. declare module BABYLON.Debug {
  41253. /**
  41254. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  41255. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  41256. */
  41257. export class BoneAxesViewer extends AxesViewer {
  41258. /**
  41259. * Gets or sets the target mesh where to display the axes viewer
  41260. */
  41261. mesh: Nullable<Mesh>;
  41262. /**
  41263. * Gets or sets the target bone where to display the axes viewer
  41264. */
  41265. bone: Nullable<Bone>;
  41266. /** Gets current position */
  41267. pos: Vector3;
  41268. /** Gets direction of X axis */
  41269. xaxis: Vector3;
  41270. /** Gets direction of Y axis */
  41271. yaxis: Vector3;
  41272. /** Gets direction of Z axis */
  41273. zaxis: Vector3;
  41274. /**
  41275. * Creates a new BoneAxesViewer
  41276. * @param scene defines the hosting scene
  41277. * @param bone defines the target bone
  41278. * @param mesh defines the target mesh
  41279. * @param scaleLines defines a scaling factor for line length (1 by default)
  41280. */
  41281. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  41282. /**
  41283. * Force the viewer to update
  41284. */
  41285. update(): void;
  41286. /** Releases resources */
  41287. dispose(): void;
  41288. }
  41289. }
  41290. declare module BABYLON {
  41291. /**
  41292. * Interface used to define scene explorer extensibility option
  41293. */
  41294. export interface IExplorerExtensibilityOption {
  41295. /**
  41296. * Define the option label
  41297. */
  41298. label: string;
  41299. /**
  41300. * Defines the action to execute on click
  41301. */
  41302. action: (entity: any) => void;
  41303. }
  41304. /**
  41305. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  41306. */
  41307. export interface IExplorerExtensibilityGroup {
  41308. /**
  41309. * Defines a predicate to test if a given type mut be extended
  41310. */
  41311. predicate: (entity: any) => boolean;
  41312. /**
  41313. * Gets the list of options added to a type
  41314. */
  41315. entries: IExplorerExtensibilityOption[];
  41316. }
  41317. /**
  41318. * Interface used to define the options to use to create the Inspector
  41319. */
  41320. export interface IInspectorOptions {
  41321. /**
  41322. * Display in overlay mode (default: false)
  41323. */
  41324. overlay?: boolean;
  41325. /**
  41326. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  41327. */
  41328. globalRoot?: HTMLElement;
  41329. /**
  41330. * Display the Scene explorer
  41331. */
  41332. showExplorer?: boolean;
  41333. /**
  41334. * Display the property inspector
  41335. */
  41336. showInspector?: boolean;
  41337. /**
  41338. * Display in embed mode (both panes on the right)
  41339. */
  41340. embedMode?: boolean;
  41341. /**
  41342. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  41343. */
  41344. handleResize?: boolean;
  41345. /**
  41346. * Allow the panes to popup (default: true)
  41347. */
  41348. enablePopup?: boolean;
  41349. /**
  41350. * Allow the panes to be closed by users (default: true)
  41351. */
  41352. enableClose?: boolean;
  41353. /**
  41354. * Optional list of extensibility entries
  41355. */
  41356. explorerExtensibility?: IExplorerExtensibilityGroup[];
  41357. /**
  41358. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  41359. */
  41360. inspectorURL?: string;
  41361. }
  41362. interface Scene {
  41363. /**
  41364. * @hidden
  41365. * Backing field
  41366. */
  41367. _debugLayer: DebugLayer;
  41368. /**
  41369. * Gets the debug layer (aka Inspector) associated with the scene
  41370. * @see http://doc.babylonjs.com/features/playground_debuglayer
  41371. */
  41372. debugLayer: DebugLayer;
  41373. }
  41374. /**
  41375. * The debug layer (aka Inspector) is the go to tool in order to better understand
  41376. * what is happening in your scene
  41377. * @see http://doc.babylonjs.com/features/playground_debuglayer
  41378. */
  41379. export class DebugLayer {
  41380. /**
  41381. * Define the url to get the inspector script from.
  41382. * By default it uses the babylonjs CDN.
  41383. * @ignoreNaming
  41384. */
  41385. static InspectorURL: string;
  41386. private _scene;
  41387. private BJSINSPECTOR;
  41388. /**
  41389. * Observable triggered when a property is changed through the inspector.
  41390. */
  41391. onPropertyChangedObservable: Observable<{
  41392. object: any;
  41393. property: string;
  41394. value: any;
  41395. initialValue: any;
  41396. }>;
  41397. /**
  41398. * Instantiates a new debug layer.
  41399. * The debug layer (aka Inspector) is the go to tool in order to better understand
  41400. * what is happening in your scene
  41401. * @see http://doc.babylonjs.com/features/playground_debuglayer
  41402. * @param scene Defines the scene to inspect
  41403. */
  41404. constructor(scene: Scene);
  41405. /** Creates the inspector window. */
  41406. private _createInspector;
  41407. /**
  41408. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  41409. * @param entity defines the entity to select
  41410. * @param lineContainerTitle defines the specific block to highlight
  41411. */
  41412. select(entity: any, lineContainerTitle?: string): void;
  41413. /** Get the inspector from bundle or global */
  41414. private _getGlobalInspector;
  41415. /**
  41416. * Get if the inspector is visible or not.
  41417. * @returns true if visible otherwise, false
  41418. */
  41419. isVisible(): boolean;
  41420. /**
  41421. * Hide the inspector and close its window.
  41422. */
  41423. hide(): void;
  41424. /**
  41425. * Launch the debugLayer.
  41426. * @param config Define the configuration of the inspector
  41427. * @return a promise fulfilled when the debug layer is visible
  41428. */
  41429. show(config?: IInspectorOptions): Promise<DebugLayer>;
  41430. }
  41431. }
  41432. declare module BABYLON {
  41433. /**
  41434. * Class containing static functions to help procedurally build meshes
  41435. */
  41436. export class BoxBuilder {
  41437. /**
  41438. * Creates a box mesh
  41439. * * The parameter `size` sets the size (float) of each box side (default 1)
  41440. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  41441. * * 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)
  41442. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  41443. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  41444. * * 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
  41445. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41446. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  41447. * @param name defines the name of the mesh
  41448. * @param options defines the options used to create the mesh
  41449. * @param scene defines the hosting scene
  41450. * @returns the box mesh
  41451. */
  41452. static CreateBox(name: string, options: {
  41453. size?: number;
  41454. width?: number;
  41455. height?: number;
  41456. depth?: number;
  41457. faceUV?: Vector4[];
  41458. faceColors?: Color4[];
  41459. sideOrientation?: number;
  41460. frontUVs?: Vector4;
  41461. backUVs?: Vector4;
  41462. wrap?: boolean;
  41463. topBaseAt?: number;
  41464. bottomBaseAt?: number;
  41465. updatable?: boolean;
  41466. }, scene?: Nullable<Scene>): Mesh;
  41467. }
  41468. }
  41469. declare module BABYLON {
  41470. /**
  41471. * Class containing static functions to help procedurally build meshes
  41472. */
  41473. export class SphereBuilder {
  41474. /**
  41475. * Creates a sphere mesh
  41476. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  41477. * * 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`)
  41478. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  41479. * * 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
  41480. * * 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)
  41481. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  41482. * * 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
  41483. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41484. * @param name defines the name of the mesh
  41485. * @param options defines the options used to create the mesh
  41486. * @param scene defines the hosting scene
  41487. * @returns the sphere mesh
  41488. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  41489. */
  41490. static CreateSphere(name: string, options: {
  41491. segments?: number;
  41492. diameter?: number;
  41493. diameterX?: number;
  41494. diameterY?: number;
  41495. diameterZ?: number;
  41496. arc?: number;
  41497. slice?: number;
  41498. sideOrientation?: number;
  41499. frontUVs?: Vector4;
  41500. backUVs?: Vector4;
  41501. updatable?: boolean;
  41502. }, scene: any): Mesh;
  41503. }
  41504. }
  41505. declare module BABYLON.Debug {
  41506. /**
  41507. * Used to show the physics impostor around the specific mesh
  41508. */
  41509. export class PhysicsViewer {
  41510. /** @hidden */
  41511. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  41512. /** @hidden */
  41513. protected _meshes: Array<Nullable<AbstractMesh>>;
  41514. /** @hidden */
  41515. protected _scene: Nullable<Scene>;
  41516. /** @hidden */
  41517. protected _numMeshes: number;
  41518. /** @hidden */
  41519. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  41520. private _renderFunction;
  41521. private _utilityLayer;
  41522. private _debugBoxMesh;
  41523. private _debugSphereMesh;
  41524. private _debugCylinderMesh;
  41525. private _debugMaterial;
  41526. private _debugMeshMeshes;
  41527. /**
  41528. * Creates a new PhysicsViewer
  41529. * @param scene defines the hosting scene
  41530. */
  41531. constructor(scene: Scene);
  41532. /** @hidden */
  41533. protected _updateDebugMeshes(): void;
  41534. /**
  41535. * Renders a specified physic impostor
  41536. * @param impostor defines the impostor to render
  41537. * @param targetMesh defines the mesh represented by the impostor
  41538. * @returns the new debug mesh used to render the impostor
  41539. */
  41540. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  41541. /**
  41542. * Hides a specified physic impostor
  41543. * @param impostor defines the impostor to hide
  41544. */
  41545. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  41546. private _getDebugMaterial;
  41547. private _getDebugBoxMesh;
  41548. private _getDebugSphereMesh;
  41549. private _getDebugCylinderMesh;
  41550. private _getDebugMeshMesh;
  41551. private _getDebugMesh;
  41552. /** Releases all resources */
  41553. dispose(): void;
  41554. }
  41555. }
  41556. declare module BABYLON {
  41557. /**
  41558. * Class containing static functions to help procedurally build meshes
  41559. */
  41560. export class LinesBuilder {
  41561. /**
  41562. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  41563. * * 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
  41564. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  41565. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  41566. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  41567. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  41568. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  41569. * * 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
  41570. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  41571. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41572. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  41573. * @param name defines the name of the new line system
  41574. * @param options defines the options used to create the line system
  41575. * @param scene defines the hosting scene
  41576. * @returns a new line system mesh
  41577. */
  41578. static CreateLineSystem(name: string, options: {
  41579. lines: Vector3[][];
  41580. updatable?: boolean;
  41581. instance?: Nullable<LinesMesh>;
  41582. colors?: Nullable<Color4[][]>;
  41583. useVertexAlpha?: boolean;
  41584. }, scene: Nullable<Scene>): LinesMesh;
  41585. /**
  41586. * Creates a line mesh
  41587. * 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
  41588. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  41589. * * The parameter `points` is an array successive Vector3
  41590. * * 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
  41591. * * The optional parameter `colors` is an array of successive Color4, one per line point
  41592. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  41593. * * When updating an instance, remember that only point positions can change, not the number of points
  41594. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41595. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  41596. * @param name defines the name of the new line system
  41597. * @param options defines the options used to create the line system
  41598. * @param scene defines the hosting scene
  41599. * @returns a new line mesh
  41600. */
  41601. static CreateLines(name: string, options: {
  41602. points: Vector3[];
  41603. updatable?: boolean;
  41604. instance?: Nullable<LinesMesh>;
  41605. colors?: Color4[];
  41606. useVertexAlpha?: boolean;
  41607. }, scene?: Nullable<Scene>): LinesMesh;
  41608. /**
  41609. * Creates a dashed line mesh
  41610. * * 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
  41611. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  41612. * * The parameter `points` is an array successive Vector3
  41613. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  41614. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  41615. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  41616. * * 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
  41617. * * When updating an instance, remember that only point positions can change, not the number of points
  41618. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41619. * @param name defines the name of the mesh
  41620. * @param options defines the options used to create the mesh
  41621. * @param scene defines the hosting scene
  41622. * @returns the dashed line mesh
  41623. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  41624. */
  41625. static CreateDashedLines(name: string, options: {
  41626. points: Vector3[];
  41627. dashSize?: number;
  41628. gapSize?: number;
  41629. dashNb?: number;
  41630. updatable?: boolean;
  41631. instance?: LinesMesh;
  41632. }, scene?: Nullable<Scene>): LinesMesh;
  41633. }
  41634. }
  41635. declare module BABYLON {
  41636. /**
  41637. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  41638. * in order to better appreciate the issue one might have.
  41639. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  41640. */
  41641. export class RayHelper {
  41642. /**
  41643. * Defines the ray we are currently tryin to visualize.
  41644. */
  41645. ray: Nullable<Ray>;
  41646. private _renderPoints;
  41647. private _renderLine;
  41648. private _renderFunction;
  41649. private _scene;
  41650. private _updateToMeshFunction;
  41651. private _attachedToMesh;
  41652. private _meshSpaceDirection;
  41653. private _meshSpaceOrigin;
  41654. /**
  41655. * Helper function to create a colored helper in a scene in one line.
  41656. * @param ray Defines the ray we are currently tryin to visualize
  41657. * @param scene Defines the scene the ray is used in
  41658. * @param color Defines the color we want to see the ray in
  41659. * @returns The newly created ray helper.
  41660. */
  41661. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  41662. /**
  41663. * Instantiate a new ray helper.
  41664. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  41665. * in order to better appreciate the issue one might have.
  41666. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  41667. * @param ray Defines the ray we are currently tryin to visualize
  41668. */
  41669. constructor(ray: Ray);
  41670. /**
  41671. * Shows the ray we are willing to debug.
  41672. * @param scene Defines the scene the ray needs to be rendered in
  41673. * @param color Defines the color the ray needs to be rendered in
  41674. */
  41675. show(scene: Scene, color?: Color3): void;
  41676. /**
  41677. * Hides the ray we are debugging.
  41678. */
  41679. hide(): void;
  41680. private _render;
  41681. /**
  41682. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  41683. * @param mesh Defines the mesh we want the helper attached to
  41684. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  41685. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  41686. * @param length Defines the length of the ray
  41687. */
  41688. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  41689. /**
  41690. * Detach the ray helper from the mesh it has previously been attached to.
  41691. */
  41692. detachFromMesh(): void;
  41693. private _updateToMesh;
  41694. /**
  41695. * Dispose the helper and release its associated resources.
  41696. */
  41697. dispose(): void;
  41698. }
  41699. }
  41700. declare module BABYLON.Debug {
  41701. /**
  41702. * Class used to render a debug view of a given skeleton
  41703. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  41704. */
  41705. export class SkeletonViewer {
  41706. /** defines the skeleton to render */
  41707. skeleton: Skeleton;
  41708. /** defines the mesh attached to the skeleton */
  41709. mesh: AbstractMesh;
  41710. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  41711. autoUpdateBonesMatrices: boolean;
  41712. /** defines the rendering group id to use with the viewer */
  41713. renderingGroupId: number;
  41714. /** Gets or sets the color used to render the skeleton */
  41715. color: Color3;
  41716. private _scene;
  41717. private _debugLines;
  41718. private _debugMesh;
  41719. private _isEnabled;
  41720. private _renderFunction;
  41721. private _utilityLayer;
  41722. /**
  41723. * Returns the mesh used to render the bones
  41724. */
  41725. readonly debugMesh: Nullable<LinesMesh>;
  41726. /**
  41727. * Creates a new SkeletonViewer
  41728. * @param skeleton defines the skeleton to render
  41729. * @param mesh defines the mesh attached to the skeleton
  41730. * @param scene defines the hosting scene
  41731. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  41732. * @param renderingGroupId defines the rendering group id to use with the viewer
  41733. */
  41734. constructor(
  41735. /** defines the skeleton to render */
  41736. skeleton: Skeleton,
  41737. /** defines the mesh attached to the skeleton */
  41738. mesh: AbstractMesh, scene: Scene,
  41739. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  41740. autoUpdateBonesMatrices?: boolean,
  41741. /** defines the rendering group id to use with the viewer */
  41742. renderingGroupId?: number);
  41743. /** Gets or sets a boolean indicating if the viewer is enabled */
  41744. isEnabled: boolean;
  41745. private _getBonePosition;
  41746. private _getLinesForBonesWithLength;
  41747. private _getLinesForBonesNoLength;
  41748. /** Update the viewer to sync with current skeleton state */
  41749. update(): void;
  41750. /** Release associated resources */
  41751. dispose(): void;
  41752. }
  41753. }
  41754. declare module BABYLON {
  41755. /**
  41756. * Options to create the null engine
  41757. */
  41758. export class NullEngineOptions {
  41759. /**
  41760. * Render width (Default: 512)
  41761. */
  41762. renderWidth: number;
  41763. /**
  41764. * Render height (Default: 256)
  41765. */
  41766. renderHeight: number;
  41767. /**
  41768. * Texture size (Default: 512)
  41769. */
  41770. textureSize: number;
  41771. /**
  41772. * If delta time between frames should be constant
  41773. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41774. */
  41775. deterministicLockstep: boolean;
  41776. /**
  41777. * Maximum about of steps between frames (Default: 4)
  41778. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41779. */
  41780. lockstepMaxSteps: number;
  41781. }
  41782. /**
  41783. * The null engine class provides support for headless version of babylon.js.
  41784. * This can be used in server side scenario or for testing purposes
  41785. */
  41786. export class NullEngine extends Engine {
  41787. private _options;
  41788. /**
  41789. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41790. */
  41791. isDeterministicLockStep(): boolean;
  41792. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  41793. getLockstepMaxSteps(): number;
  41794. /**
  41795. * Sets hardware scaling, used to save performance if needed
  41796. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  41797. */
  41798. getHardwareScalingLevel(): number;
  41799. constructor(options?: NullEngineOptions);
  41800. createVertexBuffer(vertices: FloatArray): DataBuffer;
  41801. createIndexBuffer(indices: IndicesArray): DataBuffer;
  41802. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  41803. getRenderWidth(useScreen?: boolean): number;
  41804. getRenderHeight(useScreen?: boolean): number;
  41805. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  41806. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  41807. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  41808. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  41809. bindSamplers(effect: Effect): void;
  41810. enableEffect(effect: Effect): void;
  41811. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  41812. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  41813. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  41814. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  41815. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  41816. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  41817. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  41818. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  41819. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  41820. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  41821. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  41822. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  41823. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  41824. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  41825. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  41826. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  41827. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  41828. setFloat(uniform: WebGLUniformLocation, value: number): void;
  41829. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  41830. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  41831. setBool(uniform: WebGLUniformLocation, bool: number): void;
  41832. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  41833. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  41834. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  41835. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  41836. bindBuffers(vertexBuffers: {
  41837. [key: string]: VertexBuffer;
  41838. }, indexBuffer: DataBuffer, effect: Effect): void;
  41839. wipeCaches(bruteForce?: boolean): void;
  41840. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  41841. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  41842. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  41843. /** @hidden */
  41844. _createTexture(): WebGLTexture;
  41845. /** @hidden */
  41846. _releaseTexture(texture: InternalTexture): void;
  41847. 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;
  41848. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  41849. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  41850. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  41851. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  41852. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  41853. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  41854. areAllEffectsReady(): boolean;
  41855. /**
  41856. * @hidden
  41857. * Get the current error code of the webGL context
  41858. * @returns the error code
  41859. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  41860. */
  41861. getError(): number;
  41862. /** @hidden */
  41863. _getUnpackAlignement(): number;
  41864. /** @hidden */
  41865. _unpackFlipY(value: boolean): void;
  41866. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  41867. /**
  41868. * Updates a dynamic vertex buffer.
  41869. * @param vertexBuffer the vertex buffer to update
  41870. * @param data the data used to update the vertex buffer
  41871. * @param byteOffset the byte offset of the data (optional)
  41872. * @param byteLength the byte length of the data (optional)
  41873. */
  41874. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  41875. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  41876. /** @hidden */
  41877. _bindTexture(channel: number, texture: InternalTexture): void;
  41878. /** @hidden */
  41879. _releaseBuffer(buffer: DataBuffer): boolean;
  41880. releaseEffects(): void;
  41881. displayLoadingUI(): void;
  41882. hideLoadingUI(): void;
  41883. /** @hidden */
  41884. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  41885. /** @hidden */
  41886. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  41887. /** @hidden */
  41888. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  41889. /** @hidden */
  41890. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  41891. }
  41892. }
  41893. declare module BABYLON {
  41894. /** @hidden */
  41895. export class _OcclusionDataStorage {
  41896. /** @hidden */
  41897. occlusionInternalRetryCounter: number;
  41898. /** @hidden */
  41899. isOcclusionQueryInProgress: boolean;
  41900. /** @hidden */
  41901. isOccluded: boolean;
  41902. /** @hidden */
  41903. occlusionRetryCount: number;
  41904. /** @hidden */
  41905. occlusionType: number;
  41906. /** @hidden */
  41907. occlusionQueryAlgorithmType: number;
  41908. }
  41909. interface Engine {
  41910. /**
  41911. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  41912. * @return the new query
  41913. */
  41914. createQuery(): WebGLQuery;
  41915. /**
  41916. * Delete and release a webGL query
  41917. * @param query defines the query to delete
  41918. * @return the current engine
  41919. */
  41920. deleteQuery(query: WebGLQuery): Engine;
  41921. /**
  41922. * Check if a given query has resolved and got its value
  41923. * @param query defines the query to check
  41924. * @returns true if the query got its value
  41925. */
  41926. isQueryResultAvailable(query: WebGLQuery): boolean;
  41927. /**
  41928. * Gets the value of a given query
  41929. * @param query defines the query to check
  41930. * @returns the value of the query
  41931. */
  41932. getQueryResult(query: WebGLQuery): number;
  41933. /**
  41934. * Initiates an occlusion query
  41935. * @param algorithmType defines the algorithm to use
  41936. * @param query defines the query to use
  41937. * @returns the current engine
  41938. * @see http://doc.babylonjs.com/features/occlusionquery
  41939. */
  41940. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  41941. /**
  41942. * Ends an occlusion query
  41943. * @see http://doc.babylonjs.com/features/occlusionquery
  41944. * @param algorithmType defines the algorithm to use
  41945. * @returns the current engine
  41946. */
  41947. endOcclusionQuery(algorithmType: number): Engine;
  41948. /**
  41949. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  41950. * Please note that only one query can be issued at a time
  41951. * @returns a time token used to track the time span
  41952. */
  41953. startTimeQuery(): Nullable<_TimeToken>;
  41954. /**
  41955. * Ends a time query
  41956. * @param token defines the token used to measure the time span
  41957. * @returns the time spent (in ns)
  41958. */
  41959. endTimeQuery(token: _TimeToken): int;
  41960. /** @hidden */
  41961. _currentNonTimestampToken: Nullable<_TimeToken>;
  41962. /** @hidden */
  41963. _createTimeQuery(): WebGLQuery;
  41964. /** @hidden */
  41965. _deleteTimeQuery(query: WebGLQuery): void;
  41966. /** @hidden */
  41967. _getGlAlgorithmType(algorithmType: number): number;
  41968. /** @hidden */
  41969. _getTimeQueryResult(query: WebGLQuery): any;
  41970. /** @hidden */
  41971. _getTimeQueryAvailability(query: WebGLQuery): any;
  41972. }
  41973. interface AbstractMesh {
  41974. /**
  41975. * Backing filed
  41976. * @hidden
  41977. */
  41978. __occlusionDataStorage: _OcclusionDataStorage;
  41979. /**
  41980. * Access property
  41981. * @hidden
  41982. */
  41983. _occlusionDataStorage: _OcclusionDataStorage;
  41984. /**
  41985. * 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.
  41986. * The default value is -1 which means don't break the query and wait till the result
  41987. * @see http://doc.babylonjs.com/features/occlusionquery
  41988. */
  41989. occlusionRetryCount: number;
  41990. /**
  41991. * 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:
  41992. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  41993. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  41994. * * 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.
  41995. * @see http://doc.babylonjs.com/features/occlusionquery
  41996. */
  41997. occlusionType: number;
  41998. /**
  41999. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  42000. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  42001. * * 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.
  42002. * @see http://doc.babylonjs.com/features/occlusionquery
  42003. */
  42004. occlusionQueryAlgorithmType: number;
  42005. /**
  42006. * 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
  42007. * @see http://doc.babylonjs.com/features/occlusionquery
  42008. */
  42009. isOccluded: boolean;
  42010. /**
  42011. * Flag to check the progress status of the query
  42012. * @see http://doc.babylonjs.com/features/occlusionquery
  42013. */
  42014. isOcclusionQueryInProgress: boolean;
  42015. }
  42016. }
  42017. declare module BABYLON {
  42018. /** @hidden */
  42019. export var _forceTransformFeedbackToBundle: boolean;
  42020. interface Engine {
  42021. /**
  42022. * Creates a webGL transform feedback object
  42023. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  42024. * @returns the webGL transform feedback object
  42025. */
  42026. createTransformFeedback(): WebGLTransformFeedback;
  42027. /**
  42028. * Delete a webGL transform feedback object
  42029. * @param value defines the webGL transform feedback object to delete
  42030. */
  42031. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  42032. /**
  42033. * Bind a webGL transform feedback object to the webgl context
  42034. * @param value defines the webGL transform feedback object to bind
  42035. */
  42036. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  42037. /**
  42038. * Begins a transform feedback operation
  42039. * @param usePoints defines if points or triangles must be used
  42040. */
  42041. beginTransformFeedback(usePoints: boolean): void;
  42042. /**
  42043. * Ends a transform feedback operation
  42044. */
  42045. endTransformFeedback(): void;
  42046. /**
  42047. * Specify the varyings to use with transform feedback
  42048. * @param program defines the associated webGL program
  42049. * @param value defines the list of strings representing the varying names
  42050. */
  42051. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  42052. /**
  42053. * Bind a webGL buffer for a transform feedback operation
  42054. * @param value defines the webGL buffer to bind
  42055. */
  42056. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  42057. }
  42058. }
  42059. declare module BABYLON {
  42060. /**
  42061. * Creation options of the multi render target texture.
  42062. */
  42063. export interface IMultiRenderTargetOptions {
  42064. /**
  42065. * Define if the texture needs to create mip maps after render.
  42066. */
  42067. generateMipMaps?: boolean;
  42068. /**
  42069. * Define the types of all the draw buffers we want to create
  42070. */
  42071. types?: number[];
  42072. /**
  42073. * Define the sampling modes of all the draw buffers we want to create
  42074. */
  42075. samplingModes?: number[];
  42076. /**
  42077. * Define if a depth buffer is required
  42078. */
  42079. generateDepthBuffer?: boolean;
  42080. /**
  42081. * Define if a stencil buffer is required
  42082. */
  42083. generateStencilBuffer?: boolean;
  42084. /**
  42085. * Define if a depth texture is required instead of a depth buffer
  42086. */
  42087. generateDepthTexture?: boolean;
  42088. /**
  42089. * Define the number of desired draw buffers
  42090. */
  42091. textureCount?: number;
  42092. /**
  42093. * Define if aspect ratio should be adapted to the texture or stay the scene one
  42094. */
  42095. doNotChangeAspectRatio?: boolean;
  42096. /**
  42097. * Define the default type of the buffers we are creating
  42098. */
  42099. defaultType?: number;
  42100. }
  42101. /**
  42102. * A multi render target, like a render target provides the ability to render to a texture.
  42103. * Unlike the render target, it can render to several draw buffers in one draw.
  42104. * This is specially interesting in deferred rendering or for any effects requiring more than
  42105. * just one color from a single pass.
  42106. */
  42107. export class MultiRenderTarget extends RenderTargetTexture {
  42108. private _internalTextures;
  42109. private _textures;
  42110. private _multiRenderTargetOptions;
  42111. /**
  42112. * Get if draw buffers are currently supported by the used hardware and browser.
  42113. */
  42114. readonly isSupported: boolean;
  42115. /**
  42116. * Get the list of textures generated by the multi render target.
  42117. */
  42118. readonly textures: Texture[];
  42119. /**
  42120. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  42121. */
  42122. readonly depthTexture: Texture;
  42123. /**
  42124. * Set the wrapping mode on U of all the textures we are rendering to.
  42125. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  42126. */
  42127. wrapU: number;
  42128. /**
  42129. * Set the wrapping mode on V of all the textures we are rendering to.
  42130. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  42131. */
  42132. wrapV: number;
  42133. /**
  42134. * Instantiate a new multi render target texture.
  42135. * A multi render target, like a render target provides the ability to render to a texture.
  42136. * Unlike the render target, it can render to several draw buffers in one draw.
  42137. * This is specially interesting in deferred rendering or for any effects requiring more than
  42138. * just one color from a single pass.
  42139. * @param name Define the name of the texture
  42140. * @param size Define the size of the buffers to render to
  42141. * @param count Define the number of target we are rendering into
  42142. * @param scene Define the scene the texture belongs to
  42143. * @param options Define the options used to create the multi render target
  42144. */
  42145. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  42146. /** @hidden */
  42147. _rebuild(): void;
  42148. private _createInternalTextures;
  42149. private _createTextures;
  42150. /**
  42151. * Define the number of samples used if MSAA is enabled.
  42152. */
  42153. samples: number;
  42154. /**
  42155. * Resize all the textures in the multi render target.
  42156. * Be carrefull as it will recreate all the data in the new texture.
  42157. * @param size Define the new size
  42158. */
  42159. resize(size: any): void;
  42160. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  42161. /**
  42162. * Dispose the render targets and their associated resources
  42163. */
  42164. dispose(): void;
  42165. /**
  42166. * Release all the underlying texture used as draw buffers.
  42167. */
  42168. releaseInternalTextures(): void;
  42169. }
  42170. }
  42171. declare module BABYLON {
  42172. interface Engine {
  42173. /**
  42174. * Unbind a list of render target textures from the webGL context
  42175. * This is used only when drawBuffer extension or webGL2 are active
  42176. * @param textures defines the render target textures to unbind
  42177. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  42178. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  42179. */
  42180. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  42181. /**
  42182. * Create a multi render target texture
  42183. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  42184. * @param size defines the size of the texture
  42185. * @param options defines the creation options
  42186. * @returns the cube texture as an InternalTexture
  42187. */
  42188. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  42189. /**
  42190. * Update the sample count for a given multiple render target texture
  42191. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  42192. * @param textures defines the textures to update
  42193. * @param samples defines the sample count to set
  42194. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  42195. */
  42196. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  42197. }
  42198. }
  42199. declare module BABYLON {
  42200. /**
  42201. * Gather the list of clipboard event types as constants.
  42202. */
  42203. export class ClipboardEventTypes {
  42204. /**
  42205. * The clipboard event is fired when a copy command is active (pressed).
  42206. */
  42207. static readonly COPY: number;
  42208. /**
  42209. * The clipboard event is fired when a cut command is active (pressed).
  42210. */
  42211. static readonly CUT: number;
  42212. /**
  42213. * The clipboard event is fired when a paste command is active (pressed).
  42214. */
  42215. static readonly PASTE: number;
  42216. }
  42217. /**
  42218. * This class is used to store clipboard related info for the onClipboardObservable event.
  42219. */
  42220. export class ClipboardInfo {
  42221. /**
  42222. * Defines the type of event (BABYLON.ClipboardEventTypes)
  42223. */
  42224. type: number;
  42225. /**
  42226. * Defines the related dom event
  42227. */
  42228. event: ClipboardEvent;
  42229. /**
  42230. *Creates an instance of ClipboardInfo.
  42231. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  42232. * @param event Defines the related dom event
  42233. */
  42234. constructor(
  42235. /**
  42236. * Defines the type of event (BABYLON.ClipboardEventTypes)
  42237. */
  42238. type: number,
  42239. /**
  42240. * Defines the related dom event
  42241. */
  42242. event: ClipboardEvent);
  42243. /**
  42244. * Get the clipboard event's type from the keycode.
  42245. * @param keyCode Defines the keyCode for the current keyboard event.
  42246. * @return {number}
  42247. */
  42248. static GetTypeFromCharacter(keyCode: number): number;
  42249. }
  42250. }
  42251. declare module BABYLON {
  42252. /**
  42253. * Class used to represent data loading progression
  42254. */
  42255. export class SceneLoaderProgressEvent {
  42256. /** defines if data length to load can be evaluated */
  42257. readonly lengthComputable: boolean;
  42258. /** defines the loaded data length */
  42259. readonly loaded: number;
  42260. /** defines the data length to load */
  42261. readonly total: number;
  42262. /**
  42263. * Create a new progress event
  42264. * @param lengthComputable defines if data length to load can be evaluated
  42265. * @param loaded defines the loaded data length
  42266. * @param total defines the data length to load
  42267. */
  42268. constructor(
  42269. /** defines if data length to load can be evaluated */
  42270. lengthComputable: boolean,
  42271. /** defines the loaded data length */
  42272. loaded: number,
  42273. /** defines the data length to load */
  42274. total: number);
  42275. /**
  42276. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  42277. * @param event defines the source event
  42278. * @returns a new SceneLoaderProgressEvent
  42279. */
  42280. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  42281. }
  42282. /**
  42283. * Interface used by SceneLoader plugins to define supported file extensions
  42284. */
  42285. export interface ISceneLoaderPluginExtensions {
  42286. /**
  42287. * Defines the list of supported extensions
  42288. */
  42289. [extension: string]: {
  42290. isBinary: boolean;
  42291. };
  42292. }
  42293. /**
  42294. * Interface used by SceneLoader plugin factory
  42295. */
  42296. export interface ISceneLoaderPluginFactory {
  42297. /**
  42298. * Defines the name of the factory
  42299. */
  42300. name: string;
  42301. /**
  42302. * Function called to create a new plugin
  42303. * @return the new plugin
  42304. */
  42305. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  42306. /**
  42307. * Boolean indicating if the plugin can direct load specific data
  42308. */
  42309. canDirectLoad?: (data: string) => boolean;
  42310. }
  42311. /**
  42312. * Interface used to define a SceneLoader plugin
  42313. */
  42314. export interface ISceneLoaderPlugin {
  42315. /**
  42316. * The friendly name of this plugin.
  42317. */
  42318. name: string;
  42319. /**
  42320. * The file extensions supported by this plugin.
  42321. */
  42322. extensions: string | ISceneLoaderPluginExtensions;
  42323. /**
  42324. * Import meshes into a scene.
  42325. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42326. * @param scene The scene to import into
  42327. * @param data The data to import
  42328. * @param rootUrl The root url for scene and resources
  42329. * @param meshes The meshes array to import into
  42330. * @param particleSystems The particle systems array to import into
  42331. * @param skeletons The skeletons array to import into
  42332. * @param onError The callback when import fails
  42333. * @returns True if successful or false otherwise
  42334. */
  42335. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  42336. /**
  42337. * Load into a scene.
  42338. * @param scene The scene to load into
  42339. * @param data The data to import
  42340. * @param rootUrl The root url for scene and resources
  42341. * @param onError The callback when import fails
  42342. * @returns true if successful or false otherwise
  42343. */
  42344. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  42345. /**
  42346. * The callback that returns true if the data can be directly loaded.
  42347. */
  42348. canDirectLoad?: (data: string) => boolean;
  42349. /**
  42350. * The callback that allows custom handling of the root url based on the response url.
  42351. */
  42352. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  42353. /**
  42354. * Load into an asset container.
  42355. * @param scene The scene to load into
  42356. * @param data The data to import
  42357. * @param rootUrl The root url for scene and resources
  42358. * @param onError The callback when import fails
  42359. * @returns The loaded asset container
  42360. */
  42361. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  42362. }
  42363. /**
  42364. * Interface used to define an async SceneLoader plugin
  42365. */
  42366. export interface ISceneLoaderPluginAsync {
  42367. /**
  42368. * The friendly name of this plugin.
  42369. */
  42370. name: string;
  42371. /**
  42372. * The file extensions supported by this plugin.
  42373. */
  42374. extensions: string | ISceneLoaderPluginExtensions;
  42375. /**
  42376. * Import meshes into a scene.
  42377. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42378. * @param scene The scene to import into
  42379. * @param data The data to import
  42380. * @param rootUrl The root url for scene and resources
  42381. * @param onProgress The callback when the load progresses
  42382. * @param fileName Defines the name of the file to load
  42383. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  42384. */
  42385. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  42386. meshes: AbstractMesh[];
  42387. particleSystems: IParticleSystem[];
  42388. skeletons: Skeleton[];
  42389. animationGroups: AnimationGroup[];
  42390. }>;
  42391. /**
  42392. * Load into a scene.
  42393. * @param scene The scene to load into
  42394. * @param data The data to import
  42395. * @param rootUrl The root url for scene and resources
  42396. * @param onProgress The callback when the load progresses
  42397. * @param fileName Defines the name of the file to load
  42398. * @returns Nothing
  42399. */
  42400. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  42401. /**
  42402. * The callback that returns true if the data can be directly loaded.
  42403. */
  42404. canDirectLoad?: (data: string) => boolean;
  42405. /**
  42406. * The callback that allows custom handling of the root url based on the response url.
  42407. */
  42408. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  42409. /**
  42410. * Load into an asset container.
  42411. * @param scene The scene to load into
  42412. * @param data The data to import
  42413. * @param rootUrl The root url for scene and resources
  42414. * @param onProgress The callback when the load progresses
  42415. * @param fileName Defines the name of the file to load
  42416. * @returns The loaded asset container
  42417. */
  42418. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  42419. }
  42420. /**
  42421. * Class used to load scene from various file formats using registered plugins
  42422. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  42423. */
  42424. export class SceneLoader {
  42425. /**
  42426. * No logging while loading
  42427. */
  42428. static readonly NO_LOGGING: number;
  42429. /**
  42430. * Minimal logging while loading
  42431. */
  42432. static readonly MINIMAL_LOGGING: number;
  42433. /**
  42434. * Summary logging while loading
  42435. */
  42436. static readonly SUMMARY_LOGGING: number;
  42437. /**
  42438. * Detailled logging while loading
  42439. */
  42440. static readonly DETAILED_LOGGING: number;
  42441. /**
  42442. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  42443. */
  42444. static ForceFullSceneLoadingForIncremental: boolean;
  42445. /**
  42446. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  42447. */
  42448. static ShowLoadingScreen: boolean;
  42449. /**
  42450. * Defines the current logging level (while loading the scene)
  42451. * @ignorenaming
  42452. */
  42453. static loggingLevel: number;
  42454. /**
  42455. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  42456. */
  42457. static CleanBoneMatrixWeights: boolean;
  42458. /**
  42459. * Event raised when a plugin is used to load a scene
  42460. */
  42461. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  42462. private static _registeredPlugins;
  42463. private static _getDefaultPlugin;
  42464. private static _getPluginForExtension;
  42465. private static _getPluginForDirectLoad;
  42466. private static _getPluginForFilename;
  42467. private static _getDirectLoad;
  42468. private static _loadData;
  42469. private static _getFileInfo;
  42470. /**
  42471. * Gets a plugin that can load the given extension
  42472. * @param extension defines the extension to load
  42473. * @returns a plugin or null if none works
  42474. */
  42475. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  42476. /**
  42477. * Gets a boolean indicating that the given extension can be loaded
  42478. * @param extension defines the extension to load
  42479. * @returns true if the extension is supported
  42480. */
  42481. static IsPluginForExtensionAvailable(extension: string): boolean;
  42482. /**
  42483. * Adds a new plugin to the list of registered plugins
  42484. * @param plugin defines the plugin to add
  42485. */
  42486. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  42487. /**
  42488. * Import meshes into a scene
  42489. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42490. * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)
  42491. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene or a File object (default: empty string)
  42492. * @param scene the instance of BABYLON.Scene to append to
  42493. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  42494. * @param onProgress a callback with a progress event for each file being loaded
  42495. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42496. * @param pluginExtension the extension used to determine the plugin
  42497. * @returns The loaded plugin
  42498. */
  42499. 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>;
  42500. /**
  42501. * Import meshes into a scene
  42502. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42503. * @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)
  42504. * @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)
  42505. * @param scene the instance of BABYLON.Scene to append to
  42506. * @param onProgress a callback with a progress event for each file being loaded
  42507. * @param pluginExtension the extension used to determine the plugin
  42508. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  42509. */
  42510. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  42511. meshes: AbstractMesh[];
  42512. particleSystems: IParticleSystem[];
  42513. skeletons: Skeleton[];
  42514. animationGroups: AnimationGroup[];
  42515. }>;
  42516. /**
  42517. * Load a scene
  42518. * @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)
  42519. * @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)
  42520. * @param engine is the instance of BABYLON.Engine to use to create the scene
  42521. * @param onSuccess a callback with the scene when import succeeds
  42522. * @param onProgress a callback with a progress event for each file being loaded
  42523. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42524. * @param pluginExtension the extension used to determine the plugin
  42525. * @returns The loaded plugin
  42526. */
  42527. 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>;
  42528. /**
  42529. * Load a scene
  42530. * @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)
  42531. * @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)
  42532. * @param engine is the instance of BABYLON.Engine to use to create the scene
  42533. * @param onProgress a callback with a progress event for each file being loaded
  42534. * @param pluginExtension the extension used to determine the plugin
  42535. * @returns The loaded scene
  42536. */
  42537. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  42538. /**
  42539. * Append a scene
  42540. * @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)
  42541. * @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)
  42542. * @param scene is the instance of BABYLON.Scene to append to
  42543. * @param onSuccess a callback with the scene when import succeeds
  42544. * @param onProgress a callback with a progress event for each file being loaded
  42545. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42546. * @param pluginExtension the extension used to determine the plugin
  42547. * @returns The loaded plugin
  42548. */
  42549. 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>;
  42550. /**
  42551. * Append a scene
  42552. * @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)
  42553. * @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)
  42554. * @param scene is the instance of BABYLON.Scene to append to
  42555. * @param onProgress a callback with a progress event for each file being loaded
  42556. * @param pluginExtension the extension used to determine the plugin
  42557. * @returns The given scene
  42558. */
  42559. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  42560. /**
  42561. * Load a scene into an asset container
  42562. * @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)
  42563. * @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)
  42564. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  42565. * @param onSuccess a callback with the scene when import succeeds
  42566. * @param onProgress a callback with a progress event for each file being loaded
  42567. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42568. * @param pluginExtension the extension used to determine the plugin
  42569. * @returns The loaded plugin
  42570. */
  42571. 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>;
  42572. /**
  42573. * Load a scene into an asset container
  42574. * @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)
  42575. * @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)
  42576. * @param scene is the instance of Scene to append to
  42577. * @param onProgress a callback with a progress event for each file being loaded
  42578. * @param pluginExtension the extension used to determine the plugin
  42579. * @returns The loaded asset container
  42580. */
  42581. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  42582. }
  42583. }
  42584. declare module BABYLON {
  42585. /**
  42586. * Google Daydream controller
  42587. */
  42588. export class DaydreamController extends WebVRController {
  42589. /**
  42590. * Base Url for the controller model.
  42591. */
  42592. static MODEL_BASE_URL: string;
  42593. /**
  42594. * File name for the controller model.
  42595. */
  42596. static MODEL_FILENAME: string;
  42597. /**
  42598. * Gamepad Id prefix used to identify Daydream Controller.
  42599. */
  42600. static readonly GAMEPAD_ID_PREFIX: string;
  42601. /**
  42602. * Creates a new DaydreamController from a gamepad
  42603. * @param vrGamepad the gamepad that the controller should be created from
  42604. */
  42605. constructor(vrGamepad: any);
  42606. /**
  42607. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42608. * @param scene scene in which to add meshes
  42609. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42610. */
  42611. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42612. /**
  42613. * Called once for each button that changed state since the last frame
  42614. * @param buttonIdx Which button index changed
  42615. * @param state New state of the button
  42616. * @param changes Which properties on the state changed since last frame
  42617. */
  42618. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42619. }
  42620. }
  42621. declare module BABYLON {
  42622. /**
  42623. * Gear VR Controller
  42624. */
  42625. export class GearVRController extends WebVRController {
  42626. /**
  42627. * Base Url for the controller model.
  42628. */
  42629. static MODEL_BASE_URL: string;
  42630. /**
  42631. * File name for the controller model.
  42632. */
  42633. static MODEL_FILENAME: string;
  42634. /**
  42635. * Gamepad Id prefix used to identify this controller.
  42636. */
  42637. static readonly GAMEPAD_ID_PREFIX: string;
  42638. private readonly _buttonIndexToObservableNameMap;
  42639. /**
  42640. * Creates a new GearVRController from a gamepad
  42641. * @param vrGamepad the gamepad that the controller should be created from
  42642. */
  42643. constructor(vrGamepad: any);
  42644. /**
  42645. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42646. * @param scene scene in which to add meshes
  42647. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42648. */
  42649. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42650. /**
  42651. * Called once for each button that changed state since the last frame
  42652. * @param buttonIdx Which button index changed
  42653. * @param state New state of the button
  42654. * @param changes Which properties on the state changed since last frame
  42655. */
  42656. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42657. }
  42658. }
  42659. declare module BABYLON {
  42660. /**
  42661. * Generic Controller
  42662. */
  42663. export class GenericController extends WebVRController {
  42664. /**
  42665. * Base Url for the controller model.
  42666. */
  42667. static readonly MODEL_BASE_URL: string;
  42668. /**
  42669. * File name for the controller model.
  42670. */
  42671. static readonly MODEL_FILENAME: string;
  42672. /**
  42673. * Creates a new GenericController from a gamepad
  42674. * @param vrGamepad the gamepad that the controller should be created from
  42675. */
  42676. constructor(vrGamepad: any);
  42677. /**
  42678. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42679. * @param scene scene in which to add meshes
  42680. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42681. */
  42682. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42683. /**
  42684. * Called once for each button that changed state since the last frame
  42685. * @param buttonIdx Which button index changed
  42686. * @param state New state of the button
  42687. * @param changes Which properties on the state changed since last frame
  42688. */
  42689. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42690. }
  42691. }
  42692. declare module BABYLON {
  42693. /**
  42694. * Oculus Touch Controller
  42695. */
  42696. export class OculusTouchController extends WebVRController {
  42697. /**
  42698. * Base Url for the controller model.
  42699. */
  42700. static MODEL_BASE_URL: string;
  42701. /**
  42702. * File name for the left controller model.
  42703. */
  42704. static MODEL_LEFT_FILENAME: string;
  42705. /**
  42706. * File name for the right controller model.
  42707. */
  42708. static MODEL_RIGHT_FILENAME: string;
  42709. /**
  42710. * Fired when the secondary trigger on this controller is modified
  42711. */
  42712. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  42713. /**
  42714. * Fired when the thumb rest on this controller is modified
  42715. */
  42716. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  42717. /**
  42718. * Creates a new OculusTouchController from a gamepad
  42719. * @param vrGamepad the gamepad that the controller should be created from
  42720. */
  42721. constructor(vrGamepad: any);
  42722. /**
  42723. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42724. * @param scene scene in which to add meshes
  42725. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42726. */
  42727. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42728. /**
  42729. * Fired when the A button on this controller is modified
  42730. */
  42731. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42732. /**
  42733. * Fired when the B button on this controller is modified
  42734. */
  42735. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42736. /**
  42737. * Fired when the X button on this controller is modified
  42738. */
  42739. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42740. /**
  42741. * Fired when the Y button on this controller is modified
  42742. */
  42743. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42744. /**
  42745. * Called once for each button that changed state since the last frame
  42746. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  42747. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  42748. * 2) secondary trigger (same)
  42749. * 3) A (right) X (left), touch, pressed = value
  42750. * 4) B / Y
  42751. * 5) thumb rest
  42752. * @param buttonIdx Which button index changed
  42753. * @param state New state of the button
  42754. * @param changes Which properties on the state changed since last frame
  42755. */
  42756. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42757. }
  42758. }
  42759. declare module BABYLON {
  42760. /**
  42761. * Vive Controller
  42762. */
  42763. export class ViveController extends WebVRController {
  42764. /**
  42765. * Base Url for the controller model.
  42766. */
  42767. static MODEL_BASE_URL: string;
  42768. /**
  42769. * File name for the controller model.
  42770. */
  42771. static MODEL_FILENAME: string;
  42772. /**
  42773. * Creates a new ViveController from a gamepad
  42774. * @param vrGamepad the gamepad that the controller should be created from
  42775. */
  42776. constructor(vrGamepad: any);
  42777. /**
  42778. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42779. * @param scene scene in which to add meshes
  42780. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42781. */
  42782. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42783. /**
  42784. * Fired when the left button on this controller is modified
  42785. */
  42786. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42787. /**
  42788. * Fired when the right button on this controller is modified
  42789. */
  42790. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42791. /**
  42792. * Fired when the menu button on this controller is modified
  42793. */
  42794. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42795. /**
  42796. * Called once for each button that changed state since the last frame
  42797. * Vive mapping:
  42798. * 0: touchpad
  42799. * 1: trigger
  42800. * 2: left AND right buttons
  42801. * 3: menu button
  42802. * @param buttonIdx Which button index changed
  42803. * @param state New state of the button
  42804. * @param changes Which properties on the state changed since last frame
  42805. */
  42806. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42807. }
  42808. }
  42809. declare module BABYLON {
  42810. /**
  42811. * Defines the WindowsMotionController object that the state of the windows motion controller
  42812. */
  42813. export class WindowsMotionController extends WebVRController {
  42814. /**
  42815. * The base url used to load the left and right controller models
  42816. */
  42817. static MODEL_BASE_URL: string;
  42818. /**
  42819. * The name of the left controller model file
  42820. */
  42821. static MODEL_LEFT_FILENAME: string;
  42822. /**
  42823. * The name of the right controller model file
  42824. */
  42825. static MODEL_RIGHT_FILENAME: string;
  42826. /**
  42827. * The controller name prefix for this controller type
  42828. */
  42829. static readonly GAMEPAD_ID_PREFIX: string;
  42830. /**
  42831. * The controller id pattern for this controller type
  42832. */
  42833. private static readonly GAMEPAD_ID_PATTERN;
  42834. private _loadedMeshInfo;
  42835. private readonly _mapping;
  42836. /**
  42837. * Fired when the trackpad on this controller is clicked
  42838. */
  42839. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  42840. /**
  42841. * Fired when the trackpad on this controller is modified
  42842. */
  42843. onTrackpadValuesChangedObservable: Observable<StickValues>;
  42844. /**
  42845. * The current x and y values of this controller's trackpad
  42846. */
  42847. trackpad: StickValues;
  42848. /**
  42849. * Creates a new WindowsMotionController from a gamepad
  42850. * @param vrGamepad the gamepad that the controller should be created from
  42851. */
  42852. constructor(vrGamepad: any);
  42853. /**
  42854. * Fired when the trigger on this controller is modified
  42855. */
  42856. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42857. /**
  42858. * Fired when the menu button on this controller is modified
  42859. */
  42860. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42861. /**
  42862. * Fired when the grip button on this controller is modified
  42863. */
  42864. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42865. /**
  42866. * Fired when the thumbstick button on this controller is modified
  42867. */
  42868. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42869. /**
  42870. * Fired when the touchpad button on this controller is modified
  42871. */
  42872. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42873. /**
  42874. * Fired when the touchpad values on this controller are modified
  42875. */
  42876. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  42877. private _updateTrackpad;
  42878. /**
  42879. * Called once per frame by the engine.
  42880. */
  42881. update(): void;
  42882. /**
  42883. * Called once for each button that changed state since the last frame
  42884. * @param buttonIdx Which button index changed
  42885. * @param state New state of the button
  42886. * @param changes Which properties on the state changed since last frame
  42887. */
  42888. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42889. /**
  42890. * Moves the buttons on the controller mesh based on their current state
  42891. * @param buttonName the name of the button to move
  42892. * @param buttonValue the value of the button which determines the buttons new position
  42893. */
  42894. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  42895. /**
  42896. * Moves the axis on the controller mesh based on its current state
  42897. * @param axis the index of the axis
  42898. * @param axisValue the value of the axis which determines the meshes new position
  42899. * @hidden
  42900. */
  42901. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  42902. /**
  42903. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42904. * @param scene scene in which to add meshes
  42905. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42906. */
  42907. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  42908. /**
  42909. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  42910. * can be transformed by button presses and axes values, based on this._mapping.
  42911. *
  42912. * @param scene scene in which the meshes exist
  42913. * @param meshes list of meshes that make up the controller model to process
  42914. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  42915. */
  42916. private processModel;
  42917. private createMeshInfo;
  42918. /**
  42919. * Gets the ray of the controller in the direction the controller is pointing
  42920. * @param length the length the resulting ray should be
  42921. * @returns a ray in the direction the controller is pointing
  42922. */
  42923. getForwardRay(length?: number): Ray;
  42924. /**
  42925. * Disposes of the controller
  42926. */
  42927. dispose(): void;
  42928. }
  42929. }
  42930. declare module BABYLON {
  42931. /**
  42932. * Class containing static functions to help procedurally build meshes
  42933. */
  42934. export class PolyhedronBuilder {
  42935. /**
  42936. * Creates a polyhedron mesh
  42937. * * 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
  42938. * * The parameter `size` (positive float, default 1) sets the polygon size
  42939. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  42940. * * 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`
  42941. * * 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
  42942. * * 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)`)
  42943. * * 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
  42944. * * 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
  42945. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42946. * * 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
  42947. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42948. * @param name defines the name of the mesh
  42949. * @param options defines the options used to create the mesh
  42950. * @param scene defines the hosting scene
  42951. * @returns the polyhedron mesh
  42952. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  42953. */
  42954. static CreatePolyhedron(name: string, options: {
  42955. type?: number;
  42956. size?: number;
  42957. sizeX?: number;
  42958. sizeY?: number;
  42959. sizeZ?: number;
  42960. custom?: any;
  42961. faceUV?: Vector4[];
  42962. faceColors?: Color4[];
  42963. flat?: boolean;
  42964. updatable?: boolean;
  42965. sideOrientation?: number;
  42966. frontUVs?: Vector4;
  42967. backUVs?: Vector4;
  42968. }, scene?: Nullable<Scene>): Mesh;
  42969. }
  42970. }
  42971. declare module BABYLON {
  42972. /**
  42973. * Gizmo that enables scaling a mesh along 3 axis
  42974. */
  42975. export class ScaleGizmo extends Gizmo {
  42976. /**
  42977. * Internal gizmo used for interactions on the x axis
  42978. */
  42979. xGizmo: AxisScaleGizmo;
  42980. /**
  42981. * Internal gizmo used for interactions on the y axis
  42982. */
  42983. yGizmo: AxisScaleGizmo;
  42984. /**
  42985. * Internal gizmo used for interactions on the z axis
  42986. */
  42987. zGizmo: AxisScaleGizmo;
  42988. /**
  42989. * Internal gizmo used to scale all axis equally
  42990. */
  42991. uniformScaleGizmo: AxisScaleGizmo;
  42992. private _meshAttached;
  42993. private _updateGizmoRotationToMatchAttachedMesh;
  42994. private _snapDistance;
  42995. private _scaleRatio;
  42996. private _uniformScalingMesh;
  42997. private _octahedron;
  42998. /** Fires an event when any of it's sub gizmos are dragged */
  42999. onDragStartObservable: Observable<{}>;
  43000. /** Fires an event when any of it's sub gizmos are released from dragging */
  43001. onDragEndObservable: Observable<{}>;
  43002. attachedMesh: Nullable<AbstractMesh>;
  43003. /**
  43004. * Creates a ScaleGizmo
  43005. * @param gizmoLayer The utility layer the gizmo will be added to
  43006. */
  43007. constructor(gizmoLayer?: UtilityLayerRenderer);
  43008. updateGizmoRotationToMatchAttachedMesh: boolean;
  43009. /**
  43010. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43011. */
  43012. snapDistance: number;
  43013. /**
  43014. * Ratio for the scale of the gizmo (Default: 1)
  43015. */
  43016. scaleRatio: number;
  43017. /**
  43018. * Disposes of the gizmo
  43019. */
  43020. dispose(): void;
  43021. }
  43022. }
  43023. declare module BABYLON {
  43024. /**
  43025. * Single axis scale gizmo
  43026. */
  43027. export class AxisScaleGizmo extends Gizmo {
  43028. /**
  43029. * Drag behavior responsible for the gizmos dragging interactions
  43030. */
  43031. dragBehavior: PointerDragBehavior;
  43032. private _pointerObserver;
  43033. /**
  43034. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43035. */
  43036. snapDistance: number;
  43037. /**
  43038. * Event that fires each time the gizmo snaps to a new location.
  43039. * * snapDistance is the the change in distance
  43040. */
  43041. onSnapObservable: Observable<{
  43042. snapDistance: number;
  43043. }>;
  43044. /**
  43045. * If the scaling operation should be done on all axis (default: false)
  43046. */
  43047. uniformScaling: boolean;
  43048. private _isEnabled;
  43049. private _parent;
  43050. private _arrow;
  43051. private _coloredMaterial;
  43052. private _hoverMaterial;
  43053. /**
  43054. * Creates an AxisScaleGizmo
  43055. * @param gizmoLayer The utility layer the gizmo will be added to
  43056. * @param dragAxis The axis which the gizmo will be able to scale on
  43057. * @param color The color of the gizmo
  43058. */
  43059. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  43060. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  43061. /**
  43062. * If the gizmo is enabled
  43063. */
  43064. isEnabled: boolean;
  43065. /**
  43066. * Disposes of the gizmo
  43067. */
  43068. dispose(): void;
  43069. /**
  43070. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  43071. * @param mesh The mesh to replace the default mesh of the gizmo
  43072. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  43073. */
  43074. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  43075. }
  43076. }
  43077. declare module BABYLON {
  43078. /**
  43079. * Bounding box gizmo
  43080. */
  43081. export class BoundingBoxGizmo extends Gizmo {
  43082. private _lineBoundingBox;
  43083. private _rotateSpheresParent;
  43084. private _scaleBoxesParent;
  43085. private _boundingDimensions;
  43086. private _renderObserver;
  43087. private _pointerObserver;
  43088. private _scaleDragSpeed;
  43089. private _tmpQuaternion;
  43090. private _tmpVector;
  43091. private _tmpRotationMatrix;
  43092. /**
  43093. * 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)
  43094. */
  43095. ignoreChildren: boolean;
  43096. /**
  43097. * 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)
  43098. */
  43099. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  43100. /**
  43101. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  43102. */
  43103. rotationSphereSize: number;
  43104. /**
  43105. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  43106. */
  43107. scaleBoxSize: number;
  43108. /**
  43109. * 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)
  43110. */
  43111. fixedDragMeshScreenSize: boolean;
  43112. /**
  43113. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  43114. */
  43115. fixedDragMeshScreenSizeDistanceFactor: number;
  43116. /**
  43117. * Fired when a rotation sphere or scale box is dragged
  43118. */
  43119. onDragStartObservable: Observable<{}>;
  43120. /**
  43121. * Fired when a scale box is dragged
  43122. */
  43123. onScaleBoxDragObservable: Observable<{}>;
  43124. /**
  43125. * Fired when a scale box drag is ended
  43126. */
  43127. onScaleBoxDragEndObservable: Observable<{}>;
  43128. /**
  43129. * Fired when a rotation sphere is dragged
  43130. */
  43131. onRotationSphereDragObservable: Observable<{}>;
  43132. /**
  43133. * Fired when a rotation sphere drag is ended
  43134. */
  43135. onRotationSphereDragEndObservable: Observable<{}>;
  43136. /**
  43137. * 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)
  43138. */
  43139. scalePivot: Nullable<Vector3>;
  43140. /**
  43141. * Mesh used as a pivot to rotate the attached mesh
  43142. */
  43143. private _anchorMesh;
  43144. private _existingMeshScale;
  43145. private _dragMesh;
  43146. private pointerDragBehavior;
  43147. private coloredMaterial;
  43148. private hoverColoredMaterial;
  43149. /**
  43150. * Sets the color of the bounding box gizmo
  43151. * @param color the color to set
  43152. */
  43153. setColor(color: Color3): void;
  43154. /**
  43155. * Creates an BoundingBoxGizmo
  43156. * @param gizmoLayer The utility layer the gizmo will be added to
  43157. * @param color The color of the gizmo
  43158. */
  43159. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  43160. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  43161. private _selectNode;
  43162. /**
  43163. * Updates the bounding box information for the Gizmo
  43164. */
  43165. updateBoundingBox(): void;
  43166. private _updateRotationSpheres;
  43167. private _updateScaleBoxes;
  43168. /**
  43169. * Enables rotation on the specified axis and disables rotation on the others
  43170. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  43171. */
  43172. setEnabledRotationAxis(axis: string): void;
  43173. /**
  43174. * Enables/disables scaling
  43175. * @param enable if scaling should be enabled
  43176. */
  43177. setEnabledScaling(enable: boolean): void;
  43178. private _updateDummy;
  43179. /**
  43180. * Enables a pointer drag behavior on the bounding box of the gizmo
  43181. */
  43182. enableDragBehavior(): void;
  43183. /**
  43184. * Disposes of the gizmo
  43185. */
  43186. dispose(): void;
  43187. /**
  43188. * 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)
  43189. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  43190. * @returns the bounding box mesh with the passed in mesh as a child
  43191. */
  43192. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  43193. /**
  43194. * CustomMeshes are not supported by this gizmo
  43195. * @param mesh The mesh to replace the default mesh of the gizmo
  43196. */
  43197. setCustomMesh(mesh: Mesh): void;
  43198. }
  43199. }
  43200. declare module BABYLON {
  43201. /**
  43202. * Single plane rotation gizmo
  43203. */
  43204. export class PlaneRotationGizmo extends Gizmo {
  43205. /**
  43206. * Drag behavior responsible for the gizmos dragging interactions
  43207. */
  43208. dragBehavior: PointerDragBehavior;
  43209. private _pointerObserver;
  43210. /**
  43211. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  43212. */
  43213. snapDistance: number;
  43214. /**
  43215. * Event that fires each time the gizmo snaps to a new location.
  43216. * * snapDistance is the the change in distance
  43217. */
  43218. onSnapObservable: Observable<{
  43219. snapDistance: number;
  43220. }>;
  43221. private _isEnabled;
  43222. private _parent;
  43223. /**
  43224. * Creates a PlaneRotationGizmo
  43225. * @param gizmoLayer The utility layer the gizmo will be added to
  43226. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  43227. * @param color The color of the gizmo
  43228. * @param tessellation Amount of tessellation to be used when creating rotation circles
  43229. */
  43230. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>);
  43231. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  43232. /**
  43233. * If the gizmo is enabled
  43234. */
  43235. isEnabled: boolean;
  43236. /**
  43237. * Disposes of the gizmo
  43238. */
  43239. dispose(): void;
  43240. }
  43241. }
  43242. declare module BABYLON {
  43243. /**
  43244. * Gizmo that enables rotating a mesh along 3 axis
  43245. */
  43246. export class RotationGizmo extends Gizmo {
  43247. /**
  43248. * Internal gizmo used for interactions on the x axis
  43249. */
  43250. xGizmo: PlaneRotationGizmo;
  43251. /**
  43252. * Internal gizmo used for interactions on the y axis
  43253. */
  43254. yGizmo: PlaneRotationGizmo;
  43255. /**
  43256. * Internal gizmo used for interactions on the z axis
  43257. */
  43258. zGizmo: PlaneRotationGizmo;
  43259. /** Fires an event when any of it's sub gizmos are dragged */
  43260. onDragStartObservable: Observable<{}>;
  43261. /** Fires an event when any of it's sub gizmos are released from dragging */
  43262. onDragEndObservable: Observable<{}>;
  43263. private _meshAttached;
  43264. attachedMesh: Nullable<AbstractMesh>;
  43265. /**
  43266. * Creates a RotationGizmo
  43267. * @param gizmoLayer The utility layer the gizmo will be added to
  43268. * @param tessellation Amount of tessellation to be used when creating rotation circles
  43269. */
  43270. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  43271. updateGizmoRotationToMatchAttachedMesh: boolean;
  43272. /**
  43273. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43274. */
  43275. snapDistance: number;
  43276. /**
  43277. * Ratio for the scale of the gizmo (Default: 1)
  43278. */
  43279. scaleRatio: number;
  43280. /**
  43281. * Disposes of the gizmo
  43282. */
  43283. dispose(): void;
  43284. /**
  43285. * CustomMeshes are not supported by this gizmo
  43286. * @param mesh The mesh to replace the default mesh of the gizmo
  43287. */
  43288. setCustomMesh(mesh: Mesh): void;
  43289. }
  43290. }
  43291. declare module BABYLON {
  43292. /**
  43293. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  43294. */
  43295. export class GizmoManager implements IDisposable {
  43296. private scene;
  43297. /**
  43298. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  43299. */
  43300. gizmos: {
  43301. positionGizmo: Nullable<PositionGizmo>;
  43302. rotationGizmo: Nullable<RotationGizmo>;
  43303. scaleGizmo: Nullable<ScaleGizmo>;
  43304. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  43305. };
  43306. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  43307. clearGizmoOnEmptyPointerEvent: boolean;
  43308. /** Fires an event when the manager is attached to a mesh */
  43309. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  43310. private _gizmosEnabled;
  43311. private _pointerObserver;
  43312. private _attachedMesh;
  43313. private _boundingBoxColor;
  43314. private _defaultUtilityLayer;
  43315. private _defaultKeepDepthUtilityLayer;
  43316. /**
  43317. * When bounding box gizmo is enabled, this can be used to track drag/end events
  43318. */
  43319. boundingBoxDragBehavior: SixDofDragBehavior;
  43320. /**
  43321. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  43322. */
  43323. attachableMeshes: Nullable<Array<AbstractMesh>>;
  43324. /**
  43325. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  43326. */
  43327. usePointerToAttachGizmos: boolean;
  43328. /**
  43329. * Utility layer that the bounding box gizmo belongs to
  43330. */
  43331. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  43332. /**
  43333. * Utility layer that all gizmos besides bounding box belong to
  43334. */
  43335. readonly utilityLayer: UtilityLayerRenderer;
  43336. /**
  43337. * Instatiates a gizmo manager
  43338. * @param scene the scene to overlay the gizmos on top of
  43339. */
  43340. constructor(scene: Scene);
  43341. /**
  43342. * Attaches a set of gizmos to the specified mesh
  43343. * @param mesh The mesh the gizmo's should be attached to
  43344. */
  43345. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  43346. /**
  43347. * If the position gizmo is enabled
  43348. */
  43349. positionGizmoEnabled: boolean;
  43350. /**
  43351. * If the rotation gizmo is enabled
  43352. */
  43353. rotationGizmoEnabled: boolean;
  43354. /**
  43355. * If the scale gizmo is enabled
  43356. */
  43357. scaleGizmoEnabled: boolean;
  43358. /**
  43359. * If the boundingBox gizmo is enabled
  43360. */
  43361. boundingBoxGizmoEnabled: boolean;
  43362. /**
  43363. * Disposes of the gizmo manager
  43364. */
  43365. dispose(): void;
  43366. }
  43367. }
  43368. declare module BABYLON {
  43369. /**
  43370. * A directional light is defined by a direction (what a surprise!).
  43371. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  43372. * 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.
  43373. * Documentation: https://doc.babylonjs.com/babylon101/lights
  43374. */
  43375. export class DirectionalLight extends ShadowLight {
  43376. private _shadowFrustumSize;
  43377. /**
  43378. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  43379. */
  43380. /**
  43381. * Specifies a fix frustum size for the shadow generation.
  43382. */
  43383. shadowFrustumSize: number;
  43384. private _shadowOrthoScale;
  43385. /**
  43386. * Gets the shadow projection scale against the optimal computed one.
  43387. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  43388. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  43389. */
  43390. /**
  43391. * Sets the shadow projection scale against the optimal computed one.
  43392. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  43393. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  43394. */
  43395. shadowOrthoScale: number;
  43396. /**
  43397. * Automatically compute the projection matrix to best fit (including all the casters)
  43398. * on each frame.
  43399. */
  43400. autoUpdateExtends: boolean;
  43401. private _orthoLeft;
  43402. private _orthoRight;
  43403. private _orthoTop;
  43404. private _orthoBottom;
  43405. /**
  43406. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  43407. * The directional light is emitted from everywhere in the given direction.
  43408. * It can cast shadows.
  43409. * Documentation : https://doc.babylonjs.com/babylon101/lights
  43410. * @param name The friendly name of the light
  43411. * @param direction The direction of the light
  43412. * @param scene The scene the light belongs to
  43413. */
  43414. constructor(name: string, direction: Vector3, scene: Scene);
  43415. /**
  43416. * Returns the string "DirectionalLight".
  43417. * @return The class name
  43418. */
  43419. getClassName(): string;
  43420. /**
  43421. * Returns the integer 1.
  43422. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  43423. */
  43424. getTypeID(): number;
  43425. /**
  43426. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  43427. * Returns the DirectionalLight Shadow projection matrix.
  43428. */
  43429. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  43430. /**
  43431. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  43432. * Returns the DirectionalLight Shadow projection matrix.
  43433. */
  43434. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  43435. /**
  43436. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  43437. * Returns the DirectionalLight Shadow projection matrix.
  43438. */
  43439. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  43440. protected _buildUniformLayout(): void;
  43441. /**
  43442. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  43443. * @param effect The effect to update
  43444. * @param lightIndex The index of the light in the effect to update
  43445. * @returns The directional light
  43446. */
  43447. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  43448. /**
  43449. * Gets the minZ used for shadow according to both the scene and the light.
  43450. *
  43451. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  43452. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  43453. * @param activeCamera The camera we are returning the min for
  43454. * @returns the depth min z
  43455. */
  43456. getDepthMinZ(activeCamera: Camera): number;
  43457. /**
  43458. * Gets the maxZ used for shadow according to both the scene and the light.
  43459. *
  43460. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  43461. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  43462. * @param activeCamera The camera we are returning the max for
  43463. * @returns the depth max z
  43464. */
  43465. getDepthMaxZ(activeCamera: Camera): number;
  43466. /**
  43467. * Prepares the list of defines specific to the light type.
  43468. * @param defines the list of defines
  43469. * @param lightIndex defines the index of the light for the effect
  43470. */
  43471. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  43472. }
  43473. }
  43474. declare module BABYLON {
  43475. /**
  43476. * Class containing static functions to help procedurally build meshes
  43477. */
  43478. export class HemisphereBuilder {
  43479. /**
  43480. * Creates a hemisphere mesh
  43481. * @param name defines the name of the mesh
  43482. * @param options defines the options used to create the mesh
  43483. * @param scene defines the hosting scene
  43484. * @returns the hemisphere mesh
  43485. */
  43486. static CreateHemisphere(name: string, options: {
  43487. segments?: number;
  43488. diameter?: number;
  43489. sideOrientation?: number;
  43490. }, scene: any): Mesh;
  43491. }
  43492. }
  43493. declare module BABYLON {
  43494. /**
  43495. * A spot light is defined by a position, a direction, an angle, and an exponent.
  43496. * These values define a cone of light starting from the position, emitting toward the direction.
  43497. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  43498. * and the exponent defines the speed of the decay of the light with distance (reach).
  43499. * Documentation: https://doc.babylonjs.com/babylon101/lights
  43500. */
  43501. export class SpotLight extends ShadowLight {
  43502. private _angle;
  43503. private _innerAngle;
  43504. private _cosHalfAngle;
  43505. private _lightAngleScale;
  43506. private _lightAngleOffset;
  43507. /**
  43508. * Gets the cone angle of the spot light in Radians.
  43509. */
  43510. /**
  43511. * Sets the cone angle of the spot light in Radians.
  43512. */
  43513. angle: number;
  43514. /**
  43515. * Only used in gltf falloff mode, this defines the angle where
  43516. * the directional falloff will start before cutting at angle which could be seen
  43517. * as outer angle.
  43518. */
  43519. /**
  43520. * Only used in gltf falloff mode, this defines the angle where
  43521. * the directional falloff will start before cutting at angle which could be seen
  43522. * as outer angle.
  43523. */
  43524. innerAngle: number;
  43525. private _shadowAngleScale;
  43526. /**
  43527. * Allows scaling the angle of the light for shadow generation only.
  43528. */
  43529. /**
  43530. * Allows scaling the angle of the light for shadow generation only.
  43531. */
  43532. shadowAngleScale: number;
  43533. /**
  43534. * The light decay speed with the distance from the emission spot.
  43535. */
  43536. exponent: number;
  43537. private _projectionTextureMatrix;
  43538. /**
  43539. * Allows reading the projecton texture
  43540. */
  43541. readonly projectionTextureMatrix: Matrix;
  43542. protected _projectionTextureLightNear: number;
  43543. /**
  43544. * Gets the near clip of the Spotlight for texture projection.
  43545. */
  43546. /**
  43547. * Sets the near clip of the Spotlight for texture projection.
  43548. */
  43549. projectionTextureLightNear: number;
  43550. protected _projectionTextureLightFar: number;
  43551. /**
  43552. * Gets the far clip of the Spotlight for texture projection.
  43553. */
  43554. /**
  43555. * Sets the far clip of the Spotlight for texture projection.
  43556. */
  43557. projectionTextureLightFar: number;
  43558. protected _projectionTextureUpDirection: Vector3;
  43559. /**
  43560. * Gets the Up vector of the Spotlight for texture projection.
  43561. */
  43562. /**
  43563. * Sets the Up vector of the Spotlight for texture projection.
  43564. */
  43565. projectionTextureUpDirection: Vector3;
  43566. private _projectionTexture;
  43567. /**
  43568. * Gets the projection texture of the light.
  43569. */
  43570. /**
  43571. * Sets the projection texture of the light.
  43572. */
  43573. projectionTexture: Nullable<BaseTexture>;
  43574. private _projectionTextureViewLightDirty;
  43575. private _projectionTextureProjectionLightDirty;
  43576. private _projectionTextureDirty;
  43577. private _projectionTextureViewTargetVector;
  43578. private _projectionTextureViewLightMatrix;
  43579. private _projectionTextureProjectionLightMatrix;
  43580. private _projectionTextureScalingMatrix;
  43581. /**
  43582. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  43583. * It can cast shadows.
  43584. * Documentation : https://doc.babylonjs.com/babylon101/lights
  43585. * @param name The light friendly name
  43586. * @param position The position of the spot light in the scene
  43587. * @param direction The direction of the light in the scene
  43588. * @param angle The cone angle of the light in Radians
  43589. * @param exponent The light decay speed with the distance from the emission spot
  43590. * @param scene The scene the lights belongs to
  43591. */
  43592. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  43593. /**
  43594. * Returns the string "SpotLight".
  43595. * @returns the class name
  43596. */
  43597. getClassName(): string;
  43598. /**
  43599. * Returns the integer 2.
  43600. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  43601. */
  43602. getTypeID(): number;
  43603. /**
  43604. * Overrides the direction setter to recompute the projection texture view light Matrix.
  43605. */
  43606. protected _setDirection(value: Vector3): void;
  43607. /**
  43608. * Overrides the position setter to recompute the projection texture view light Matrix.
  43609. */
  43610. protected _setPosition(value: Vector3): void;
  43611. /**
  43612. * 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.
  43613. * Returns the SpotLight.
  43614. */
  43615. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  43616. protected _computeProjectionTextureViewLightMatrix(): void;
  43617. protected _computeProjectionTextureProjectionLightMatrix(): void;
  43618. /**
  43619. * Main function for light texture projection matrix computing.
  43620. */
  43621. protected _computeProjectionTextureMatrix(): void;
  43622. protected _buildUniformLayout(): void;
  43623. private _computeAngleValues;
  43624. /**
  43625. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  43626. * @param effect The effect to update
  43627. * @param lightIndex The index of the light in the effect to update
  43628. * @returns The spot light
  43629. */
  43630. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  43631. /**
  43632. * Disposes the light and the associated resources.
  43633. */
  43634. dispose(): void;
  43635. /**
  43636. * Prepares the list of defines specific to the light type.
  43637. * @param defines the list of defines
  43638. * @param lightIndex defines the index of the light for the effect
  43639. */
  43640. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  43641. }
  43642. }
  43643. declare module BABYLON {
  43644. /**
  43645. * Gizmo that enables viewing a light
  43646. */
  43647. export class LightGizmo extends Gizmo {
  43648. private _lightMesh;
  43649. private _material;
  43650. private cachedPosition;
  43651. private cachedForward;
  43652. /**
  43653. * Creates a LightGizmo
  43654. * @param gizmoLayer The utility layer the gizmo will be added to
  43655. */
  43656. constructor(gizmoLayer?: UtilityLayerRenderer);
  43657. private _light;
  43658. /**
  43659. * The light that the gizmo is attached to
  43660. */
  43661. light: Nullable<Light>;
  43662. /**
  43663. * @hidden
  43664. * Updates the gizmo to match the attached mesh's position/rotation
  43665. */
  43666. protected _update(): void;
  43667. private static _Scale;
  43668. /**
  43669. * Creates the lines for a light mesh
  43670. */
  43671. private static _createLightLines;
  43672. /**
  43673. * Disposes of the light gizmo
  43674. */
  43675. dispose(): void;
  43676. private static _CreateHemisphericLightMesh;
  43677. private static _CreatePointLightMesh;
  43678. private static _CreateSpotLightMesh;
  43679. private static _CreateDirectionalLightMesh;
  43680. }
  43681. }
  43682. declare module BABYLON {
  43683. /** @hidden */
  43684. export var backgroundFragmentDeclaration: {
  43685. name: string;
  43686. shader: string;
  43687. };
  43688. }
  43689. declare module BABYLON {
  43690. /** @hidden */
  43691. export var backgroundUboDeclaration: {
  43692. name: string;
  43693. shader: string;
  43694. };
  43695. }
  43696. declare module BABYLON {
  43697. /** @hidden */
  43698. export var backgroundPixelShader: {
  43699. name: string;
  43700. shader: string;
  43701. };
  43702. }
  43703. declare module BABYLON {
  43704. /** @hidden */
  43705. export var backgroundVertexDeclaration: {
  43706. name: string;
  43707. shader: string;
  43708. };
  43709. }
  43710. declare module BABYLON {
  43711. /** @hidden */
  43712. export var backgroundVertexShader: {
  43713. name: string;
  43714. shader: string;
  43715. };
  43716. }
  43717. declare module BABYLON {
  43718. /**
  43719. * Background material used to create an efficient environement around your scene.
  43720. */
  43721. export class BackgroundMaterial extends PushMaterial {
  43722. /**
  43723. * Standard reflectance value at parallel view angle.
  43724. */
  43725. static StandardReflectance0: number;
  43726. /**
  43727. * Standard reflectance value at grazing angle.
  43728. */
  43729. static StandardReflectance90: number;
  43730. protected _primaryColor: Color3;
  43731. /**
  43732. * Key light Color (multiply against the environement texture)
  43733. */
  43734. primaryColor: Color3;
  43735. protected __perceptualColor: Nullable<Color3>;
  43736. /**
  43737. * Experimental Internal Use Only.
  43738. *
  43739. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  43740. * This acts as a helper to set the primary color to a more "human friendly" value.
  43741. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  43742. * output color as close as possible from the chosen value.
  43743. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  43744. * part of lighting setup.)
  43745. */
  43746. _perceptualColor: Nullable<Color3>;
  43747. protected _primaryColorShadowLevel: float;
  43748. /**
  43749. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  43750. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  43751. */
  43752. primaryColorShadowLevel: float;
  43753. protected _primaryColorHighlightLevel: float;
  43754. /**
  43755. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  43756. * The primary color is used at the level chosen to define what the white area would look.
  43757. */
  43758. primaryColorHighlightLevel: float;
  43759. protected _reflectionTexture: Nullable<BaseTexture>;
  43760. /**
  43761. * Reflection Texture used in the material.
  43762. * Should be author in a specific way for the best result (refer to the documentation).
  43763. */
  43764. reflectionTexture: Nullable<BaseTexture>;
  43765. protected _reflectionBlur: float;
  43766. /**
  43767. * Reflection Texture level of blur.
  43768. *
  43769. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  43770. * texture twice.
  43771. */
  43772. reflectionBlur: float;
  43773. protected _diffuseTexture: Nullable<BaseTexture>;
  43774. /**
  43775. * Diffuse Texture used in the material.
  43776. * Should be author in a specific way for the best result (refer to the documentation).
  43777. */
  43778. diffuseTexture: Nullable<BaseTexture>;
  43779. protected _shadowLights: Nullable<IShadowLight[]>;
  43780. /**
  43781. * Specify the list of lights casting shadow on the material.
  43782. * All scene shadow lights will be included if null.
  43783. */
  43784. shadowLights: Nullable<IShadowLight[]>;
  43785. protected _shadowLevel: float;
  43786. /**
  43787. * Helps adjusting the shadow to a softer level if required.
  43788. * 0 means black shadows and 1 means no shadows.
  43789. */
  43790. shadowLevel: float;
  43791. protected _sceneCenter: Vector3;
  43792. /**
  43793. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  43794. * It is usually zero but might be interesting to modify according to your setup.
  43795. */
  43796. sceneCenter: Vector3;
  43797. protected _opacityFresnel: boolean;
  43798. /**
  43799. * This helps specifying that the material is falling off to the sky box at grazing angle.
  43800. * This helps ensuring a nice transition when the camera goes under the ground.
  43801. */
  43802. opacityFresnel: boolean;
  43803. protected _reflectionFresnel: boolean;
  43804. /**
  43805. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  43806. * This helps adding a mirror texture on the ground.
  43807. */
  43808. reflectionFresnel: boolean;
  43809. protected _reflectionFalloffDistance: number;
  43810. /**
  43811. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  43812. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  43813. */
  43814. reflectionFalloffDistance: number;
  43815. protected _reflectionAmount: number;
  43816. /**
  43817. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  43818. */
  43819. reflectionAmount: number;
  43820. protected _reflectionReflectance0: number;
  43821. /**
  43822. * This specifies the weight of the reflection at grazing angle.
  43823. */
  43824. reflectionReflectance0: number;
  43825. protected _reflectionReflectance90: number;
  43826. /**
  43827. * This specifies the weight of the reflection at a perpendicular point of view.
  43828. */
  43829. reflectionReflectance90: number;
  43830. /**
  43831. * Sets the reflection reflectance fresnel values according to the default standard
  43832. * empirically know to work well :-)
  43833. */
  43834. reflectionStandardFresnelWeight: number;
  43835. protected _useRGBColor: boolean;
  43836. /**
  43837. * Helps to directly use the maps channels instead of their level.
  43838. */
  43839. useRGBColor: boolean;
  43840. protected _enableNoise: boolean;
  43841. /**
  43842. * This helps reducing the banding effect that could occur on the background.
  43843. */
  43844. enableNoise: boolean;
  43845. /**
  43846. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  43847. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  43848. * Recommended to be keep at 1.0 except for special cases.
  43849. */
  43850. fovMultiplier: number;
  43851. private _fovMultiplier;
  43852. /**
  43853. * Enable the FOV adjustment feature controlled by fovMultiplier.
  43854. */
  43855. useEquirectangularFOV: boolean;
  43856. private _maxSimultaneousLights;
  43857. /**
  43858. * Number of Simultaneous lights allowed on the material.
  43859. */
  43860. maxSimultaneousLights: int;
  43861. /**
  43862. * Default configuration related to image processing available in the Background Material.
  43863. */
  43864. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  43865. /**
  43866. * Keep track of the image processing observer to allow dispose and replace.
  43867. */
  43868. private _imageProcessingObserver;
  43869. /**
  43870. * Attaches a new image processing configuration to the PBR Material.
  43871. * @param configuration (if null the scene configuration will be use)
  43872. */
  43873. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  43874. /**
  43875. * Gets the image processing configuration used either in this material.
  43876. */
  43877. /**
  43878. * Sets the Default image processing configuration used either in the this material.
  43879. *
  43880. * If sets to null, the scene one is in use.
  43881. */
  43882. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  43883. /**
  43884. * Gets wether the color curves effect is enabled.
  43885. */
  43886. /**
  43887. * Sets wether the color curves effect is enabled.
  43888. */
  43889. cameraColorCurvesEnabled: boolean;
  43890. /**
  43891. * Gets wether the color grading effect is enabled.
  43892. */
  43893. /**
  43894. * Gets wether the color grading effect is enabled.
  43895. */
  43896. cameraColorGradingEnabled: boolean;
  43897. /**
  43898. * Gets wether tonemapping is enabled or not.
  43899. */
  43900. /**
  43901. * Sets wether tonemapping is enabled or not
  43902. */
  43903. cameraToneMappingEnabled: boolean;
  43904. /**
  43905. * The camera exposure used on this material.
  43906. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  43907. * This corresponds to a photographic exposure.
  43908. */
  43909. /**
  43910. * The camera exposure used on this material.
  43911. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  43912. * This corresponds to a photographic exposure.
  43913. */
  43914. cameraExposure: float;
  43915. /**
  43916. * Gets The camera contrast used on this material.
  43917. */
  43918. /**
  43919. * Sets The camera contrast used on this material.
  43920. */
  43921. cameraContrast: float;
  43922. /**
  43923. * Gets the Color Grading 2D Lookup Texture.
  43924. */
  43925. /**
  43926. * Sets the Color Grading 2D Lookup Texture.
  43927. */
  43928. cameraColorGradingTexture: Nullable<BaseTexture>;
  43929. /**
  43930. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  43931. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  43932. * 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;
  43933. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  43934. */
  43935. /**
  43936. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  43937. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  43938. * 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;
  43939. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  43940. */
  43941. cameraColorCurves: Nullable<ColorCurves>;
  43942. /**
  43943. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  43944. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  43945. */
  43946. switchToBGR: boolean;
  43947. private _renderTargets;
  43948. private _reflectionControls;
  43949. private _white;
  43950. private _primaryShadowColor;
  43951. private _primaryHighlightColor;
  43952. /**
  43953. * Instantiates a Background Material in the given scene
  43954. * @param name The friendly name of the material
  43955. * @param scene The scene to add the material to
  43956. */
  43957. constructor(name: string, scene: Scene);
  43958. /**
  43959. * Gets a boolean indicating that current material needs to register RTT
  43960. */
  43961. readonly hasRenderTargetTextures: boolean;
  43962. /**
  43963. * The entire material has been created in order to prevent overdraw.
  43964. * @returns false
  43965. */
  43966. needAlphaTesting(): boolean;
  43967. /**
  43968. * The entire material has been created in order to prevent overdraw.
  43969. * @returns true if blending is enable
  43970. */
  43971. needAlphaBlending(): boolean;
  43972. /**
  43973. * Checks wether the material is ready to be rendered for a given mesh.
  43974. * @param mesh The mesh to render
  43975. * @param subMesh The submesh to check against
  43976. * @param useInstances Specify wether or not the material is used with instances
  43977. * @returns true if all the dependencies are ready (Textures, Effects...)
  43978. */
  43979. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  43980. /**
  43981. * Compute the primary color according to the chosen perceptual color.
  43982. */
  43983. private _computePrimaryColorFromPerceptualColor;
  43984. /**
  43985. * Compute the highlights and shadow colors according to their chosen levels.
  43986. */
  43987. private _computePrimaryColors;
  43988. /**
  43989. * Build the uniform buffer used in the material.
  43990. */
  43991. buildUniformLayout(): void;
  43992. /**
  43993. * Unbind the material.
  43994. */
  43995. unbind(): void;
  43996. /**
  43997. * Bind only the world matrix to the material.
  43998. * @param world The world matrix to bind.
  43999. */
  44000. bindOnlyWorldMatrix(world: Matrix): void;
  44001. /**
  44002. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  44003. * @param world The world matrix to bind.
  44004. * @param subMesh The submesh to bind for.
  44005. */
  44006. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  44007. /**
  44008. * Dispose the material.
  44009. * @param forceDisposeEffect Force disposal of the associated effect.
  44010. * @param forceDisposeTextures Force disposal of the associated textures.
  44011. */
  44012. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  44013. /**
  44014. * Clones the material.
  44015. * @param name The cloned name.
  44016. * @returns The cloned material.
  44017. */
  44018. clone(name: string): BackgroundMaterial;
  44019. /**
  44020. * Serializes the current material to its JSON representation.
  44021. * @returns The JSON representation.
  44022. */
  44023. serialize(): any;
  44024. /**
  44025. * Gets the class name of the material
  44026. * @returns "BackgroundMaterial"
  44027. */
  44028. getClassName(): string;
  44029. /**
  44030. * Parse a JSON input to create back a background material.
  44031. * @param source The JSON data to parse
  44032. * @param scene The scene to create the parsed material in
  44033. * @param rootUrl The root url of the assets the material depends upon
  44034. * @returns the instantiated BackgroundMaterial.
  44035. */
  44036. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  44037. }
  44038. }
  44039. declare module BABYLON {
  44040. /**
  44041. * Represents the different options available during the creation of
  44042. * a Environment helper.
  44043. *
  44044. * This can control the default ground, skybox and image processing setup of your scene.
  44045. */
  44046. export interface IEnvironmentHelperOptions {
  44047. /**
  44048. * Specifies wether or not to create a ground.
  44049. * True by default.
  44050. */
  44051. createGround: boolean;
  44052. /**
  44053. * Specifies the ground size.
  44054. * 15 by default.
  44055. */
  44056. groundSize: number;
  44057. /**
  44058. * The texture used on the ground for the main color.
  44059. * Comes from the BabylonJS CDN by default.
  44060. *
  44061. * Remarks: Can be either a texture or a url.
  44062. */
  44063. groundTexture: string | BaseTexture;
  44064. /**
  44065. * The color mixed in the ground texture by default.
  44066. * BabylonJS clearColor by default.
  44067. */
  44068. groundColor: Color3;
  44069. /**
  44070. * Specifies the ground opacity.
  44071. * 1 by default.
  44072. */
  44073. groundOpacity: number;
  44074. /**
  44075. * Enables the ground to receive shadows.
  44076. * True by default.
  44077. */
  44078. enableGroundShadow: boolean;
  44079. /**
  44080. * Helps preventing the shadow to be fully black on the ground.
  44081. * 0.5 by default.
  44082. */
  44083. groundShadowLevel: number;
  44084. /**
  44085. * Creates a mirror texture attach to the ground.
  44086. * false by default.
  44087. */
  44088. enableGroundMirror: boolean;
  44089. /**
  44090. * Specifies the ground mirror size ratio.
  44091. * 0.3 by default as the default kernel is 64.
  44092. */
  44093. groundMirrorSizeRatio: number;
  44094. /**
  44095. * Specifies the ground mirror blur kernel size.
  44096. * 64 by default.
  44097. */
  44098. groundMirrorBlurKernel: number;
  44099. /**
  44100. * Specifies the ground mirror visibility amount.
  44101. * 1 by default
  44102. */
  44103. groundMirrorAmount: number;
  44104. /**
  44105. * Specifies the ground mirror reflectance weight.
  44106. * This uses the standard weight of the background material to setup the fresnel effect
  44107. * of the mirror.
  44108. * 1 by default.
  44109. */
  44110. groundMirrorFresnelWeight: number;
  44111. /**
  44112. * Specifies the ground mirror Falloff distance.
  44113. * This can helps reducing the size of the reflection.
  44114. * 0 by Default.
  44115. */
  44116. groundMirrorFallOffDistance: number;
  44117. /**
  44118. * Specifies the ground mirror texture type.
  44119. * Unsigned Int by Default.
  44120. */
  44121. groundMirrorTextureType: number;
  44122. /**
  44123. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  44124. * the shown objects.
  44125. */
  44126. groundYBias: number;
  44127. /**
  44128. * Specifies wether or not to create a skybox.
  44129. * True by default.
  44130. */
  44131. createSkybox: boolean;
  44132. /**
  44133. * Specifies the skybox size.
  44134. * 20 by default.
  44135. */
  44136. skyboxSize: number;
  44137. /**
  44138. * The texture used on the skybox for the main color.
  44139. * Comes from the BabylonJS CDN by default.
  44140. *
  44141. * Remarks: Can be either a texture or a url.
  44142. */
  44143. skyboxTexture: string | BaseTexture;
  44144. /**
  44145. * The color mixed in the skybox texture by default.
  44146. * BabylonJS clearColor by default.
  44147. */
  44148. skyboxColor: Color3;
  44149. /**
  44150. * The background rotation around the Y axis of the scene.
  44151. * This helps aligning the key lights of your scene with the background.
  44152. * 0 by default.
  44153. */
  44154. backgroundYRotation: number;
  44155. /**
  44156. * Compute automatically the size of the elements to best fit with the scene.
  44157. */
  44158. sizeAuto: boolean;
  44159. /**
  44160. * Default position of the rootMesh if autoSize is not true.
  44161. */
  44162. rootPosition: Vector3;
  44163. /**
  44164. * Sets up the image processing in the scene.
  44165. * true by default.
  44166. */
  44167. setupImageProcessing: boolean;
  44168. /**
  44169. * The texture used as your environment texture in the scene.
  44170. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  44171. *
  44172. * Remarks: Can be either a texture or a url.
  44173. */
  44174. environmentTexture: string | BaseTexture;
  44175. /**
  44176. * The value of the exposure to apply to the scene.
  44177. * 0.6 by default if setupImageProcessing is true.
  44178. */
  44179. cameraExposure: number;
  44180. /**
  44181. * The value of the contrast to apply to the scene.
  44182. * 1.6 by default if setupImageProcessing is true.
  44183. */
  44184. cameraContrast: number;
  44185. /**
  44186. * Specifies wether or not tonemapping should be enabled in the scene.
  44187. * true by default if setupImageProcessing is true.
  44188. */
  44189. toneMappingEnabled: boolean;
  44190. }
  44191. /**
  44192. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  44193. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  44194. * It also helps with the default setup of your imageProcessing configuration.
  44195. */
  44196. export class EnvironmentHelper {
  44197. /**
  44198. * Default ground texture URL.
  44199. */
  44200. private static _groundTextureCDNUrl;
  44201. /**
  44202. * Default skybox texture URL.
  44203. */
  44204. private static _skyboxTextureCDNUrl;
  44205. /**
  44206. * Default environment texture URL.
  44207. */
  44208. private static _environmentTextureCDNUrl;
  44209. /**
  44210. * Creates the default options for the helper.
  44211. */
  44212. private static _getDefaultOptions;
  44213. private _rootMesh;
  44214. /**
  44215. * Gets the root mesh created by the helper.
  44216. */
  44217. readonly rootMesh: Mesh;
  44218. private _skybox;
  44219. /**
  44220. * Gets the skybox created by the helper.
  44221. */
  44222. readonly skybox: Nullable<Mesh>;
  44223. private _skyboxTexture;
  44224. /**
  44225. * Gets the skybox texture created by the helper.
  44226. */
  44227. readonly skyboxTexture: Nullable<BaseTexture>;
  44228. private _skyboxMaterial;
  44229. /**
  44230. * Gets the skybox material created by the helper.
  44231. */
  44232. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  44233. private _ground;
  44234. /**
  44235. * Gets the ground mesh created by the helper.
  44236. */
  44237. readonly ground: Nullable<Mesh>;
  44238. private _groundTexture;
  44239. /**
  44240. * Gets the ground texture created by the helper.
  44241. */
  44242. readonly groundTexture: Nullable<BaseTexture>;
  44243. private _groundMirror;
  44244. /**
  44245. * Gets the ground mirror created by the helper.
  44246. */
  44247. readonly groundMirror: Nullable<MirrorTexture>;
  44248. /**
  44249. * Gets the ground mirror render list to helps pushing the meshes
  44250. * you wish in the ground reflection.
  44251. */
  44252. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  44253. private _groundMaterial;
  44254. /**
  44255. * Gets the ground material created by the helper.
  44256. */
  44257. readonly groundMaterial: Nullable<BackgroundMaterial>;
  44258. /**
  44259. * Stores the creation options.
  44260. */
  44261. private readonly _scene;
  44262. private _options;
  44263. /**
  44264. * This observable will be notified with any error during the creation of the environment,
  44265. * mainly texture creation errors.
  44266. */
  44267. onErrorObservable: Observable<{
  44268. message?: string;
  44269. exception?: any;
  44270. }>;
  44271. /**
  44272. * constructor
  44273. * @param options Defines the options we want to customize the helper
  44274. * @param scene The scene to add the material to
  44275. */
  44276. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  44277. /**
  44278. * Updates the background according to the new options
  44279. * @param options
  44280. */
  44281. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  44282. /**
  44283. * Sets the primary color of all the available elements.
  44284. * @param color the main color to affect to the ground and the background
  44285. */
  44286. setMainColor(color: Color3): void;
  44287. /**
  44288. * Setup the image processing according to the specified options.
  44289. */
  44290. private _setupImageProcessing;
  44291. /**
  44292. * Setup the environment texture according to the specified options.
  44293. */
  44294. private _setupEnvironmentTexture;
  44295. /**
  44296. * Setup the background according to the specified options.
  44297. */
  44298. private _setupBackground;
  44299. /**
  44300. * Get the scene sizes according to the setup.
  44301. */
  44302. private _getSceneSize;
  44303. /**
  44304. * Setup the ground according to the specified options.
  44305. */
  44306. private _setupGround;
  44307. /**
  44308. * Setup the ground material according to the specified options.
  44309. */
  44310. private _setupGroundMaterial;
  44311. /**
  44312. * Setup the ground diffuse texture according to the specified options.
  44313. */
  44314. private _setupGroundDiffuseTexture;
  44315. /**
  44316. * Setup the ground mirror texture according to the specified options.
  44317. */
  44318. private _setupGroundMirrorTexture;
  44319. /**
  44320. * Setup the ground to receive the mirror texture.
  44321. */
  44322. private _setupMirrorInGroundMaterial;
  44323. /**
  44324. * Setup the skybox according to the specified options.
  44325. */
  44326. private _setupSkybox;
  44327. /**
  44328. * Setup the skybox material according to the specified options.
  44329. */
  44330. private _setupSkyboxMaterial;
  44331. /**
  44332. * Setup the skybox reflection texture according to the specified options.
  44333. */
  44334. private _setupSkyboxReflectionTexture;
  44335. private _errorHandler;
  44336. /**
  44337. * Dispose all the elements created by the Helper.
  44338. */
  44339. dispose(): void;
  44340. }
  44341. }
  44342. declare module BABYLON {
  44343. /**
  44344. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  44345. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  44346. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  44347. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  44348. */
  44349. export class PhotoDome extends TransformNode {
  44350. /**
  44351. * Define the image as a Monoscopic panoramic 360 image.
  44352. */
  44353. static readonly MODE_MONOSCOPIC: number;
  44354. /**
  44355. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  44356. */
  44357. static readonly MODE_TOPBOTTOM: number;
  44358. /**
  44359. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  44360. */
  44361. static readonly MODE_SIDEBYSIDE: number;
  44362. private _useDirectMapping;
  44363. /**
  44364. * The texture being displayed on the sphere
  44365. */
  44366. protected _photoTexture: Texture;
  44367. /**
  44368. * Gets or sets the texture being displayed on the sphere
  44369. */
  44370. photoTexture: Texture;
  44371. /**
  44372. * Observable raised when an error occured while loading the 360 image
  44373. */
  44374. onLoadErrorObservable: Observable<string>;
  44375. /**
  44376. * The skybox material
  44377. */
  44378. protected _material: BackgroundMaterial;
  44379. /**
  44380. * The surface used for the skybox
  44381. */
  44382. protected _mesh: Mesh;
  44383. /**
  44384. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  44385. * Also see the options.resolution property.
  44386. */
  44387. fovMultiplier: number;
  44388. private _imageMode;
  44389. /**
  44390. * Gets or set the current video mode for the video. It can be:
  44391. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  44392. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  44393. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  44394. */
  44395. imageMode: number;
  44396. /**
  44397. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  44398. * @param name Element's name, child elements will append suffixes for their own names.
  44399. * @param urlsOfPhoto defines the url of the photo to display
  44400. * @param options defines an object containing optional or exposed sub element properties
  44401. * @param onError defines a callback called when an error occured while loading the texture
  44402. */
  44403. constructor(name: string, urlOfPhoto: string, options: {
  44404. resolution?: number;
  44405. size?: number;
  44406. useDirectMapping?: boolean;
  44407. faceForward?: boolean;
  44408. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  44409. private _onBeforeCameraRenderObserver;
  44410. private _changeImageMode;
  44411. /**
  44412. * Releases resources associated with this node.
  44413. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  44414. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  44415. */
  44416. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  44417. }
  44418. }
  44419. declare module BABYLON {
  44420. /** @hidden */
  44421. export var rgbdDecodePixelShader: {
  44422. name: string;
  44423. shader: string;
  44424. };
  44425. }
  44426. declare module BABYLON {
  44427. /**
  44428. * Class used to host texture specific utilities
  44429. */
  44430. export class BRDFTextureTools {
  44431. /**
  44432. * Expand the BRDF Texture from RGBD to Half Float if necessary.
  44433. * @param texture the texture to expand.
  44434. */
  44435. private static _ExpandDefaultBRDFTexture;
  44436. /**
  44437. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  44438. * @param scene defines the hosting scene
  44439. * @returns the environment BRDF texture
  44440. */
  44441. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  44442. private static _environmentBRDFBase64Texture;
  44443. }
  44444. }
  44445. declare module BABYLON {
  44446. /**
  44447. * @hidden
  44448. */
  44449. export interface IMaterialClearCoatDefines {
  44450. CLEARCOAT: boolean;
  44451. CLEARCOAT_DEFAULTIOR: boolean;
  44452. CLEARCOAT_TEXTURE: boolean;
  44453. CLEARCOAT_TEXTUREDIRECTUV: number;
  44454. CLEARCOAT_BUMP: boolean;
  44455. CLEARCOAT_BUMPDIRECTUV: number;
  44456. CLEARCOAT_TINT: boolean;
  44457. CLEARCOAT_TINT_TEXTURE: boolean;
  44458. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  44459. /** @hidden */
  44460. _areTexturesDirty: boolean;
  44461. }
  44462. /**
  44463. * Define the code related to the clear coat parameters of the pbr material.
  44464. */
  44465. export class PBRClearCoatConfiguration {
  44466. /**
  44467. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  44468. * The default fits with a polyurethane material.
  44469. */
  44470. private static readonly _DefaultIndexOfRefraction;
  44471. private _isEnabled;
  44472. /**
  44473. * Defines if the clear coat is enabled in the material.
  44474. */
  44475. isEnabled: boolean;
  44476. /**
  44477. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  44478. */
  44479. intensity: number;
  44480. /**
  44481. * Defines the clear coat layer roughness.
  44482. */
  44483. roughness: number;
  44484. private _indexOfRefraction;
  44485. /**
  44486. * Defines the index of refraction of the clear coat.
  44487. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  44488. * The default fits with a polyurethane material.
  44489. * Changing the default value is more performance intensive.
  44490. */
  44491. indexOfRefraction: number;
  44492. private _texture;
  44493. /**
  44494. * Stores the clear coat values in a texture.
  44495. */
  44496. texture: Nullable<BaseTexture>;
  44497. private _bumpTexture;
  44498. /**
  44499. * Define the clear coat specific bump texture.
  44500. */
  44501. bumpTexture: Nullable<BaseTexture>;
  44502. private _isTintEnabled;
  44503. /**
  44504. * Defines if the clear coat tint is enabled in the material.
  44505. */
  44506. isTintEnabled: boolean;
  44507. /**
  44508. * Defines the clear coat tint of the material.
  44509. * This is only use if tint is enabled
  44510. */
  44511. tintColor: Color3;
  44512. /**
  44513. * Defines the distance at which the tint color should be found in the
  44514. * clear coat media.
  44515. * This is only use if tint is enabled
  44516. */
  44517. tintColorAtDistance: number;
  44518. /**
  44519. * Defines the clear coat layer thickness.
  44520. * This is only use if tint is enabled
  44521. */
  44522. tintThickness: number;
  44523. private _tintTexture;
  44524. /**
  44525. * Stores the clear tint values in a texture.
  44526. * rgb is tint
  44527. * a is a thickness factor
  44528. */
  44529. tintTexture: Nullable<BaseTexture>;
  44530. /** @hidden */
  44531. private _internalMarkAllSubMeshesAsTexturesDirty;
  44532. /** @hidden */
  44533. _markAllSubMeshesAsTexturesDirty(): void;
  44534. /**
  44535. * Instantiate a new istance of clear coat configuration.
  44536. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  44537. */
  44538. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  44539. /**
  44540. * Gets wehter the submesh is ready to be used or not.
  44541. * @param defines the list of "defines" to update.
  44542. * @param scene defines the scene the material belongs to.
  44543. * @param engine defines the engine the material belongs to.
  44544. * @param disableBumpMap defines wether the material disables bump or not.
  44545. * @returns - boolean indicating that the submesh is ready or not.
  44546. */
  44547. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  44548. /**
  44549. * Checks to see if a texture is used in the material.
  44550. * @param defines the list of "defines" to update.
  44551. * @param scene defines the scene to the material belongs to.
  44552. */
  44553. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  44554. /**
  44555. * Binds the material data.
  44556. * @param uniformBuffer defines the Uniform buffer to fill in.
  44557. * @param scene defines the scene the material belongs to.
  44558. * @param engine defines the engine the material belongs to.
  44559. * @param disableBumpMap defines wether the material disables bump or not.
  44560. * @param isFrozen defines wether the material is frozen or not.
  44561. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  44562. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  44563. */
  44564. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  44565. /**
  44566. * Checks to see if a texture is used in the material.
  44567. * @param texture - Base texture to use.
  44568. * @returns - Boolean specifying if a texture is used in the material.
  44569. */
  44570. hasTexture(texture: BaseTexture): boolean;
  44571. /**
  44572. * Returns an array of the actively used textures.
  44573. * @param activeTextures Array of BaseTextures
  44574. */
  44575. getActiveTextures(activeTextures: BaseTexture[]): void;
  44576. /**
  44577. * Returns the animatable textures.
  44578. * @param animatables Array of animatable textures.
  44579. */
  44580. getAnimatables(animatables: IAnimatable[]): void;
  44581. /**
  44582. * Disposes the resources of the material.
  44583. * @param forceDisposeTextures - Forces the disposal of all textures.
  44584. */
  44585. dispose(forceDisposeTextures?: boolean): void;
  44586. /**
  44587. * Get the current class name of the texture useful for serialization or dynamic coding.
  44588. * @returns "PBRClearCoatConfiguration"
  44589. */
  44590. getClassName(): string;
  44591. /**
  44592. * Add fallbacks to the effect fallbacks list.
  44593. * @param defines defines the Base texture to use.
  44594. * @param fallbacks defines the current fallback list.
  44595. * @param currentRank defines the current fallback rank.
  44596. * @returns the new fallback rank.
  44597. */
  44598. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  44599. /**
  44600. * Add the required uniforms to the current list.
  44601. * @param uniforms defines the current uniform list.
  44602. */
  44603. static AddUniforms(uniforms: string[]): void;
  44604. /**
  44605. * Add the required samplers to the current list.
  44606. * @param samplers defines the current sampler list.
  44607. */
  44608. static AddSamplers(samplers: string[]): void;
  44609. /**
  44610. * Add the required uniforms to the current buffer.
  44611. * @param uniformBuffer defines the current uniform buffer.
  44612. */
  44613. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  44614. /**
  44615. * Makes a duplicate of the current configuration into another one.
  44616. * @param clearCoatConfiguration define the config where to copy the info
  44617. */
  44618. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  44619. /**
  44620. * Serializes this clear coat configuration.
  44621. * @returns - An object with the serialized config.
  44622. */
  44623. serialize(): any;
  44624. /**
  44625. * Parses a Clear Coat Configuration from a serialized object.
  44626. * @param source - Serialized object.
  44627. */
  44628. parse(source: any): void;
  44629. }
  44630. }
  44631. declare module BABYLON {
  44632. /**
  44633. * @hidden
  44634. */
  44635. export interface IMaterialAnisotropicDefines {
  44636. ANISOTROPIC: boolean;
  44637. ANISOTROPIC_TEXTURE: boolean;
  44638. ANISOTROPIC_TEXTUREDIRECTUV: number;
  44639. MAINUV1: boolean;
  44640. _areTexturesDirty: boolean;
  44641. _needUVs: boolean;
  44642. }
  44643. /**
  44644. * Define the code related to the anisotropic parameters of the pbr material.
  44645. */
  44646. export class PBRAnisotropicConfiguration {
  44647. private _isEnabled;
  44648. /**
  44649. * Defines if the anisotropy is enabled in the material.
  44650. */
  44651. isEnabled: boolean;
  44652. /**
  44653. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  44654. */
  44655. intensity: number;
  44656. /**
  44657. * Defines if the effect is along the tangents, bitangents or in between.
  44658. * By default, the effect is "strectching" the highlights along the tangents.
  44659. */
  44660. direction: Vector2;
  44661. private _texture;
  44662. /**
  44663. * Stores the anisotropy values in a texture.
  44664. * rg is direction (like normal from -1 to 1)
  44665. * b is a intensity
  44666. */
  44667. texture: Nullable<BaseTexture>;
  44668. /** @hidden */
  44669. private _internalMarkAllSubMeshesAsTexturesDirty;
  44670. /** @hidden */
  44671. _markAllSubMeshesAsTexturesDirty(): void;
  44672. /**
  44673. * Instantiate a new istance of anisotropy configuration.
  44674. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  44675. */
  44676. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  44677. /**
  44678. * Specifies that the submesh is ready to be used.
  44679. * @param defines the list of "defines" to update.
  44680. * @param scene defines the scene the material belongs to.
  44681. * @returns - boolean indicating that the submesh is ready or not.
  44682. */
  44683. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  44684. /**
  44685. * Checks to see if a texture is used in the material.
  44686. * @param defines the list of "defines" to update.
  44687. * @param mesh the mesh we are preparing the defines for.
  44688. * @param scene defines the scene the material belongs to.
  44689. */
  44690. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  44691. /**
  44692. * Binds the material data.
  44693. * @param uniformBuffer defines the Uniform buffer to fill in.
  44694. * @param scene defines the scene the material belongs to.
  44695. * @param isFrozen defines wether the material is frozen or not.
  44696. */
  44697. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  44698. /**
  44699. * Checks to see if a texture is used in the material.
  44700. * @param texture - Base texture to use.
  44701. * @returns - Boolean specifying if a texture is used in the material.
  44702. */
  44703. hasTexture(texture: BaseTexture): boolean;
  44704. /**
  44705. * Returns an array of the actively used textures.
  44706. * @param activeTextures Array of BaseTextures
  44707. */
  44708. getActiveTextures(activeTextures: BaseTexture[]): void;
  44709. /**
  44710. * Returns the animatable textures.
  44711. * @param animatables Array of animatable textures.
  44712. */
  44713. getAnimatables(animatables: IAnimatable[]): void;
  44714. /**
  44715. * Disposes the resources of the material.
  44716. * @param forceDisposeTextures - Forces the disposal of all textures.
  44717. */
  44718. dispose(forceDisposeTextures?: boolean): void;
  44719. /**
  44720. * Get the current class name of the texture useful for serialization or dynamic coding.
  44721. * @returns "PBRAnisotropicConfiguration"
  44722. */
  44723. getClassName(): string;
  44724. /**
  44725. * Add fallbacks to the effect fallbacks list.
  44726. * @param defines defines the Base texture to use.
  44727. * @param fallbacks defines the current fallback list.
  44728. * @param currentRank defines the current fallback rank.
  44729. * @returns the new fallback rank.
  44730. */
  44731. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  44732. /**
  44733. * Add the required uniforms to the current list.
  44734. * @param uniforms defines the current uniform list.
  44735. */
  44736. static AddUniforms(uniforms: string[]): void;
  44737. /**
  44738. * Add the required uniforms to the current buffer.
  44739. * @param uniformBuffer defines the current uniform buffer.
  44740. */
  44741. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  44742. /**
  44743. * Add the required samplers to the current list.
  44744. * @param samplers defines the current sampler list.
  44745. */
  44746. static AddSamplers(samplers: string[]): void;
  44747. /**
  44748. * Makes a duplicate of the current configuration into another one.
  44749. * @param anisotropicConfiguration define the config where to copy the info
  44750. */
  44751. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  44752. /**
  44753. * Serializes this anisotropy configuration.
  44754. * @returns - An object with the serialized config.
  44755. */
  44756. serialize(): any;
  44757. /**
  44758. * Parses a anisotropy Configuration from a serialized object.
  44759. * @param source - Serialized object.
  44760. */
  44761. parse(source: any): void;
  44762. }
  44763. }
  44764. declare module BABYLON {
  44765. /**
  44766. * @hidden
  44767. */
  44768. export interface IMaterialBRDFDefines {
  44769. BRDF_V_HEIGHT_CORRELATED: boolean;
  44770. MS_BRDF_ENERGY_CONSERVATION: boolean;
  44771. SPHERICAL_HARMONICS: boolean;
  44772. /** @hidden */
  44773. _areMiscDirty: boolean;
  44774. }
  44775. /**
  44776. * Define the code related to the BRDF parameters of the pbr material.
  44777. */
  44778. export class PBRBRDFConfiguration {
  44779. /**
  44780. * Default value used for the energy conservation.
  44781. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  44782. */
  44783. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  44784. /**
  44785. * Default value used for the Smith Visibility Height Correlated mode.
  44786. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  44787. */
  44788. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  44789. /**
  44790. * Default value used for the IBL diffuse part.
  44791. * This can help switching back to the polynomials mode globally which is a tiny bit
  44792. * less GPU intensive at the drawback of a lower quality.
  44793. */
  44794. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  44795. private _useEnergyConservation;
  44796. /**
  44797. * Defines if the material uses energy conservation.
  44798. */
  44799. useEnergyConservation: boolean;
  44800. private _useSmithVisibilityHeightCorrelated;
  44801. /**
  44802. * LEGACY Mode set to false
  44803. * Defines if the material uses height smith correlated visibility term.
  44804. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  44805. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  44806. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  44807. * Not relying on height correlated will also disable energy conservation.
  44808. */
  44809. useSmithVisibilityHeightCorrelated: boolean;
  44810. private _useSphericalHarmonics;
  44811. /**
  44812. * LEGACY Mode set to false
  44813. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  44814. * diffuse part of the IBL.
  44815. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  44816. * to the ground truth.
  44817. */
  44818. useSphericalHarmonics: boolean;
  44819. /** @hidden */
  44820. private _internalMarkAllSubMeshesAsMiscDirty;
  44821. /** @hidden */
  44822. _markAllSubMeshesAsMiscDirty(): void;
  44823. /**
  44824. * Instantiate a new istance of clear coat configuration.
  44825. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  44826. */
  44827. constructor(markAllSubMeshesAsMiscDirty: () => void);
  44828. /**
  44829. * Checks to see if a texture is used in the material.
  44830. * @param defines the list of "defines" to update.
  44831. */
  44832. prepareDefines(defines: IMaterialBRDFDefines): void;
  44833. /**
  44834. * Get the current class name of the texture useful for serialization or dynamic coding.
  44835. * @returns "PBRClearCoatConfiguration"
  44836. */
  44837. getClassName(): string;
  44838. /**
  44839. * Makes a duplicate of the current configuration into another one.
  44840. * @param brdfConfiguration define the config where to copy the info
  44841. */
  44842. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  44843. /**
  44844. * Serializes this BRDF configuration.
  44845. * @returns - An object with the serialized config.
  44846. */
  44847. serialize(): any;
  44848. /**
  44849. * Parses a BRDF Configuration from a serialized object.
  44850. * @param source - Serialized object.
  44851. */
  44852. parse(source: any): void;
  44853. }
  44854. }
  44855. declare module BABYLON {
  44856. /**
  44857. * @hidden
  44858. */
  44859. export interface IMaterialSheenDefines {
  44860. SHEEN: boolean;
  44861. SHEEN_TEXTURE: boolean;
  44862. SHEEN_TEXTUREDIRECTUV: number;
  44863. SHEEN_LINKWITHALBEDO: boolean;
  44864. /** @hidden */
  44865. _areTexturesDirty: boolean;
  44866. }
  44867. /**
  44868. * Define the code related to the Sheen parameters of the pbr material.
  44869. */
  44870. export class PBRSheenConfiguration {
  44871. private _isEnabled;
  44872. /**
  44873. * Defines if the material uses sheen.
  44874. */
  44875. isEnabled: boolean;
  44876. private _linkSheenWithAlbedo;
  44877. /**
  44878. * Defines if the sheen is linked to the sheen color.
  44879. */
  44880. linkSheenWithAlbedo: boolean;
  44881. /**
  44882. * Defines the sheen intensity.
  44883. */
  44884. intensity: number;
  44885. /**
  44886. * Defines the sheen color.
  44887. */
  44888. color: Color3;
  44889. private _texture;
  44890. /**
  44891. * Stores the sheen tint values in a texture.
  44892. * rgb is tint
  44893. * a is a intensity
  44894. */
  44895. texture: Nullable<BaseTexture>;
  44896. /** @hidden */
  44897. private _internalMarkAllSubMeshesAsTexturesDirty;
  44898. /** @hidden */
  44899. _markAllSubMeshesAsTexturesDirty(): void;
  44900. /**
  44901. * Instantiate a new istance of clear coat configuration.
  44902. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  44903. */
  44904. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  44905. /**
  44906. * Specifies that the submesh is ready to be used.
  44907. * @param defines the list of "defines" to update.
  44908. * @param scene defines the scene the material belongs to.
  44909. * @returns - boolean indicating that the submesh is ready or not.
  44910. */
  44911. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  44912. /**
  44913. * Checks to see if a texture is used in the material.
  44914. * @param defines the list of "defines" to update.
  44915. * @param scene defines the scene the material belongs to.
  44916. */
  44917. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  44918. /**
  44919. * Binds the material data.
  44920. * @param uniformBuffer defines the Uniform buffer to fill in.
  44921. * @param scene defines the scene the material belongs to.
  44922. * @param isFrozen defines wether the material is frozen or not.
  44923. */
  44924. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  44925. /**
  44926. * Checks to see if a texture is used in the material.
  44927. * @param texture - Base texture to use.
  44928. * @returns - Boolean specifying if a texture is used in the material.
  44929. */
  44930. hasTexture(texture: BaseTexture): boolean;
  44931. /**
  44932. * Returns an array of the actively used textures.
  44933. * @param activeTextures Array of BaseTextures
  44934. */
  44935. getActiveTextures(activeTextures: BaseTexture[]): void;
  44936. /**
  44937. * Returns the animatable textures.
  44938. * @param animatables Array of animatable textures.
  44939. */
  44940. getAnimatables(animatables: IAnimatable[]): void;
  44941. /**
  44942. * Disposes the resources of the material.
  44943. * @param forceDisposeTextures - Forces the disposal of all textures.
  44944. */
  44945. dispose(forceDisposeTextures?: boolean): void;
  44946. /**
  44947. * Get the current class name of the texture useful for serialization or dynamic coding.
  44948. * @returns "PBRSheenConfiguration"
  44949. */
  44950. getClassName(): string;
  44951. /**
  44952. * Add fallbacks to the effect fallbacks list.
  44953. * @param defines defines the Base texture to use.
  44954. * @param fallbacks defines the current fallback list.
  44955. * @param currentRank defines the current fallback rank.
  44956. * @returns the new fallback rank.
  44957. */
  44958. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  44959. /**
  44960. * Add the required uniforms to the current list.
  44961. * @param uniforms defines the current uniform list.
  44962. */
  44963. static AddUniforms(uniforms: string[]): void;
  44964. /**
  44965. * Add the required uniforms to the current buffer.
  44966. * @param uniformBuffer defines the current uniform buffer.
  44967. */
  44968. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  44969. /**
  44970. * Add the required samplers to the current list.
  44971. * @param samplers defines the current sampler list.
  44972. */
  44973. static AddSamplers(samplers: string[]): void;
  44974. /**
  44975. * Makes a duplicate of the current configuration into another one.
  44976. * @param sheenConfiguration define the config where to copy the info
  44977. */
  44978. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  44979. /**
  44980. * Serializes this BRDF configuration.
  44981. * @returns - An object with the serialized config.
  44982. */
  44983. serialize(): any;
  44984. /**
  44985. * Parses a Sheen Configuration from a serialized object.
  44986. * @param source - Serialized object.
  44987. */
  44988. parse(source: any): void;
  44989. }
  44990. }
  44991. declare module BABYLON {
  44992. /**
  44993. * @hidden
  44994. */
  44995. export interface IMaterialSubSurfaceDefines {
  44996. SUBSURFACE: boolean;
  44997. SS_REFRACTION: boolean;
  44998. SS_TRANSLUCENCY: boolean;
  44999. SS_SCATERRING: boolean;
  45000. SS_THICKNESSANDMASK_TEXTURE: boolean;
  45001. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  45002. SS_REFRACTIONMAP_3D: boolean;
  45003. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  45004. SS_LODINREFRACTIONALPHA: boolean;
  45005. SS_GAMMAREFRACTION: boolean;
  45006. SS_RGBDREFRACTION: boolean;
  45007. SS_LINEARSPECULARREFRACTION: boolean;
  45008. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  45009. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  45010. /** @hidden */
  45011. _areTexturesDirty: boolean;
  45012. }
  45013. /**
  45014. * Define the code related to the sub surface parameters of the pbr material.
  45015. */
  45016. export class PBRSubSurfaceConfiguration {
  45017. private _isRefractionEnabled;
  45018. /**
  45019. * Defines if the refraction is enabled in the material.
  45020. */
  45021. isRefractionEnabled: boolean;
  45022. private _isTranslucencyEnabled;
  45023. /**
  45024. * Defines if the translucency is enabled in the material.
  45025. */
  45026. isTranslucencyEnabled: boolean;
  45027. private _isScatteringEnabled;
  45028. /**
  45029. * Defines the refraction intensity of the material.
  45030. * The refraction when enabled replaces the Diffuse part of the material.
  45031. * The intensity helps transitionning between diffuse and refraction.
  45032. */
  45033. refractionIntensity: number;
  45034. /**
  45035. * Defines the translucency intensity of the material.
  45036. * When translucency has been enabled, this defines how much of the "translucency"
  45037. * is addded to the diffuse part of the material.
  45038. */
  45039. translucencyIntensity: number;
  45040. /**
  45041. * Defines the scattering intensity of the material.
  45042. * When scattering has been enabled, this defines how much of the "scattered light"
  45043. * is addded to the diffuse part of the material.
  45044. */
  45045. scatteringIntensity: number;
  45046. private _thicknessTexture;
  45047. /**
  45048. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  45049. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  45050. * 0 would mean minimumThickness
  45051. * 1 would mean maximumThickness
  45052. * The other channels might be use as a mask to vary the different effects intensity.
  45053. */
  45054. thicknessTexture: Nullable<BaseTexture>;
  45055. private _refractionTexture;
  45056. /**
  45057. * Defines the texture to use for refraction.
  45058. */
  45059. refractionTexture: Nullable<BaseTexture>;
  45060. private _indexOfRefraction;
  45061. /**
  45062. * Defines the index of refraction used in the material.
  45063. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  45064. */
  45065. indexOfRefraction: number;
  45066. private _invertRefractionY;
  45067. /**
  45068. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  45069. */
  45070. invertRefractionY: boolean;
  45071. private _linkRefractionWithTransparency;
  45072. /**
  45073. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  45074. * Materials half opaque for instance using refraction could benefit from this control.
  45075. */
  45076. linkRefractionWithTransparency: boolean;
  45077. /**
  45078. * Defines the minimum thickness stored in the thickness map.
  45079. * If no thickness map is defined, this value will be used to simulate thickness.
  45080. */
  45081. minimumThickness: number;
  45082. /**
  45083. * Defines the maximum thickness stored in the thickness map.
  45084. */
  45085. maximumThickness: number;
  45086. /**
  45087. * Defines the volume tint of the material.
  45088. * This is used for both translucency and scattering.
  45089. */
  45090. tintColor: Color3;
  45091. /**
  45092. * Defines the distance at which the tint color should be found in the media.
  45093. * This is used for refraction only.
  45094. */
  45095. tintColorAtDistance: number;
  45096. /**
  45097. * Defines how far each channel transmit through the media.
  45098. * It is defined as a color to simplify it selection.
  45099. */
  45100. diffusionDistance: Color3;
  45101. private _useMaskFromThicknessTexture;
  45102. /**
  45103. * Stores the intensity of the different subsurface effects in the thickness texture.
  45104. * * the green channel is the translucency intensity.
  45105. * * the blue channel is the scattering intensity.
  45106. * * the alpha channel is the refraction intensity.
  45107. */
  45108. useMaskFromThicknessTexture: boolean;
  45109. /** @hidden */
  45110. private _internalMarkAllSubMeshesAsTexturesDirty;
  45111. /** @hidden */
  45112. _markAllSubMeshesAsTexturesDirty(): void;
  45113. /**
  45114. * Instantiate a new istance of sub surface configuration.
  45115. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  45116. */
  45117. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  45118. /**
  45119. * Gets wehter the submesh is ready to be used or not.
  45120. * @param defines the list of "defines" to update.
  45121. * @param scene defines the scene the material belongs to.
  45122. * @returns - boolean indicating that the submesh is ready or not.
  45123. */
  45124. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  45125. /**
  45126. * Checks to see if a texture is used in the material.
  45127. * @param defines the list of "defines" to update.
  45128. * @param scene defines the scene to the material belongs to.
  45129. */
  45130. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  45131. /**
  45132. * Binds the material data.
  45133. * @param uniformBuffer defines the Uniform buffer to fill in.
  45134. * @param scene defines the scene the material belongs to.
  45135. * @param engine defines the engine the material belongs to.
  45136. * @param isFrozen defines wether the material is frozen or not.
  45137. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  45138. */
  45139. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  45140. /**
  45141. * Unbinds the material from the mesh.
  45142. * @param activeEffect defines the effect that should be unbound from.
  45143. * @returns true if unbound, otherwise false
  45144. */
  45145. unbind(activeEffect: Effect): boolean;
  45146. /**
  45147. * Returns the texture used for refraction or null if none is used.
  45148. * @param scene defines the scene the material belongs to.
  45149. * @returns - Refraction texture if present. If no refraction texture and refraction
  45150. * is linked with transparency, returns environment texture. Otherwise, returns null.
  45151. */
  45152. private _getRefractionTexture;
  45153. /**
  45154. * Returns true if alpha blending should be disabled.
  45155. */
  45156. readonly disableAlphaBlending: boolean;
  45157. /**
  45158. * Fills the list of render target textures.
  45159. * @param renderTargets the list of render targets to update
  45160. */
  45161. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  45162. /**
  45163. * Checks to see if a texture is used in the material.
  45164. * @param texture - Base texture to use.
  45165. * @returns - Boolean specifying if a texture is used in the material.
  45166. */
  45167. hasTexture(texture: BaseTexture): boolean;
  45168. /**
  45169. * Gets a boolean indicating that current material needs to register RTT
  45170. * @returns true if this uses a render target otherwise false.
  45171. */
  45172. hasRenderTargetTextures(): boolean;
  45173. /**
  45174. * Returns an array of the actively used textures.
  45175. * @param activeTextures Array of BaseTextures
  45176. */
  45177. getActiveTextures(activeTextures: BaseTexture[]): void;
  45178. /**
  45179. * Returns the animatable textures.
  45180. * @param animatables Array of animatable textures.
  45181. */
  45182. getAnimatables(animatables: IAnimatable[]): void;
  45183. /**
  45184. * Disposes the resources of the material.
  45185. * @param forceDisposeTextures - Forces the disposal of all textures.
  45186. */
  45187. dispose(forceDisposeTextures?: boolean): void;
  45188. /**
  45189. * Get the current class name of the texture useful for serialization or dynamic coding.
  45190. * @returns "PBRSubSurfaceConfiguration"
  45191. */
  45192. getClassName(): string;
  45193. /**
  45194. * Add fallbacks to the effect fallbacks list.
  45195. * @param defines defines the Base texture to use.
  45196. * @param fallbacks defines the current fallback list.
  45197. * @param currentRank defines the current fallback rank.
  45198. * @returns the new fallback rank.
  45199. */
  45200. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  45201. /**
  45202. * Add the required uniforms to the current list.
  45203. * @param uniforms defines the current uniform list.
  45204. */
  45205. static AddUniforms(uniforms: string[]): void;
  45206. /**
  45207. * Add the required samplers to the current list.
  45208. * @param samplers defines the current sampler list.
  45209. */
  45210. static AddSamplers(samplers: string[]): void;
  45211. /**
  45212. * Add the required uniforms to the current buffer.
  45213. * @param uniformBuffer defines the current uniform buffer.
  45214. */
  45215. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  45216. /**
  45217. * Makes a duplicate of the current configuration into another one.
  45218. * @param configuration define the config where to copy the info
  45219. */
  45220. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  45221. /**
  45222. * Serializes this Sub Surface configuration.
  45223. * @returns - An object with the serialized config.
  45224. */
  45225. serialize(): any;
  45226. /**
  45227. * Parses a Sub Surface Configuration from a serialized object.
  45228. * @param source - Serialized object.
  45229. */
  45230. parse(source: any): void;
  45231. }
  45232. }
  45233. declare module BABYLON {
  45234. /** @hidden */
  45235. export var pbrFragmentDeclaration: {
  45236. name: string;
  45237. shader: string;
  45238. };
  45239. }
  45240. declare module BABYLON {
  45241. /** @hidden */
  45242. export var pbrUboDeclaration: {
  45243. name: string;
  45244. shader: string;
  45245. };
  45246. }
  45247. declare module BABYLON {
  45248. /** @hidden */
  45249. export var pbrFragmentExtraDeclaration: {
  45250. name: string;
  45251. shader: string;
  45252. };
  45253. }
  45254. declare module BABYLON {
  45255. /** @hidden */
  45256. export var pbrFragmentSamplersDeclaration: {
  45257. name: string;
  45258. shader: string;
  45259. };
  45260. }
  45261. declare module BABYLON {
  45262. /** @hidden */
  45263. export var pbrHelperFunctions: {
  45264. name: string;
  45265. shader: string;
  45266. };
  45267. }
  45268. declare module BABYLON {
  45269. /** @hidden */
  45270. export var harmonicsFunctions: {
  45271. name: string;
  45272. shader: string;
  45273. };
  45274. }
  45275. declare module BABYLON {
  45276. /** @hidden */
  45277. export var pbrDirectLightingSetupFunctions: {
  45278. name: string;
  45279. shader: string;
  45280. };
  45281. }
  45282. declare module BABYLON {
  45283. /** @hidden */
  45284. export var pbrDirectLightingFalloffFunctions: {
  45285. name: string;
  45286. shader: string;
  45287. };
  45288. }
  45289. declare module BABYLON {
  45290. /** @hidden */
  45291. export var pbrBRDFFunctions: {
  45292. name: string;
  45293. shader: string;
  45294. };
  45295. }
  45296. declare module BABYLON {
  45297. /** @hidden */
  45298. export var pbrDirectLightingFunctions: {
  45299. name: string;
  45300. shader: string;
  45301. };
  45302. }
  45303. declare module BABYLON {
  45304. /** @hidden */
  45305. export var pbrIBLFunctions: {
  45306. name: string;
  45307. shader: string;
  45308. };
  45309. }
  45310. declare module BABYLON {
  45311. /** @hidden */
  45312. export var pbrDebug: {
  45313. name: string;
  45314. shader: string;
  45315. };
  45316. }
  45317. declare module BABYLON {
  45318. /** @hidden */
  45319. export var pbrPixelShader: {
  45320. name: string;
  45321. shader: string;
  45322. };
  45323. }
  45324. declare module BABYLON {
  45325. /** @hidden */
  45326. export var pbrVertexDeclaration: {
  45327. name: string;
  45328. shader: string;
  45329. };
  45330. }
  45331. declare module BABYLON {
  45332. /** @hidden */
  45333. export var pbrVertexShader: {
  45334. name: string;
  45335. shader: string;
  45336. };
  45337. }
  45338. declare module BABYLON {
  45339. /**
  45340. * Manages the defines for the PBR Material.
  45341. * @hidden
  45342. */
  45343. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  45344. PBR: boolean;
  45345. MAINUV1: boolean;
  45346. MAINUV2: boolean;
  45347. UV1: boolean;
  45348. UV2: boolean;
  45349. ALBEDO: boolean;
  45350. ALBEDODIRECTUV: number;
  45351. VERTEXCOLOR: boolean;
  45352. AMBIENT: boolean;
  45353. AMBIENTDIRECTUV: number;
  45354. AMBIENTINGRAYSCALE: boolean;
  45355. OPACITY: boolean;
  45356. VERTEXALPHA: boolean;
  45357. OPACITYDIRECTUV: number;
  45358. OPACITYRGB: boolean;
  45359. ALPHATEST: boolean;
  45360. DEPTHPREPASS: boolean;
  45361. ALPHABLEND: boolean;
  45362. ALPHAFROMALBEDO: boolean;
  45363. ALPHATESTVALUE: string;
  45364. SPECULAROVERALPHA: boolean;
  45365. RADIANCEOVERALPHA: boolean;
  45366. ALPHAFRESNEL: boolean;
  45367. LINEARALPHAFRESNEL: boolean;
  45368. PREMULTIPLYALPHA: boolean;
  45369. EMISSIVE: boolean;
  45370. EMISSIVEDIRECTUV: number;
  45371. REFLECTIVITY: boolean;
  45372. REFLECTIVITYDIRECTUV: number;
  45373. SPECULARTERM: boolean;
  45374. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  45375. MICROSURFACEAUTOMATIC: boolean;
  45376. LODBASEDMICROSFURACE: boolean;
  45377. MICROSURFACEMAP: boolean;
  45378. MICROSURFACEMAPDIRECTUV: number;
  45379. METALLICWORKFLOW: boolean;
  45380. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  45381. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  45382. METALLNESSSTOREINMETALMAPBLUE: boolean;
  45383. AOSTOREINMETALMAPRED: boolean;
  45384. ENVIRONMENTBRDF: boolean;
  45385. ENVIRONMENTBRDF_RGBD: boolean;
  45386. NORMAL: boolean;
  45387. TANGENT: boolean;
  45388. BUMP: boolean;
  45389. BUMPDIRECTUV: number;
  45390. OBJECTSPACE_NORMALMAP: boolean;
  45391. PARALLAX: boolean;
  45392. PARALLAXOCCLUSION: boolean;
  45393. NORMALXYSCALE: boolean;
  45394. LIGHTMAP: boolean;
  45395. LIGHTMAPDIRECTUV: number;
  45396. USELIGHTMAPASSHADOWMAP: boolean;
  45397. GAMMALIGHTMAP: boolean;
  45398. REFLECTION: boolean;
  45399. REFLECTIONMAP_3D: boolean;
  45400. REFLECTIONMAP_SPHERICAL: boolean;
  45401. REFLECTIONMAP_PLANAR: boolean;
  45402. REFLECTIONMAP_CUBIC: boolean;
  45403. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  45404. REFLECTIONMAP_PROJECTION: boolean;
  45405. REFLECTIONMAP_SKYBOX: boolean;
  45406. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  45407. REFLECTIONMAP_EXPLICIT: boolean;
  45408. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  45409. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  45410. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  45411. INVERTCUBICMAP: boolean;
  45412. USESPHERICALFROMREFLECTIONMAP: boolean;
  45413. USEIRRADIANCEMAP: boolean;
  45414. SPHERICAL_HARMONICS: boolean;
  45415. USESPHERICALINVERTEX: boolean;
  45416. REFLECTIONMAP_OPPOSITEZ: boolean;
  45417. LODINREFLECTIONALPHA: boolean;
  45418. GAMMAREFLECTION: boolean;
  45419. RGBDREFLECTION: boolean;
  45420. LINEARSPECULARREFLECTION: boolean;
  45421. RADIANCEOCCLUSION: boolean;
  45422. HORIZONOCCLUSION: boolean;
  45423. INSTANCES: boolean;
  45424. NUM_BONE_INFLUENCERS: number;
  45425. BonesPerMesh: number;
  45426. BONETEXTURE: boolean;
  45427. NONUNIFORMSCALING: boolean;
  45428. MORPHTARGETS: boolean;
  45429. MORPHTARGETS_NORMAL: boolean;
  45430. MORPHTARGETS_TANGENT: boolean;
  45431. NUM_MORPH_INFLUENCERS: number;
  45432. IMAGEPROCESSING: boolean;
  45433. VIGNETTE: boolean;
  45434. VIGNETTEBLENDMODEMULTIPLY: boolean;
  45435. VIGNETTEBLENDMODEOPAQUE: boolean;
  45436. TONEMAPPING: boolean;
  45437. TONEMAPPING_ACES: boolean;
  45438. CONTRAST: boolean;
  45439. COLORCURVES: boolean;
  45440. COLORGRADING: boolean;
  45441. COLORGRADING3D: boolean;
  45442. SAMPLER3DGREENDEPTH: boolean;
  45443. SAMPLER3DBGRMAP: boolean;
  45444. IMAGEPROCESSINGPOSTPROCESS: boolean;
  45445. EXPOSURE: boolean;
  45446. MULTIVIEW: boolean;
  45447. USEPHYSICALLIGHTFALLOFF: boolean;
  45448. USEGLTFLIGHTFALLOFF: boolean;
  45449. TWOSIDEDLIGHTING: boolean;
  45450. SHADOWFLOAT: boolean;
  45451. CLIPPLANE: boolean;
  45452. CLIPPLANE2: boolean;
  45453. CLIPPLANE3: boolean;
  45454. CLIPPLANE4: boolean;
  45455. POINTSIZE: boolean;
  45456. FOG: boolean;
  45457. LOGARITHMICDEPTH: boolean;
  45458. FORCENORMALFORWARD: boolean;
  45459. SPECULARAA: boolean;
  45460. CLEARCOAT: boolean;
  45461. CLEARCOAT_DEFAULTIOR: boolean;
  45462. CLEARCOAT_TEXTURE: boolean;
  45463. CLEARCOAT_TEXTUREDIRECTUV: number;
  45464. CLEARCOAT_BUMP: boolean;
  45465. CLEARCOAT_BUMPDIRECTUV: number;
  45466. CLEARCOAT_TINT: boolean;
  45467. CLEARCOAT_TINT_TEXTURE: boolean;
  45468. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  45469. ANISOTROPIC: boolean;
  45470. ANISOTROPIC_TEXTURE: boolean;
  45471. ANISOTROPIC_TEXTUREDIRECTUV: number;
  45472. BRDF_V_HEIGHT_CORRELATED: boolean;
  45473. MS_BRDF_ENERGY_CONSERVATION: boolean;
  45474. SHEEN: boolean;
  45475. SHEEN_TEXTURE: boolean;
  45476. SHEEN_TEXTUREDIRECTUV: number;
  45477. SHEEN_LINKWITHALBEDO: boolean;
  45478. SUBSURFACE: boolean;
  45479. SS_REFRACTION: boolean;
  45480. SS_TRANSLUCENCY: boolean;
  45481. SS_SCATERRING: boolean;
  45482. SS_THICKNESSANDMASK_TEXTURE: boolean;
  45483. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  45484. SS_REFRACTIONMAP_3D: boolean;
  45485. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  45486. SS_LODINREFRACTIONALPHA: boolean;
  45487. SS_GAMMAREFRACTION: boolean;
  45488. SS_RGBDREFRACTION: boolean;
  45489. SS_LINEARSPECULARREFRACTION: boolean;
  45490. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  45491. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  45492. UNLIT: boolean;
  45493. DEBUGMODE: number;
  45494. /**
  45495. * Initializes the PBR Material defines.
  45496. */
  45497. constructor();
  45498. /**
  45499. * Resets the PBR Material defines.
  45500. */
  45501. reset(): void;
  45502. }
  45503. /**
  45504. * The Physically based material base class of BJS.
  45505. *
  45506. * This offers the main features of a standard PBR material.
  45507. * For more information, please refer to the documentation :
  45508. * https://doc.babylonjs.com/how_to/physically_based_rendering
  45509. */
  45510. export abstract class PBRBaseMaterial extends PushMaterial {
  45511. /**
  45512. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  45513. */
  45514. static readonly PBRMATERIAL_OPAQUE: number;
  45515. /**
  45516. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  45517. */
  45518. static readonly PBRMATERIAL_ALPHATEST: number;
  45519. /**
  45520. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  45521. */
  45522. static readonly PBRMATERIAL_ALPHABLEND: number;
  45523. /**
  45524. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  45525. * They are also discarded below the alpha cutoff threshold to improve performances.
  45526. */
  45527. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  45528. /**
  45529. * Defines the default value of how much AO map is occluding the analytical lights
  45530. * (point spot...).
  45531. */
  45532. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  45533. /**
  45534. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  45535. */
  45536. static readonly LIGHTFALLOFF_PHYSICAL: number;
  45537. /**
  45538. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  45539. * to enhance interoperability with other engines.
  45540. */
  45541. static readonly LIGHTFALLOFF_GLTF: number;
  45542. /**
  45543. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  45544. * to enhance interoperability with other materials.
  45545. */
  45546. static readonly LIGHTFALLOFF_STANDARD: number;
  45547. /**
  45548. * Intensity of the direct lights e.g. the four lights available in your scene.
  45549. * This impacts both the direct diffuse and specular highlights.
  45550. */
  45551. protected _directIntensity: number;
  45552. /**
  45553. * Intensity of the emissive part of the material.
  45554. * This helps controlling the emissive effect without modifying the emissive color.
  45555. */
  45556. protected _emissiveIntensity: number;
  45557. /**
  45558. * Intensity of the environment e.g. how much the environment will light the object
  45559. * either through harmonics for rough material or through the refelction for shiny ones.
  45560. */
  45561. protected _environmentIntensity: number;
  45562. /**
  45563. * This is a special control allowing the reduction of the specular highlights coming from the
  45564. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  45565. */
  45566. protected _specularIntensity: number;
  45567. /**
  45568. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  45569. */
  45570. private _lightingInfos;
  45571. /**
  45572. * Debug Control allowing disabling the bump map on this material.
  45573. */
  45574. protected _disableBumpMap: boolean;
  45575. /**
  45576. * AKA Diffuse Texture in standard nomenclature.
  45577. */
  45578. protected _albedoTexture: Nullable<BaseTexture>;
  45579. /**
  45580. * AKA Occlusion Texture in other nomenclature.
  45581. */
  45582. protected _ambientTexture: Nullable<BaseTexture>;
  45583. /**
  45584. * AKA Occlusion Texture Intensity in other nomenclature.
  45585. */
  45586. protected _ambientTextureStrength: number;
  45587. /**
  45588. * Defines how much the AO map is occluding the analytical lights (point spot...).
  45589. * 1 means it completely occludes it
  45590. * 0 mean it has no impact
  45591. */
  45592. protected _ambientTextureImpactOnAnalyticalLights: number;
  45593. /**
  45594. * Stores the alpha values in a texture.
  45595. */
  45596. protected _opacityTexture: Nullable<BaseTexture>;
  45597. /**
  45598. * Stores the reflection values in a texture.
  45599. */
  45600. protected _reflectionTexture: Nullable<BaseTexture>;
  45601. /**
  45602. * Stores the emissive values in a texture.
  45603. */
  45604. protected _emissiveTexture: Nullable<BaseTexture>;
  45605. /**
  45606. * AKA Specular texture in other nomenclature.
  45607. */
  45608. protected _reflectivityTexture: Nullable<BaseTexture>;
  45609. /**
  45610. * Used to switch from specular/glossiness to metallic/roughness workflow.
  45611. */
  45612. protected _metallicTexture: Nullable<BaseTexture>;
  45613. /**
  45614. * Specifies the metallic scalar of the metallic/roughness workflow.
  45615. * Can also be used to scale the metalness values of the metallic texture.
  45616. */
  45617. protected _metallic: Nullable<number>;
  45618. /**
  45619. * Specifies the roughness scalar of the metallic/roughness workflow.
  45620. * Can also be used to scale the roughness values of the metallic texture.
  45621. */
  45622. protected _roughness: Nullable<number>;
  45623. /**
  45624. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  45625. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  45626. */
  45627. protected _microSurfaceTexture: Nullable<BaseTexture>;
  45628. /**
  45629. * Stores surface normal data used to displace a mesh in a texture.
  45630. */
  45631. protected _bumpTexture: Nullable<BaseTexture>;
  45632. /**
  45633. * Stores the pre-calculated light information of a mesh in a texture.
  45634. */
  45635. protected _lightmapTexture: Nullable<BaseTexture>;
  45636. /**
  45637. * The color of a material in ambient lighting.
  45638. */
  45639. protected _ambientColor: Color3;
  45640. /**
  45641. * AKA Diffuse Color in other nomenclature.
  45642. */
  45643. protected _albedoColor: Color3;
  45644. /**
  45645. * AKA Specular Color in other nomenclature.
  45646. */
  45647. protected _reflectivityColor: Color3;
  45648. /**
  45649. * The color applied when light is reflected from a material.
  45650. */
  45651. protected _reflectionColor: Color3;
  45652. /**
  45653. * The color applied when light is emitted from a material.
  45654. */
  45655. protected _emissiveColor: Color3;
  45656. /**
  45657. * AKA Glossiness in other nomenclature.
  45658. */
  45659. protected _microSurface: number;
  45660. /**
  45661. * Specifies that the material will use the light map as a show map.
  45662. */
  45663. protected _useLightmapAsShadowmap: boolean;
  45664. /**
  45665. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  45666. * makes the reflect vector face the model (under horizon).
  45667. */
  45668. protected _useHorizonOcclusion: boolean;
  45669. /**
  45670. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  45671. * too much the area relying on ambient texture to define their ambient occlusion.
  45672. */
  45673. protected _useRadianceOcclusion: boolean;
  45674. /**
  45675. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  45676. */
  45677. protected _useAlphaFromAlbedoTexture: boolean;
  45678. /**
  45679. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  45680. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  45681. */
  45682. protected _useSpecularOverAlpha: boolean;
  45683. /**
  45684. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  45685. */
  45686. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  45687. /**
  45688. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  45689. */
  45690. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  45691. /**
  45692. * Specifies if the metallic texture contains the roughness information in its green channel.
  45693. */
  45694. protected _useRoughnessFromMetallicTextureGreen: boolean;
  45695. /**
  45696. * Specifies if the metallic texture contains the metallness information in its blue channel.
  45697. */
  45698. protected _useMetallnessFromMetallicTextureBlue: boolean;
  45699. /**
  45700. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  45701. */
  45702. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  45703. /**
  45704. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  45705. */
  45706. protected _useAmbientInGrayScale: boolean;
  45707. /**
  45708. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  45709. * The material will try to infer what glossiness each pixel should be.
  45710. */
  45711. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  45712. /**
  45713. * Defines the falloff type used in this material.
  45714. * It by default is Physical.
  45715. */
  45716. protected _lightFalloff: number;
  45717. /**
  45718. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  45719. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  45720. */
  45721. protected _useRadianceOverAlpha: boolean;
  45722. /**
  45723. * Allows using an object space normal map (instead of tangent space).
  45724. */
  45725. protected _useObjectSpaceNormalMap: boolean;
  45726. /**
  45727. * Allows using the bump map in parallax mode.
  45728. */
  45729. protected _useParallax: boolean;
  45730. /**
  45731. * Allows using the bump map in parallax occlusion mode.
  45732. */
  45733. protected _useParallaxOcclusion: boolean;
  45734. /**
  45735. * Controls the scale bias of the parallax mode.
  45736. */
  45737. protected _parallaxScaleBias: number;
  45738. /**
  45739. * If sets to true, disables all the lights affecting the material.
  45740. */
  45741. protected _disableLighting: boolean;
  45742. /**
  45743. * Number of Simultaneous lights allowed on the material.
  45744. */
  45745. protected _maxSimultaneousLights: number;
  45746. /**
  45747. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  45748. */
  45749. protected _invertNormalMapX: boolean;
  45750. /**
  45751. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  45752. */
  45753. protected _invertNormalMapY: boolean;
  45754. /**
  45755. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  45756. */
  45757. protected _twoSidedLighting: boolean;
  45758. /**
  45759. * Defines the alpha limits in alpha test mode.
  45760. */
  45761. protected _alphaCutOff: number;
  45762. /**
  45763. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  45764. */
  45765. protected _forceAlphaTest: boolean;
  45766. /**
  45767. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45768. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  45769. */
  45770. protected _useAlphaFresnel: boolean;
  45771. /**
  45772. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45773. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  45774. */
  45775. protected _useLinearAlphaFresnel: boolean;
  45776. /**
  45777. * The transparency mode of the material.
  45778. */
  45779. protected _transparencyMode: Nullable<number>;
  45780. /**
  45781. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  45782. * from cos thetav and roughness:
  45783. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  45784. */
  45785. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  45786. /**
  45787. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  45788. */
  45789. protected _forceIrradianceInFragment: boolean;
  45790. /**
  45791. * Force normal to face away from face.
  45792. */
  45793. protected _forceNormalForward: boolean;
  45794. /**
  45795. * Enables specular anti aliasing in the PBR shader.
  45796. * It will both interacts on the Geometry for analytical and IBL lighting.
  45797. * It also prefilter the roughness map based on the bump values.
  45798. */
  45799. protected _enableSpecularAntiAliasing: boolean;
  45800. /**
  45801. * Default configuration related to image processing available in the PBR Material.
  45802. */
  45803. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  45804. /**
  45805. * Keep track of the image processing observer to allow dispose and replace.
  45806. */
  45807. private _imageProcessingObserver;
  45808. /**
  45809. * Attaches a new image processing configuration to the PBR Material.
  45810. * @param configuration
  45811. */
  45812. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  45813. /**
  45814. * Stores the available render targets.
  45815. */
  45816. private _renderTargets;
  45817. /**
  45818. * Sets the global ambient color for the material used in lighting calculations.
  45819. */
  45820. private _globalAmbientColor;
  45821. /**
  45822. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  45823. */
  45824. private _useLogarithmicDepth;
  45825. /**
  45826. * If set to true, no lighting calculations will be applied.
  45827. */
  45828. private _unlit;
  45829. private _debugMode;
  45830. /**
  45831. * @hidden
  45832. * This is reserved for the inspector.
  45833. * Defines the material debug mode.
  45834. * It helps seeing only some components of the material while troubleshooting.
  45835. */
  45836. debugMode: number;
  45837. /**
  45838. * @hidden
  45839. * This is reserved for the inspector.
  45840. * Specify from where on screen the debug mode should start.
  45841. * The value goes from -1 (full screen) to 1 (not visible)
  45842. * It helps with side by side comparison against the final render
  45843. * This defaults to -1
  45844. */
  45845. private debugLimit;
  45846. /**
  45847. * @hidden
  45848. * This is reserved for the inspector.
  45849. * As the default viewing range might not be enough (if the ambient is really small for instance)
  45850. * You can use the factor to better multiply the final value.
  45851. */
  45852. private debugFactor;
  45853. /**
  45854. * Defines the clear coat layer parameters for the material.
  45855. */
  45856. readonly clearCoat: PBRClearCoatConfiguration;
  45857. /**
  45858. * Defines the anisotropic parameters for the material.
  45859. */
  45860. readonly anisotropy: PBRAnisotropicConfiguration;
  45861. /**
  45862. * Defines the BRDF parameters for the material.
  45863. */
  45864. readonly brdf: PBRBRDFConfiguration;
  45865. /**
  45866. * Defines the Sheen parameters for the material.
  45867. */
  45868. readonly sheen: PBRSheenConfiguration;
  45869. /**
  45870. * Defines the SubSurface parameters for the material.
  45871. */
  45872. readonly subSurface: PBRSubSurfaceConfiguration;
  45873. /**
  45874. * Custom callback helping to override the default shader used in the material.
  45875. */
  45876. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  45877. /**
  45878. * Instantiates a new PBRMaterial instance.
  45879. *
  45880. * @param name The material name
  45881. * @param scene The scene the material will be use in.
  45882. */
  45883. constructor(name: string, scene: Scene);
  45884. /**
  45885. * Gets a boolean indicating that current material needs to register RTT
  45886. */
  45887. readonly hasRenderTargetTextures: boolean;
  45888. /**
  45889. * Gets the name of the material class.
  45890. */
  45891. getClassName(): string;
  45892. /**
  45893. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  45894. */
  45895. /**
  45896. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  45897. */
  45898. useLogarithmicDepth: boolean;
  45899. /**
  45900. * Gets the current transparency mode.
  45901. */
  45902. /**
  45903. * Sets the transparency mode of the material.
  45904. *
  45905. * | Value | Type | Description |
  45906. * | ----- | ----------------------------------- | ----------- |
  45907. * | 0 | OPAQUE | |
  45908. * | 1 | ALPHATEST | |
  45909. * | 2 | ALPHABLEND | |
  45910. * | 3 | ALPHATESTANDBLEND | |
  45911. *
  45912. */
  45913. transparencyMode: Nullable<number>;
  45914. /**
  45915. * Returns true if alpha blending should be disabled.
  45916. */
  45917. private readonly _disableAlphaBlending;
  45918. /**
  45919. * Specifies whether or not this material should be rendered in alpha blend mode.
  45920. */
  45921. needAlphaBlending(): boolean;
  45922. /**
  45923. * Specifies if the mesh will require alpha blending.
  45924. * @param mesh - BJS mesh.
  45925. */
  45926. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  45927. /**
  45928. * Specifies whether or not this material should be rendered in alpha test mode.
  45929. */
  45930. needAlphaTesting(): boolean;
  45931. /**
  45932. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  45933. */
  45934. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  45935. /**
  45936. * Gets the texture used for the alpha test.
  45937. */
  45938. getAlphaTestTexture(): Nullable<BaseTexture>;
  45939. /**
  45940. * Specifies that the submesh is ready to be used.
  45941. * @param mesh - BJS mesh.
  45942. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  45943. * @param useInstances - Specifies that instances should be used.
  45944. * @returns - boolean indicating that the submesh is ready or not.
  45945. */
  45946. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  45947. /**
  45948. * Specifies if the material uses metallic roughness workflow.
  45949. * @returns boolean specifiying if the material uses metallic roughness workflow.
  45950. */
  45951. isMetallicWorkflow(): boolean;
  45952. private _prepareEffect;
  45953. private _prepareDefines;
  45954. /**
  45955. * Force shader compilation
  45956. */
  45957. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  45958. clipPlane: boolean;
  45959. }>): void;
  45960. /**
  45961. * Initializes the uniform buffer layout for the shader.
  45962. */
  45963. buildUniformLayout(): void;
  45964. /**
  45965. * Unbinds the material from the mesh
  45966. */
  45967. unbind(): void;
  45968. /**
  45969. * Binds the submesh data.
  45970. * @param world - The world matrix.
  45971. * @param mesh - The BJS mesh.
  45972. * @param subMesh - A submesh of the BJS mesh.
  45973. */
  45974. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  45975. /**
  45976. * Returns the animatable textures.
  45977. * @returns - Array of animatable textures.
  45978. */
  45979. getAnimatables(): IAnimatable[];
  45980. /**
  45981. * Returns the texture used for reflections.
  45982. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  45983. */
  45984. private _getReflectionTexture;
  45985. /**
  45986. * Returns an array of the actively used textures.
  45987. * @returns - Array of BaseTextures
  45988. */
  45989. getActiveTextures(): BaseTexture[];
  45990. /**
  45991. * Checks to see if a texture is used in the material.
  45992. * @param texture - Base texture to use.
  45993. * @returns - Boolean specifying if a texture is used in the material.
  45994. */
  45995. hasTexture(texture: BaseTexture): boolean;
  45996. /**
  45997. * Disposes the resources of the material.
  45998. * @param forceDisposeEffect - Forces the disposal of effects.
  45999. * @param forceDisposeTextures - Forces the disposal of all textures.
  46000. */
  46001. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  46002. }
  46003. }
  46004. declare module BABYLON {
  46005. /**
  46006. * The Physically based material of BJS.
  46007. *
  46008. * This offers the main features of a standard PBR material.
  46009. * For more information, please refer to the documentation :
  46010. * https://doc.babylonjs.com/how_to/physically_based_rendering
  46011. */
  46012. export class PBRMaterial extends PBRBaseMaterial {
  46013. /**
  46014. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  46015. */
  46016. static readonly PBRMATERIAL_OPAQUE: number;
  46017. /**
  46018. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  46019. */
  46020. static readonly PBRMATERIAL_ALPHATEST: number;
  46021. /**
  46022. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  46023. */
  46024. static readonly PBRMATERIAL_ALPHABLEND: number;
  46025. /**
  46026. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  46027. * They are also discarded below the alpha cutoff threshold to improve performances.
  46028. */
  46029. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  46030. /**
  46031. * Defines the default value of how much AO map is occluding the analytical lights
  46032. * (point spot...).
  46033. */
  46034. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  46035. /**
  46036. * Intensity of the direct lights e.g. the four lights available in your scene.
  46037. * This impacts both the direct diffuse and specular highlights.
  46038. */
  46039. directIntensity: number;
  46040. /**
  46041. * Intensity of the emissive part of the material.
  46042. * This helps controlling the emissive effect without modifying the emissive color.
  46043. */
  46044. emissiveIntensity: number;
  46045. /**
  46046. * Intensity of the environment e.g. how much the environment will light the object
  46047. * either through harmonics for rough material or through the refelction for shiny ones.
  46048. */
  46049. environmentIntensity: number;
  46050. /**
  46051. * This is a special control allowing the reduction of the specular highlights coming from the
  46052. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  46053. */
  46054. specularIntensity: number;
  46055. /**
  46056. * Debug Control allowing disabling the bump map on this material.
  46057. */
  46058. disableBumpMap: boolean;
  46059. /**
  46060. * AKA Diffuse Texture in standard nomenclature.
  46061. */
  46062. albedoTexture: BaseTexture;
  46063. /**
  46064. * AKA Occlusion Texture in other nomenclature.
  46065. */
  46066. ambientTexture: BaseTexture;
  46067. /**
  46068. * AKA Occlusion Texture Intensity in other nomenclature.
  46069. */
  46070. ambientTextureStrength: number;
  46071. /**
  46072. * Defines how much the AO map is occluding the analytical lights (point spot...).
  46073. * 1 means it completely occludes it
  46074. * 0 mean it has no impact
  46075. */
  46076. ambientTextureImpactOnAnalyticalLights: number;
  46077. /**
  46078. * Stores the alpha values in a texture.
  46079. */
  46080. opacityTexture: BaseTexture;
  46081. /**
  46082. * Stores the reflection values in a texture.
  46083. */
  46084. reflectionTexture: Nullable<BaseTexture>;
  46085. /**
  46086. * Stores the emissive values in a texture.
  46087. */
  46088. emissiveTexture: BaseTexture;
  46089. /**
  46090. * AKA Specular texture in other nomenclature.
  46091. */
  46092. reflectivityTexture: BaseTexture;
  46093. /**
  46094. * Used to switch from specular/glossiness to metallic/roughness workflow.
  46095. */
  46096. metallicTexture: BaseTexture;
  46097. /**
  46098. * Specifies the metallic scalar of the metallic/roughness workflow.
  46099. * Can also be used to scale the metalness values of the metallic texture.
  46100. */
  46101. metallic: Nullable<number>;
  46102. /**
  46103. * Specifies the roughness scalar of the metallic/roughness workflow.
  46104. * Can also be used to scale the roughness values of the metallic texture.
  46105. */
  46106. roughness: Nullable<number>;
  46107. /**
  46108. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  46109. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  46110. */
  46111. microSurfaceTexture: BaseTexture;
  46112. /**
  46113. * Stores surface normal data used to displace a mesh in a texture.
  46114. */
  46115. bumpTexture: BaseTexture;
  46116. /**
  46117. * Stores the pre-calculated light information of a mesh in a texture.
  46118. */
  46119. lightmapTexture: BaseTexture;
  46120. /**
  46121. * Stores the refracted light information in a texture.
  46122. */
  46123. refractionTexture: Nullable<BaseTexture>;
  46124. /**
  46125. * The color of a material in ambient lighting.
  46126. */
  46127. ambientColor: Color3;
  46128. /**
  46129. * AKA Diffuse Color in other nomenclature.
  46130. */
  46131. albedoColor: Color3;
  46132. /**
  46133. * AKA Specular Color in other nomenclature.
  46134. */
  46135. reflectivityColor: Color3;
  46136. /**
  46137. * The color reflected from the material.
  46138. */
  46139. reflectionColor: Color3;
  46140. /**
  46141. * The color emitted from the material.
  46142. */
  46143. emissiveColor: Color3;
  46144. /**
  46145. * AKA Glossiness in other nomenclature.
  46146. */
  46147. microSurface: number;
  46148. /**
  46149. * source material index of refraction (IOR)' / 'destination material IOR.
  46150. */
  46151. indexOfRefraction: number;
  46152. /**
  46153. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  46154. */
  46155. invertRefractionY: boolean;
  46156. /**
  46157. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  46158. * Materials half opaque for instance using refraction could benefit from this control.
  46159. */
  46160. linkRefractionWithTransparency: boolean;
  46161. /**
  46162. * If true, the light map contains occlusion information instead of lighting info.
  46163. */
  46164. useLightmapAsShadowmap: boolean;
  46165. /**
  46166. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  46167. */
  46168. useAlphaFromAlbedoTexture: boolean;
  46169. /**
  46170. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  46171. */
  46172. forceAlphaTest: boolean;
  46173. /**
  46174. * Defines the alpha limits in alpha test mode.
  46175. */
  46176. alphaCutOff: number;
  46177. /**
  46178. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  46179. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  46180. */
  46181. useSpecularOverAlpha: boolean;
  46182. /**
  46183. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  46184. */
  46185. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  46186. /**
  46187. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  46188. */
  46189. useRoughnessFromMetallicTextureAlpha: boolean;
  46190. /**
  46191. * Specifies if the metallic texture contains the roughness information in its green channel.
  46192. */
  46193. useRoughnessFromMetallicTextureGreen: boolean;
  46194. /**
  46195. * Specifies if the metallic texture contains the metallness information in its blue channel.
  46196. */
  46197. useMetallnessFromMetallicTextureBlue: boolean;
  46198. /**
  46199. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  46200. */
  46201. useAmbientOcclusionFromMetallicTextureRed: boolean;
  46202. /**
  46203. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  46204. */
  46205. useAmbientInGrayScale: boolean;
  46206. /**
  46207. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  46208. * The material will try to infer what glossiness each pixel should be.
  46209. */
  46210. useAutoMicroSurfaceFromReflectivityMap: boolean;
  46211. /**
  46212. * BJS is using an harcoded light falloff based on a manually sets up range.
  46213. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  46214. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  46215. */
  46216. /**
  46217. * BJS is using an harcoded light falloff based on a manually sets up range.
  46218. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  46219. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  46220. */
  46221. usePhysicalLightFalloff: boolean;
  46222. /**
  46223. * In order to support the falloff compatibility with gltf, a special mode has been added
  46224. * to reproduce the gltf light falloff.
  46225. */
  46226. /**
  46227. * In order to support the falloff compatibility with gltf, a special mode has been added
  46228. * to reproduce the gltf light falloff.
  46229. */
  46230. useGLTFLightFalloff: boolean;
  46231. /**
  46232. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  46233. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  46234. */
  46235. useRadianceOverAlpha: boolean;
  46236. /**
  46237. * Allows using an object space normal map (instead of tangent space).
  46238. */
  46239. useObjectSpaceNormalMap: boolean;
  46240. /**
  46241. * Allows using the bump map in parallax mode.
  46242. */
  46243. useParallax: boolean;
  46244. /**
  46245. * Allows using the bump map in parallax occlusion mode.
  46246. */
  46247. useParallaxOcclusion: boolean;
  46248. /**
  46249. * Controls the scale bias of the parallax mode.
  46250. */
  46251. parallaxScaleBias: number;
  46252. /**
  46253. * If sets to true, disables all the lights affecting the material.
  46254. */
  46255. disableLighting: boolean;
  46256. /**
  46257. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  46258. */
  46259. forceIrradianceInFragment: boolean;
  46260. /**
  46261. * Number of Simultaneous lights allowed on the material.
  46262. */
  46263. maxSimultaneousLights: number;
  46264. /**
  46265. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  46266. */
  46267. invertNormalMapX: boolean;
  46268. /**
  46269. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  46270. */
  46271. invertNormalMapY: boolean;
  46272. /**
  46273. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  46274. */
  46275. twoSidedLighting: boolean;
  46276. /**
  46277. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  46278. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  46279. */
  46280. useAlphaFresnel: boolean;
  46281. /**
  46282. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  46283. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  46284. */
  46285. useLinearAlphaFresnel: boolean;
  46286. /**
  46287. * Let user defines the brdf lookup texture used for IBL.
  46288. * A default 8bit version is embedded but you could point at :
  46289. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.png
  46290. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  46291. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  46292. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  46293. */
  46294. environmentBRDFTexture: Nullable<BaseTexture>;
  46295. /**
  46296. * Force normal to face away from face.
  46297. */
  46298. forceNormalForward: boolean;
  46299. /**
  46300. * Enables specular anti aliasing in the PBR shader.
  46301. * It will both interacts on the Geometry for analytical and IBL lighting.
  46302. * It also prefilter the roughness map based on the bump values.
  46303. */
  46304. enableSpecularAntiAliasing: boolean;
  46305. /**
  46306. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  46307. * makes the reflect vector face the model (under horizon).
  46308. */
  46309. useHorizonOcclusion: boolean;
  46310. /**
  46311. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  46312. * too much the area relying on ambient texture to define their ambient occlusion.
  46313. */
  46314. useRadianceOcclusion: boolean;
  46315. /**
  46316. * If set to true, no lighting calculations will be applied.
  46317. */
  46318. unlit: boolean;
  46319. /**
  46320. * Gets the image processing configuration used either in this material.
  46321. */
  46322. /**
  46323. * Sets the Default image processing configuration used either in the this material.
  46324. *
  46325. * If sets to null, the scene one is in use.
  46326. */
  46327. imageProcessingConfiguration: ImageProcessingConfiguration;
  46328. /**
  46329. * Gets wether the color curves effect is enabled.
  46330. */
  46331. /**
  46332. * Sets wether the color curves effect is enabled.
  46333. */
  46334. cameraColorCurvesEnabled: boolean;
  46335. /**
  46336. * Gets wether the color grading effect is enabled.
  46337. */
  46338. /**
  46339. * Gets wether the color grading effect is enabled.
  46340. */
  46341. cameraColorGradingEnabled: boolean;
  46342. /**
  46343. * Gets wether tonemapping is enabled or not.
  46344. */
  46345. /**
  46346. * Sets wether tonemapping is enabled or not
  46347. */
  46348. cameraToneMappingEnabled: boolean;
  46349. /**
  46350. * The camera exposure used on this material.
  46351. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  46352. * This corresponds to a photographic exposure.
  46353. */
  46354. /**
  46355. * The camera exposure used on this material.
  46356. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  46357. * This corresponds to a photographic exposure.
  46358. */
  46359. cameraExposure: number;
  46360. /**
  46361. * Gets The camera contrast used on this material.
  46362. */
  46363. /**
  46364. * Sets The camera contrast used on this material.
  46365. */
  46366. cameraContrast: number;
  46367. /**
  46368. * Gets the Color Grading 2D Lookup Texture.
  46369. */
  46370. /**
  46371. * Sets the Color Grading 2D Lookup Texture.
  46372. */
  46373. cameraColorGradingTexture: Nullable<BaseTexture>;
  46374. /**
  46375. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  46376. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  46377. * 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;
  46378. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  46379. */
  46380. /**
  46381. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  46382. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  46383. * 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;
  46384. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  46385. */
  46386. cameraColorCurves: Nullable<ColorCurves>;
  46387. /**
  46388. * Instantiates a new PBRMaterial instance.
  46389. *
  46390. * @param name The material name
  46391. * @param scene The scene the material will be use in.
  46392. */
  46393. constructor(name: string, scene: Scene);
  46394. /**
  46395. * Returns the name of this material class.
  46396. */
  46397. getClassName(): string;
  46398. /**
  46399. * Makes a duplicate of the current material.
  46400. * @param name - name to use for the new material.
  46401. */
  46402. clone(name: string): PBRMaterial;
  46403. /**
  46404. * Serializes this PBR Material.
  46405. * @returns - An object with the serialized material.
  46406. */
  46407. serialize(): any;
  46408. /**
  46409. * Parses a PBR Material from a serialized object.
  46410. * @param source - Serialized object.
  46411. * @param scene - BJS scene instance.
  46412. * @param rootUrl - url for the scene object
  46413. * @returns - PBRMaterial
  46414. */
  46415. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  46416. }
  46417. }
  46418. declare module BABYLON {
  46419. /**
  46420. * Direct draw surface info
  46421. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  46422. */
  46423. export interface DDSInfo {
  46424. /**
  46425. * Width of the texture
  46426. */
  46427. width: number;
  46428. /**
  46429. * Width of the texture
  46430. */
  46431. height: number;
  46432. /**
  46433. * Number of Mipmaps for the texture
  46434. * @see https://en.wikipedia.org/wiki/Mipmap
  46435. */
  46436. mipmapCount: number;
  46437. /**
  46438. * If the textures format is a known fourCC format
  46439. * @see https://www.fourcc.org/
  46440. */
  46441. isFourCC: boolean;
  46442. /**
  46443. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  46444. */
  46445. isRGB: boolean;
  46446. /**
  46447. * If the texture is a lumincance format
  46448. */
  46449. isLuminance: boolean;
  46450. /**
  46451. * If this is a cube texture
  46452. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  46453. */
  46454. isCube: boolean;
  46455. /**
  46456. * If the texture is a compressed format eg. FOURCC_DXT1
  46457. */
  46458. isCompressed: boolean;
  46459. /**
  46460. * The dxgiFormat of the texture
  46461. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  46462. */
  46463. dxgiFormat: number;
  46464. /**
  46465. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  46466. */
  46467. textureType: number;
  46468. /**
  46469. * Sphericle polynomial created for the dds texture
  46470. */
  46471. sphericalPolynomial?: SphericalPolynomial;
  46472. }
  46473. /**
  46474. * Class used to provide DDS decompression tools
  46475. */
  46476. export class DDSTools {
  46477. /**
  46478. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  46479. */
  46480. static StoreLODInAlphaChannel: boolean;
  46481. /**
  46482. * Gets DDS information from an array buffer
  46483. * @param arrayBuffer defines the array buffer to read data from
  46484. * @returns the DDS information
  46485. */
  46486. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  46487. private static _FloatView;
  46488. private static _Int32View;
  46489. private static _ToHalfFloat;
  46490. private static _FromHalfFloat;
  46491. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  46492. private static _GetHalfFloatRGBAArrayBuffer;
  46493. private static _GetFloatRGBAArrayBuffer;
  46494. private static _GetFloatAsUIntRGBAArrayBuffer;
  46495. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  46496. private static _GetRGBAArrayBuffer;
  46497. private static _ExtractLongWordOrder;
  46498. private static _GetRGBArrayBuffer;
  46499. private static _GetLuminanceArrayBuffer;
  46500. /**
  46501. * Uploads DDS Levels to a Babylon Texture
  46502. * @hidden
  46503. */
  46504. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  46505. }
  46506. interface Engine {
  46507. /**
  46508. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  46509. * @param rootUrl defines the url where the file to load is located
  46510. * @param scene defines the current scene
  46511. * @param lodScale defines scale to apply to the mip map selection
  46512. * @param lodOffset defines offset to apply to the mip map selection
  46513. * @param onLoad defines an optional callback raised when the texture is loaded
  46514. * @param onError defines an optional callback raised if there is an issue to load the texture
  46515. * @param format defines the format of the data
  46516. * @param forcedExtension defines the extension to use to pick the right loader
  46517. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  46518. * @returns the cube texture as an InternalTexture
  46519. */
  46520. 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;
  46521. }
  46522. }
  46523. declare module BABYLON {
  46524. /**
  46525. * Implementation of the DDS Texture Loader.
  46526. * @hidden
  46527. */
  46528. export class _DDSTextureLoader implements IInternalTextureLoader {
  46529. /**
  46530. * Defines wether the loader supports cascade loading the different faces.
  46531. */
  46532. readonly supportCascades: boolean;
  46533. /**
  46534. * This returns if the loader support the current file information.
  46535. * @param extension defines the file extension of the file being loaded
  46536. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46537. * @param fallback defines the fallback internal texture if any
  46538. * @param isBase64 defines whether the texture is encoded as a base64
  46539. * @param isBuffer defines whether the texture data are stored as a buffer
  46540. * @returns true if the loader can load the specified file
  46541. */
  46542. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  46543. /**
  46544. * Transform the url before loading if required.
  46545. * @param rootUrl the url of the texture
  46546. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46547. * @returns the transformed texture
  46548. */
  46549. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  46550. /**
  46551. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  46552. * @param rootUrl the url of the texture
  46553. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46554. * @returns the fallback texture
  46555. */
  46556. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  46557. /**
  46558. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  46559. * @param data contains the texture data
  46560. * @param texture defines the BabylonJS internal texture
  46561. * @param createPolynomials will be true if polynomials have been requested
  46562. * @param onLoad defines the callback to trigger once the texture is ready
  46563. * @param onError defines the callback to trigger in case of error
  46564. */
  46565. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  46566. /**
  46567. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  46568. * @param data contains the texture data
  46569. * @param texture defines the BabylonJS internal texture
  46570. * @param callback defines the method to call once ready to upload
  46571. */
  46572. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  46573. }
  46574. }
  46575. declare module BABYLON {
  46576. /** @hidden */
  46577. export var rgbdEncodePixelShader: {
  46578. name: string;
  46579. shader: string;
  46580. };
  46581. }
  46582. declare module BABYLON {
  46583. /**
  46584. * Raw texture data and descriptor sufficient for WebGL texture upload
  46585. */
  46586. export interface EnvironmentTextureInfo {
  46587. /**
  46588. * Version of the environment map
  46589. */
  46590. version: number;
  46591. /**
  46592. * Width of image
  46593. */
  46594. width: number;
  46595. /**
  46596. * Irradiance information stored in the file.
  46597. */
  46598. irradiance: any;
  46599. /**
  46600. * Specular information stored in the file.
  46601. */
  46602. specular: any;
  46603. }
  46604. /**
  46605. * Sets of helpers addressing the serialization and deserialization of environment texture
  46606. * stored in a BabylonJS env file.
  46607. * Those files are usually stored as .env files.
  46608. */
  46609. export class EnvironmentTextureTools {
  46610. /**
  46611. * Magic number identifying the env file.
  46612. */
  46613. private static _MagicBytes;
  46614. /**
  46615. * Gets the environment info from an env file.
  46616. * @param data The array buffer containing the .env bytes.
  46617. * @returns the environment file info (the json header) if successfully parsed.
  46618. */
  46619. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  46620. /**
  46621. * Creates an environment texture from a loaded cube texture.
  46622. * @param texture defines the cube texture to convert in env file
  46623. * @return a promise containing the environment data if succesfull.
  46624. */
  46625. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  46626. /**
  46627. * Creates a JSON representation of the spherical data.
  46628. * @param texture defines the texture containing the polynomials
  46629. * @return the JSON representation of the spherical info
  46630. */
  46631. private static _CreateEnvTextureIrradiance;
  46632. /**
  46633. * Uploads the texture info contained in the env file to the GPU.
  46634. * @param texture defines the internal texture to upload to
  46635. * @param arrayBuffer defines the buffer cotaining the data to load
  46636. * @param info defines the texture info retrieved through the GetEnvInfo method
  46637. * @returns a promise
  46638. */
  46639. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  46640. /**
  46641. * Uploads the levels of image data to the GPU.
  46642. * @param texture defines the internal texture to upload to
  46643. * @param imageData defines the array buffer views of image data [mipmap][face]
  46644. * @returns a promise
  46645. */
  46646. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  46647. /**
  46648. * Uploads spherical polynomials information to the texture.
  46649. * @param texture defines the texture we are trying to upload the information to
  46650. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  46651. */
  46652. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  46653. /** @hidden */
  46654. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  46655. }
  46656. }
  46657. declare module BABYLON {
  46658. /**
  46659. * Implementation of the ENV Texture Loader.
  46660. * @hidden
  46661. */
  46662. export class _ENVTextureLoader implements IInternalTextureLoader {
  46663. /**
  46664. * Defines wether the loader supports cascade loading the different faces.
  46665. */
  46666. readonly supportCascades: boolean;
  46667. /**
  46668. * This returns if the loader support the current file information.
  46669. * @param extension defines the file extension of the file being loaded
  46670. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46671. * @param fallback defines the fallback internal texture if any
  46672. * @param isBase64 defines whether the texture is encoded as a base64
  46673. * @param isBuffer defines whether the texture data are stored as a buffer
  46674. * @returns true if the loader can load the specified file
  46675. */
  46676. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  46677. /**
  46678. * Transform the url before loading if required.
  46679. * @param rootUrl the url of the texture
  46680. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46681. * @returns the transformed texture
  46682. */
  46683. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  46684. /**
  46685. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  46686. * @param rootUrl the url of the texture
  46687. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46688. * @returns the fallback texture
  46689. */
  46690. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  46691. /**
  46692. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  46693. * @param data contains the texture data
  46694. * @param texture defines the BabylonJS internal texture
  46695. * @param createPolynomials will be true if polynomials have been requested
  46696. * @param onLoad defines the callback to trigger once the texture is ready
  46697. * @param onError defines the callback to trigger in case of error
  46698. */
  46699. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  46700. /**
  46701. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  46702. * @param data contains the texture data
  46703. * @param texture defines the BabylonJS internal texture
  46704. * @param callback defines the method to call once ready to upload
  46705. */
  46706. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  46707. }
  46708. }
  46709. declare module BABYLON {
  46710. /**
  46711. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  46712. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  46713. */
  46714. export class KhronosTextureContainer {
  46715. /** contents of the KTX container file */
  46716. arrayBuffer: any;
  46717. private static HEADER_LEN;
  46718. private static COMPRESSED_2D;
  46719. private static COMPRESSED_3D;
  46720. private static TEX_2D;
  46721. private static TEX_3D;
  46722. /**
  46723. * Gets the openGL type
  46724. */
  46725. glType: number;
  46726. /**
  46727. * Gets the openGL type size
  46728. */
  46729. glTypeSize: number;
  46730. /**
  46731. * Gets the openGL format
  46732. */
  46733. glFormat: number;
  46734. /**
  46735. * Gets the openGL internal format
  46736. */
  46737. glInternalFormat: number;
  46738. /**
  46739. * Gets the base internal format
  46740. */
  46741. glBaseInternalFormat: number;
  46742. /**
  46743. * Gets image width in pixel
  46744. */
  46745. pixelWidth: number;
  46746. /**
  46747. * Gets image height in pixel
  46748. */
  46749. pixelHeight: number;
  46750. /**
  46751. * Gets image depth in pixels
  46752. */
  46753. pixelDepth: number;
  46754. /**
  46755. * Gets the number of array elements
  46756. */
  46757. numberOfArrayElements: number;
  46758. /**
  46759. * Gets the number of faces
  46760. */
  46761. numberOfFaces: number;
  46762. /**
  46763. * Gets the number of mipmap levels
  46764. */
  46765. numberOfMipmapLevels: number;
  46766. /**
  46767. * Gets the bytes of key value data
  46768. */
  46769. bytesOfKeyValueData: number;
  46770. /**
  46771. * Gets the load type
  46772. */
  46773. loadType: number;
  46774. /**
  46775. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  46776. */
  46777. isInvalid: boolean;
  46778. /**
  46779. * Creates a new KhronosTextureContainer
  46780. * @param arrayBuffer contents of the KTX container file
  46781. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  46782. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  46783. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  46784. */
  46785. constructor(
  46786. /** contents of the KTX container file */
  46787. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  46788. /**
  46789. * Uploads KTX content to a Babylon Texture.
  46790. * It is assumed that the texture has already been created & is currently bound
  46791. * @hidden
  46792. */
  46793. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  46794. private _upload2DCompressedLevels;
  46795. }
  46796. }
  46797. declare module BABYLON {
  46798. /**
  46799. * Implementation of the KTX Texture Loader.
  46800. * @hidden
  46801. */
  46802. export class _KTXTextureLoader implements IInternalTextureLoader {
  46803. /**
  46804. * Defines wether the loader supports cascade loading the different faces.
  46805. */
  46806. readonly supportCascades: boolean;
  46807. /**
  46808. * This returns if the loader support the current file information.
  46809. * @param extension defines the file extension of the file being loaded
  46810. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46811. * @param fallback defines the fallback internal texture if any
  46812. * @param isBase64 defines whether the texture is encoded as a base64
  46813. * @param isBuffer defines whether the texture data are stored as a buffer
  46814. * @returns true if the loader can load the specified file
  46815. */
  46816. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  46817. /**
  46818. * Transform the url before loading if required.
  46819. * @param rootUrl the url of the texture
  46820. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46821. * @returns the transformed texture
  46822. */
  46823. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  46824. /**
  46825. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  46826. * @param rootUrl the url of the texture
  46827. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46828. * @returns the fallback texture
  46829. */
  46830. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  46831. /**
  46832. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  46833. * @param data contains the texture data
  46834. * @param texture defines the BabylonJS internal texture
  46835. * @param createPolynomials will be true if polynomials have been requested
  46836. * @param onLoad defines the callback to trigger once the texture is ready
  46837. * @param onError defines the callback to trigger in case of error
  46838. */
  46839. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  46840. /**
  46841. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  46842. * @param data contains the texture data
  46843. * @param texture defines the BabylonJS internal texture
  46844. * @param callback defines the method to call once ready to upload
  46845. */
  46846. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  46847. }
  46848. }
  46849. declare module BABYLON {
  46850. /** @hidden */
  46851. export var _forceSceneHelpersToBundle: boolean;
  46852. interface Scene {
  46853. /**
  46854. * Creates a default light for the scene.
  46855. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  46856. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  46857. */
  46858. createDefaultLight(replace?: boolean): void;
  46859. /**
  46860. * Creates a default camera for the scene.
  46861. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  46862. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  46863. * @param replace has default false, when true replaces the active camera in the scene
  46864. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  46865. */
  46866. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  46867. /**
  46868. * Creates a default camera and a default light.
  46869. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  46870. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  46871. * @param replace has the default false, when true replaces the active camera/light in the scene
  46872. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  46873. */
  46874. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  46875. /**
  46876. * Creates a new sky box
  46877. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  46878. * @param environmentTexture defines the texture to use as environment texture
  46879. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  46880. * @param scale defines the overall scale of the skybox
  46881. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  46882. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  46883. * @returns a new mesh holding the sky box
  46884. */
  46885. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  46886. /**
  46887. * Creates a new environment
  46888. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  46889. * @param options defines the options you can use to configure the environment
  46890. * @returns the new EnvironmentHelper
  46891. */
  46892. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  46893. /**
  46894. * Creates a new VREXperienceHelper
  46895. * @see http://doc.babylonjs.com/how_to/webvr_helper
  46896. * @param webVROptions defines the options used to create the new VREXperienceHelper
  46897. * @returns a new VREXperienceHelper
  46898. */
  46899. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  46900. /**
  46901. * Creates a new XREXperienceHelper
  46902. * @see http://doc.babylonjs.com/how_to/webxr
  46903. * @returns a promise for a new XREXperienceHelper
  46904. */
  46905. createDefaultXRExperienceAsync(): Promise<WebXRExperienceHelper>;
  46906. }
  46907. }
  46908. declare module BABYLON {
  46909. /**
  46910. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  46911. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  46912. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  46913. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  46914. */
  46915. export class VideoDome extends TransformNode {
  46916. /**
  46917. * Define the video source as a Monoscopic panoramic 360 video.
  46918. */
  46919. static readonly MODE_MONOSCOPIC: number;
  46920. /**
  46921. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  46922. */
  46923. static readonly MODE_TOPBOTTOM: number;
  46924. /**
  46925. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  46926. */
  46927. static readonly MODE_SIDEBYSIDE: number;
  46928. private _useDirectMapping;
  46929. /**
  46930. * The video texture being displayed on the sphere
  46931. */
  46932. protected _videoTexture: VideoTexture;
  46933. /**
  46934. * Gets the video texture being displayed on the sphere
  46935. */
  46936. readonly videoTexture: VideoTexture;
  46937. /**
  46938. * The skybox material
  46939. */
  46940. protected _material: BackgroundMaterial;
  46941. /**
  46942. * The surface used for the skybox
  46943. */
  46944. protected _mesh: Mesh;
  46945. /**
  46946. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  46947. * Also see the options.resolution property.
  46948. */
  46949. fovMultiplier: number;
  46950. private _videoMode;
  46951. /**
  46952. * Gets or set the current video mode for the video. It can be:
  46953. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  46954. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  46955. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  46956. */
  46957. videoMode: number;
  46958. /**
  46959. * Oberserver used in Stereoscopic VR Mode.
  46960. */
  46961. private _onBeforeCameraRenderObserver;
  46962. /**
  46963. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  46964. * @param name Element's name, child elements will append suffixes for their own names.
  46965. * @param urlsOrVideo defines the url(s) or the video element to use
  46966. * @param options An object containing optional or exposed sub element properties
  46967. */
  46968. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  46969. resolution?: number;
  46970. clickToPlay?: boolean;
  46971. autoPlay?: boolean;
  46972. loop?: boolean;
  46973. size?: number;
  46974. poster?: string;
  46975. faceForward?: boolean;
  46976. useDirectMapping?: boolean;
  46977. }, scene: Scene);
  46978. private _changeVideoMode;
  46979. /**
  46980. * Releases resources associated with this node.
  46981. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  46982. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  46983. */
  46984. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  46985. }
  46986. }
  46987. declare module BABYLON {
  46988. /**
  46989. * This class can be used to get instrumentation data from a Babylon engine
  46990. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  46991. */
  46992. export class EngineInstrumentation implements IDisposable {
  46993. /**
  46994. * Define the instrumented engine.
  46995. */
  46996. engine: Engine;
  46997. private _captureGPUFrameTime;
  46998. private _gpuFrameTimeToken;
  46999. private _gpuFrameTime;
  47000. private _captureShaderCompilationTime;
  47001. private _shaderCompilationTime;
  47002. private _onBeginFrameObserver;
  47003. private _onEndFrameObserver;
  47004. private _onBeforeShaderCompilationObserver;
  47005. private _onAfterShaderCompilationObserver;
  47006. /**
  47007. * Gets the perf counter used for GPU frame time
  47008. */
  47009. readonly gpuFrameTimeCounter: PerfCounter;
  47010. /**
  47011. * Gets the GPU frame time capture status
  47012. */
  47013. /**
  47014. * Enable or disable the GPU frame time capture
  47015. */
  47016. captureGPUFrameTime: boolean;
  47017. /**
  47018. * Gets the perf counter used for shader compilation time
  47019. */
  47020. readonly shaderCompilationTimeCounter: PerfCounter;
  47021. /**
  47022. * Gets the shader compilation time capture status
  47023. */
  47024. /**
  47025. * Enable or disable the shader compilation time capture
  47026. */
  47027. captureShaderCompilationTime: boolean;
  47028. /**
  47029. * Instantiates a new engine instrumentation.
  47030. * This class can be used to get instrumentation data from a Babylon engine
  47031. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  47032. * @param engine Defines the engine to instrument
  47033. */
  47034. constructor(
  47035. /**
  47036. * Define the instrumented engine.
  47037. */
  47038. engine: Engine);
  47039. /**
  47040. * Dispose and release associated resources.
  47041. */
  47042. dispose(): void;
  47043. }
  47044. }
  47045. declare module BABYLON {
  47046. /**
  47047. * This class can be used to get instrumentation data from a Babylon engine
  47048. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  47049. */
  47050. export class SceneInstrumentation implements IDisposable {
  47051. /**
  47052. * Defines the scene to instrument
  47053. */
  47054. scene: Scene;
  47055. private _captureActiveMeshesEvaluationTime;
  47056. private _activeMeshesEvaluationTime;
  47057. private _captureRenderTargetsRenderTime;
  47058. private _renderTargetsRenderTime;
  47059. private _captureFrameTime;
  47060. private _frameTime;
  47061. private _captureRenderTime;
  47062. private _renderTime;
  47063. private _captureInterFrameTime;
  47064. private _interFrameTime;
  47065. private _captureParticlesRenderTime;
  47066. private _particlesRenderTime;
  47067. private _captureSpritesRenderTime;
  47068. private _spritesRenderTime;
  47069. private _capturePhysicsTime;
  47070. private _physicsTime;
  47071. private _captureAnimationsTime;
  47072. private _animationsTime;
  47073. private _captureCameraRenderTime;
  47074. private _cameraRenderTime;
  47075. private _onBeforeActiveMeshesEvaluationObserver;
  47076. private _onAfterActiveMeshesEvaluationObserver;
  47077. private _onBeforeRenderTargetsRenderObserver;
  47078. private _onAfterRenderTargetsRenderObserver;
  47079. private _onAfterRenderObserver;
  47080. private _onBeforeDrawPhaseObserver;
  47081. private _onAfterDrawPhaseObserver;
  47082. private _onBeforeAnimationsObserver;
  47083. private _onBeforeParticlesRenderingObserver;
  47084. private _onAfterParticlesRenderingObserver;
  47085. private _onBeforeSpritesRenderingObserver;
  47086. private _onAfterSpritesRenderingObserver;
  47087. private _onBeforePhysicsObserver;
  47088. private _onAfterPhysicsObserver;
  47089. private _onAfterAnimationsObserver;
  47090. private _onBeforeCameraRenderObserver;
  47091. private _onAfterCameraRenderObserver;
  47092. /**
  47093. * Gets the perf counter used for active meshes evaluation time
  47094. */
  47095. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  47096. /**
  47097. * Gets the active meshes evaluation time capture status
  47098. */
  47099. /**
  47100. * Enable or disable the active meshes evaluation time capture
  47101. */
  47102. captureActiveMeshesEvaluationTime: boolean;
  47103. /**
  47104. * Gets the perf counter used for render targets render time
  47105. */
  47106. readonly renderTargetsRenderTimeCounter: PerfCounter;
  47107. /**
  47108. * Gets the render targets render time capture status
  47109. */
  47110. /**
  47111. * Enable or disable the render targets render time capture
  47112. */
  47113. captureRenderTargetsRenderTime: boolean;
  47114. /**
  47115. * Gets the perf counter used for particles render time
  47116. */
  47117. readonly particlesRenderTimeCounter: PerfCounter;
  47118. /**
  47119. * Gets the particles render time capture status
  47120. */
  47121. /**
  47122. * Enable or disable the particles render time capture
  47123. */
  47124. captureParticlesRenderTime: boolean;
  47125. /**
  47126. * Gets the perf counter used for sprites render time
  47127. */
  47128. readonly spritesRenderTimeCounter: PerfCounter;
  47129. /**
  47130. * Gets the sprites render time capture status
  47131. */
  47132. /**
  47133. * Enable or disable the sprites render time capture
  47134. */
  47135. captureSpritesRenderTime: boolean;
  47136. /**
  47137. * Gets the perf counter used for physics time
  47138. */
  47139. readonly physicsTimeCounter: PerfCounter;
  47140. /**
  47141. * Gets the physics time capture status
  47142. */
  47143. /**
  47144. * Enable or disable the physics time capture
  47145. */
  47146. capturePhysicsTime: boolean;
  47147. /**
  47148. * Gets the perf counter used for animations time
  47149. */
  47150. readonly animationsTimeCounter: PerfCounter;
  47151. /**
  47152. * Gets the animations time capture status
  47153. */
  47154. /**
  47155. * Enable or disable the animations time capture
  47156. */
  47157. captureAnimationsTime: boolean;
  47158. /**
  47159. * Gets the perf counter used for frame time capture
  47160. */
  47161. readonly frameTimeCounter: PerfCounter;
  47162. /**
  47163. * Gets the frame time capture status
  47164. */
  47165. /**
  47166. * Enable or disable the frame time capture
  47167. */
  47168. captureFrameTime: boolean;
  47169. /**
  47170. * Gets the perf counter used for inter-frames time capture
  47171. */
  47172. readonly interFrameTimeCounter: PerfCounter;
  47173. /**
  47174. * Gets the inter-frames time capture status
  47175. */
  47176. /**
  47177. * Enable or disable the inter-frames time capture
  47178. */
  47179. captureInterFrameTime: boolean;
  47180. /**
  47181. * Gets the perf counter used for render time capture
  47182. */
  47183. readonly renderTimeCounter: PerfCounter;
  47184. /**
  47185. * Gets the render time capture status
  47186. */
  47187. /**
  47188. * Enable or disable the render time capture
  47189. */
  47190. captureRenderTime: boolean;
  47191. /**
  47192. * Gets the perf counter used for camera render time capture
  47193. */
  47194. readonly cameraRenderTimeCounter: PerfCounter;
  47195. /**
  47196. * Gets the camera render time capture status
  47197. */
  47198. /**
  47199. * Enable or disable the camera render time capture
  47200. */
  47201. captureCameraRenderTime: boolean;
  47202. /**
  47203. * Gets the perf counter used for draw calls
  47204. */
  47205. readonly drawCallsCounter: PerfCounter;
  47206. /**
  47207. * Instantiates a new scene instrumentation.
  47208. * This class can be used to get instrumentation data from a Babylon engine
  47209. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  47210. * @param scene Defines the scene to instrument
  47211. */
  47212. constructor(
  47213. /**
  47214. * Defines the scene to instrument
  47215. */
  47216. scene: Scene);
  47217. /**
  47218. * Dispose and release associated resources.
  47219. */
  47220. dispose(): void;
  47221. }
  47222. }
  47223. declare module BABYLON {
  47224. /** @hidden */
  47225. export var glowMapGenerationPixelShader: {
  47226. name: string;
  47227. shader: string;
  47228. };
  47229. }
  47230. declare module BABYLON {
  47231. /** @hidden */
  47232. export var glowMapGenerationVertexShader: {
  47233. name: string;
  47234. shader: string;
  47235. };
  47236. }
  47237. declare module BABYLON {
  47238. /**
  47239. * Effect layer options. This helps customizing the behaviour
  47240. * of the effect layer.
  47241. */
  47242. export interface IEffectLayerOptions {
  47243. /**
  47244. * Multiplication factor apply to the canvas size to compute the render target size
  47245. * used to generated the objects (the smaller the faster).
  47246. */
  47247. mainTextureRatio: number;
  47248. /**
  47249. * Enforces a fixed size texture to ensure effect stability across devices.
  47250. */
  47251. mainTextureFixedSize?: number;
  47252. /**
  47253. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  47254. */
  47255. alphaBlendingMode: number;
  47256. /**
  47257. * The camera attached to the layer.
  47258. */
  47259. camera: Nullable<Camera>;
  47260. /**
  47261. * The rendering group to draw the layer in.
  47262. */
  47263. renderingGroupId: number;
  47264. }
  47265. /**
  47266. * The effect layer Helps adding post process effect blended with the main pass.
  47267. *
  47268. * This can be for instance use to generate glow or higlight effects on the scene.
  47269. *
  47270. * The effect layer class can not be used directly and is intented to inherited from to be
  47271. * customized per effects.
  47272. */
  47273. export abstract class EffectLayer {
  47274. private _vertexBuffers;
  47275. private _indexBuffer;
  47276. private _cachedDefines;
  47277. private _effectLayerMapGenerationEffect;
  47278. private _effectLayerOptions;
  47279. private _mergeEffect;
  47280. protected _scene: Scene;
  47281. protected _engine: Engine;
  47282. protected _maxSize: number;
  47283. protected _mainTextureDesiredSize: ISize;
  47284. protected _mainTexture: RenderTargetTexture;
  47285. protected _shouldRender: boolean;
  47286. protected _postProcesses: PostProcess[];
  47287. protected _textures: BaseTexture[];
  47288. protected _emissiveTextureAndColor: {
  47289. texture: Nullable<BaseTexture>;
  47290. color: Color4;
  47291. };
  47292. /**
  47293. * The name of the layer
  47294. */
  47295. name: string;
  47296. /**
  47297. * The clear color of the texture used to generate the glow map.
  47298. */
  47299. neutralColor: Color4;
  47300. /**
  47301. * Specifies wether the highlight layer is enabled or not.
  47302. */
  47303. isEnabled: boolean;
  47304. /**
  47305. * Gets the camera attached to the layer.
  47306. */
  47307. readonly camera: Nullable<Camera>;
  47308. /**
  47309. * Gets the rendering group id the layer should render in.
  47310. */
  47311. readonly renderingGroupId: number;
  47312. /**
  47313. * An event triggered when the effect layer has been disposed.
  47314. */
  47315. onDisposeObservable: Observable<EffectLayer>;
  47316. /**
  47317. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  47318. */
  47319. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  47320. /**
  47321. * An event triggered when the generated texture is being merged in the scene.
  47322. */
  47323. onBeforeComposeObservable: Observable<EffectLayer>;
  47324. /**
  47325. * An event triggered when the generated texture has been merged in the scene.
  47326. */
  47327. onAfterComposeObservable: Observable<EffectLayer>;
  47328. /**
  47329. * An event triggered when the efffect layer changes its size.
  47330. */
  47331. onSizeChangedObservable: Observable<EffectLayer>;
  47332. /** @hidden */
  47333. static _SceneComponentInitialization: (scene: Scene) => void;
  47334. /**
  47335. * Instantiates a new effect Layer and references it in the scene.
  47336. * @param name The name of the layer
  47337. * @param scene The scene to use the layer in
  47338. */
  47339. constructor(
  47340. /** The Friendly of the effect in the scene */
  47341. name: string, scene: Scene);
  47342. /**
  47343. * Get the effect name of the layer.
  47344. * @return The effect name
  47345. */
  47346. abstract getEffectName(): string;
  47347. /**
  47348. * Checks for the readiness of the element composing the layer.
  47349. * @param subMesh the mesh to check for
  47350. * @param useInstances specify wether or not to use instances to render the mesh
  47351. * @return true if ready otherwise, false
  47352. */
  47353. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  47354. /**
  47355. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  47356. * @returns true if the effect requires stencil during the main canvas render pass.
  47357. */
  47358. abstract needStencil(): boolean;
  47359. /**
  47360. * Create the merge effect. This is the shader use to blit the information back
  47361. * to the main canvas at the end of the scene rendering.
  47362. * @returns The effect containing the shader used to merge the effect on the main canvas
  47363. */
  47364. protected abstract _createMergeEffect(): Effect;
  47365. /**
  47366. * Creates the render target textures and post processes used in the effect layer.
  47367. */
  47368. protected abstract _createTextureAndPostProcesses(): void;
  47369. /**
  47370. * Implementation specific of rendering the generating effect on the main canvas.
  47371. * @param effect The effect used to render through
  47372. */
  47373. protected abstract _internalRender(effect: Effect): void;
  47374. /**
  47375. * Sets the required values for both the emissive texture and and the main color.
  47376. */
  47377. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  47378. /**
  47379. * Free any resources and references associated to a mesh.
  47380. * Internal use
  47381. * @param mesh The mesh to free.
  47382. */
  47383. abstract _disposeMesh(mesh: Mesh): void;
  47384. /**
  47385. * Serializes this layer (Glow or Highlight for example)
  47386. * @returns a serialized layer object
  47387. */
  47388. abstract serialize?(): any;
  47389. /**
  47390. * Initializes the effect layer with the required options.
  47391. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  47392. */
  47393. protected _init(options: Partial<IEffectLayerOptions>): void;
  47394. /**
  47395. * Generates the index buffer of the full screen quad blending to the main canvas.
  47396. */
  47397. private _generateIndexBuffer;
  47398. /**
  47399. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  47400. */
  47401. private _generateVertexBuffer;
  47402. /**
  47403. * Sets the main texture desired size which is the closest power of two
  47404. * of the engine canvas size.
  47405. */
  47406. private _setMainTextureSize;
  47407. /**
  47408. * Creates the main texture for the effect layer.
  47409. */
  47410. protected _createMainTexture(): void;
  47411. /**
  47412. * Adds specific effects defines.
  47413. * @param defines The defines to add specifics to.
  47414. */
  47415. protected _addCustomEffectDefines(defines: string[]): void;
  47416. /**
  47417. * Checks for the readiness of the element composing the layer.
  47418. * @param subMesh the mesh to check for
  47419. * @param useInstances specify wether or not to use instances to render the mesh
  47420. * @param emissiveTexture the associated emissive texture used to generate the glow
  47421. * @return true if ready otherwise, false
  47422. */
  47423. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  47424. /**
  47425. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  47426. */
  47427. render(): void;
  47428. /**
  47429. * Determine if a given mesh will be used in the current effect.
  47430. * @param mesh mesh to test
  47431. * @returns true if the mesh will be used
  47432. */
  47433. hasMesh(mesh: AbstractMesh): boolean;
  47434. /**
  47435. * Returns true if the layer contains information to display, otherwise false.
  47436. * @returns true if the glow layer should be rendered
  47437. */
  47438. shouldRender(): boolean;
  47439. /**
  47440. * Returns true if the mesh should render, otherwise false.
  47441. * @param mesh The mesh to render
  47442. * @returns true if it should render otherwise false
  47443. */
  47444. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  47445. /**
  47446. * Returns true if the mesh can be rendered, otherwise false.
  47447. * @param mesh The mesh to render
  47448. * @param material The material used on the mesh
  47449. * @returns true if it can be rendered otherwise false
  47450. */
  47451. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  47452. /**
  47453. * Returns true if the mesh should render, otherwise false.
  47454. * @param mesh The mesh to render
  47455. * @returns true if it should render otherwise false
  47456. */
  47457. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  47458. /**
  47459. * Renders the submesh passed in parameter to the generation map.
  47460. */
  47461. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  47462. /**
  47463. * Rebuild the required buffers.
  47464. * @hidden Internal use only.
  47465. */
  47466. _rebuild(): void;
  47467. /**
  47468. * Dispose only the render target textures and post process.
  47469. */
  47470. private _disposeTextureAndPostProcesses;
  47471. /**
  47472. * Dispose the highlight layer and free resources.
  47473. */
  47474. dispose(): void;
  47475. /**
  47476. * Gets the class name of the effect layer
  47477. * @returns the string with the class name of the effect layer
  47478. */
  47479. getClassName(): string;
  47480. /**
  47481. * Creates an effect layer from parsed effect layer data
  47482. * @param parsedEffectLayer defines effect layer data
  47483. * @param scene defines the current scene
  47484. * @param rootUrl defines the root URL containing the effect layer information
  47485. * @returns a parsed effect Layer
  47486. */
  47487. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  47488. }
  47489. }
  47490. declare module BABYLON {
  47491. interface AbstractScene {
  47492. /**
  47493. * The list of effect layers (highlights/glow) added to the scene
  47494. * @see http://doc.babylonjs.com/how_to/highlight_layer
  47495. * @see http://doc.babylonjs.com/how_to/glow_layer
  47496. */
  47497. effectLayers: Array<EffectLayer>;
  47498. /**
  47499. * Removes the given effect layer from this scene.
  47500. * @param toRemove defines the effect layer to remove
  47501. * @returns the index of the removed effect layer
  47502. */
  47503. removeEffectLayer(toRemove: EffectLayer): number;
  47504. /**
  47505. * Adds the given effect layer to this scene
  47506. * @param newEffectLayer defines the effect layer to add
  47507. */
  47508. addEffectLayer(newEffectLayer: EffectLayer): void;
  47509. }
  47510. /**
  47511. * Defines the layer scene component responsible to manage any effect layers
  47512. * in a given scene.
  47513. */
  47514. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  47515. /**
  47516. * The component name helpfull to identify the component in the list of scene components.
  47517. */
  47518. readonly name: string;
  47519. /**
  47520. * The scene the component belongs to.
  47521. */
  47522. scene: Scene;
  47523. private _engine;
  47524. private _renderEffects;
  47525. private _needStencil;
  47526. private _previousStencilState;
  47527. /**
  47528. * Creates a new instance of the component for the given scene
  47529. * @param scene Defines the scene to register the component in
  47530. */
  47531. constructor(scene: Scene);
  47532. /**
  47533. * Registers the component in a given scene
  47534. */
  47535. register(): void;
  47536. /**
  47537. * Rebuilds the elements related to this component in case of
  47538. * context lost for instance.
  47539. */
  47540. rebuild(): void;
  47541. /**
  47542. * Serializes the component data to the specified json object
  47543. * @param serializationObject The object to serialize to
  47544. */
  47545. serialize(serializationObject: any): void;
  47546. /**
  47547. * Adds all the elements from the container to the scene
  47548. * @param container the container holding the elements
  47549. */
  47550. addFromContainer(container: AbstractScene): void;
  47551. /**
  47552. * Removes all the elements in the container from the scene
  47553. * @param container contains the elements to remove
  47554. * @param dispose if the removed element should be disposed (default: false)
  47555. */
  47556. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  47557. /**
  47558. * Disposes the component and the associated ressources.
  47559. */
  47560. dispose(): void;
  47561. private _isReadyForMesh;
  47562. private _renderMainTexture;
  47563. private _setStencil;
  47564. private _setStencilBack;
  47565. private _draw;
  47566. private _drawCamera;
  47567. private _drawRenderingGroup;
  47568. }
  47569. }
  47570. declare module BABYLON {
  47571. /** @hidden */
  47572. export var glowMapMergePixelShader: {
  47573. name: string;
  47574. shader: string;
  47575. };
  47576. }
  47577. declare module BABYLON {
  47578. /** @hidden */
  47579. export var glowMapMergeVertexShader: {
  47580. name: string;
  47581. shader: string;
  47582. };
  47583. }
  47584. declare module BABYLON {
  47585. interface AbstractScene {
  47586. /**
  47587. * Return a the first highlight layer of the scene with a given name.
  47588. * @param name The name of the highlight layer to look for.
  47589. * @return The highlight layer if found otherwise null.
  47590. */
  47591. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  47592. }
  47593. /**
  47594. * Glow layer options. This helps customizing the behaviour
  47595. * of the glow layer.
  47596. */
  47597. export interface IGlowLayerOptions {
  47598. /**
  47599. * Multiplication factor apply to the canvas size to compute the render target size
  47600. * used to generated the glowing objects (the smaller the faster).
  47601. */
  47602. mainTextureRatio: number;
  47603. /**
  47604. * Enforces a fixed size texture to ensure resize independant blur.
  47605. */
  47606. mainTextureFixedSize?: number;
  47607. /**
  47608. * How big is the kernel of the blur texture.
  47609. */
  47610. blurKernelSize: number;
  47611. /**
  47612. * The camera attached to the layer.
  47613. */
  47614. camera: Nullable<Camera>;
  47615. /**
  47616. * Enable MSAA by chosing the number of samples.
  47617. */
  47618. mainTextureSamples?: number;
  47619. /**
  47620. * The rendering group to draw the layer in.
  47621. */
  47622. renderingGroupId: number;
  47623. }
  47624. /**
  47625. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  47626. *
  47627. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  47628. * glowy meshes to your scene.
  47629. *
  47630. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  47631. */
  47632. export class GlowLayer extends EffectLayer {
  47633. /**
  47634. * Effect Name of the layer.
  47635. */
  47636. static readonly EffectName: string;
  47637. /**
  47638. * The default blur kernel size used for the glow.
  47639. */
  47640. static DefaultBlurKernelSize: number;
  47641. /**
  47642. * The default texture size ratio used for the glow.
  47643. */
  47644. static DefaultTextureRatio: number;
  47645. /**
  47646. * Sets the kernel size of the blur.
  47647. */
  47648. /**
  47649. * Gets the kernel size of the blur.
  47650. */
  47651. blurKernelSize: number;
  47652. /**
  47653. * Sets the glow intensity.
  47654. */
  47655. /**
  47656. * Gets the glow intensity.
  47657. */
  47658. intensity: number;
  47659. private _options;
  47660. private _intensity;
  47661. private _horizontalBlurPostprocess1;
  47662. private _verticalBlurPostprocess1;
  47663. private _horizontalBlurPostprocess2;
  47664. private _verticalBlurPostprocess2;
  47665. private _blurTexture1;
  47666. private _blurTexture2;
  47667. private _postProcesses1;
  47668. private _postProcesses2;
  47669. private _includedOnlyMeshes;
  47670. private _excludedMeshes;
  47671. /**
  47672. * Callback used to let the user override the color selection on a per mesh basis
  47673. */
  47674. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  47675. /**
  47676. * Callback used to let the user override the texture selection on a per mesh basis
  47677. */
  47678. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  47679. /**
  47680. * Instantiates a new glow Layer and references it to the scene.
  47681. * @param name The name of the layer
  47682. * @param scene The scene to use the layer in
  47683. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  47684. */
  47685. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  47686. /**
  47687. * Get the effect name of the layer.
  47688. * @return The effect name
  47689. */
  47690. getEffectName(): string;
  47691. /**
  47692. * Create the merge effect. This is the shader use to blit the information back
  47693. * to the main canvas at the end of the scene rendering.
  47694. */
  47695. protected _createMergeEffect(): Effect;
  47696. /**
  47697. * Creates the render target textures and post processes used in the glow layer.
  47698. */
  47699. protected _createTextureAndPostProcesses(): void;
  47700. /**
  47701. * Checks for the readiness of the element composing the layer.
  47702. * @param subMesh the mesh to check for
  47703. * @param useInstances specify wether or not to use instances to render the mesh
  47704. * @param emissiveTexture the associated emissive texture used to generate the glow
  47705. * @return true if ready otherwise, false
  47706. */
  47707. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  47708. /**
  47709. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  47710. */
  47711. needStencil(): boolean;
  47712. /**
  47713. * Returns true if the mesh can be rendered, otherwise false.
  47714. * @param mesh The mesh to render
  47715. * @param material The material used on the mesh
  47716. * @returns true if it can be rendered otherwise false
  47717. */
  47718. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  47719. /**
  47720. * Implementation specific of rendering the generating effect on the main canvas.
  47721. * @param effect The effect used to render through
  47722. */
  47723. protected _internalRender(effect: Effect): void;
  47724. /**
  47725. * Sets the required values for both the emissive texture and and the main color.
  47726. */
  47727. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  47728. /**
  47729. * Returns true if the mesh should render, otherwise false.
  47730. * @param mesh The mesh to render
  47731. * @returns true if it should render otherwise false
  47732. */
  47733. protected _shouldRenderMesh(mesh: Mesh): boolean;
  47734. /**
  47735. * Adds specific effects defines.
  47736. * @param defines The defines to add specifics to.
  47737. */
  47738. protected _addCustomEffectDefines(defines: string[]): void;
  47739. /**
  47740. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  47741. * @param mesh The mesh to exclude from the glow layer
  47742. */
  47743. addExcludedMesh(mesh: Mesh): void;
  47744. /**
  47745. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  47746. * @param mesh The mesh to remove
  47747. */
  47748. removeExcludedMesh(mesh: Mesh): void;
  47749. /**
  47750. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  47751. * @param mesh The mesh to include in the glow layer
  47752. */
  47753. addIncludedOnlyMesh(mesh: Mesh): void;
  47754. /**
  47755. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  47756. * @param mesh The mesh to remove
  47757. */
  47758. removeIncludedOnlyMesh(mesh: Mesh): void;
  47759. /**
  47760. * Determine if a given mesh will be used in the glow layer
  47761. * @param mesh The mesh to test
  47762. * @returns true if the mesh will be highlighted by the current glow layer
  47763. */
  47764. hasMesh(mesh: AbstractMesh): boolean;
  47765. /**
  47766. * Free any resources and references associated to a mesh.
  47767. * Internal use
  47768. * @param mesh The mesh to free.
  47769. * @hidden
  47770. */
  47771. _disposeMesh(mesh: Mesh): void;
  47772. /**
  47773. * Gets the class name of the effect layer
  47774. * @returns the string with the class name of the effect layer
  47775. */
  47776. getClassName(): string;
  47777. /**
  47778. * Serializes this glow layer
  47779. * @returns a serialized glow layer object
  47780. */
  47781. serialize(): any;
  47782. /**
  47783. * Creates a Glow Layer from parsed glow layer data
  47784. * @param parsedGlowLayer defines glow layer data
  47785. * @param scene defines the current scene
  47786. * @param rootUrl defines the root URL containing the glow layer information
  47787. * @returns a parsed Glow Layer
  47788. */
  47789. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  47790. }
  47791. }
  47792. declare module BABYLON {
  47793. /** @hidden */
  47794. export var glowBlurPostProcessPixelShader: {
  47795. name: string;
  47796. shader: string;
  47797. };
  47798. }
  47799. declare module BABYLON {
  47800. interface AbstractScene {
  47801. /**
  47802. * Return a the first highlight layer of the scene with a given name.
  47803. * @param name The name of the highlight layer to look for.
  47804. * @return The highlight layer if found otherwise null.
  47805. */
  47806. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  47807. }
  47808. /**
  47809. * Highlight layer options. This helps customizing the behaviour
  47810. * of the highlight layer.
  47811. */
  47812. export interface IHighlightLayerOptions {
  47813. /**
  47814. * Multiplication factor apply to the canvas size to compute the render target size
  47815. * used to generated the glowing objects (the smaller the faster).
  47816. */
  47817. mainTextureRatio: number;
  47818. /**
  47819. * Enforces a fixed size texture to ensure resize independant blur.
  47820. */
  47821. mainTextureFixedSize?: number;
  47822. /**
  47823. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  47824. * of the picture to blur (the smaller the faster).
  47825. */
  47826. blurTextureSizeRatio: number;
  47827. /**
  47828. * How big in texel of the blur texture is the vertical blur.
  47829. */
  47830. blurVerticalSize: number;
  47831. /**
  47832. * How big in texel of the blur texture is the horizontal blur.
  47833. */
  47834. blurHorizontalSize: number;
  47835. /**
  47836. * Alpha blending mode used to apply the blur. Default is combine.
  47837. */
  47838. alphaBlendingMode: number;
  47839. /**
  47840. * The camera attached to the layer.
  47841. */
  47842. camera: Nullable<Camera>;
  47843. /**
  47844. * Should we display highlight as a solid stroke?
  47845. */
  47846. isStroke?: boolean;
  47847. /**
  47848. * The rendering group to draw the layer in.
  47849. */
  47850. renderingGroupId: number;
  47851. }
  47852. /**
  47853. * The highlight layer Helps adding a glow effect around a mesh.
  47854. *
  47855. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  47856. * glowy meshes to your scene.
  47857. *
  47858. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  47859. */
  47860. export class HighlightLayer extends EffectLayer {
  47861. name: string;
  47862. /**
  47863. * Effect Name of the highlight layer.
  47864. */
  47865. static readonly EffectName: string;
  47866. /**
  47867. * The neutral color used during the preparation of the glow effect.
  47868. * This is black by default as the blend operation is a blend operation.
  47869. */
  47870. static NeutralColor: Color4;
  47871. /**
  47872. * Stencil value used for glowing meshes.
  47873. */
  47874. static GlowingMeshStencilReference: number;
  47875. /**
  47876. * Stencil value used for the other meshes in the scene.
  47877. */
  47878. static NormalMeshStencilReference: number;
  47879. /**
  47880. * Specifies whether or not the inner glow is ACTIVE in the layer.
  47881. */
  47882. innerGlow: boolean;
  47883. /**
  47884. * Specifies whether or not the outer glow is ACTIVE in the layer.
  47885. */
  47886. outerGlow: boolean;
  47887. /**
  47888. * Specifies the horizontal size of the blur.
  47889. */
  47890. /**
  47891. * Gets the horizontal size of the blur.
  47892. */
  47893. blurHorizontalSize: number;
  47894. /**
  47895. * Specifies the vertical size of the blur.
  47896. */
  47897. /**
  47898. * Gets the vertical size of the blur.
  47899. */
  47900. blurVerticalSize: number;
  47901. /**
  47902. * An event triggered when the highlight layer is being blurred.
  47903. */
  47904. onBeforeBlurObservable: Observable<HighlightLayer>;
  47905. /**
  47906. * An event triggered when the highlight layer has been blurred.
  47907. */
  47908. onAfterBlurObservable: Observable<HighlightLayer>;
  47909. private _instanceGlowingMeshStencilReference;
  47910. private _options;
  47911. private _downSamplePostprocess;
  47912. private _horizontalBlurPostprocess;
  47913. private _verticalBlurPostprocess;
  47914. private _blurTexture;
  47915. private _meshes;
  47916. private _excludedMeshes;
  47917. /**
  47918. * Instantiates a new highlight Layer and references it to the scene..
  47919. * @param name The name of the layer
  47920. * @param scene The scene to use the layer in
  47921. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  47922. */
  47923. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  47924. /**
  47925. * Get the effect name of the layer.
  47926. * @return The effect name
  47927. */
  47928. getEffectName(): string;
  47929. /**
  47930. * Create the merge effect. This is the shader use to blit the information back
  47931. * to the main canvas at the end of the scene rendering.
  47932. */
  47933. protected _createMergeEffect(): Effect;
  47934. /**
  47935. * Creates the render target textures and post processes used in the highlight layer.
  47936. */
  47937. protected _createTextureAndPostProcesses(): void;
  47938. /**
  47939. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  47940. */
  47941. needStencil(): boolean;
  47942. /**
  47943. * Checks for the readiness of the element composing the layer.
  47944. * @param subMesh the mesh to check for
  47945. * @param useInstances specify wether or not to use instances to render the mesh
  47946. * @param emissiveTexture the associated emissive texture used to generate the glow
  47947. * @return true if ready otherwise, false
  47948. */
  47949. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  47950. /**
  47951. * Implementation specific of rendering the generating effect on the main canvas.
  47952. * @param effect The effect used to render through
  47953. */
  47954. protected _internalRender(effect: Effect): void;
  47955. /**
  47956. * Returns true if the layer contains information to display, otherwise false.
  47957. */
  47958. shouldRender(): boolean;
  47959. /**
  47960. * Returns true if the mesh should render, otherwise false.
  47961. * @param mesh The mesh to render
  47962. * @returns true if it should render otherwise false
  47963. */
  47964. protected _shouldRenderMesh(mesh: Mesh): boolean;
  47965. /**
  47966. * Sets the required values for both the emissive texture and and the main color.
  47967. */
  47968. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  47969. /**
  47970. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  47971. * @param mesh The mesh to exclude from the highlight layer
  47972. */
  47973. addExcludedMesh(mesh: Mesh): void;
  47974. /**
  47975. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  47976. * @param mesh The mesh to highlight
  47977. */
  47978. removeExcludedMesh(mesh: Mesh): void;
  47979. /**
  47980. * Determine if a given mesh will be highlighted by the current HighlightLayer
  47981. * @param mesh mesh to test
  47982. * @returns true if the mesh will be highlighted by the current HighlightLayer
  47983. */
  47984. hasMesh(mesh: AbstractMesh): boolean;
  47985. /**
  47986. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  47987. * @param mesh The mesh to highlight
  47988. * @param color The color of the highlight
  47989. * @param glowEmissiveOnly Extract the glow from the emissive texture
  47990. */
  47991. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  47992. /**
  47993. * Remove a mesh from the highlight layer in order to make it stop glowing.
  47994. * @param mesh The mesh to highlight
  47995. */
  47996. removeMesh(mesh: Mesh): void;
  47997. /**
  47998. * Force the stencil to the normal expected value for none glowing parts
  47999. */
  48000. private _defaultStencilReference;
  48001. /**
  48002. * Free any resources and references associated to a mesh.
  48003. * Internal use
  48004. * @param mesh The mesh to free.
  48005. * @hidden
  48006. */
  48007. _disposeMesh(mesh: Mesh): void;
  48008. /**
  48009. * Dispose the highlight layer and free resources.
  48010. */
  48011. dispose(): void;
  48012. /**
  48013. * Gets the class name of the effect layer
  48014. * @returns the string with the class name of the effect layer
  48015. */
  48016. getClassName(): string;
  48017. /**
  48018. * Serializes this Highlight layer
  48019. * @returns a serialized Highlight layer object
  48020. */
  48021. serialize(): any;
  48022. /**
  48023. * Creates a Highlight layer from parsed Highlight layer data
  48024. * @param parsedHightlightLayer defines the Highlight layer data
  48025. * @param scene defines the current scene
  48026. * @param rootUrl defines the root URL containing the Highlight layer information
  48027. * @returns a parsed Highlight layer
  48028. */
  48029. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  48030. }
  48031. }
  48032. declare module BABYLON {
  48033. interface AbstractScene {
  48034. /**
  48035. * The list of layers (background and foreground) of the scene
  48036. */
  48037. layers: Array<Layer>;
  48038. }
  48039. /**
  48040. * Defines the layer scene component responsible to manage any layers
  48041. * in a given scene.
  48042. */
  48043. export class LayerSceneComponent implements ISceneComponent {
  48044. /**
  48045. * The component name helpfull to identify the component in the list of scene components.
  48046. */
  48047. readonly name: string;
  48048. /**
  48049. * The scene the component belongs to.
  48050. */
  48051. scene: Scene;
  48052. private _engine;
  48053. /**
  48054. * Creates a new instance of the component for the given scene
  48055. * @param scene Defines the scene to register the component in
  48056. */
  48057. constructor(scene: Scene);
  48058. /**
  48059. * Registers the component in a given scene
  48060. */
  48061. register(): void;
  48062. /**
  48063. * Rebuilds the elements related to this component in case of
  48064. * context lost for instance.
  48065. */
  48066. rebuild(): void;
  48067. /**
  48068. * Disposes the component and the associated ressources.
  48069. */
  48070. dispose(): void;
  48071. private _draw;
  48072. private _drawCameraPredicate;
  48073. private _drawCameraBackground;
  48074. private _drawCameraForeground;
  48075. private _drawRenderTargetPredicate;
  48076. private _drawRenderTargetBackground;
  48077. private _drawRenderTargetForeground;
  48078. /**
  48079. * Adds all the elements from the container to the scene
  48080. * @param container the container holding the elements
  48081. */
  48082. addFromContainer(container: AbstractScene): void;
  48083. /**
  48084. * Removes all the elements in the container from the scene
  48085. * @param container contains the elements to remove
  48086. * @param dispose if the removed element should be disposed (default: false)
  48087. */
  48088. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  48089. }
  48090. }
  48091. declare module BABYLON {
  48092. /** @hidden */
  48093. export var layerPixelShader: {
  48094. name: string;
  48095. shader: string;
  48096. };
  48097. }
  48098. declare module BABYLON {
  48099. /** @hidden */
  48100. export var layerVertexShader: {
  48101. name: string;
  48102. shader: string;
  48103. };
  48104. }
  48105. declare module BABYLON {
  48106. /**
  48107. * This represents a full screen 2d layer.
  48108. * This can be useful to display a picture in the background of your scene for instance.
  48109. * @see https://www.babylonjs-playground.com/#08A2BS#1
  48110. */
  48111. export class Layer {
  48112. /**
  48113. * Define the name of the layer.
  48114. */
  48115. name: string;
  48116. /**
  48117. * Define the texture the layer should display.
  48118. */
  48119. texture: Nullable<Texture>;
  48120. /**
  48121. * Is the layer in background or foreground.
  48122. */
  48123. isBackground: boolean;
  48124. /**
  48125. * Define the color of the layer (instead of texture).
  48126. */
  48127. color: Color4;
  48128. /**
  48129. * Define the scale of the layer in order to zoom in out of the texture.
  48130. */
  48131. scale: Vector2;
  48132. /**
  48133. * Define an offset for the layer in order to shift the texture.
  48134. */
  48135. offset: Vector2;
  48136. /**
  48137. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  48138. */
  48139. alphaBlendingMode: number;
  48140. /**
  48141. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  48142. * Alpha test will not mix with the background color in case of transparency.
  48143. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  48144. */
  48145. alphaTest: boolean;
  48146. /**
  48147. * Define a mask to restrict the layer to only some of the scene cameras.
  48148. */
  48149. layerMask: number;
  48150. /**
  48151. * Define the list of render target the layer is visible into.
  48152. */
  48153. renderTargetTextures: RenderTargetTexture[];
  48154. /**
  48155. * Define if the layer is only used in renderTarget or if it also
  48156. * renders in the main frame buffer of the canvas.
  48157. */
  48158. renderOnlyInRenderTargetTextures: boolean;
  48159. private _scene;
  48160. private _vertexBuffers;
  48161. private _indexBuffer;
  48162. private _effect;
  48163. private _alphaTestEffect;
  48164. /**
  48165. * An event triggered when the layer is disposed.
  48166. */
  48167. onDisposeObservable: Observable<Layer>;
  48168. private _onDisposeObserver;
  48169. /**
  48170. * Back compatibility with callback before the onDisposeObservable existed.
  48171. * The set callback will be triggered when the layer has been disposed.
  48172. */
  48173. onDispose: () => void;
  48174. /**
  48175. * An event triggered before rendering the scene
  48176. */
  48177. onBeforeRenderObservable: Observable<Layer>;
  48178. private _onBeforeRenderObserver;
  48179. /**
  48180. * Back compatibility with callback before the onBeforeRenderObservable existed.
  48181. * The set callback will be triggered just before rendering the layer.
  48182. */
  48183. onBeforeRender: () => void;
  48184. /**
  48185. * An event triggered after rendering the scene
  48186. */
  48187. onAfterRenderObservable: Observable<Layer>;
  48188. private _onAfterRenderObserver;
  48189. /**
  48190. * Back compatibility with callback before the onAfterRenderObservable existed.
  48191. * The set callback will be triggered just after rendering the layer.
  48192. */
  48193. onAfterRender: () => void;
  48194. /**
  48195. * Instantiates a new layer.
  48196. * This represents a full screen 2d layer.
  48197. * This can be useful to display a picture in the background of your scene for instance.
  48198. * @see https://www.babylonjs-playground.com/#08A2BS#1
  48199. * @param name Define the name of the layer in the scene
  48200. * @param imgUrl Define the url of the texture to display in the layer
  48201. * @param scene Define the scene the layer belongs to
  48202. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  48203. * @param color Defines a color for the layer
  48204. */
  48205. constructor(
  48206. /**
  48207. * Define the name of the layer.
  48208. */
  48209. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  48210. private _createIndexBuffer;
  48211. /** @hidden */
  48212. _rebuild(): void;
  48213. /**
  48214. * Renders the layer in the scene.
  48215. */
  48216. render(): void;
  48217. /**
  48218. * Disposes and releases the associated ressources.
  48219. */
  48220. dispose(): void;
  48221. }
  48222. }
  48223. declare module BABYLON {
  48224. /** @hidden */
  48225. export var lensFlarePixelShader: {
  48226. name: string;
  48227. shader: string;
  48228. };
  48229. }
  48230. declare module BABYLON {
  48231. /** @hidden */
  48232. export var lensFlareVertexShader: {
  48233. name: string;
  48234. shader: string;
  48235. };
  48236. }
  48237. declare module BABYLON {
  48238. /**
  48239. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  48240. * It is usually composed of several `lensFlare`.
  48241. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  48242. */
  48243. export class LensFlareSystem {
  48244. /**
  48245. * Define the name of the lens flare system
  48246. */
  48247. name: string;
  48248. /**
  48249. * List of lens flares used in this system.
  48250. */
  48251. lensFlares: LensFlare[];
  48252. /**
  48253. * Define a limit from the border the lens flare can be visible.
  48254. */
  48255. borderLimit: number;
  48256. /**
  48257. * Define a viewport border we do not want to see the lens flare in.
  48258. */
  48259. viewportBorder: number;
  48260. /**
  48261. * Define a predicate which could limit the list of meshes able to occlude the effect.
  48262. */
  48263. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  48264. /**
  48265. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  48266. */
  48267. layerMask: number;
  48268. /**
  48269. * Define the id of the lens flare system in the scene.
  48270. * (equal to name by default)
  48271. */
  48272. id: string;
  48273. private _scene;
  48274. private _emitter;
  48275. private _vertexBuffers;
  48276. private _indexBuffer;
  48277. private _effect;
  48278. private _positionX;
  48279. private _positionY;
  48280. private _isEnabled;
  48281. /** @hidden */
  48282. static _SceneComponentInitialization: (scene: Scene) => void;
  48283. /**
  48284. * Instantiates a lens flare system.
  48285. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  48286. * It is usually composed of several `lensFlare`.
  48287. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  48288. * @param name Define the name of the lens flare system in the scene
  48289. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  48290. * @param scene Define the scene the lens flare system belongs to
  48291. */
  48292. constructor(
  48293. /**
  48294. * Define the name of the lens flare system
  48295. */
  48296. name: string, emitter: any, scene: Scene);
  48297. /**
  48298. * Define if the lens flare system is enabled.
  48299. */
  48300. isEnabled: boolean;
  48301. /**
  48302. * Get the scene the effects belongs to.
  48303. * @returns the scene holding the lens flare system
  48304. */
  48305. getScene(): Scene;
  48306. /**
  48307. * Get the emitter of the lens flare system.
  48308. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  48309. * @returns the emitter of the lens flare system
  48310. */
  48311. getEmitter(): any;
  48312. /**
  48313. * Set the emitter of the lens flare system.
  48314. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  48315. * @param newEmitter Define the new emitter of the system
  48316. */
  48317. setEmitter(newEmitter: any): void;
  48318. /**
  48319. * Get the lens flare system emitter position.
  48320. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  48321. * @returns the position
  48322. */
  48323. getEmitterPosition(): Vector3;
  48324. /**
  48325. * @hidden
  48326. */
  48327. computeEffectivePosition(globalViewport: Viewport): boolean;
  48328. /** @hidden */
  48329. _isVisible(): boolean;
  48330. /**
  48331. * @hidden
  48332. */
  48333. render(): boolean;
  48334. /**
  48335. * Dispose and release the lens flare with its associated resources.
  48336. */
  48337. dispose(): void;
  48338. /**
  48339. * Parse a lens flare system from a JSON repressentation
  48340. * @param parsedLensFlareSystem Define the JSON to parse
  48341. * @param scene Define the scene the parsed system should be instantiated in
  48342. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  48343. * @returns the parsed system
  48344. */
  48345. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  48346. /**
  48347. * Serialize the current Lens Flare System into a JSON representation.
  48348. * @returns the serialized JSON
  48349. */
  48350. serialize(): any;
  48351. }
  48352. }
  48353. declare module BABYLON {
  48354. /**
  48355. * This represents one of the lens effect in a `lensFlareSystem`.
  48356. * It controls one of the indiviual texture used in the effect.
  48357. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  48358. */
  48359. export class LensFlare {
  48360. /**
  48361. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  48362. */
  48363. size: number;
  48364. /**
  48365. * 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.
  48366. */
  48367. position: number;
  48368. /**
  48369. * Define the lens color.
  48370. */
  48371. color: Color3;
  48372. /**
  48373. * Define the lens texture.
  48374. */
  48375. texture: Nullable<Texture>;
  48376. /**
  48377. * Define the alpha mode to render this particular lens.
  48378. */
  48379. alphaMode: number;
  48380. private _system;
  48381. /**
  48382. * Creates a new Lens Flare.
  48383. * This represents one of the lens effect in a `lensFlareSystem`.
  48384. * It controls one of the indiviual texture used in the effect.
  48385. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  48386. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  48387. * @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.
  48388. * @param color Define the lens color
  48389. * @param imgUrl Define the lens texture url
  48390. * @param system Define the `lensFlareSystem` this flare is part of
  48391. * @returns The newly created Lens Flare
  48392. */
  48393. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  48394. /**
  48395. * Instantiates a new Lens Flare.
  48396. * This represents one of the lens effect in a `lensFlareSystem`.
  48397. * It controls one of the indiviual texture used in the effect.
  48398. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  48399. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  48400. * @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.
  48401. * @param color Define the lens color
  48402. * @param imgUrl Define the lens texture url
  48403. * @param system Define the `lensFlareSystem` this flare is part of
  48404. */
  48405. constructor(
  48406. /**
  48407. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  48408. */
  48409. size: number,
  48410. /**
  48411. * 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.
  48412. */
  48413. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  48414. /**
  48415. * Dispose and release the lens flare with its associated resources.
  48416. */
  48417. dispose(): void;
  48418. }
  48419. }
  48420. declare module BABYLON {
  48421. interface AbstractScene {
  48422. /**
  48423. * The list of lens flare system added to the scene
  48424. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  48425. */
  48426. lensFlareSystems: Array<LensFlareSystem>;
  48427. /**
  48428. * Removes the given lens flare system from this scene.
  48429. * @param toRemove The lens flare system to remove
  48430. * @returns The index of the removed lens flare system
  48431. */
  48432. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  48433. /**
  48434. * Adds the given lens flare system to this scene
  48435. * @param newLensFlareSystem The lens flare system to add
  48436. */
  48437. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  48438. /**
  48439. * Gets a lens flare system using its name
  48440. * @param name defines the name to look for
  48441. * @returns the lens flare system or null if not found
  48442. */
  48443. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  48444. /**
  48445. * Gets a lens flare system using its id
  48446. * @param id defines the id to look for
  48447. * @returns the lens flare system or null if not found
  48448. */
  48449. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  48450. }
  48451. /**
  48452. * Defines the lens flare scene component responsible to manage any lens flares
  48453. * in a given scene.
  48454. */
  48455. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  48456. /**
  48457. * The component name helpfull to identify the component in the list of scene components.
  48458. */
  48459. readonly name: string;
  48460. /**
  48461. * The scene the component belongs to.
  48462. */
  48463. scene: Scene;
  48464. /**
  48465. * Creates a new instance of the component for the given scene
  48466. * @param scene Defines the scene to register the component in
  48467. */
  48468. constructor(scene: Scene);
  48469. /**
  48470. * Registers the component in a given scene
  48471. */
  48472. register(): void;
  48473. /**
  48474. * Rebuilds the elements related to this component in case of
  48475. * context lost for instance.
  48476. */
  48477. rebuild(): void;
  48478. /**
  48479. * Adds all the elements from the container to the scene
  48480. * @param container the container holding the elements
  48481. */
  48482. addFromContainer(container: AbstractScene): void;
  48483. /**
  48484. * Removes all the elements in the container from the scene
  48485. * @param container contains the elements to remove
  48486. * @param dispose if the removed element should be disposed (default: false)
  48487. */
  48488. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  48489. /**
  48490. * Serializes the component data to the specified json object
  48491. * @param serializationObject The object to serialize to
  48492. */
  48493. serialize(serializationObject: any): void;
  48494. /**
  48495. * Disposes the component and the associated ressources.
  48496. */
  48497. dispose(): void;
  48498. private _draw;
  48499. }
  48500. }
  48501. declare module BABYLON {
  48502. /**
  48503. * Defines the shadow generator component responsible to manage any shadow generators
  48504. * in a given scene.
  48505. */
  48506. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  48507. /**
  48508. * The component name helpfull to identify the component in the list of scene components.
  48509. */
  48510. readonly name: string;
  48511. /**
  48512. * The scene the component belongs to.
  48513. */
  48514. scene: Scene;
  48515. /**
  48516. * Creates a new instance of the component for the given scene
  48517. * @param scene Defines the scene to register the component in
  48518. */
  48519. constructor(scene: Scene);
  48520. /**
  48521. * Registers the component in a given scene
  48522. */
  48523. register(): void;
  48524. /**
  48525. * Rebuilds the elements related to this component in case of
  48526. * context lost for instance.
  48527. */
  48528. rebuild(): void;
  48529. /**
  48530. * Serializes the component data to the specified json object
  48531. * @param serializationObject The object to serialize to
  48532. */
  48533. serialize(serializationObject: any): void;
  48534. /**
  48535. * Adds all the elements from the container to the scene
  48536. * @param container the container holding the elements
  48537. */
  48538. addFromContainer(container: AbstractScene): void;
  48539. /**
  48540. * Removes all the elements in the container from the scene
  48541. * @param container contains the elements to remove
  48542. * @param dispose if the removed element should be disposed (default: false)
  48543. */
  48544. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  48545. /**
  48546. * Rebuilds the elements related to this component in case of
  48547. * context lost for instance.
  48548. */
  48549. dispose(): void;
  48550. private _gatherRenderTargets;
  48551. }
  48552. }
  48553. declare module BABYLON {
  48554. /**
  48555. * A point light is a light defined by an unique point in world space.
  48556. * The light is emitted in every direction from this point.
  48557. * A good example of a point light is a standard light bulb.
  48558. * Documentation: https://doc.babylonjs.com/babylon101/lights
  48559. */
  48560. export class PointLight extends ShadowLight {
  48561. private _shadowAngle;
  48562. /**
  48563. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  48564. * This specifies what angle the shadow will use to be created.
  48565. *
  48566. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  48567. */
  48568. /**
  48569. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  48570. * This specifies what angle the shadow will use to be created.
  48571. *
  48572. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  48573. */
  48574. shadowAngle: number;
  48575. /**
  48576. * Gets the direction if it has been set.
  48577. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  48578. */
  48579. /**
  48580. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  48581. */
  48582. direction: Vector3;
  48583. /**
  48584. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  48585. * A PointLight emits the light in every direction.
  48586. * It can cast shadows.
  48587. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  48588. * ```javascript
  48589. * var pointLight = new PointLight("pl", camera.position, scene);
  48590. * ```
  48591. * Documentation : https://doc.babylonjs.com/babylon101/lights
  48592. * @param name The light friendly name
  48593. * @param position The position of the point light in the scene
  48594. * @param scene The scene the lights belongs to
  48595. */
  48596. constructor(name: string, position: Vector3, scene: Scene);
  48597. /**
  48598. * Returns the string "PointLight"
  48599. * @returns the class name
  48600. */
  48601. getClassName(): string;
  48602. /**
  48603. * Returns the integer 0.
  48604. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  48605. */
  48606. getTypeID(): number;
  48607. /**
  48608. * Specifies wether or not the shadowmap should be a cube texture.
  48609. * @returns true if the shadowmap needs to be a cube texture.
  48610. */
  48611. needCube(): boolean;
  48612. /**
  48613. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  48614. * @param faceIndex The index of the face we are computed the direction to generate shadow
  48615. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  48616. */
  48617. getShadowDirection(faceIndex?: number): Vector3;
  48618. /**
  48619. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  48620. * - fov = PI / 2
  48621. * - aspect ratio : 1.0
  48622. * - z-near and far equal to the active camera minZ and maxZ.
  48623. * Returns the PointLight.
  48624. */
  48625. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  48626. protected _buildUniformLayout(): void;
  48627. /**
  48628. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  48629. * @param effect The effect to update
  48630. * @param lightIndex The index of the light in the effect to update
  48631. * @returns The point light
  48632. */
  48633. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  48634. /**
  48635. * Prepares the list of defines specific to the light type.
  48636. * @param defines the list of defines
  48637. * @param lightIndex defines the index of the light for the effect
  48638. */
  48639. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  48640. }
  48641. }
  48642. declare module BABYLON {
  48643. /**
  48644. * Header information of HDR texture files.
  48645. */
  48646. export interface HDRInfo {
  48647. /**
  48648. * The height of the texture in pixels.
  48649. */
  48650. height: number;
  48651. /**
  48652. * The width of the texture in pixels.
  48653. */
  48654. width: number;
  48655. /**
  48656. * The index of the beginning of the data in the binary file.
  48657. */
  48658. dataPosition: number;
  48659. }
  48660. /**
  48661. * This groups tools to convert HDR texture to native colors array.
  48662. */
  48663. export class HDRTools {
  48664. private static Ldexp;
  48665. private static Rgbe2float;
  48666. private static readStringLine;
  48667. /**
  48668. * Reads header information from an RGBE texture stored in a native array.
  48669. * More information on this format are available here:
  48670. * https://en.wikipedia.org/wiki/RGBE_image_format
  48671. *
  48672. * @param uint8array The binary file stored in native array.
  48673. * @return The header information.
  48674. */
  48675. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  48676. /**
  48677. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  48678. * This RGBE texture needs to store the information as a panorama.
  48679. *
  48680. * More information on this format are available here:
  48681. * https://en.wikipedia.org/wiki/RGBE_image_format
  48682. *
  48683. * @param buffer The binary file stored in an array buffer.
  48684. * @param size The expected size of the extracted cubemap.
  48685. * @return The Cube Map information.
  48686. */
  48687. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  48688. /**
  48689. * Returns the pixels data extracted from an RGBE texture.
  48690. * This pixels will be stored left to right up to down in the R G B order in one array.
  48691. *
  48692. * More information on this format are available here:
  48693. * https://en.wikipedia.org/wiki/RGBE_image_format
  48694. *
  48695. * @param uint8array The binary file stored in an array buffer.
  48696. * @param hdrInfo The header information of the file.
  48697. * @return The pixels data in RGB right to left up to down order.
  48698. */
  48699. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  48700. private static RGBE_ReadPixels_RLE;
  48701. }
  48702. }
  48703. declare module BABYLON {
  48704. /**
  48705. * This represents a texture coming from an HDR input.
  48706. *
  48707. * The only supported format is currently panorama picture stored in RGBE format.
  48708. * Example of such files can be found on HDRLib: http://hdrlib.com/
  48709. */
  48710. export class HDRCubeTexture extends BaseTexture {
  48711. private static _facesMapping;
  48712. private _generateHarmonics;
  48713. private _noMipmap;
  48714. private _textureMatrix;
  48715. private _size;
  48716. private _onLoad;
  48717. private _onError;
  48718. /**
  48719. * The texture URL.
  48720. */
  48721. url: string;
  48722. /**
  48723. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  48724. */
  48725. coordinatesMode: number;
  48726. protected _isBlocking: boolean;
  48727. /**
  48728. * Sets wether or not the texture is blocking during loading.
  48729. */
  48730. /**
  48731. * Gets wether or not the texture is blocking during loading.
  48732. */
  48733. isBlocking: boolean;
  48734. protected _rotationY: number;
  48735. /**
  48736. * Sets texture matrix rotation angle around Y axis in radians.
  48737. */
  48738. /**
  48739. * Gets texture matrix rotation angle around Y axis radians.
  48740. */
  48741. rotationY: number;
  48742. /**
  48743. * Gets or sets the center of the bounding box associated with the cube texture
  48744. * It must define where the camera used to render the texture was set
  48745. */
  48746. boundingBoxPosition: Vector3;
  48747. private _boundingBoxSize;
  48748. /**
  48749. * Gets or sets the size of the bounding box associated with the cube texture
  48750. * When defined, the cubemap will switch to local mode
  48751. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  48752. * @example https://www.babylonjs-playground.com/#RNASML
  48753. */
  48754. boundingBoxSize: Vector3;
  48755. /**
  48756. * Instantiates an HDRTexture from the following parameters.
  48757. *
  48758. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  48759. * @param scene The scene the texture will be used in
  48760. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  48761. * @param noMipmap Forces to not generate the mipmap if true
  48762. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  48763. * @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)
  48764. * @param reserved Reserved flag for internal use.
  48765. */
  48766. 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>);
  48767. /**
  48768. * Get the current class name of the texture useful for serialization or dynamic coding.
  48769. * @returns "HDRCubeTexture"
  48770. */
  48771. getClassName(): string;
  48772. /**
  48773. * Occurs when the file is raw .hdr file.
  48774. */
  48775. private loadTexture;
  48776. clone(): HDRCubeTexture;
  48777. delayLoad(): void;
  48778. /**
  48779. * Get the texture reflection matrix used to rotate/transform the reflection.
  48780. * @returns the reflection matrix
  48781. */
  48782. getReflectionTextureMatrix(): Matrix;
  48783. /**
  48784. * Set the texture reflection matrix used to rotate/transform the reflection.
  48785. * @param value Define the reflection matrix to set
  48786. */
  48787. setReflectionTextureMatrix(value: Matrix): void;
  48788. /**
  48789. * Parses a JSON representation of an HDR Texture in order to create the texture
  48790. * @param parsedTexture Define the JSON representation
  48791. * @param scene Define the scene the texture should be created in
  48792. * @param rootUrl Define the root url in case we need to load relative dependencies
  48793. * @returns the newly created texture after parsing
  48794. */
  48795. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  48796. serialize(): any;
  48797. }
  48798. }
  48799. declare module BABYLON {
  48800. /**
  48801. * Class used to control physics engine
  48802. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  48803. */
  48804. export class PhysicsEngine implements IPhysicsEngine {
  48805. private _physicsPlugin;
  48806. /**
  48807. * Global value used to control the smallest number supported by the simulation
  48808. */
  48809. static Epsilon: number;
  48810. private _impostors;
  48811. private _joints;
  48812. /**
  48813. * Gets the gravity vector used by the simulation
  48814. */
  48815. gravity: Vector3;
  48816. /**
  48817. * Factory used to create the default physics plugin.
  48818. * @returns The default physics plugin
  48819. */
  48820. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  48821. /**
  48822. * Creates a new Physics Engine
  48823. * @param gravity defines the gravity vector used by the simulation
  48824. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  48825. */
  48826. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  48827. /**
  48828. * Sets the gravity vector used by the simulation
  48829. * @param gravity defines the gravity vector to use
  48830. */
  48831. setGravity(gravity: Vector3): void;
  48832. /**
  48833. * Set the time step of the physics engine.
  48834. * Default is 1/60.
  48835. * To slow it down, enter 1/600 for example.
  48836. * To speed it up, 1/30
  48837. * @param newTimeStep defines the new timestep to apply to this world.
  48838. */
  48839. setTimeStep(newTimeStep?: number): void;
  48840. /**
  48841. * Get the time step of the physics engine.
  48842. * @returns the current time step
  48843. */
  48844. getTimeStep(): number;
  48845. /**
  48846. * Release all resources
  48847. */
  48848. dispose(): void;
  48849. /**
  48850. * Gets the name of the current physics plugin
  48851. * @returns the name of the plugin
  48852. */
  48853. getPhysicsPluginName(): string;
  48854. /**
  48855. * Adding a new impostor for the impostor tracking.
  48856. * This will be done by the impostor itself.
  48857. * @param impostor the impostor to add
  48858. */
  48859. addImpostor(impostor: PhysicsImpostor): void;
  48860. /**
  48861. * Remove an impostor from the engine.
  48862. * This impostor and its mesh will not longer be updated by the physics engine.
  48863. * @param impostor the impostor to remove
  48864. */
  48865. removeImpostor(impostor: PhysicsImpostor): void;
  48866. /**
  48867. * Add a joint to the physics engine
  48868. * @param mainImpostor defines the main impostor to which the joint is added.
  48869. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  48870. * @param joint defines the joint that will connect both impostors.
  48871. */
  48872. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  48873. /**
  48874. * Removes a joint from the simulation
  48875. * @param mainImpostor defines the impostor used with the joint
  48876. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  48877. * @param joint defines the joint to remove
  48878. */
  48879. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  48880. /**
  48881. * Called by the scene. No need to call it.
  48882. * @param delta defines the timespam between frames
  48883. */
  48884. _step(delta: number): void;
  48885. /**
  48886. * Gets the current plugin used to run the simulation
  48887. * @returns current plugin
  48888. */
  48889. getPhysicsPlugin(): IPhysicsEnginePlugin;
  48890. /**
  48891. * Gets the list of physic impostors
  48892. * @returns an array of PhysicsImpostor
  48893. */
  48894. getImpostors(): Array<PhysicsImpostor>;
  48895. /**
  48896. * Gets the impostor for a physics enabled object
  48897. * @param object defines the object impersonated by the impostor
  48898. * @returns the PhysicsImpostor or null if not found
  48899. */
  48900. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  48901. /**
  48902. * Gets the impostor for a physics body object
  48903. * @param body defines physics body used by the impostor
  48904. * @returns the PhysicsImpostor or null if not found
  48905. */
  48906. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  48907. /**
  48908. * Does a raycast in the physics world
  48909. * @param from when should the ray start?
  48910. * @param to when should the ray end?
  48911. * @returns PhysicsRaycastResult
  48912. */
  48913. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  48914. }
  48915. }
  48916. declare module BABYLON {
  48917. /** @hidden */
  48918. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  48919. private _useDeltaForWorldStep;
  48920. world: any;
  48921. name: string;
  48922. private _physicsMaterials;
  48923. private _fixedTimeStep;
  48924. private _cannonRaycastResult;
  48925. private _raycastResult;
  48926. private _removeAfterStep;
  48927. BJSCANNON: any;
  48928. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  48929. setGravity(gravity: Vector3): void;
  48930. setTimeStep(timeStep: number): void;
  48931. getTimeStep(): number;
  48932. executeStep(delta: number): void;
  48933. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  48934. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  48935. generatePhysicsBody(impostor: PhysicsImpostor): void;
  48936. private _processChildMeshes;
  48937. removePhysicsBody(impostor: PhysicsImpostor): void;
  48938. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  48939. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  48940. private _addMaterial;
  48941. private _checkWithEpsilon;
  48942. private _createShape;
  48943. private _createHeightmap;
  48944. private _minus90X;
  48945. private _plus90X;
  48946. private _tmpPosition;
  48947. private _tmpDeltaPosition;
  48948. private _tmpUnityRotation;
  48949. private _updatePhysicsBodyTransformation;
  48950. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  48951. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  48952. isSupported(): boolean;
  48953. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  48954. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  48955. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  48956. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  48957. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  48958. getBodyMass(impostor: PhysicsImpostor): number;
  48959. getBodyFriction(impostor: PhysicsImpostor): number;
  48960. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  48961. getBodyRestitution(impostor: PhysicsImpostor): number;
  48962. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  48963. sleepBody(impostor: PhysicsImpostor): void;
  48964. wakeUpBody(impostor: PhysicsImpostor): void;
  48965. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  48966. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  48967. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  48968. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  48969. getRadius(impostor: PhysicsImpostor): number;
  48970. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  48971. dispose(): void;
  48972. private _extendNamespace;
  48973. /**
  48974. * Does a raycast in the physics world
  48975. * @param from when should the ray start?
  48976. * @param to when should the ray end?
  48977. * @returns PhysicsRaycastResult
  48978. */
  48979. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  48980. }
  48981. }
  48982. declare module BABYLON {
  48983. /** @hidden */
  48984. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  48985. world: any;
  48986. name: string;
  48987. BJSOIMO: any;
  48988. private _raycastResult;
  48989. constructor(iterations?: number, oimoInjection?: any);
  48990. setGravity(gravity: Vector3): void;
  48991. setTimeStep(timeStep: number): void;
  48992. getTimeStep(): number;
  48993. private _tmpImpostorsArray;
  48994. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  48995. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  48996. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  48997. generatePhysicsBody(impostor: PhysicsImpostor): void;
  48998. private _tmpPositionVector;
  48999. removePhysicsBody(impostor: PhysicsImpostor): void;
  49000. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  49001. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  49002. isSupported(): boolean;
  49003. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  49004. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  49005. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  49006. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  49007. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49008. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49009. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  49010. getBodyMass(impostor: PhysicsImpostor): number;
  49011. getBodyFriction(impostor: PhysicsImpostor): number;
  49012. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  49013. getBodyRestitution(impostor: PhysicsImpostor): number;
  49014. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  49015. sleepBody(impostor: PhysicsImpostor): void;
  49016. wakeUpBody(impostor: PhysicsImpostor): void;
  49017. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  49018. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  49019. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  49020. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  49021. getRadius(impostor: PhysicsImpostor): number;
  49022. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  49023. dispose(): void;
  49024. /**
  49025. * Does a raycast in the physics world
  49026. * @param from when should the ray start?
  49027. * @param to when should the ray end?
  49028. * @returns PhysicsRaycastResult
  49029. */
  49030. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  49031. }
  49032. }
  49033. declare module BABYLON {
  49034. /**
  49035. * Class containing static functions to help procedurally build meshes
  49036. */
  49037. export class RibbonBuilder {
  49038. /**
  49039. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  49040. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  49041. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  49042. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  49043. * * 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
  49044. * * 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
  49045. * * 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
  49046. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49047. * * 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
  49048. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  49049. * * 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
  49050. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  49051. * * 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
  49052. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  49053. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49054. * @param name defines the name of the mesh
  49055. * @param options defines the options used to create the mesh
  49056. * @param scene defines the hosting scene
  49057. * @returns the ribbon mesh
  49058. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  49059. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  49060. */
  49061. static CreateRibbon(name: string, options: {
  49062. pathArray: Vector3[][];
  49063. closeArray?: boolean;
  49064. closePath?: boolean;
  49065. offset?: number;
  49066. updatable?: boolean;
  49067. sideOrientation?: number;
  49068. frontUVs?: Vector4;
  49069. backUVs?: Vector4;
  49070. instance?: Mesh;
  49071. invertUV?: boolean;
  49072. uvs?: Vector2[];
  49073. colors?: Color4[];
  49074. }, scene?: Nullable<Scene>): Mesh;
  49075. }
  49076. }
  49077. declare module BABYLON {
  49078. /**
  49079. * Class containing static functions to help procedurally build meshes
  49080. */
  49081. export class ShapeBuilder {
  49082. /**
  49083. * 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.
  49084. * * 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.
  49085. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  49086. * * 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.
  49087. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  49088. * * 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
  49089. * * 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
  49090. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  49091. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49092. * * 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
  49093. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  49094. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  49095. * @param name defines the name of the mesh
  49096. * @param options defines the options used to create the mesh
  49097. * @param scene defines the hosting scene
  49098. * @returns the extruded shape mesh
  49099. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  49100. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  49101. */
  49102. static ExtrudeShape(name: string, options: {
  49103. shape: Vector3[];
  49104. path: Vector3[];
  49105. scale?: number;
  49106. rotation?: number;
  49107. cap?: number;
  49108. updatable?: boolean;
  49109. sideOrientation?: number;
  49110. frontUVs?: Vector4;
  49111. backUVs?: Vector4;
  49112. instance?: Mesh;
  49113. invertUV?: boolean;
  49114. }, scene?: Nullable<Scene>): Mesh;
  49115. /**
  49116. * Creates an custom extruded shape mesh.
  49117. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  49118. * * 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.
  49119. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  49120. * * 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
  49121. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  49122. * * 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
  49123. * * It must returns a float value that will be the scale value applied to the shape on each path point
  49124. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  49125. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  49126. * * 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
  49127. * * 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
  49128. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  49129. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49130. * * 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
  49131. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  49132. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49133. * @param name defines the name of the mesh
  49134. * @param options defines the options used to create the mesh
  49135. * @param scene defines the hosting scene
  49136. * @returns the custom extruded shape mesh
  49137. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  49138. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  49139. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  49140. */
  49141. static ExtrudeShapeCustom(name: string, options: {
  49142. shape: Vector3[];
  49143. path: Vector3[];
  49144. scaleFunction?: any;
  49145. rotationFunction?: any;
  49146. ribbonCloseArray?: boolean;
  49147. ribbonClosePath?: boolean;
  49148. cap?: number;
  49149. updatable?: boolean;
  49150. sideOrientation?: number;
  49151. frontUVs?: Vector4;
  49152. backUVs?: Vector4;
  49153. instance?: Mesh;
  49154. invertUV?: boolean;
  49155. }, scene?: Nullable<Scene>): Mesh;
  49156. private static _ExtrudeShapeGeneric;
  49157. }
  49158. }
  49159. declare module BABYLON {
  49160. /**
  49161. * AmmoJS Physics plugin
  49162. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  49163. * @see https://github.com/kripken/ammo.js/
  49164. */
  49165. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  49166. private _useDeltaForWorldStep;
  49167. /**
  49168. * Reference to the Ammo library
  49169. */
  49170. bjsAMMO: any;
  49171. /**
  49172. * Created ammoJS world which physics bodies are added to
  49173. */
  49174. world: any;
  49175. /**
  49176. * Name of the plugin
  49177. */
  49178. name: string;
  49179. private _timeStep;
  49180. private _fixedTimeStep;
  49181. private _maxSteps;
  49182. private _tmpQuaternion;
  49183. private _tmpAmmoTransform;
  49184. private _tmpAmmoQuaternion;
  49185. private _tmpAmmoConcreteContactResultCallback;
  49186. private _collisionConfiguration;
  49187. private _dispatcher;
  49188. private _overlappingPairCache;
  49189. private _solver;
  49190. private _softBodySolver;
  49191. private _tmpAmmoVectorA;
  49192. private _tmpAmmoVectorB;
  49193. private _tmpAmmoVectorC;
  49194. private _tmpAmmoVectorD;
  49195. private _tmpContactCallbackResult;
  49196. private _tmpAmmoVectorRCA;
  49197. private _tmpAmmoVectorRCB;
  49198. private _raycastResult;
  49199. private static readonly DISABLE_COLLISION_FLAG;
  49200. private static readonly KINEMATIC_FLAG;
  49201. private static readonly DISABLE_DEACTIVATION_FLAG;
  49202. /**
  49203. * Initializes the ammoJS plugin
  49204. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  49205. * @param ammoInjection can be used to inject your own ammo reference
  49206. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  49207. */
  49208. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  49209. /**
  49210. * Sets the gravity of the physics world (m/(s^2))
  49211. * @param gravity Gravity to set
  49212. */
  49213. setGravity(gravity: Vector3): void;
  49214. /**
  49215. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  49216. * @param timeStep timestep to use in seconds
  49217. */
  49218. setTimeStep(timeStep: number): void;
  49219. /**
  49220. * 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)
  49221. * @param fixedTimeStep fixedTimeStep to use in seconds
  49222. */
  49223. setFixedTimeStep(fixedTimeStep: number): void;
  49224. /**
  49225. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  49226. * @param maxSteps the maximum number of steps by the physics engine per frame
  49227. */
  49228. setMaxSteps(maxSteps: number): void;
  49229. /**
  49230. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  49231. * @returns the current timestep in seconds
  49232. */
  49233. getTimeStep(): number;
  49234. private _isImpostorInContact;
  49235. private _isImpostorPairInContact;
  49236. private _stepSimulation;
  49237. /**
  49238. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  49239. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  49240. * After the step the babylon meshes are set to the position of the physics imposters
  49241. * @param delta amount of time to step forward
  49242. * @param impostors array of imposters to update before/after the step
  49243. */
  49244. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  49245. /**
  49246. * Update babylon mesh to match physics world object
  49247. * @param impostor imposter to match
  49248. */
  49249. private _afterSoftStep;
  49250. /**
  49251. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  49252. * @param impostor imposter to match
  49253. */
  49254. private _ropeStep;
  49255. /**
  49256. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  49257. * @param impostor imposter to match
  49258. */
  49259. private _softbodyOrClothStep;
  49260. private _tmpVector;
  49261. private _tmpMatrix;
  49262. /**
  49263. * Applies an impulse on the imposter
  49264. * @param impostor imposter to apply impulse to
  49265. * @param force amount of force to be applied to the imposter
  49266. * @param contactPoint the location to apply the impulse on the imposter
  49267. */
  49268. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49269. /**
  49270. * Applies a force on the imposter
  49271. * @param impostor imposter to apply force
  49272. * @param force amount of force to be applied to the imposter
  49273. * @param contactPoint the location to apply the force on the imposter
  49274. */
  49275. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49276. /**
  49277. * Creates a physics body using the plugin
  49278. * @param impostor the imposter to create the physics body on
  49279. */
  49280. generatePhysicsBody(impostor: PhysicsImpostor): void;
  49281. /**
  49282. * Removes the physics body from the imposter and disposes of the body's memory
  49283. * @param impostor imposter to remove the physics body from
  49284. */
  49285. removePhysicsBody(impostor: PhysicsImpostor): void;
  49286. /**
  49287. * Generates a joint
  49288. * @param impostorJoint the imposter joint to create the joint with
  49289. */
  49290. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  49291. /**
  49292. * Removes a joint
  49293. * @param impostorJoint the imposter joint to remove the joint from
  49294. */
  49295. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  49296. private _addMeshVerts;
  49297. /**
  49298. * Initialise the soft body vertices to match its object's (mesh) vertices
  49299. * Softbody vertices (nodes) are in world space and to match this
  49300. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  49301. * @param impostor to create the softbody for
  49302. */
  49303. private _softVertexData;
  49304. /**
  49305. * Create an impostor's soft body
  49306. * @param impostor to create the softbody for
  49307. */
  49308. private _createSoftbody;
  49309. /**
  49310. * Create cloth for an impostor
  49311. * @param impostor to create the softbody for
  49312. */
  49313. private _createCloth;
  49314. /**
  49315. * Create rope for an impostor
  49316. * @param impostor to create the softbody for
  49317. */
  49318. private _createRope;
  49319. private _addHullVerts;
  49320. private _createShape;
  49321. /**
  49322. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  49323. * @param impostor imposter containing the physics body and babylon object
  49324. */
  49325. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  49326. /**
  49327. * Sets the babylon object's position/rotation from the physics body's position/rotation
  49328. * @param impostor imposter containing the physics body and babylon object
  49329. * @param newPosition new position
  49330. * @param newRotation new rotation
  49331. */
  49332. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  49333. /**
  49334. * If this plugin is supported
  49335. * @returns true if its supported
  49336. */
  49337. isSupported(): boolean;
  49338. /**
  49339. * Sets the linear velocity of the physics body
  49340. * @param impostor imposter to set the velocity on
  49341. * @param velocity velocity to set
  49342. */
  49343. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  49344. /**
  49345. * Sets the angular velocity of the physics body
  49346. * @param impostor imposter to set the velocity on
  49347. * @param velocity velocity to set
  49348. */
  49349. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  49350. /**
  49351. * gets the linear velocity
  49352. * @param impostor imposter to get linear velocity from
  49353. * @returns linear velocity
  49354. */
  49355. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49356. /**
  49357. * gets the angular velocity
  49358. * @param impostor imposter to get angular velocity from
  49359. * @returns angular velocity
  49360. */
  49361. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49362. /**
  49363. * Sets the mass of physics body
  49364. * @param impostor imposter to set the mass on
  49365. * @param mass mass to set
  49366. */
  49367. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  49368. /**
  49369. * Gets the mass of the physics body
  49370. * @param impostor imposter to get the mass from
  49371. * @returns mass
  49372. */
  49373. getBodyMass(impostor: PhysicsImpostor): number;
  49374. /**
  49375. * Gets friction of the impostor
  49376. * @param impostor impostor to get friction from
  49377. * @returns friction value
  49378. */
  49379. getBodyFriction(impostor: PhysicsImpostor): number;
  49380. /**
  49381. * Sets friction of the impostor
  49382. * @param impostor impostor to set friction on
  49383. * @param friction friction value
  49384. */
  49385. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  49386. /**
  49387. * Gets restitution of the impostor
  49388. * @param impostor impostor to get restitution from
  49389. * @returns restitution value
  49390. */
  49391. getBodyRestitution(impostor: PhysicsImpostor): number;
  49392. /**
  49393. * Sets resitution of the impostor
  49394. * @param impostor impostor to set resitution on
  49395. * @param restitution resitution value
  49396. */
  49397. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  49398. /**
  49399. * Gets pressure inside the impostor
  49400. * @param impostor impostor to get pressure from
  49401. * @returns pressure value
  49402. */
  49403. getBodyPressure(impostor: PhysicsImpostor): number;
  49404. /**
  49405. * Sets pressure inside a soft body impostor
  49406. * Cloth and rope must remain 0 pressure
  49407. * @param impostor impostor to set pressure on
  49408. * @param pressure pressure value
  49409. */
  49410. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  49411. /**
  49412. * Gets stiffness of the impostor
  49413. * @param impostor impostor to get stiffness from
  49414. * @returns pressure value
  49415. */
  49416. getBodyStiffness(impostor: PhysicsImpostor): number;
  49417. /**
  49418. * Sets stiffness of the impostor
  49419. * @param impostor impostor to set stiffness on
  49420. * @param stiffness stiffness value from 0 to 1
  49421. */
  49422. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  49423. /**
  49424. * Gets velocityIterations of the impostor
  49425. * @param impostor impostor to get velocity iterations from
  49426. * @returns velocityIterations value
  49427. */
  49428. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  49429. /**
  49430. * Sets velocityIterations of the impostor
  49431. * @param impostor impostor to set velocity iterations on
  49432. * @param velocityIterations velocityIterations value
  49433. */
  49434. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  49435. /**
  49436. * Gets positionIterations of the impostor
  49437. * @param impostor impostor to get position iterations from
  49438. * @returns positionIterations value
  49439. */
  49440. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  49441. /**
  49442. * Sets positionIterations of the impostor
  49443. * @param impostor impostor to set position on
  49444. * @param positionIterations positionIterations value
  49445. */
  49446. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  49447. /**
  49448. * Append an anchor to a cloth object
  49449. * @param impostor is the cloth impostor to add anchor to
  49450. * @param otherImpostor is the rigid impostor to anchor to
  49451. * @param width ratio across width from 0 to 1
  49452. * @param height ratio up height from 0 to 1
  49453. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  49454. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  49455. */
  49456. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  49457. /**
  49458. * Append an hook to a rope object
  49459. * @param impostor is the rope impostor to add hook to
  49460. * @param otherImpostor is the rigid impostor to hook to
  49461. * @param length ratio along the rope from 0 to 1
  49462. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  49463. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  49464. */
  49465. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  49466. /**
  49467. * Sleeps the physics body and stops it from being active
  49468. * @param impostor impostor to sleep
  49469. */
  49470. sleepBody(impostor: PhysicsImpostor): void;
  49471. /**
  49472. * Activates the physics body
  49473. * @param impostor impostor to activate
  49474. */
  49475. wakeUpBody(impostor: PhysicsImpostor): void;
  49476. /**
  49477. * Updates the distance parameters of the joint
  49478. * @param joint joint to update
  49479. * @param maxDistance maximum distance of the joint
  49480. * @param minDistance minimum distance of the joint
  49481. */
  49482. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  49483. /**
  49484. * Sets a motor on the joint
  49485. * @param joint joint to set motor on
  49486. * @param speed speed of the motor
  49487. * @param maxForce maximum force of the motor
  49488. * @param motorIndex index of the motor
  49489. */
  49490. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  49491. /**
  49492. * Sets the motors limit
  49493. * @param joint joint to set limit on
  49494. * @param upperLimit upper limit
  49495. * @param lowerLimit lower limit
  49496. */
  49497. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  49498. /**
  49499. * Syncs the position and rotation of a mesh with the impostor
  49500. * @param mesh mesh to sync
  49501. * @param impostor impostor to update the mesh with
  49502. */
  49503. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  49504. /**
  49505. * Gets the radius of the impostor
  49506. * @param impostor impostor to get radius from
  49507. * @returns the radius
  49508. */
  49509. getRadius(impostor: PhysicsImpostor): number;
  49510. /**
  49511. * Gets the box size of the impostor
  49512. * @param impostor impostor to get box size from
  49513. * @param result the resulting box size
  49514. */
  49515. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  49516. /**
  49517. * Disposes of the impostor
  49518. */
  49519. dispose(): void;
  49520. /**
  49521. * Does a raycast in the physics world
  49522. * @param from when should the ray start?
  49523. * @param to when should the ray end?
  49524. * @returns PhysicsRaycastResult
  49525. */
  49526. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  49527. }
  49528. }
  49529. declare module BABYLON {
  49530. interface AbstractScene {
  49531. /**
  49532. * The list of reflection probes added to the scene
  49533. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  49534. */
  49535. reflectionProbes: Array<ReflectionProbe>;
  49536. /**
  49537. * Removes the given reflection probe from this scene.
  49538. * @param toRemove The reflection probe to remove
  49539. * @returns The index of the removed reflection probe
  49540. */
  49541. removeReflectionProbe(toRemove: ReflectionProbe): number;
  49542. /**
  49543. * Adds the given reflection probe to this scene.
  49544. * @param newReflectionProbe The reflection probe to add
  49545. */
  49546. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  49547. }
  49548. /**
  49549. * Class used to generate realtime reflection / refraction cube textures
  49550. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  49551. */
  49552. export class ReflectionProbe {
  49553. /** defines the name of the probe */
  49554. name: string;
  49555. private _scene;
  49556. private _renderTargetTexture;
  49557. private _projectionMatrix;
  49558. private _viewMatrix;
  49559. private _target;
  49560. private _add;
  49561. private _attachedMesh;
  49562. private _invertYAxis;
  49563. /** Gets or sets probe position (center of the cube map) */
  49564. position: Vector3;
  49565. /**
  49566. * Creates a new reflection probe
  49567. * @param name defines the name of the probe
  49568. * @param size defines the texture resolution (for each face)
  49569. * @param scene defines the hosting scene
  49570. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  49571. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  49572. */
  49573. constructor(
  49574. /** defines the name of the probe */
  49575. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  49576. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  49577. samples: number;
  49578. /** Gets or sets the refresh rate to use (on every frame by default) */
  49579. refreshRate: number;
  49580. /**
  49581. * Gets the hosting scene
  49582. * @returns a Scene
  49583. */
  49584. getScene(): Scene;
  49585. /** Gets the internal CubeTexture used to render to */
  49586. readonly cubeTexture: RenderTargetTexture;
  49587. /** Gets the list of meshes to render */
  49588. readonly renderList: Nullable<AbstractMesh[]>;
  49589. /**
  49590. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  49591. * @param mesh defines the mesh to attach to
  49592. */
  49593. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  49594. /**
  49595. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  49596. * @param renderingGroupId The rendering group id corresponding to its index
  49597. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  49598. */
  49599. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  49600. /**
  49601. * Clean all associated resources
  49602. */
  49603. dispose(): void;
  49604. /**
  49605. * Converts the reflection probe information to a readable string for debug purpose.
  49606. * @param fullDetails Supports for multiple levels of logging within scene loading
  49607. * @returns the human readable reflection probe info
  49608. */
  49609. toString(fullDetails?: boolean): string;
  49610. /**
  49611. * Get the class name of the relfection probe.
  49612. * @returns "ReflectionProbe"
  49613. */
  49614. getClassName(): string;
  49615. /**
  49616. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  49617. * @returns The JSON representation of the texture
  49618. */
  49619. serialize(): any;
  49620. /**
  49621. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  49622. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  49623. * @param scene Define the scene the parsed reflection probe should be instantiated in
  49624. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  49625. * @returns The parsed reflection probe if successful
  49626. */
  49627. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  49628. }
  49629. }
  49630. declare module BABYLON {
  49631. /** @hidden */
  49632. export var _BabylonLoaderRegistered: boolean;
  49633. }
  49634. declare module BABYLON {
  49635. /**
  49636. * The Physically based simple base material of BJS.
  49637. *
  49638. * This enables better naming and convention enforcements on top of the pbrMaterial.
  49639. * It is used as the base class for both the specGloss and metalRough conventions.
  49640. */
  49641. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  49642. /**
  49643. * Number of Simultaneous lights allowed on the material.
  49644. */
  49645. maxSimultaneousLights: number;
  49646. /**
  49647. * If sets to true, disables all the lights affecting the material.
  49648. */
  49649. disableLighting: boolean;
  49650. /**
  49651. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  49652. */
  49653. environmentTexture: BaseTexture;
  49654. /**
  49655. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  49656. */
  49657. invertNormalMapX: boolean;
  49658. /**
  49659. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  49660. */
  49661. invertNormalMapY: boolean;
  49662. /**
  49663. * Normal map used in the model.
  49664. */
  49665. normalTexture: BaseTexture;
  49666. /**
  49667. * Emissivie color used to self-illuminate the model.
  49668. */
  49669. emissiveColor: Color3;
  49670. /**
  49671. * Emissivie texture used to self-illuminate the model.
  49672. */
  49673. emissiveTexture: BaseTexture;
  49674. /**
  49675. * Occlusion Channel Strenght.
  49676. */
  49677. occlusionStrength: number;
  49678. /**
  49679. * Occlusion Texture of the material (adding extra occlusion effects).
  49680. */
  49681. occlusionTexture: BaseTexture;
  49682. /**
  49683. * Defines the alpha limits in alpha test mode.
  49684. */
  49685. alphaCutOff: number;
  49686. /**
  49687. * Gets the current double sided mode.
  49688. */
  49689. /**
  49690. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  49691. */
  49692. doubleSided: boolean;
  49693. /**
  49694. * Stores the pre-calculated light information of a mesh in a texture.
  49695. */
  49696. lightmapTexture: BaseTexture;
  49697. /**
  49698. * If true, the light map contains occlusion information instead of lighting info.
  49699. */
  49700. useLightmapAsShadowmap: boolean;
  49701. /**
  49702. * Instantiates a new PBRMaterial instance.
  49703. *
  49704. * @param name The material name
  49705. * @param scene The scene the material will be use in.
  49706. */
  49707. constructor(name: string, scene: Scene);
  49708. getClassName(): string;
  49709. }
  49710. }
  49711. declare module BABYLON {
  49712. /**
  49713. * The PBR material of BJS following the metal roughness convention.
  49714. *
  49715. * This fits to the PBR convention in the GLTF definition:
  49716. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  49717. */
  49718. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  49719. /**
  49720. * The base color has two different interpretations depending on the value of metalness.
  49721. * When the material is a metal, the base color is the specific measured reflectance value
  49722. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  49723. * of the material.
  49724. */
  49725. baseColor: Color3;
  49726. /**
  49727. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  49728. * well as opacity information in the alpha channel.
  49729. */
  49730. baseTexture: BaseTexture;
  49731. /**
  49732. * Specifies the metallic scalar value of the material.
  49733. * Can also be used to scale the metalness values of the metallic texture.
  49734. */
  49735. metallic: number;
  49736. /**
  49737. * Specifies the roughness scalar value of the material.
  49738. * Can also be used to scale the roughness values of the metallic texture.
  49739. */
  49740. roughness: number;
  49741. /**
  49742. * Texture containing both the metallic value in the B channel and the
  49743. * roughness value in the G channel to keep better precision.
  49744. */
  49745. metallicRoughnessTexture: BaseTexture;
  49746. /**
  49747. * Instantiates a new PBRMetalRoughnessMaterial instance.
  49748. *
  49749. * @param name The material name
  49750. * @param scene The scene the material will be use in.
  49751. */
  49752. constructor(name: string, scene: Scene);
  49753. /**
  49754. * Return the currrent class name of the material.
  49755. */
  49756. getClassName(): string;
  49757. /**
  49758. * Makes a duplicate of the current material.
  49759. * @param name - name to use for the new material.
  49760. */
  49761. clone(name: string): PBRMetallicRoughnessMaterial;
  49762. /**
  49763. * Serialize the material to a parsable JSON object.
  49764. */
  49765. serialize(): any;
  49766. /**
  49767. * Parses a JSON object correponding to the serialize function.
  49768. */
  49769. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  49770. }
  49771. }
  49772. declare module BABYLON {
  49773. /**
  49774. * The PBR material of BJS following the specular glossiness convention.
  49775. *
  49776. * This fits to the PBR convention in the GLTF definition:
  49777. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  49778. */
  49779. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  49780. /**
  49781. * Specifies the diffuse color of the material.
  49782. */
  49783. diffuseColor: Color3;
  49784. /**
  49785. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  49786. * channel.
  49787. */
  49788. diffuseTexture: BaseTexture;
  49789. /**
  49790. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  49791. */
  49792. specularColor: Color3;
  49793. /**
  49794. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  49795. */
  49796. glossiness: number;
  49797. /**
  49798. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  49799. */
  49800. specularGlossinessTexture: BaseTexture;
  49801. /**
  49802. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  49803. *
  49804. * @param name The material name
  49805. * @param scene The scene the material will be use in.
  49806. */
  49807. constructor(name: string, scene: Scene);
  49808. /**
  49809. * Return the currrent class name of the material.
  49810. */
  49811. getClassName(): string;
  49812. /**
  49813. * Makes a duplicate of the current material.
  49814. * @param name - name to use for the new material.
  49815. */
  49816. clone(name: string): PBRSpecularGlossinessMaterial;
  49817. /**
  49818. * Serialize the material to a parsable JSON object.
  49819. */
  49820. serialize(): any;
  49821. /**
  49822. * Parses a JSON object correponding to the serialize function.
  49823. */
  49824. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  49825. }
  49826. }
  49827. declare module BABYLON {
  49828. /**
  49829. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  49830. * It can help converting any input color in a desired output one. This can then be used to create effects
  49831. * from sepia, black and white to sixties or futuristic rendering...
  49832. *
  49833. * The only supported format is currently 3dl.
  49834. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  49835. */
  49836. export class ColorGradingTexture extends BaseTexture {
  49837. /**
  49838. * The current texture matrix. (will always be identity in color grading texture)
  49839. */
  49840. private _textureMatrix;
  49841. /**
  49842. * The texture URL.
  49843. */
  49844. url: string;
  49845. /**
  49846. * Empty line regex stored for GC.
  49847. */
  49848. private static _noneEmptyLineRegex;
  49849. private _engine;
  49850. /**
  49851. * Instantiates a ColorGradingTexture from the following parameters.
  49852. *
  49853. * @param url The location of the color gradind data (currently only supporting 3dl)
  49854. * @param scene The scene the texture will be used in
  49855. */
  49856. constructor(url: string, scene: Scene);
  49857. /**
  49858. * Returns the texture matrix used in most of the material.
  49859. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  49860. */
  49861. getTextureMatrix(): Matrix;
  49862. /**
  49863. * Occurs when the file being loaded is a .3dl LUT file.
  49864. */
  49865. private load3dlTexture;
  49866. /**
  49867. * Starts the loading process of the texture.
  49868. */
  49869. private loadTexture;
  49870. /**
  49871. * Clones the color gradind texture.
  49872. */
  49873. clone(): ColorGradingTexture;
  49874. /**
  49875. * Called during delayed load for textures.
  49876. */
  49877. delayLoad(): void;
  49878. /**
  49879. * Parses a color grading texture serialized by Babylon.
  49880. * @param parsedTexture The texture information being parsedTexture
  49881. * @param scene The scene to load the texture in
  49882. * @param rootUrl The root url of the data assets to load
  49883. * @return A color gradind texture
  49884. */
  49885. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  49886. /**
  49887. * Serializes the LUT texture to json format.
  49888. */
  49889. serialize(): any;
  49890. }
  49891. }
  49892. declare module BABYLON {
  49893. /**
  49894. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  49895. */
  49896. export class EquiRectangularCubeTexture extends BaseTexture {
  49897. /** The six faces of the cube. */
  49898. private static _FacesMapping;
  49899. private _noMipmap;
  49900. private _onLoad;
  49901. private _onError;
  49902. /** The size of the cubemap. */
  49903. private _size;
  49904. /** The buffer of the image. */
  49905. private _buffer;
  49906. /** The width of the input image. */
  49907. private _width;
  49908. /** The height of the input image. */
  49909. private _height;
  49910. /** The URL to the image. */
  49911. url: string;
  49912. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  49913. coordinatesMode: number;
  49914. /**
  49915. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  49916. * @param url The location of the image
  49917. * @param scene The scene the texture will be used in
  49918. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  49919. * @param noMipmap Forces to not generate the mipmap if true
  49920. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  49921. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  49922. * @param onLoad — defines a callback called when texture is loaded
  49923. * @param onError — defines a callback called if there is an error
  49924. */
  49925. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  49926. /**
  49927. * Load the image data, by putting the image on a canvas and extracting its buffer.
  49928. */
  49929. private loadImage;
  49930. /**
  49931. * Convert the image buffer into a cubemap and create a CubeTexture.
  49932. */
  49933. private loadTexture;
  49934. /**
  49935. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  49936. * @param buffer The ArrayBuffer that should be converted.
  49937. * @returns The buffer as Float32Array.
  49938. */
  49939. private getFloat32ArrayFromArrayBuffer;
  49940. /**
  49941. * Get the current class name of the texture useful for serialization or dynamic coding.
  49942. * @returns "EquiRectangularCubeTexture"
  49943. */
  49944. getClassName(): string;
  49945. /**
  49946. * Create a clone of the current EquiRectangularCubeTexture and return it.
  49947. * @returns A clone of the current EquiRectangularCubeTexture.
  49948. */
  49949. clone(): EquiRectangularCubeTexture;
  49950. }
  49951. }
  49952. declare module BABYLON {
  49953. /**
  49954. * Based on jsTGALoader - Javascript loader for TGA file
  49955. * By Vincent Thibault
  49956. * @see http://blog.robrowser.com/javascript-tga-loader.html
  49957. */
  49958. export class TGATools {
  49959. private static _TYPE_INDEXED;
  49960. private static _TYPE_RGB;
  49961. private static _TYPE_GREY;
  49962. private static _TYPE_RLE_INDEXED;
  49963. private static _TYPE_RLE_RGB;
  49964. private static _TYPE_RLE_GREY;
  49965. private static _ORIGIN_MASK;
  49966. private static _ORIGIN_SHIFT;
  49967. private static _ORIGIN_BL;
  49968. private static _ORIGIN_BR;
  49969. private static _ORIGIN_UL;
  49970. private static _ORIGIN_UR;
  49971. /**
  49972. * Gets the header of a TGA file
  49973. * @param data defines the TGA data
  49974. * @returns the header
  49975. */
  49976. static GetTGAHeader(data: Uint8Array): any;
  49977. /**
  49978. * Uploads TGA content to a Babylon Texture
  49979. * @hidden
  49980. */
  49981. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  49982. /** @hidden */
  49983. 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;
  49984. /** @hidden */
  49985. 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;
  49986. /** @hidden */
  49987. 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;
  49988. /** @hidden */
  49989. 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;
  49990. /** @hidden */
  49991. 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;
  49992. /** @hidden */
  49993. 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;
  49994. }
  49995. }
  49996. declare module BABYLON {
  49997. /**
  49998. * Implementation of the TGA Texture Loader.
  49999. * @hidden
  50000. */
  50001. export class _TGATextureLoader implements IInternalTextureLoader {
  50002. /**
  50003. * Defines wether the loader supports cascade loading the different faces.
  50004. */
  50005. readonly supportCascades: boolean;
  50006. /**
  50007. * This returns if the loader support the current file information.
  50008. * @param extension defines the file extension of the file being loaded
  50009. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50010. * @param fallback defines the fallback internal texture if any
  50011. * @param isBase64 defines whether the texture is encoded as a base64
  50012. * @param isBuffer defines whether the texture data are stored as a buffer
  50013. * @returns true if the loader can load the specified file
  50014. */
  50015. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  50016. /**
  50017. * Transform the url before loading if required.
  50018. * @param rootUrl the url of the texture
  50019. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50020. * @returns the transformed texture
  50021. */
  50022. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  50023. /**
  50024. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  50025. * @param rootUrl the url of the texture
  50026. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50027. * @returns the fallback texture
  50028. */
  50029. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  50030. /**
  50031. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  50032. * @param data contains the texture data
  50033. * @param texture defines the BabylonJS internal texture
  50034. * @param createPolynomials will be true if polynomials have been requested
  50035. * @param onLoad defines the callback to trigger once the texture is ready
  50036. * @param onError defines the callback to trigger in case of error
  50037. */
  50038. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  50039. /**
  50040. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  50041. * @param data contains the texture data
  50042. * @param texture defines the BabylonJS internal texture
  50043. * @param callback defines the method to call once ready to upload
  50044. */
  50045. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  50046. }
  50047. }
  50048. declare module BABYLON {
  50049. /**
  50050. * Info about the .basis files
  50051. */
  50052. class BasisFileInfo {
  50053. /**
  50054. * If the file has alpha
  50055. */
  50056. hasAlpha: boolean;
  50057. /**
  50058. * Width of the image
  50059. */
  50060. width: number;
  50061. /**
  50062. * Height of the image
  50063. */
  50064. height: number;
  50065. /**
  50066. * Aligned width used when falling back to Rgb565 ((width + 3) & ~3)
  50067. */
  50068. alignedWidth: number;
  50069. /**
  50070. * Aligned height used when falling back to Rgb565 ((height + 3) & ~3)
  50071. */
  50072. alignedHeight: number;
  50073. }
  50074. /**
  50075. * Used to load .Basis files
  50076. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  50077. */
  50078. export class BasisTools {
  50079. private static _IgnoreSupportedFormats;
  50080. private static _LoadScriptPromise;
  50081. private static _FallbackURL;
  50082. private static _BASIS_FORMAT;
  50083. /**
  50084. * Basis module can be aquired from https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  50085. * This should be set prior to loading a .basis texture
  50086. */
  50087. static BasisModule: Nullable<any>;
  50088. /**
  50089. * Verifies that the BasisModule has been populated and falls back to loading from the web if not availible
  50090. * @returns promise which will resolve if the basis module was loaded
  50091. */
  50092. static VerifyBasisModuleAsync(): any;
  50093. /**
  50094. * Verifies that the basis module has been populated and creates a bsis file from the image data
  50095. * @param data array buffer of the .basis file
  50096. * @returns the Basis file
  50097. */
  50098. static LoadBasisFile(data: ArrayBuffer): any;
  50099. /**
  50100. * Detects the supported transcode format for the file
  50101. * @param engine Babylon engine
  50102. * @param fileInfo info about the file
  50103. * @returns the chosed format or null if none are supported
  50104. */
  50105. static GetSupportedTranscodeFormat(engine: Engine, fileInfo: BasisFileInfo): Nullable<number>;
  50106. /**
  50107. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  50108. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  50109. * @returns internal format corresponding to the Basis format
  50110. */
  50111. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  50112. /**
  50113. * Retreives information about the basis file eg. dimensions
  50114. * @param basisFile the basis file to get the info from
  50115. * @returns information about the basis file
  50116. */
  50117. static GetFileInfo(basisFile: any): BasisFileInfo;
  50118. /**
  50119. * Transcodes the basis file to the requested format to be transferred to the gpu
  50120. * @param format fromat to be transferred to
  50121. * @param fileInfo information about the loaded file
  50122. * @param loadedFile the loaded basis file
  50123. * @returns the resulting pixels and if the transcode fell back to using Rgb565
  50124. */
  50125. static TranscodeFile(format: Nullable<number>, fileInfo: BasisFileInfo, loadedFile: any): {
  50126. fallbackToRgb565: boolean;
  50127. pixels: Uint8Array;
  50128. };
  50129. /**
  50130. * From https://github.com/BinomialLLC/basis_universal/blob/master/webgl/texture/dxt-to-rgb565.js
  50131. * An unoptimized version of dxtToRgb565. Also, the floating
  50132. * point math used to compute the colors actually results in
  50133. * slightly different colors compared to hardware DXT decoders.
  50134. * @param src dxt src pixels
  50135. * @param srcByteOffset offset for the start of src
  50136. * @param width aligned width of the image
  50137. * @param height aligned height of the image
  50138. * @return the converted pixels
  50139. */
  50140. static ConvertDxtToRgb565(src: Uint16Array, srcByteOffset: number, width: number, height: number): Uint16Array;
  50141. }
  50142. }
  50143. declare module BABYLON {
  50144. /**
  50145. * Loader for .basis file format
  50146. */
  50147. export class _BasisTextureLoader implements IInternalTextureLoader {
  50148. /**
  50149. * Defines whether the loader supports cascade loading the different faces.
  50150. */
  50151. readonly supportCascades: boolean;
  50152. /**
  50153. * This returns if the loader support the current file information.
  50154. * @param extension defines the file extension of the file being loaded
  50155. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50156. * @param fallback defines the fallback internal texture if any
  50157. * @param isBase64 defines whether the texture is encoded as a base64
  50158. * @param isBuffer defines whether the texture data are stored as a buffer
  50159. * @returns true if the loader can load the specified file
  50160. */
  50161. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  50162. /**
  50163. * Transform the url before loading if required.
  50164. * @param rootUrl the url of the texture
  50165. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50166. * @returns the transformed texture
  50167. */
  50168. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  50169. /**
  50170. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  50171. * @param rootUrl the url of the texture
  50172. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50173. * @returns the fallback texture
  50174. */
  50175. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  50176. /**
  50177. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  50178. * @param data contains the texture data
  50179. * @param texture defines the BabylonJS internal texture
  50180. * @param createPolynomials will be true if polynomials have been requested
  50181. * @param onLoad defines the callback to trigger once the texture is ready
  50182. * @param onError defines the callback to trigger in case of error
  50183. */
  50184. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  50185. /**
  50186. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  50187. * @param data contains the texture data
  50188. * @param texture defines the BabylonJS internal texture
  50189. * @param callback defines the method to call once ready to upload
  50190. */
  50191. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  50192. }
  50193. }
  50194. declare module BABYLON {
  50195. /**
  50196. * 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.
  50197. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  50198. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  50199. */
  50200. export class CustomProceduralTexture extends ProceduralTexture {
  50201. private _animate;
  50202. private _time;
  50203. private _config;
  50204. private _texturePath;
  50205. /**
  50206. * Instantiates a new Custom Procedural Texture.
  50207. * 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.
  50208. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  50209. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  50210. * @param name Define the name of the texture
  50211. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  50212. * @param size Define the size of the texture to create
  50213. * @param scene Define the scene the texture belongs to
  50214. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  50215. * @param generateMipMaps Define if the texture should creates mip maps or not
  50216. */
  50217. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  50218. private _loadJson;
  50219. /**
  50220. * Is the texture ready to be used ? (rendered at least once)
  50221. * @returns true if ready, otherwise, false.
  50222. */
  50223. isReady(): boolean;
  50224. /**
  50225. * Render the texture to its associated render target.
  50226. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  50227. */
  50228. render(useCameraPostProcess?: boolean): void;
  50229. /**
  50230. * Update the list of dependant textures samplers in the shader.
  50231. */
  50232. updateTextures(): void;
  50233. /**
  50234. * Update the uniform values of the procedural texture in the shader.
  50235. */
  50236. updateShaderUniforms(): void;
  50237. /**
  50238. * Define if the texture animates or not.
  50239. */
  50240. animate: boolean;
  50241. }
  50242. }
  50243. declare module BABYLON {
  50244. /** @hidden */
  50245. export var noisePixelShader: {
  50246. name: string;
  50247. shader: string;
  50248. };
  50249. }
  50250. declare module BABYLON {
  50251. /**
  50252. * Class used to generate noise procedural textures
  50253. */
  50254. export class NoiseProceduralTexture extends ProceduralTexture {
  50255. private _time;
  50256. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  50257. brightness: number;
  50258. /** Defines the number of octaves to process */
  50259. octaves: number;
  50260. /** Defines the level of persistence (0.8 by default) */
  50261. persistence: number;
  50262. /** Gets or sets animation speed factor (default is 1) */
  50263. animationSpeedFactor: number;
  50264. /**
  50265. * Creates a new NoiseProceduralTexture
  50266. * @param name defines the name fo the texture
  50267. * @param size defines the size of the texture (default is 256)
  50268. * @param scene defines the hosting scene
  50269. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  50270. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  50271. */
  50272. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  50273. private _updateShaderUniforms;
  50274. protected _getDefines(): string;
  50275. /** Generate the current state of the procedural texture */
  50276. render(useCameraPostProcess?: boolean): void;
  50277. /**
  50278. * Serializes this noise procedural texture
  50279. * @returns a serialized noise procedural texture object
  50280. */
  50281. serialize(): any;
  50282. /**
  50283. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  50284. * @param parsedTexture defines parsed texture data
  50285. * @param scene defines the current scene
  50286. * @param rootUrl defines the root URL containing noise procedural texture information
  50287. * @returns a parsed NoiseProceduralTexture
  50288. */
  50289. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  50290. }
  50291. }
  50292. declare module BABYLON {
  50293. /**
  50294. * Raw cube texture where the raw buffers are passed in
  50295. */
  50296. export class RawCubeTexture extends CubeTexture {
  50297. /**
  50298. * Creates a cube texture where the raw buffers are passed in.
  50299. * @param scene defines the scene the texture is attached to
  50300. * @param data defines the array of data to use to create each face
  50301. * @param size defines the size of the textures
  50302. * @param format defines the format of the data
  50303. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  50304. * @param generateMipMaps defines if the engine should generate the mip levels
  50305. * @param invertY defines if data must be stored with Y axis inverted
  50306. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  50307. * @param compression defines the compression used (null by default)
  50308. */
  50309. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  50310. /**
  50311. * Updates the raw cube texture.
  50312. * @param data defines the data to store
  50313. * @param format defines the data format
  50314. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  50315. * @param invertY defines if data must be stored with Y axis inverted
  50316. * @param compression defines the compression used (null by default)
  50317. * @param level defines which level of the texture to update
  50318. */
  50319. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  50320. /**
  50321. * Updates a raw cube texture with RGBD encoded data.
  50322. * @param data defines the array of data [mipmap][face] to use to create each face
  50323. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  50324. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  50325. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  50326. * @returns a promsie that resolves when the operation is complete
  50327. */
  50328. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  50329. /**
  50330. * Clones the raw cube texture.
  50331. * @return a new cube texture
  50332. */
  50333. clone(): CubeTexture;
  50334. /** @hidden */
  50335. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  50336. }
  50337. }
  50338. declare module BABYLON {
  50339. /**
  50340. * Class used to store 3D textures containing user data
  50341. */
  50342. export class RawTexture3D extends Texture {
  50343. /** Gets or sets the texture format to use */
  50344. format: number;
  50345. private _engine;
  50346. /**
  50347. * Create a new RawTexture3D
  50348. * @param data defines the data of the texture
  50349. * @param width defines the width of the texture
  50350. * @param height defines the height of the texture
  50351. * @param depth defines the depth of the texture
  50352. * @param format defines the texture format to use
  50353. * @param scene defines the hosting scene
  50354. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  50355. * @param invertY defines if texture must be stored with Y axis inverted
  50356. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  50357. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  50358. */
  50359. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  50360. /** Gets or sets the texture format to use */
  50361. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  50362. /**
  50363. * Update the texture with new data
  50364. * @param data defines the data to store in the texture
  50365. */
  50366. update(data: ArrayBufferView): void;
  50367. }
  50368. }
  50369. declare module BABYLON {
  50370. /**
  50371. * Creates a refraction texture used by refraction channel of the standard material.
  50372. * It is like a mirror but to see through a material.
  50373. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  50374. */
  50375. export class RefractionTexture extends RenderTargetTexture {
  50376. /**
  50377. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  50378. * 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.
  50379. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  50380. */
  50381. refractionPlane: Plane;
  50382. /**
  50383. * Define how deep under the surface we should see.
  50384. */
  50385. depth: number;
  50386. /**
  50387. * Creates a refraction texture used by refraction channel of the standard material.
  50388. * It is like a mirror but to see through a material.
  50389. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  50390. * @param name Define the texture name
  50391. * @param size Define the size of the underlying texture
  50392. * @param scene Define the scene the refraction belongs to
  50393. * @param generateMipMaps Define if we need to generate mips level for the refraction
  50394. */
  50395. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  50396. /**
  50397. * Clone the refraction texture.
  50398. * @returns the cloned texture
  50399. */
  50400. clone(): RefractionTexture;
  50401. /**
  50402. * Serialize the texture to a JSON representation you could use in Parse later on
  50403. * @returns the serialized JSON representation
  50404. */
  50405. serialize(): any;
  50406. }
  50407. }
  50408. declare module BABYLON {
  50409. /**
  50410. * Defines the options related to the creation of an HtmlElementTexture
  50411. */
  50412. export interface IHtmlElementTextureOptions {
  50413. /**
  50414. * Defines wether mip maps should be created or not.
  50415. */
  50416. generateMipMaps?: boolean;
  50417. /**
  50418. * Defines the sampling mode of the texture.
  50419. */
  50420. samplingMode?: number;
  50421. /**
  50422. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  50423. */
  50424. engine: Nullable<Engine>;
  50425. /**
  50426. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  50427. */
  50428. scene: Nullable<Scene>;
  50429. }
  50430. /**
  50431. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  50432. * To be as efficient as possible depending on your constraints nothing aside the first upload
  50433. * is automatically managed.
  50434. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  50435. * in your application.
  50436. *
  50437. * As the update is not automatic, you need to call them manually.
  50438. */
  50439. export class HtmlElementTexture extends BaseTexture {
  50440. /**
  50441. * The texture URL.
  50442. */
  50443. element: HTMLVideoElement | HTMLCanvasElement;
  50444. private static readonly DefaultOptions;
  50445. private _textureMatrix;
  50446. private _engine;
  50447. private _isVideo;
  50448. private _generateMipMaps;
  50449. private _samplingMode;
  50450. /**
  50451. * Instantiates a HtmlElementTexture from the following parameters.
  50452. *
  50453. * @param name Defines the name of the texture
  50454. * @param element Defines the video or canvas the texture is filled with
  50455. * @param options Defines the other none mandatory texture creation options
  50456. */
  50457. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  50458. private _createInternalTexture;
  50459. /**
  50460. * Returns the texture matrix used in most of the material.
  50461. */
  50462. getTextureMatrix(): Matrix;
  50463. /**
  50464. * Updates the content of the texture.
  50465. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  50466. */
  50467. update(invertY?: Nullable<boolean>): void;
  50468. }
  50469. }
  50470. declare module BABYLON {
  50471. /**
  50472. * Enum used to define the target of a block
  50473. */
  50474. export enum NodeMaterialBlockTargets {
  50475. /** Vertex shader */
  50476. Vertex = 1,
  50477. /** Fragment shader */
  50478. Fragment = 2,
  50479. /** Vertex and Fragment */
  50480. VertexAndFragment = 3
  50481. }
  50482. }
  50483. declare module BABYLON {
  50484. /**
  50485. * Defines the kind of connection point for node based material
  50486. */
  50487. export enum NodeMaterialBlockConnectionPointTypes {
  50488. /** Float */
  50489. Float = 1,
  50490. /** Int */
  50491. Int = 2,
  50492. /** Vector2 */
  50493. Vector2 = 4,
  50494. /** Vector3 */
  50495. Vector3 = 8,
  50496. /** Vector4 */
  50497. Vector4 = 16,
  50498. /** Color3 */
  50499. Color3 = 32,
  50500. /** Color4 */
  50501. Color4 = 64,
  50502. /** Matrix */
  50503. Matrix = 128,
  50504. /** Texture */
  50505. Texture = 256,
  50506. /** Texture3D */
  50507. Texture3D = 512,
  50508. /** Vector3 or Color3 */
  50509. Vector3OrColor3 = 40,
  50510. /** Vector3 or Vector4 */
  50511. Vector3OrVector4 = 24,
  50512. /** Vector4 or Color4 */
  50513. Vector4OrColor4 = 80,
  50514. /** Color3 or Color4 */
  50515. Color3OrColor4 = 96,
  50516. /** Vector3 or Color3 */
  50517. Vector3OrColor3OrVector4OrColor4 = 120
  50518. }
  50519. }
  50520. declare module BABYLON {
  50521. /**
  50522. * Enum used to define well known values e.g. values automatically provided by the system
  50523. */
  50524. export enum NodeMaterialWellKnownValues {
  50525. /** World */
  50526. World = 1,
  50527. /** View */
  50528. View = 2,
  50529. /** Projection */
  50530. Projection = 3,
  50531. /** ViewProjection */
  50532. ViewProjection = 4,
  50533. /** WorldView */
  50534. WorldView = 5,
  50535. /** WorldViewProjection */
  50536. WorldViewProjection = 6,
  50537. /** Will be filled by the block itself */
  50538. Automatic = 7
  50539. }
  50540. }
  50541. declare module BABYLON {
  50542. /**
  50543. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  50544. */
  50545. export enum NodeMaterialBlockConnectionPointMode {
  50546. /** Value is an uniform */
  50547. Uniform = 0,
  50548. /** Value is a mesh attribute */
  50549. Attribute = 1,
  50550. /** Value is a varying between vertex and fragment shaders */
  50551. Varying = 2,
  50552. /** Mode is undefined */
  50553. Undefined = 3
  50554. }
  50555. }
  50556. declare module BABYLON {
  50557. /**
  50558. * Class used to store shared data between 2 NodeMaterialBuildState
  50559. */
  50560. export class NodeMaterialBuildStateSharedData {
  50561. /**
  50562. * Gets the list of emitted varyings
  50563. */
  50564. varyings: string[];
  50565. /**
  50566. * Gets the varying declaration string
  50567. */
  50568. varyingDeclaration: string;
  50569. /**
  50570. * Uniform connection points
  50571. */
  50572. uniformConnectionPoints: NodeMaterialConnectionPoint[];
  50573. /**
  50574. * Bindable blocks (Blocks that need to set data to the effect)
  50575. */
  50576. bindableBlocks: NodeMaterialBlock[];
  50577. /**
  50578. * List of blocks that can provide a compilation fallback
  50579. */
  50580. blocksWithFallbacks: NodeMaterialBlock[];
  50581. /**
  50582. * List of blocks that can provide a define update
  50583. */
  50584. blocksWithDefines: NodeMaterialBlock[];
  50585. /**
  50586. * List of blocks that can provide a repeatable content
  50587. */
  50588. repeatableContentBlocks: NodeMaterialBlock[];
  50589. /**
  50590. * List of blocks that can block the isReady function for the material
  50591. */
  50592. blockingBlocks: NodeMaterialBlock[];
  50593. /**
  50594. * Build Id used to avoid multiple recompilations
  50595. */
  50596. buildId: number;
  50597. /** List of emitted variables */
  50598. variableNames: {
  50599. [key: string]: number;
  50600. };
  50601. /** List of emitted defines */
  50602. defineNames: {
  50603. [key: string]: number;
  50604. };
  50605. /** Should emit comments? */
  50606. emitComments: boolean;
  50607. /** Emit build activity */
  50608. verbose: boolean;
  50609. /**
  50610. * Gets the compilation hints emitted at compilation time
  50611. */
  50612. hints: {
  50613. needWorldViewMatrix: boolean;
  50614. needWorldViewProjectionMatrix: boolean;
  50615. needAlphaBlending: boolean;
  50616. needAlphaTesting: boolean;
  50617. };
  50618. /**
  50619. * List of compilation checks
  50620. */
  50621. checks: {
  50622. emitVertex: boolean;
  50623. emitFragment: boolean;
  50624. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  50625. };
  50626. /** Creates a new shared data */
  50627. constructor();
  50628. /**
  50629. * Emits console errors and exceptions if there is a failing check
  50630. */
  50631. emitErrors(): void;
  50632. }
  50633. }
  50634. declare module BABYLON {
  50635. /**
  50636. * Class used to store node based material build state
  50637. */
  50638. export class NodeMaterialBuildState {
  50639. /**
  50640. * Gets the list of emitted attributes
  50641. */
  50642. attributes: string[];
  50643. /**
  50644. * Gets the list of emitted uniforms
  50645. */
  50646. uniforms: string[];
  50647. /**
  50648. * Gets the list of emitted samplers
  50649. */
  50650. samplers: string[];
  50651. /**
  50652. * Gets the list of emitted functions
  50653. */
  50654. functions: {
  50655. [key: string]: string;
  50656. };
  50657. /**
  50658. * Gets the target of the compilation state
  50659. */
  50660. target: NodeMaterialBlockTargets;
  50661. /**
  50662. * Shared data between multiple NodeMaterialBuildState instances
  50663. */
  50664. sharedData: NodeMaterialBuildStateSharedData;
  50665. /** @hidden */
  50666. _vertexState: NodeMaterialBuildState;
  50667. private _attributeDeclaration;
  50668. private _uniformDeclaration;
  50669. private _samplerDeclaration;
  50670. private _varyingTransfer;
  50671. private _repeatableContentAnchorIndex;
  50672. /** @hidden */
  50673. _builtCompilationString: string;
  50674. /**
  50675. * Gets the emitted compilation strings
  50676. */
  50677. compilationString: string;
  50678. /**
  50679. * Finalize the compilation strings
  50680. * @param state defines the current compilation state
  50681. */
  50682. finalize(state: NodeMaterialBuildState): void;
  50683. /** @hidden */
  50684. readonly _repeatableContentAnchor: string;
  50685. /** @hidden */
  50686. _getFreeVariableName(prefix: string): string;
  50687. /** @hidden */
  50688. _getFreeDefineName(prefix: string): string;
  50689. /** @hidden */
  50690. _excludeVariableName(name: string): void;
  50691. /** @hidden */
  50692. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  50693. /** @hidden */
  50694. _emitFunction(name: string, code: string, comments: string): void;
  50695. /** @hidden */
  50696. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  50697. replaceStrings?: {
  50698. search: RegExp;
  50699. replace: string;
  50700. }[];
  50701. }): string;
  50702. /** @hidden */
  50703. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  50704. repeatKey?: string;
  50705. removeAttributes?: boolean;
  50706. removeUniforms?: boolean;
  50707. removeVaryings?: boolean;
  50708. removeIfDef?: boolean;
  50709. replaceStrings?: {
  50710. search: RegExp;
  50711. replace: string;
  50712. }[];
  50713. }): void;
  50714. /** @hidden */
  50715. _emitVaryings(point: NodeMaterialConnectionPoint, define?: string, force?: boolean, fromFragment?: boolean, replacementName?: string): void;
  50716. private _emitDefine;
  50717. /** @hidden */
  50718. _emitUniformOrAttributes(point: NodeMaterialConnectionPoint, define?: string): void;
  50719. }
  50720. }
  50721. declare module BABYLON {
  50722. /**
  50723. * Root class for all node material optimizers
  50724. */
  50725. export class NodeMaterialOptimizer {
  50726. /**
  50727. * Function used to optimize a NodeMaterial graph
  50728. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  50729. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  50730. */
  50731. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  50732. }
  50733. }
  50734. declare module BABYLON {
  50735. /**
  50736. * Block used to transform a vector4 with a matrix
  50737. */
  50738. export class Vector4TransformBlock extends NodeMaterialBlock {
  50739. /**
  50740. * Defines the value to use to complement Vector3 to transform it to a Vector4
  50741. */
  50742. complementW: number;
  50743. /**
  50744. * Creates a new Vector4TransformBlock
  50745. * @param name defines the block name
  50746. */
  50747. constructor(name: string);
  50748. /**
  50749. * Gets the current class name
  50750. * @returns the class name
  50751. */
  50752. getClassName(): string;
  50753. /**
  50754. * Gets the vector input
  50755. */
  50756. readonly vector: NodeMaterialConnectionPoint;
  50757. /**
  50758. * Gets the matrix transform input
  50759. */
  50760. readonly transform: NodeMaterialConnectionPoint;
  50761. protected _buildBlock(state: NodeMaterialBuildState): this;
  50762. }
  50763. }
  50764. declare module BABYLON {
  50765. /**
  50766. * Block used to output the vertex position
  50767. */
  50768. export class VertexOutputBlock extends NodeMaterialBlock {
  50769. /**
  50770. * Creates a new VertexOutputBlock
  50771. * @param name defines the block name
  50772. */
  50773. constructor(name: string);
  50774. /**
  50775. * Gets the current class name
  50776. * @returns the class name
  50777. */
  50778. getClassName(): string;
  50779. /**
  50780. * Gets the vector input component
  50781. */
  50782. readonly vector: NodeMaterialConnectionPoint;
  50783. protected _buildBlock(state: NodeMaterialBuildState): this;
  50784. }
  50785. }
  50786. declare module BABYLON {
  50787. /**
  50788. * Block used to output the final color
  50789. */
  50790. export class FragmentOutputBlock extends NodeMaterialBlock {
  50791. /**
  50792. * Gets or sets a boolean indicating if this block will output an alpha value
  50793. */
  50794. alphaBlendingEnabled: boolean;
  50795. /**
  50796. * Create a new FragmentOutputBlock
  50797. * @param name defines the block name
  50798. */
  50799. constructor(name: string);
  50800. /**
  50801. * Gets the current class name
  50802. * @returns the class name
  50803. */
  50804. getClassName(): string;
  50805. /**
  50806. * Gets the color input component
  50807. */
  50808. readonly color: NodeMaterialConnectionPoint;
  50809. protected _buildBlock(state: NodeMaterialBuildState): this;
  50810. }
  50811. }
  50812. declare module BABYLON {
  50813. /**
  50814. * Interface used to configure the node material editor
  50815. */
  50816. export interface INodeMaterialEditorOptions {
  50817. /** Define the URl to load node editor script */
  50818. editorURL?: string;
  50819. }
  50820. /** @hidden */
  50821. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  50822. /** BONES */
  50823. NUM_BONE_INFLUENCERS: number;
  50824. BonesPerMesh: number;
  50825. BONETEXTURE: boolean;
  50826. /** MORPH TARGETS */
  50827. MORPHTARGETS: boolean;
  50828. MORPHTARGETS_NORMAL: boolean;
  50829. MORPHTARGETS_TANGENT: boolean;
  50830. NUM_MORPH_INFLUENCERS: number;
  50831. /** IMAGE PROCESSING */
  50832. IMAGEPROCESSING: boolean;
  50833. VIGNETTE: boolean;
  50834. VIGNETTEBLENDMODEMULTIPLY: boolean;
  50835. VIGNETTEBLENDMODEOPAQUE: boolean;
  50836. TONEMAPPING: boolean;
  50837. TONEMAPPING_ACES: boolean;
  50838. CONTRAST: boolean;
  50839. EXPOSURE: boolean;
  50840. COLORCURVES: boolean;
  50841. COLORGRADING: boolean;
  50842. COLORGRADING3D: boolean;
  50843. SAMPLER3DGREENDEPTH: boolean;
  50844. SAMPLER3DBGRMAP: boolean;
  50845. IMAGEPROCESSINGPOSTPROCESS: boolean;
  50846. constructor();
  50847. setValue(name: string, value: boolean): void;
  50848. }
  50849. /**
  50850. * Class used to configure NodeMaterial
  50851. */
  50852. export interface INodeMaterialOptions {
  50853. /**
  50854. * Defines if blocks should emit comments
  50855. */
  50856. emitComments: boolean;
  50857. }
  50858. /**
  50859. * Class used to create a node based material built by assembling shader blocks
  50860. */
  50861. export class NodeMaterial extends PushMaterial {
  50862. private _options;
  50863. private _vertexCompilationState;
  50864. private _fragmentCompilationState;
  50865. private _sharedData;
  50866. private _buildId;
  50867. private _buildWasSuccessful;
  50868. private _cachedWorldViewMatrix;
  50869. private _cachedWorldViewProjectionMatrix;
  50870. private _textureConnectionPoints;
  50871. private _optimizers;
  50872. /** Define the URl to load node editor script */
  50873. static EditorURL: string;
  50874. private BJSNODEMATERIALEDITOR;
  50875. /** Get the inspector from bundle or global */
  50876. private _getGlobalNodeMaterialEditor;
  50877. /**
  50878. * Defines the maximum number of lights that can be used in the material
  50879. */
  50880. maxSimultaneousLights: number;
  50881. /**
  50882. * Observable raised when the material is built
  50883. */
  50884. onBuildObservable: Observable<NodeMaterial>;
  50885. /**
  50886. * Gets or sets the root nodes of the material vertex shader
  50887. */
  50888. _vertexOutputNodes: NodeMaterialBlock[];
  50889. /**
  50890. * Gets or sets the root nodes of the material fragment (pixel) shader
  50891. */
  50892. _fragmentOutputNodes: NodeMaterialBlock[];
  50893. /** Gets or sets options to control the node material overall behavior */
  50894. options: INodeMaterialOptions;
  50895. /**
  50896. * Default configuration related to image processing available in the standard Material.
  50897. */
  50898. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  50899. /**
  50900. * Gets the image processing configuration used either in this material.
  50901. */
  50902. /**
  50903. * Sets the Default image processing configuration used either in the this material.
  50904. *
  50905. * If sets to null, the scene one is in use.
  50906. */
  50907. imageProcessingConfiguration: ImageProcessingConfiguration;
  50908. /**
  50909. * Create a new node based material
  50910. * @param name defines the material name
  50911. * @param scene defines the hosting scene
  50912. * @param options defines creation option
  50913. */
  50914. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  50915. /**
  50916. * Gets the current class name of the material e.g. "NodeMaterial"
  50917. * @returns the class name
  50918. */
  50919. getClassName(): string;
  50920. /**
  50921. * Keep track of the image processing observer to allow dispose and replace.
  50922. */
  50923. private _imageProcessingObserver;
  50924. /**
  50925. * Attaches a new image processing configuration to the Standard Material.
  50926. * @param configuration
  50927. */
  50928. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  50929. /**
  50930. * Adds a new optimizer to the list of optimizers
  50931. * @param optimizer defines the optimizers to add
  50932. * @returns the current material
  50933. */
  50934. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  50935. /**
  50936. * Remove an optimizer from the list of optimizers
  50937. * @param optimizer defines the optimizers to remove
  50938. * @returns the current material
  50939. */
  50940. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  50941. /**
  50942. * Add a new block to the list of output nodes
  50943. * @param node defines the node to add
  50944. * @returns the current material
  50945. */
  50946. addOutputNode(node: NodeMaterialBlock): this;
  50947. /**
  50948. * Remove a block from the list of root nodes
  50949. * @param node defines the node to remove
  50950. * @returns the current material
  50951. */
  50952. removeOutputNode(node: NodeMaterialBlock): this;
  50953. private _addVertexOutputNode;
  50954. private _removeVertexOutputNode;
  50955. private _addFragmentOutputNode;
  50956. private _removeFragmentOutputNode;
  50957. /**
  50958. * Specifies if the material will require alpha blending
  50959. * @returns a boolean specifying if alpha blending is needed
  50960. */
  50961. needAlphaBlending(): boolean;
  50962. /**
  50963. * Specifies if this material should be rendered in alpha test mode
  50964. * @returns a boolean specifying if an alpha test is needed.
  50965. */
  50966. needAlphaTesting(): boolean;
  50967. private _initializeBlock;
  50968. private _resetDualBlocks;
  50969. /**
  50970. * Build the material and generates the inner effect
  50971. * @param verbose defines if the build should log activity
  50972. */
  50973. build(verbose?: boolean): void;
  50974. /**
  50975. * Runs an otpimization phase to try to improve the shader code
  50976. */
  50977. optimize(): void;
  50978. private _prepareDefinesForAttributes;
  50979. /**
  50980. * Get if the submesh is ready to be used and all its information available.
  50981. * Child classes can use it to update shaders
  50982. * @param mesh defines the mesh to check
  50983. * @param subMesh defines which submesh to check
  50984. * @param useInstances specifies that instances should be used
  50985. * @returns a boolean indicating that the submesh is ready or not
  50986. */
  50987. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  50988. /**
  50989. * Binds the world matrix to the material
  50990. * @param world defines the world transformation matrix
  50991. */
  50992. bindOnlyWorldMatrix(world: Matrix): void;
  50993. /**
  50994. * Binds the submesh to this material by preparing the effect and shader to draw
  50995. * @param world defines the world transformation matrix
  50996. * @param mesh defines the mesh containing the submesh
  50997. * @param subMesh defines the submesh to bind the material to
  50998. */
  50999. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  51000. /**
  51001. * Gets the active textures from the material
  51002. * @returns an array of textures
  51003. */
  51004. getActiveTextures(): BaseTexture[];
  51005. /**
  51006. * Specifies if the material uses a texture
  51007. * @param texture defines the texture to check against the material
  51008. * @returns a boolean specifying if the material uses the texture
  51009. */
  51010. hasTexture(texture: BaseTexture): boolean;
  51011. /**
  51012. * Disposes the material
  51013. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  51014. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  51015. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  51016. */
  51017. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  51018. /** Creates the node editor window. */
  51019. private _createNodeEditor;
  51020. /**
  51021. * Launch the node material editor
  51022. * @param config Define the configuration of the editor
  51023. * @return a promise fulfilled when the node editor is visible
  51024. */
  51025. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  51026. /**
  51027. * Clear the current material
  51028. */
  51029. clear(): void;
  51030. /**
  51031. * Clear the current material and set it to a default state
  51032. */
  51033. setToDefault(): void;
  51034. }
  51035. }
  51036. declare module BABYLON {
  51037. /**
  51038. * Defines a block that can be used inside a node based material
  51039. */
  51040. export class NodeMaterialBlock {
  51041. private _buildId;
  51042. private _target;
  51043. private _isFinalMerger;
  51044. /** @hidden */
  51045. _inputs: NodeMaterialConnectionPoint[];
  51046. /** @hidden */
  51047. _outputs: NodeMaterialConnectionPoint[];
  51048. /**
  51049. * Gets or sets the name of the block
  51050. */
  51051. name: string;
  51052. /**
  51053. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  51054. */
  51055. readonly isFinalMerger: boolean;
  51056. /**
  51057. * Gets or sets the build Id
  51058. */
  51059. buildId: number;
  51060. /**
  51061. * Gets or sets the target of the block
  51062. */
  51063. target: NodeMaterialBlockTargets;
  51064. /**
  51065. * Gets the list of input points
  51066. */
  51067. readonly inputs: NodeMaterialConnectionPoint[];
  51068. /** Gets the list of output points */
  51069. readonly outputs: NodeMaterialConnectionPoint[];
  51070. /**
  51071. * Find an input by its name
  51072. * @param name defines the name of the input to look for
  51073. * @returns the input or null if not found
  51074. */
  51075. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  51076. /**
  51077. * Find an output by its name
  51078. * @param name defines the name of the outputto look for
  51079. * @returns the output or null if not found
  51080. */
  51081. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  51082. /**
  51083. * Creates a new NodeMaterialBlock
  51084. * @param name defines the block name
  51085. * @param target defines the target of that block (Vertex by default)
  51086. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  51087. */
  51088. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean);
  51089. /**
  51090. * Initialize the block and prepare the context for build
  51091. * @param state defines the state that will be used for the build
  51092. */
  51093. initialize(state: NodeMaterialBuildState): void;
  51094. /**
  51095. * Bind data to effect. Will only be called for blocks with isBindable === true
  51096. * @param effect defines the effect to bind data to
  51097. * @param nodeMaterial defines the hosting NodeMaterial
  51098. * @param mesh defines the mesh that will be rendered
  51099. */
  51100. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  51101. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  51102. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  51103. protected _writeFloat(value: number): string;
  51104. /**
  51105. * Gets the current class name e.g. "NodeMaterialBlock"
  51106. * @returns the class name
  51107. */
  51108. getClassName(): string;
  51109. /**
  51110. * Register a new input. Must be called inside a block constructor
  51111. * @param name defines the connection point name
  51112. * @param type defines the connection point type
  51113. * @param isOptional defines a boolean indicating that this input can be omitted
  51114. * @param target defines the target to use to limit the connection point (will be VetexAndFragment by default)
  51115. * @returns the current block
  51116. */
  51117. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  51118. /**
  51119. * Register a new output. Must be called inside a block constructor
  51120. * @param name defines the connection point name
  51121. * @param type defines the connection point type
  51122. * @param target defines the target to use to limit the connection point (will be VetexAndFragment by default)
  51123. * @returns the current block
  51124. */
  51125. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  51126. /**
  51127. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  51128. * @param forOutput defines an optional connection point to check compatibility with
  51129. * @returns the first available input or null
  51130. */
  51131. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  51132. /**
  51133. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  51134. * @param forBlock defines an optional block to check compatibility with
  51135. * @returns the first available input or null
  51136. */
  51137. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  51138. /**
  51139. * Connect current block with another block
  51140. * @param other defines the block to connect with
  51141. * @param options define the various options to help pick the right connections
  51142. * @returns the current block
  51143. */
  51144. connectTo(other: NodeMaterialBlock, options?: {
  51145. input?: string;
  51146. output?: string;
  51147. outputSwizzle?: string;
  51148. }): this | undefined;
  51149. protected _buildBlock(state: NodeMaterialBuildState): void;
  51150. /**
  51151. * Add potential fallbacks if shader compilation fails
  51152. * @param mesh defines the mesh to be rendered
  51153. * @param fallbacks defines the current prioritized list of fallbacks
  51154. */
  51155. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  51156. /**
  51157. * Update defines for shader compilation
  51158. * @param mesh defines the mesh to be rendered
  51159. * @param nodeMaterial defines the node material requesting the update
  51160. * @param defines defines the material defines to update
  51161. * @param useInstances specifies that instances should be used
  51162. */
  51163. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  51164. /**
  51165. * Lets the block try to connect some inputs automatically
  51166. */
  51167. autoConfigure(): void;
  51168. /**
  51169. * Function called when a block is declared as repeatable content generator
  51170. * @param vertexShaderState defines the current compilation state for the vertex shader
  51171. * @param fragmentShaderState defines the current compilation state for the fragment shader
  51172. * @param mesh defines the mesh to be rendered
  51173. * @param defines defines the material defines to update
  51174. */
  51175. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  51176. /**
  51177. * Checks if the block is ready
  51178. * @param mesh defines the mesh to be rendered
  51179. * @param nodeMaterial defines the node material requesting the update
  51180. * @param defines defines the material defines to update
  51181. * @param useInstances specifies that instances should be used
  51182. * @returns true if the block is ready
  51183. */
  51184. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  51185. /**
  51186. * Compile the current node and generate the shader code
  51187. * @param state defines the current compilation state (uniforms, samplers, current string)
  51188. * @returns the current block
  51189. */
  51190. build(state: NodeMaterialBuildState): this | undefined;
  51191. }
  51192. }
  51193. declare module BABYLON {
  51194. /**
  51195. * Defines a connection point for a block
  51196. */
  51197. export class NodeMaterialConnectionPoint {
  51198. /** @hidden */
  51199. _ownerBlock: NodeMaterialBlock;
  51200. /** @hidden */
  51201. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  51202. private _associatedVariableName;
  51203. private _endpoints;
  51204. private _storedValue;
  51205. private _valueCallback;
  51206. private _mode;
  51207. /** @hidden */
  51208. _wellKnownValue: Nullable<NodeMaterialWellKnownValues>;
  51209. /** @hidden */
  51210. _needToEmitVarying: boolean;
  51211. /**
  51212. * Gets or sets the connection point type (default is float)
  51213. */
  51214. type: NodeMaterialBlockConnectionPointTypes;
  51215. /**
  51216. * Gets or sets the connection point name
  51217. */
  51218. name: string;
  51219. /**
  51220. * Gets or sets the swizzle to apply to this connection point when reading or writing
  51221. */
  51222. swizzle: string;
  51223. /**
  51224. * Gets or sets a boolean indicating that this connection point can be omitted
  51225. */
  51226. isOptional: boolean;
  51227. /**
  51228. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  51229. */
  51230. define: string;
  51231. /** Gets or sets the target of that connection point */
  51232. target: NodeMaterialBlockTargets;
  51233. /**
  51234. * Gets or sets the value of that point.
  51235. * Please note that this value will be ignored if valueCallback is defined
  51236. */
  51237. value: any;
  51238. /**
  51239. * Gets or sets a callback used to get the value of that point.
  51240. * Please note that setting this value will force the connection point to ignore the value property
  51241. */
  51242. valueCallback: () => any;
  51243. /**
  51244. * Gets or sets the associated variable name in the shader
  51245. */
  51246. associatedVariableName: string;
  51247. /**
  51248. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  51249. * In this case the connection point name must be the name of the uniform to use.
  51250. * Can only be set on inputs
  51251. */
  51252. isUniform: boolean;
  51253. /**
  51254. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  51255. * In this case the connection point name must be the name of the attribute to use
  51256. * Can only be set on inputs
  51257. */
  51258. isAttribute: boolean;
  51259. /**
  51260. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  51261. * Can only be set on exit points
  51262. */
  51263. isVarying: boolean;
  51264. /** Get the other side of the connection (if any) */
  51265. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  51266. /** Get the block that owns this connection point */
  51267. readonly ownerBlock: NodeMaterialBlock;
  51268. /** Get the block connected on the other side of this connection (if any) */
  51269. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  51270. /** Get the block connected on the endpoints of this connection (if any) */
  51271. readonly connectedBlocks: Array<NodeMaterialBlock>;
  51272. /**
  51273. * Creates a new connection point
  51274. * @param name defines the connection point name
  51275. * @param ownerBlock defines the block hosting this connection point
  51276. */
  51277. constructor(name: string, ownerBlock: NodeMaterialBlock);
  51278. /**
  51279. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  51280. * @returns the class name
  51281. */
  51282. getClassName(): string;
  51283. /**
  51284. * Set the source of this connection point to a vertex attribute
  51285. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  51286. * @returns the current connection point
  51287. */
  51288. setAsAttribute(attributeName?: string): NodeMaterialConnectionPoint;
  51289. /**
  51290. * Set the source of this connection point to a well known value
  51291. * @param value define the well known value to use (world, view, etc...) or null to switch to manual value
  51292. * @returns the current connection point
  51293. */
  51294. setAsWellKnownValue(value: Nullable<NodeMaterialWellKnownValues>): NodeMaterialConnectionPoint;
  51295. /**
  51296. * Gets a boolean indicating that the current connection point is a well known value
  51297. */
  51298. readonly isWellKnownValue: boolean;
  51299. /**
  51300. * Gets or sets the current well known value or null if not defined as well know value
  51301. */
  51302. wellKnownValue: Nullable<NodeMaterialWellKnownValues>;
  51303. private _getTypeLength;
  51304. /**
  51305. * Connect this point to another connection point
  51306. * @param connectionPoint defines the other connection point
  51307. * @returns the current connection point
  51308. */
  51309. connectTo(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  51310. /**
  51311. * Disconnect this point from one of his endpoint
  51312. * @param endpoint defines the other connection point
  51313. * @returns the current connection point
  51314. */
  51315. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  51316. /**
  51317. * When connection point is an uniform, this function will send its value to the effect
  51318. * @param effect defines the effect to transmit value to
  51319. * @param world defines the world matrix
  51320. * @param worldView defines the worldxview matrix
  51321. * @param worldViewProjection defines the worldxviewxprojection matrix
  51322. */
  51323. transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  51324. /**
  51325. * When connection point is an uniform, this function will send its value to the effect
  51326. * @param effect defines the effect to transmit value to
  51327. * @param scene defines the hosting scene
  51328. */
  51329. transmit(effect: Effect, scene: Scene): void;
  51330. }
  51331. }
  51332. declare module BABYLON {
  51333. /**
  51334. * Block used to add support for vertex skinning (bones)
  51335. */
  51336. export class BonesBlock extends NodeMaterialBlock {
  51337. /**
  51338. * Creates a new BonesBlock
  51339. * @param name defines the block name
  51340. */
  51341. constructor(name: string);
  51342. /**
  51343. * Initialize the block and prepare the context for build
  51344. * @param state defines the state that will be used for the build
  51345. */
  51346. initialize(state: NodeMaterialBuildState): void;
  51347. /**
  51348. * Gets the current class name
  51349. * @returns the class name
  51350. */
  51351. getClassName(): string;
  51352. /**
  51353. * Gets the matrix indices input component
  51354. */
  51355. readonly matricesIndices: NodeMaterialConnectionPoint;
  51356. /**
  51357. * Gets the matrix weights input component
  51358. */
  51359. readonly matricesWeights: NodeMaterialConnectionPoint;
  51360. /**
  51361. * Gets the extra matrix indices input component
  51362. */
  51363. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  51364. /**
  51365. * Gets the extra matrix weights input component
  51366. */
  51367. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  51368. /**
  51369. * Gets the world input component
  51370. */
  51371. readonly world: NodeMaterialConnectionPoint;
  51372. autoConfigure(): void;
  51373. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  51374. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  51375. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  51376. protected _buildBlock(state: NodeMaterialBuildState): this;
  51377. }
  51378. }
  51379. declare module BABYLON {
  51380. /**
  51381. * Block used to add support for instances
  51382. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  51383. */
  51384. export class InstancesBlock extends NodeMaterialBlock {
  51385. /**
  51386. * Creates a new InstancesBlock
  51387. * @param name defines the block name
  51388. */
  51389. constructor(name: string);
  51390. /**
  51391. * Gets the current class name
  51392. * @returns the class name
  51393. */
  51394. getClassName(): string;
  51395. /**
  51396. * Gets the first world row input component
  51397. */
  51398. readonly world0: NodeMaterialConnectionPoint;
  51399. /**
  51400. * Gets the second world row input component
  51401. */
  51402. readonly world1: NodeMaterialConnectionPoint;
  51403. /**
  51404. * Gets the third world row input component
  51405. */
  51406. readonly world2: NodeMaterialConnectionPoint;
  51407. /**
  51408. * Gets the forth world row input component
  51409. */
  51410. readonly world3: NodeMaterialConnectionPoint;
  51411. /**
  51412. * Gets the world input component
  51413. */
  51414. readonly world: NodeMaterialConnectionPoint;
  51415. /**
  51416. * Gets the output component
  51417. */
  51418. readonly output: NodeMaterialConnectionPoint;
  51419. autoConfigure(): void;
  51420. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  51421. protected _buildBlock(state: NodeMaterialBuildState): this;
  51422. }
  51423. }
  51424. declare module BABYLON {
  51425. /**
  51426. * Block used to add morph targets support to vertex shader
  51427. */
  51428. export class MorphTargetsBlock extends NodeMaterialBlock {
  51429. private _repeatableContentAnchor;
  51430. private _repeatebleContentGenerated;
  51431. /**
  51432. * Create a new MorphTargetsBlock
  51433. * @param name defines the block name
  51434. */
  51435. constructor(name: string);
  51436. /**
  51437. * Gets the current class name
  51438. * @returns the class name
  51439. */
  51440. getClassName(): string;
  51441. /**
  51442. * Gets the position input component
  51443. */
  51444. readonly position: NodeMaterialConnectionPoint;
  51445. /**
  51446. * Gets the normal input component
  51447. */
  51448. readonly normal: NodeMaterialConnectionPoint;
  51449. /**
  51450. * Gets the tangent input component
  51451. */
  51452. readonly tangent: NodeMaterialConnectionPoint;
  51453. /**
  51454. * Gets the position output component
  51455. */
  51456. readonly positionOutput: NodeMaterialConnectionPoint;
  51457. /**
  51458. * Gets the normal output component
  51459. */
  51460. readonly normalOutput: NodeMaterialConnectionPoint;
  51461. /**
  51462. * Gets the tangent output component
  51463. */
  51464. readonly tangentOutput: NodeMaterialConnectionPoint;
  51465. initialize(state: NodeMaterialBuildState): void;
  51466. autoConfigure(): void;
  51467. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  51468. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  51469. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  51470. protected _buildBlock(state: NodeMaterialBuildState): this;
  51471. }
  51472. }
  51473. declare module BABYLON {
  51474. /**
  51475. * Block used to add an alpha test in the fragment shader
  51476. */
  51477. export class AlphaTestBlock extends NodeMaterialBlock {
  51478. /**
  51479. * Gets or sets the alpha value where alpha testing happens
  51480. */
  51481. alphaCutOff: number;
  51482. /**
  51483. * Create a new AlphaTestBlock
  51484. * @param name defines the block name
  51485. */
  51486. constructor(name: string);
  51487. /**
  51488. * Gets the current class name
  51489. * @returns the class name
  51490. */
  51491. getClassName(): string;
  51492. /**
  51493. * Gets the color input component
  51494. */
  51495. readonly color: NodeMaterialConnectionPoint;
  51496. protected _buildBlock(state: NodeMaterialBuildState): this;
  51497. }
  51498. }
  51499. declare module BABYLON {
  51500. /**
  51501. * Block used to create a Color4 out of 4 inputs (one for each component)
  51502. */
  51503. export class RGBAMergerBlock extends NodeMaterialBlock {
  51504. /**
  51505. * Create a new RGBAMergerBlock
  51506. * @param name defines the block name
  51507. */
  51508. constructor(name: string);
  51509. /**
  51510. * Gets the current class name
  51511. * @returns the class name
  51512. */
  51513. getClassName(): string;
  51514. /**
  51515. * Gets the R input component
  51516. */
  51517. readonly r: NodeMaterialConnectionPoint;
  51518. /**
  51519. * Gets the G input component
  51520. */
  51521. readonly g: NodeMaterialConnectionPoint;
  51522. /**
  51523. * Gets the B input component
  51524. */
  51525. readonly b: NodeMaterialConnectionPoint;
  51526. /**
  51527. * Gets the RGB input component
  51528. */
  51529. readonly rgb: NodeMaterialConnectionPoint;
  51530. /**
  51531. * Gets the R input component
  51532. */
  51533. readonly a: NodeMaterialConnectionPoint;
  51534. protected _buildBlock(state: NodeMaterialBuildState): this;
  51535. }
  51536. }
  51537. declare module BABYLON {
  51538. /**
  51539. * Block used to create a Color3 out of 3 inputs (one for each component)
  51540. */
  51541. export class RGBMergerBlock extends NodeMaterialBlock {
  51542. /**
  51543. * Create a new RGBMergerBlock
  51544. * @param name defines the block name
  51545. */
  51546. constructor(name: string);
  51547. /**
  51548. * Gets the current class name
  51549. * @returns the class name
  51550. */
  51551. getClassName(): string;
  51552. /**
  51553. * Gets the R component input
  51554. */
  51555. readonly r: NodeMaterialConnectionPoint;
  51556. /**
  51557. * Gets the G component input
  51558. */
  51559. readonly g: NodeMaterialConnectionPoint;
  51560. /**
  51561. * Gets the B component input
  51562. */
  51563. readonly b: NodeMaterialConnectionPoint;
  51564. protected _buildBlock(state: NodeMaterialBuildState): this;
  51565. }
  51566. }
  51567. declare module BABYLON {
  51568. /**
  51569. * Block used to expand a Color4 or a Vector4 into 4 outputs (one for each component)
  51570. */
  51571. export class RGBASplitterBlock extends NodeMaterialBlock {
  51572. /**
  51573. * Create a new RGBASplitterBlock
  51574. * @param name defines the block name
  51575. */
  51576. constructor(name: string);
  51577. /**
  51578. * Gets the current class name
  51579. * @returns the class name
  51580. */
  51581. getClassName(): string;
  51582. /**
  51583. * Gets the input component
  51584. */
  51585. readonly input: NodeMaterialConnectionPoint;
  51586. protected _buildBlock(state: NodeMaterialBuildState): this;
  51587. }
  51588. }
  51589. declare module BABYLON {
  51590. /**
  51591. * Block used to expand a Color3 or a Vector3 into 3 outputs (one for each component)
  51592. */
  51593. export class RGBSplitterBlock extends NodeMaterialBlock {
  51594. /**
  51595. * Create a new RGBSplitterBlock
  51596. * @param name defines the block name
  51597. */
  51598. constructor(name: string);
  51599. /**
  51600. * Gets the current class name
  51601. * @returns the class name
  51602. */
  51603. getClassName(): string;
  51604. /**
  51605. * Gets the input component
  51606. */
  51607. readonly input: NodeMaterialConnectionPoint;
  51608. protected _buildBlock(state: NodeMaterialBuildState): this;
  51609. }
  51610. }
  51611. declare module BABYLON {
  51612. /**
  51613. * Block used to read a texture from a sampler
  51614. */
  51615. export class TextureBlock extends NodeMaterialBlock {
  51616. private _defineName;
  51617. /**
  51618. * Gets or sets a boolean indicating that the block can automatically fetch the texture matrix
  51619. */
  51620. autoConnectTextureMatrix: boolean;
  51621. /**
  51622. * Gets or sets a boolean indicating that the block can automatically select the uv channel based on texture
  51623. */
  51624. autoSelectUV: boolean;
  51625. /**
  51626. * Create a new TextureBlock
  51627. * @param name defines the block name
  51628. */
  51629. constructor(name: string);
  51630. /**
  51631. * Gets the current class name
  51632. * @returns the class name
  51633. */
  51634. getClassName(): string;
  51635. /**
  51636. * Gets the uv input component
  51637. */
  51638. readonly uv: NodeMaterialConnectionPoint;
  51639. /**
  51640. * Gets the texture information input component
  51641. */
  51642. readonly textureInfo: NodeMaterialConnectionPoint;
  51643. /**
  51644. * Gets the transformed uv input component
  51645. */
  51646. readonly transformedUV: NodeMaterialConnectionPoint;
  51647. /**
  51648. * Gets the texture input component
  51649. */
  51650. readonly texture: NodeMaterialConnectionPoint;
  51651. /**
  51652. * Gets the texture transform input component
  51653. */
  51654. readonly textureTransform: NodeMaterialConnectionPoint;
  51655. autoConfigure(): void;
  51656. initialize(state: NodeMaterialBuildState): void;
  51657. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  51658. isReady(): boolean;
  51659. private _injectVertexCode;
  51660. protected _buildBlock(state: NodeMaterialBuildState): this;
  51661. }
  51662. }
  51663. declare module BABYLON {
  51664. /**
  51665. * Block used to add image processing support to fragment shader
  51666. */
  51667. export class ImageProcessingBlock extends NodeMaterialBlock {
  51668. /**
  51669. * Create a new ImageProcessingBlock
  51670. * @param name defines the block name
  51671. */
  51672. constructor(name: string);
  51673. /**
  51674. * Gets the current class name
  51675. * @returns the class name
  51676. */
  51677. getClassName(): string;
  51678. /**
  51679. * Gets the color input component
  51680. */
  51681. readonly color: NodeMaterialConnectionPoint;
  51682. /**
  51683. * Initialize the block and prepare the context for build
  51684. * @param state defines the state that will be used for the build
  51685. */
  51686. initialize(state: NodeMaterialBuildState): void;
  51687. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  51688. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  51689. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  51690. protected _buildBlock(state: NodeMaterialBuildState): this;
  51691. }
  51692. }
  51693. declare module BABYLON {
  51694. /**
  51695. * Block used to add support for scene fog
  51696. */
  51697. export class FogBlock extends NodeMaterialBlock {
  51698. /**
  51699. * Create a new FogBlock
  51700. * @param name defines the block name
  51701. */
  51702. constructor(name: string);
  51703. /**
  51704. * Gets the current class name
  51705. * @returns the class name
  51706. */
  51707. getClassName(): string;
  51708. /**
  51709. * Gets the world position input component
  51710. */
  51711. readonly worldPosition: NodeMaterialConnectionPoint;
  51712. /**
  51713. * Gets the view input component
  51714. */
  51715. readonly view: NodeMaterialConnectionPoint;
  51716. /**
  51717. * Gets the color input component
  51718. */
  51719. readonly color: NodeMaterialConnectionPoint;
  51720. /**
  51721. * Gets the fog color input component
  51722. */
  51723. readonly fogColor: NodeMaterialConnectionPoint;
  51724. /**
  51725. * Gets the for parameter input component
  51726. */
  51727. readonly fogParameters: NodeMaterialConnectionPoint;
  51728. autoConfigure(): void;
  51729. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  51730. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  51731. protected _buildBlock(state: NodeMaterialBuildState): this;
  51732. }
  51733. }
  51734. declare module BABYLON {
  51735. /**
  51736. * Block used to multiply 2 vector4
  51737. */
  51738. export class MultiplyBlock extends NodeMaterialBlock {
  51739. /**
  51740. * Creates a new MultiplyBlock
  51741. * @param name defines the block name
  51742. */
  51743. constructor(name: string);
  51744. /**
  51745. * Gets the current class name
  51746. * @returns the class name
  51747. */
  51748. getClassName(): string;
  51749. /**
  51750. * Gets the left operand input component
  51751. */
  51752. readonly left: NodeMaterialConnectionPoint;
  51753. /**
  51754. * Gets the right operand input component
  51755. */
  51756. readonly right: NodeMaterialConnectionPoint;
  51757. protected _buildBlock(state: NodeMaterialBuildState): this;
  51758. }
  51759. }
  51760. declare module BABYLON {
  51761. /**
  51762. * Block used to add 2 vector4
  51763. */
  51764. export class AddBlock extends NodeMaterialBlock {
  51765. /**
  51766. * Creates a new AddBlock
  51767. * @param name defines the block name
  51768. */
  51769. constructor(name: string);
  51770. /**
  51771. * Gets the current class name
  51772. * @returns the class name
  51773. */
  51774. getClassName(): string;
  51775. /**
  51776. * Gets the left operand input component
  51777. */
  51778. readonly left: NodeMaterialConnectionPoint;
  51779. /**
  51780. * Gets the right operand input component
  51781. */
  51782. readonly right: NodeMaterialConnectionPoint;
  51783. protected _buildBlock(state: NodeMaterialBuildState): this;
  51784. }
  51785. }
  51786. declare module BABYLON {
  51787. /**
  51788. * Block used to clamp a float
  51789. */
  51790. export class ClampBlock extends NodeMaterialBlock {
  51791. /** Gets or sets the minimum range */
  51792. minimum: number;
  51793. /** Gets or sets the maximum range */
  51794. maximum: number;
  51795. /**
  51796. * Creates a new ClampBlock
  51797. * @param name defines the block name
  51798. */
  51799. constructor(name: string);
  51800. /**
  51801. * Gets the current class name
  51802. * @returns the class name
  51803. */
  51804. getClassName(): string;
  51805. /**
  51806. * Gets the value input component
  51807. */
  51808. readonly value: NodeMaterialConnectionPoint;
  51809. protected _buildBlock(state: NodeMaterialBuildState): this;
  51810. }
  51811. }
  51812. declare module BABYLON {
  51813. /**
  51814. * Block used to transform a vector2 with a matrix
  51815. */
  51816. export class Vector2TransformBlock extends NodeMaterialBlock {
  51817. /**
  51818. * Defines the value to use to complement Vector2 to transform it to a Vector4
  51819. */
  51820. complementZ: number;
  51821. /**
  51822. * Defines the value to use to complement Vector2 to transform it to a Vector4
  51823. */
  51824. complementW: number;
  51825. /**
  51826. * Creates a new Vector2TransformBlock
  51827. * @param name defines the block name
  51828. */
  51829. constructor(name: string);
  51830. /**
  51831. * Gets the vector input
  51832. */
  51833. readonly vector: NodeMaterialConnectionPoint;
  51834. /**
  51835. * Gets the matrix transform input
  51836. */
  51837. readonly transform: NodeMaterialConnectionPoint;
  51838. /**
  51839. * Gets the current class name
  51840. * @returns the class name
  51841. */
  51842. getClassName(): string;
  51843. protected _buildBlock(state: NodeMaterialBuildState): this;
  51844. }
  51845. }
  51846. declare module BABYLON {
  51847. /**
  51848. * Block used to transform a vector3 with a matrix
  51849. */
  51850. export class Vector3TransformBlock extends NodeMaterialBlock {
  51851. /**
  51852. * Defines the value to use to complement Vector3 to transform it to a Vector4
  51853. */
  51854. complement: number;
  51855. /**
  51856. * Creates a new Vector3TransformBlock
  51857. * @param name defines the block name
  51858. */
  51859. constructor(name: string);
  51860. /**
  51861. * Gets the vector input
  51862. */
  51863. readonly vector: NodeMaterialConnectionPoint;
  51864. /**
  51865. * Gets the matrix transform input
  51866. */
  51867. readonly transform: NodeMaterialConnectionPoint;
  51868. /**
  51869. * Gets the current class name
  51870. * @returns the class name
  51871. */
  51872. getClassName(): string;
  51873. protected _buildBlock(state: NodeMaterialBuildState): this;
  51874. }
  51875. }
  51876. declare module BABYLON {
  51877. /**
  51878. * Block used to multiply two matrices
  51879. */
  51880. export class MatrixMultiplicationBlock extends NodeMaterialBlock {
  51881. /**
  51882. * Creates a new MatrixMultiplicationBlock
  51883. * @param name defines the block name
  51884. */
  51885. constructor(name: string);
  51886. /**
  51887. * Gets the left operand
  51888. */
  51889. readonly left: NodeMaterialConnectionPoint;
  51890. /**
  51891. * Gets the right operand
  51892. */
  51893. readonly right: NodeMaterialConnectionPoint;
  51894. /**
  51895. * Gets the current class name
  51896. * @returns the class name
  51897. */
  51898. getClassName(): string;
  51899. protected _buildBlock(state: NodeMaterialBuildState): this;
  51900. }
  51901. }
  51902. declare module BABYLON {
  51903. /**
  51904. * Helper class to push actions to a pool of workers.
  51905. */
  51906. export class WorkerPool implements IDisposable {
  51907. private _workerInfos;
  51908. private _pendingActions;
  51909. /**
  51910. * Constructor
  51911. * @param workers Array of workers to use for actions
  51912. */
  51913. constructor(workers: Array<Worker>);
  51914. /**
  51915. * Terminates all workers and clears any pending actions.
  51916. */
  51917. dispose(): void;
  51918. /**
  51919. * Pushes an action to the worker pool. If all the workers are active, the action will be
  51920. * pended until a worker has completed its action.
  51921. * @param action The action to perform. Call onComplete when the action is complete.
  51922. */
  51923. push(action: (worker: Worker, onComplete: () => void) => void): void;
  51924. private _execute;
  51925. }
  51926. }
  51927. declare module BABYLON {
  51928. /**
  51929. * Configuration for Draco compression
  51930. */
  51931. export interface IDracoCompressionConfiguration {
  51932. /**
  51933. * Configuration for the decoder.
  51934. */
  51935. decoder: {
  51936. /**
  51937. * The url to the WebAssembly module.
  51938. */
  51939. wasmUrl?: string;
  51940. /**
  51941. * The url to the WebAssembly binary.
  51942. */
  51943. wasmBinaryUrl?: string;
  51944. /**
  51945. * The url to the fallback JavaScript module.
  51946. */
  51947. fallbackUrl?: string;
  51948. };
  51949. }
  51950. /**
  51951. * Draco compression (https://google.github.io/draco/)
  51952. *
  51953. * This class wraps the Draco module.
  51954. *
  51955. * **Encoder**
  51956. *
  51957. * The encoder is not currently implemented.
  51958. *
  51959. * **Decoder**
  51960. *
  51961. * 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.
  51962. *
  51963. * To update the configuration, use the following code:
  51964. * ```javascript
  51965. * DracoCompression.Configuration = {
  51966. * decoder: {
  51967. * wasmUrl: "<url to the WebAssembly library>",
  51968. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  51969. * fallbackUrl: "<url to the fallback JavaScript library>",
  51970. * }
  51971. * };
  51972. * ```
  51973. *
  51974. * 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.
  51975. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  51976. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  51977. *
  51978. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  51979. * ```javascript
  51980. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  51981. * ```
  51982. *
  51983. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  51984. */
  51985. export class DracoCompression implements IDisposable {
  51986. private _workerPoolPromise?;
  51987. private _decoderModulePromise?;
  51988. /**
  51989. * The configuration. Defaults to the following urls:
  51990. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  51991. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  51992. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  51993. */
  51994. static Configuration: IDracoCompressionConfiguration;
  51995. /**
  51996. * Returns true if the decoder configuration is available.
  51997. */
  51998. static readonly DecoderAvailable: boolean;
  51999. /**
  52000. * Default number of workers to create when creating the draco compression object.
  52001. */
  52002. static DefaultNumWorkers: number;
  52003. private static GetDefaultNumWorkers;
  52004. private static _Default;
  52005. /**
  52006. * Default instance for the draco compression object.
  52007. */
  52008. static readonly Default: DracoCompression;
  52009. /**
  52010. * Constructor
  52011. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  52012. */
  52013. constructor(numWorkers?: number);
  52014. /**
  52015. * Stop all async operations and release resources.
  52016. */
  52017. dispose(): void;
  52018. /**
  52019. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  52020. * @returns a promise that resolves when ready
  52021. */
  52022. whenReadyAsync(): Promise<void>;
  52023. /**
  52024. * Decode Draco compressed mesh data to vertex data.
  52025. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  52026. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  52027. * @returns A promise that resolves with the decoded vertex data
  52028. */
  52029. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  52030. [kind: string]: number;
  52031. }): Promise<VertexData>;
  52032. }
  52033. }
  52034. declare module BABYLON {
  52035. /**
  52036. * Class for building Constructive Solid Geometry
  52037. */
  52038. export class CSG {
  52039. private polygons;
  52040. /**
  52041. * The world matrix
  52042. */
  52043. matrix: Matrix;
  52044. /**
  52045. * Stores the position
  52046. */
  52047. position: Vector3;
  52048. /**
  52049. * Stores the rotation
  52050. */
  52051. rotation: Vector3;
  52052. /**
  52053. * Stores the rotation quaternion
  52054. */
  52055. rotationQuaternion: Nullable<Quaternion>;
  52056. /**
  52057. * Stores the scaling vector
  52058. */
  52059. scaling: Vector3;
  52060. /**
  52061. * Convert the Mesh to CSG
  52062. * @param mesh The Mesh to convert to CSG
  52063. * @returns A new CSG from the Mesh
  52064. */
  52065. static FromMesh(mesh: Mesh): CSG;
  52066. /**
  52067. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  52068. * @param polygons Polygons used to construct a CSG solid
  52069. */
  52070. private static FromPolygons;
  52071. /**
  52072. * Clones, or makes a deep copy, of the CSG
  52073. * @returns A new CSG
  52074. */
  52075. clone(): CSG;
  52076. /**
  52077. * Unions this CSG with another CSG
  52078. * @param csg The CSG to union against this CSG
  52079. * @returns The unioned CSG
  52080. */
  52081. union(csg: CSG): CSG;
  52082. /**
  52083. * Unions this CSG with another CSG in place
  52084. * @param csg The CSG to union against this CSG
  52085. */
  52086. unionInPlace(csg: CSG): void;
  52087. /**
  52088. * Subtracts this CSG with another CSG
  52089. * @param csg The CSG to subtract against this CSG
  52090. * @returns A new CSG
  52091. */
  52092. subtract(csg: CSG): CSG;
  52093. /**
  52094. * Subtracts this CSG with another CSG in place
  52095. * @param csg The CSG to subtact against this CSG
  52096. */
  52097. subtractInPlace(csg: CSG): void;
  52098. /**
  52099. * Intersect this CSG with another CSG
  52100. * @param csg The CSG to intersect against this CSG
  52101. * @returns A new CSG
  52102. */
  52103. intersect(csg: CSG): CSG;
  52104. /**
  52105. * Intersects this CSG with another CSG in place
  52106. * @param csg The CSG to intersect against this CSG
  52107. */
  52108. intersectInPlace(csg: CSG): void;
  52109. /**
  52110. * Return a new CSG solid with solid and empty space switched. This solid is
  52111. * not modified.
  52112. * @returns A new CSG solid with solid and empty space switched
  52113. */
  52114. inverse(): CSG;
  52115. /**
  52116. * Inverses the CSG in place
  52117. */
  52118. inverseInPlace(): void;
  52119. /**
  52120. * This is used to keep meshes transformations so they can be restored
  52121. * when we build back a Babylon Mesh
  52122. * NB : All CSG operations are performed in world coordinates
  52123. * @param csg The CSG to copy the transform attributes from
  52124. * @returns This CSG
  52125. */
  52126. copyTransformAttributes(csg: CSG): CSG;
  52127. /**
  52128. * Build Raw mesh from CSG
  52129. * Coordinates here are in world space
  52130. * @param name The name of the mesh geometry
  52131. * @param scene The Scene
  52132. * @param keepSubMeshes Specifies if the submeshes should be kept
  52133. * @returns A new Mesh
  52134. */
  52135. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  52136. /**
  52137. * Build Mesh from CSG taking material and transforms into account
  52138. * @param name The name of the Mesh
  52139. * @param material The material of the Mesh
  52140. * @param scene The Scene
  52141. * @param keepSubMeshes Specifies if submeshes should be kept
  52142. * @returns The new Mesh
  52143. */
  52144. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  52145. }
  52146. }
  52147. declare module BABYLON {
  52148. /**
  52149. * Class used to create a trail following a mesh
  52150. */
  52151. export class TrailMesh extends Mesh {
  52152. private _generator;
  52153. private _autoStart;
  52154. private _running;
  52155. private _diameter;
  52156. private _length;
  52157. private _sectionPolygonPointsCount;
  52158. private _sectionVectors;
  52159. private _sectionNormalVectors;
  52160. private _beforeRenderObserver;
  52161. /**
  52162. * @constructor
  52163. * @param name The value used by scene.getMeshByName() to do a lookup.
  52164. * @param generator The mesh to generate a trail.
  52165. * @param scene The scene to add this mesh to.
  52166. * @param diameter Diameter of trailing mesh. Default is 1.
  52167. * @param length Length of trailing mesh. Default is 60.
  52168. * @param autoStart Automatically start trailing mesh. Default true.
  52169. */
  52170. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  52171. /**
  52172. * "TrailMesh"
  52173. * @returns "TrailMesh"
  52174. */
  52175. getClassName(): string;
  52176. private _createMesh;
  52177. /**
  52178. * Start trailing mesh.
  52179. */
  52180. start(): void;
  52181. /**
  52182. * Stop trailing mesh.
  52183. */
  52184. stop(): void;
  52185. /**
  52186. * Update trailing mesh geometry.
  52187. */
  52188. update(): void;
  52189. /**
  52190. * Returns a new TrailMesh object.
  52191. * @param name is a string, the name given to the new mesh
  52192. * @param newGenerator use new generator object for cloned trail mesh
  52193. * @returns a new mesh
  52194. */
  52195. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  52196. /**
  52197. * Serializes this trail mesh
  52198. * @param serializationObject object to write serialization to
  52199. */
  52200. serialize(serializationObject: any): void;
  52201. /**
  52202. * Parses a serialized trail mesh
  52203. * @param parsedMesh the serialized mesh
  52204. * @param scene the scene to create the trail mesh in
  52205. * @returns the created trail mesh
  52206. */
  52207. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  52208. }
  52209. }
  52210. declare module BABYLON {
  52211. /**
  52212. * Class containing static functions to help procedurally build meshes
  52213. */
  52214. export class TiledBoxBuilder {
  52215. /**
  52216. * Creates a box mesh
  52217. * 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)
  52218. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  52219. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52220. * * 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
  52221. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52222. * @param name defines the name of the mesh
  52223. * @param options defines the options used to create the mesh
  52224. * @param scene defines the hosting scene
  52225. * @returns the box mesh
  52226. */
  52227. static CreateTiledBox(name: string, options: {
  52228. pattern?: number;
  52229. width?: number;
  52230. height?: number;
  52231. depth?: number;
  52232. tileSize?: number;
  52233. tileWidth?: number;
  52234. tileHeight?: number;
  52235. alignHorizontal?: number;
  52236. alignVertical?: number;
  52237. faceUV?: Vector4[];
  52238. faceColors?: Color4[];
  52239. sideOrientation?: number;
  52240. updatable?: boolean;
  52241. }, scene?: Nullable<Scene>): Mesh;
  52242. }
  52243. }
  52244. declare module BABYLON {
  52245. /**
  52246. * Class containing static functions to help procedurally build meshes
  52247. */
  52248. export class TorusKnotBuilder {
  52249. /**
  52250. * Creates a torus knot mesh
  52251. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  52252. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  52253. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  52254. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  52255. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52256. * * 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
  52257. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52258. * @param name defines the name of the mesh
  52259. * @param options defines the options used to create the mesh
  52260. * @param scene defines the hosting scene
  52261. * @returns the torus knot mesh
  52262. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  52263. */
  52264. static CreateTorusKnot(name: string, options: {
  52265. radius?: number;
  52266. tube?: number;
  52267. radialSegments?: number;
  52268. tubularSegments?: number;
  52269. p?: number;
  52270. q?: number;
  52271. updatable?: boolean;
  52272. sideOrientation?: number;
  52273. frontUVs?: Vector4;
  52274. backUVs?: Vector4;
  52275. }, scene: any): Mesh;
  52276. }
  52277. }
  52278. declare module BABYLON {
  52279. /**
  52280. * Polygon
  52281. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  52282. */
  52283. export class Polygon {
  52284. /**
  52285. * Creates a rectangle
  52286. * @param xmin bottom X coord
  52287. * @param ymin bottom Y coord
  52288. * @param xmax top X coord
  52289. * @param ymax top Y coord
  52290. * @returns points that make the resulting rectation
  52291. */
  52292. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  52293. /**
  52294. * Creates a circle
  52295. * @param radius radius of circle
  52296. * @param cx scale in x
  52297. * @param cy scale in y
  52298. * @param numberOfSides number of sides that make up the circle
  52299. * @returns points that make the resulting circle
  52300. */
  52301. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  52302. /**
  52303. * Creates a polygon from input string
  52304. * @param input Input polygon data
  52305. * @returns the parsed points
  52306. */
  52307. static Parse(input: string): Vector2[];
  52308. /**
  52309. * Starts building a polygon from x and y coordinates
  52310. * @param x x coordinate
  52311. * @param y y coordinate
  52312. * @returns the started path2
  52313. */
  52314. static StartingAt(x: number, y: number): Path2;
  52315. }
  52316. /**
  52317. * Builds a polygon
  52318. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  52319. */
  52320. export class PolygonMeshBuilder {
  52321. private _points;
  52322. private _outlinepoints;
  52323. private _holes;
  52324. private _name;
  52325. private _scene;
  52326. private _epoints;
  52327. private _eholes;
  52328. private _addToepoint;
  52329. /**
  52330. * Babylon reference to the earcut plugin.
  52331. */
  52332. bjsEarcut: any;
  52333. /**
  52334. * Creates a PolygonMeshBuilder
  52335. * @param name name of the builder
  52336. * @param contours Path of the polygon
  52337. * @param scene scene to add to when creating the mesh
  52338. * @param earcutInjection can be used to inject your own earcut reference
  52339. */
  52340. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  52341. /**
  52342. * Adds a whole within the polygon
  52343. * @param hole Array of points defining the hole
  52344. * @returns this
  52345. */
  52346. addHole(hole: Vector2[]): PolygonMeshBuilder;
  52347. /**
  52348. * Creates the polygon
  52349. * @param updatable If the mesh should be updatable
  52350. * @param depth The depth of the mesh created
  52351. * @returns the created mesh
  52352. */
  52353. build(updatable?: boolean, depth?: number): Mesh;
  52354. /**
  52355. * Creates the polygon
  52356. * @param depth The depth of the mesh created
  52357. * @returns the created VertexData
  52358. */
  52359. buildVertexData(depth?: number): VertexData;
  52360. /**
  52361. * Adds a side to the polygon
  52362. * @param positions points that make the polygon
  52363. * @param normals normals of the polygon
  52364. * @param uvs uvs of the polygon
  52365. * @param indices indices of the polygon
  52366. * @param bounds bounds of the polygon
  52367. * @param points points of the polygon
  52368. * @param depth depth of the polygon
  52369. * @param flip flip of the polygon
  52370. */
  52371. private addSide;
  52372. }
  52373. }
  52374. declare module BABYLON {
  52375. /**
  52376. * Class containing static functions to help procedurally build meshes
  52377. */
  52378. export class PolygonBuilder {
  52379. /**
  52380. * Creates a polygon mesh
  52381. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  52382. * * 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
  52383. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  52384. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52385. * * 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)
  52386. * * Remember you can only change the shape positions, not their number when updating a polygon
  52387. * @param name defines the name of the mesh
  52388. * @param options defines the options used to create the mesh
  52389. * @param scene defines the hosting scene
  52390. * @param earcutInjection can be used to inject your own earcut reference
  52391. * @returns the polygon mesh
  52392. */
  52393. static CreatePolygon(name: string, options: {
  52394. shape: Vector3[];
  52395. holes?: Vector3[][];
  52396. depth?: number;
  52397. faceUV?: Vector4[];
  52398. faceColors?: Color4[];
  52399. updatable?: boolean;
  52400. sideOrientation?: number;
  52401. frontUVs?: Vector4;
  52402. backUVs?: Vector4;
  52403. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  52404. /**
  52405. * Creates an extruded polygon mesh, with depth in the Y direction.
  52406. * * 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)
  52407. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  52408. * @param name defines the name of the mesh
  52409. * @param options defines the options used to create the mesh
  52410. * @param scene defines the hosting scene
  52411. * @param earcutInjection can be used to inject your own earcut reference
  52412. * @returns the polygon mesh
  52413. */
  52414. static ExtrudePolygon(name: string, options: {
  52415. shape: Vector3[];
  52416. holes?: Vector3[][];
  52417. depth?: number;
  52418. faceUV?: Vector4[];
  52419. faceColors?: Color4[];
  52420. updatable?: boolean;
  52421. sideOrientation?: number;
  52422. frontUVs?: Vector4;
  52423. backUVs?: Vector4;
  52424. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  52425. }
  52426. }
  52427. declare module BABYLON {
  52428. /**
  52429. * Class containing static functions to help procedurally build meshes
  52430. */
  52431. export class LatheBuilder {
  52432. /**
  52433. * Creates lathe mesh.
  52434. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  52435. * * 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
  52436. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  52437. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  52438. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  52439. * * 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
  52440. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  52441. * * 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
  52442. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52443. * * 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
  52444. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  52445. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52446. * @param name defines the name of the mesh
  52447. * @param options defines the options used to create the mesh
  52448. * @param scene defines the hosting scene
  52449. * @returns the lathe mesh
  52450. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  52451. */
  52452. static CreateLathe(name: string, options: {
  52453. shape: Vector3[];
  52454. radius?: number;
  52455. tessellation?: number;
  52456. clip?: number;
  52457. arc?: number;
  52458. closed?: boolean;
  52459. updatable?: boolean;
  52460. sideOrientation?: number;
  52461. frontUVs?: Vector4;
  52462. backUVs?: Vector4;
  52463. cap?: number;
  52464. invertUV?: boolean;
  52465. }, scene?: Nullable<Scene>): Mesh;
  52466. }
  52467. }
  52468. declare module BABYLON {
  52469. /**
  52470. * Class containing static functions to help procedurally build meshes
  52471. */
  52472. export class TiledPlaneBuilder {
  52473. /**
  52474. * Creates a tiled plane mesh
  52475. * * The parameter `pattern` will, depending on value, do nothing or
  52476. * * * flip (reflect about central vertical) alternate tiles across and up
  52477. * * * flip every tile on alternate rows
  52478. * * * rotate (180 degs) alternate tiles across and up
  52479. * * * rotate every tile on alternate rows
  52480. * * * flip and rotate alternate tiles across and up
  52481. * * * flip and rotate every tile on alternate rows
  52482. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  52483. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  52484. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52485. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  52486. * * 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)
  52487. * * 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)
  52488. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  52489. * @param name defines the name of the mesh
  52490. * @param options defines the options used to create the mesh
  52491. * @param scene defines the hosting scene
  52492. * @returns the box mesh
  52493. */
  52494. static CreateTiledPlane(name: string, options: {
  52495. pattern?: number;
  52496. tileSize?: number;
  52497. tileWidth?: number;
  52498. tileHeight?: number;
  52499. size?: number;
  52500. width?: number;
  52501. height?: number;
  52502. alignHorizontal?: number;
  52503. alignVertical?: number;
  52504. sideOrientation?: number;
  52505. frontUVs?: Vector4;
  52506. backUVs?: Vector4;
  52507. updatable?: boolean;
  52508. }, scene?: Nullable<Scene>): Mesh;
  52509. }
  52510. }
  52511. declare module BABYLON {
  52512. /**
  52513. * Class containing static functions to help procedurally build meshes
  52514. */
  52515. export class TubeBuilder {
  52516. /**
  52517. * Creates a tube mesh.
  52518. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  52519. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  52520. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  52521. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  52522. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  52523. * * 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)
  52524. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  52525. * * 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
  52526. * * 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
  52527. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52528. * * 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
  52529. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  52530. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52531. * @param name defines the name of the mesh
  52532. * @param options defines the options used to create the mesh
  52533. * @param scene defines the hosting scene
  52534. * @returns the tube mesh
  52535. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52536. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  52537. */
  52538. static CreateTube(name: string, options: {
  52539. path: Vector3[];
  52540. radius?: number;
  52541. tessellation?: number;
  52542. radiusFunction?: {
  52543. (i: number, distance: number): number;
  52544. };
  52545. cap?: number;
  52546. arc?: number;
  52547. updatable?: boolean;
  52548. sideOrientation?: number;
  52549. frontUVs?: Vector4;
  52550. backUVs?: Vector4;
  52551. instance?: Mesh;
  52552. invertUV?: boolean;
  52553. }, scene?: Nullable<Scene>): Mesh;
  52554. }
  52555. }
  52556. declare module BABYLON {
  52557. /**
  52558. * Class containing static functions to help procedurally build meshes
  52559. */
  52560. export class IcoSphereBuilder {
  52561. /**
  52562. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  52563. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  52564. * * 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`)
  52565. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  52566. * * 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
  52567. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52568. * * 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
  52569. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52570. * @param name defines the name of the mesh
  52571. * @param options defines the options used to create the mesh
  52572. * @param scene defines the hosting scene
  52573. * @returns the icosahedron mesh
  52574. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  52575. */
  52576. static CreateIcoSphere(name: string, options: {
  52577. radius?: number;
  52578. radiusX?: number;
  52579. radiusY?: number;
  52580. radiusZ?: number;
  52581. flat?: boolean;
  52582. subdivisions?: number;
  52583. sideOrientation?: number;
  52584. frontUVs?: Vector4;
  52585. backUVs?: Vector4;
  52586. updatable?: boolean;
  52587. }, scene?: Nullable<Scene>): Mesh;
  52588. }
  52589. }
  52590. declare module BABYLON {
  52591. /**
  52592. * Class containing static functions to help procedurally build meshes
  52593. */
  52594. export class DecalBuilder {
  52595. /**
  52596. * Creates a decal mesh.
  52597. * 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
  52598. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  52599. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  52600. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  52601. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  52602. * @param name defines the name of the mesh
  52603. * @param sourceMesh defines the mesh where the decal must be applied
  52604. * @param options defines the options used to create the mesh
  52605. * @param scene defines the hosting scene
  52606. * @returns the decal mesh
  52607. * @see https://doc.babylonjs.com/how_to/decals
  52608. */
  52609. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  52610. position?: Vector3;
  52611. normal?: Vector3;
  52612. size?: Vector3;
  52613. angle?: number;
  52614. }): Mesh;
  52615. }
  52616. }
  52617. declare module BABYLON {
  52618. /**
  52619. * Class containing static functions to help procedurally build meshes
  52620. */
  52621. export class MeshBuilder {
  52622. /**
  52623. * Creates a box mesh
  52624. * * The parameter `size` sets the size (float) of each box side (default 1)
  52625. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  52626. * * 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)
  52627. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  52628. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52629. * * 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
  52630. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52631. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  52632. * @param name defines the name of the mesh
  52633. * @param options defines the options used to create the mesh
  52634. * @param scene defines the hosting scene
  52635. * @returns the box mesh
  52636. */
  52637. static CreateBox(name: string, options: {
  52638. size?: number;
  52639. width?: number;
  52640. height?: number;
  52641. depth?: number;
  52642. faceUV?: Vector4[];
  52643. faceColors?: Color4[];
  52644. sideOrientation?: number;
  52645. frontUVs?: Vector4;
  52646. backUVs?: Vector4;
  52647. updatable?: boolean;
  52648. }, scene?: Nullable<Scene>): Mesh;
  52649. /**
  52650. * Creates a tiled box mesh
  52651. * * faceTiles sets the pattern, tile size and number of tiles for a face
  52652. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52653. * @param name defines the name of the mesh
  52654. * @param options defines the options used to create the mesh
  52655. * @param scene defines the hosting scene
  52656. * @returns the tiled box mesh
  52657. */
  52658. static CreateTiledBox(name: string, options: {
  52659. pattern?: number;
  52660. size?: number;
  52661. width?: number;
  52662. height?: number;
  52663. depth: number;
  52664. tileSize?: number;
  52665. tileWidth?: number;
  52666. tileHeight?: number;
  52667. faceUV?: Vector4[];
  52668. faceColors?: Color4[];
  52669. alignHorizontal?: number;
  52670. alignVertical?: number;
  52671. sideOrientation?: number;
  52672. updatable?: boolean;
  52673. }, scene?: Nullable<Scene>): Mesh;
  52674. /**
  52675. * Creates a sphere mesh
  52676. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  52677. * * 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`)
  52678. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  52679. * * 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
  52680. * * 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)
  52681. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52682. * * 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
  52683. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52684. * @param name defines the name of the mesh
  52685. * @param options defines the options used to create the mesh
  52686. * @param scene defines the hosting scene
  52687. * @returns the sphere mesh
  52688. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  52689. */
  52690. static CreateSphere(name: string, options: {
  52691. segments?: number;
  52692. diameter?: number;
  52693. diameterX?: number;
  52694. diameterY?: number;
  52695. diameterZ?: number;
  52696. arc?: number;
  52697. slice?: number;
  52698. sideOrientation?: number;
  52699. frontUVs?: Vector4;
  52700. backUVs?: Vector4;
  52701. updatable?: boolean;
  52702. }, scene?: Nullable<Scene>): Mesh;
  52703. /**
  52704. * Creates a plane polygonal mesh. By default, this is a disc
  52705. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  52706. * * 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
  52707. * * 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
  52708. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52709. * * 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
  52710. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52711. * @param name defines the name of the mesh
  52712. * @param options defines the options used to create the mesh
  52713. * @param scene defines the hosting scene
  52714. * @returns the plane polygonal mesh
  52715. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  52716. */
  52717. static CreateDisc(name: string, options: {
  52718. radius?: number;
  52719. tessellation?: number;
  52720. arc?: number;
  52721. updatable?: boolean;
  52722. sideOrientation?: number;
  52723. frontUVs?: Vector4;
  52724. backUVs?: Vector4;
  52725. }, scene?: Nullable<Scene>): Mesh;
  52726. /**
  52727. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  52728. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  52729. * * 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`)
  52730. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  52731. * * 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
  52732. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52733. * * 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
  52734. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52735. * @param name defines the name of the mesh
  52736. * @param options defines the options used to create the mesh
  52737. * @param scene defines the hosting scene
  52738. * @returns the icosahedron mesh
  52739. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  52740. */
  52741. static CreateIcoSphere(name: string, options: {
  52742. radius?: number;
  52743. radiusX?: number;
  52744. radiusY?: number;
  52745. radiusZ?: number;
  52746. flat?: boolean;
  52747. subdivisions?: number;
  52748. sideOrientation?: number;
  52749. frontUVs?: Vector4;
  52750. backUVs?: Vector4;
  52751. updatable?: boolean;
  52752. }, scene?: Nullable<Scene>): Mesh;
  52753. /**
  52754. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  52755. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  52756. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  52757. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  52758. * * 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
  52759. * * 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
  52760. * * 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
  52761. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52762. * * 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
  52763. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  52764. * * 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
  52765. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  52766. * * 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
  52767. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  52768. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52769. * @param name defines the name of the mesh
  52770. * @param options defines the options used to create the mesh
  52771. * @param scene defines the hosting scene
  52772. * @returns the ribbon mesh
  52773. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  52774. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52775. */
  52776. static CreateRibbon(name: string, options: {
  52777. pathArray: Vector3[][];
  52778. closeArray?: boolean;
  52779. closePath?: boolean;
  52780. offset?: number;
  52781. updatable?: boolean;
  52782. sideOrientation?: number;
  52783. frontUVs?: Vector4;
  52784. backUVs?: Vector4;
  52785. instance?: Mesh;
  52786. invertUV?: boolean;
  52787. uvs?: Vector2[];
  52788. colors?: Color4[];
  52789. }, scene?: Nullable<Scene>): Mesh;
  52790. /**
  52791. * Creates a cylinder or a cone mesh
  52792. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  52793. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  52794. * * 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.
  52795. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  52796. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  52797. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  52798. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  52799. * * 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).
  52800. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  52801. * * 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).
  52802. * * 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
  52803. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  52804. * * 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
  52805. * * 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.
  52806. * * If `enclose` is false, a ring surface is one element.
  52807. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  52808. * * 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
  52809. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52810. * * 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
  52811. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52812. * @param name defines the name of the mesh
  52813. * @param options defines the options used to create the mesh
  52814. * @param scene defines the hosting scene
  52815. * @returns the cylinder mesh
  52816. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  52817. */
  52818. static CreateCylinder(name: string, options: {
  52819. height?: number;
  52820. diameterTop?: number;
  52821. diameterBottom?: number;
  52822. diameter?: number;
  52823. tessellation?: number;
  52824. subdivisions?: number;
  52825. arc?: number;
  52826. faceColors?: Color4[];
  52827. faceUV?: Vector4[];
  52828. updatable?: boolean;
  52829. hasRings?: boolean;
  52830. enclose?: boolean;
  52831. cap?: number;
  52832. sideOrientation?: number;
  52833. frontUVs?: Vector4;
  52834. backUVs?: Vector4;
  52835. }, scene?: Nullable<Scene>): Mesh;
  52836. /**
  52837. * Creates a torus mesh
  52838. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  52839. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  52840. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  52841. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52842. * * 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
  52843. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52844. * @param name defines the name of the mesh
  52845. * @param options defines the options used to create the mesh
  52846. * @param scene defines the hosting scene
  52847. * @returns the torus mesh
  52848. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  52849. */
  52850. static CreateTorus(name: string, options: {
  52851. diameter?: number;
  52852. thickness?: number;
  52853. tessellation?: number;
  52854. updatable?: boolean;
  52855. sideOrientation?: number;
  52856. frontUVs?: Vector4;
  52857. backUVs?: Vector4;
  52858. }, scene?: Nullable<Scene>): Mesh;
  52859. /**
  52860. * Creates a torus knot mesh
  52861. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  52862. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  52863. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  52864. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  52865. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52866. * * 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
  52867. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52868. * @param name defines the name of the mesh
  52869. * @param options defines the options used to create the mesh
  52870. * @param scene defines the hosting scene
  52871. * @returns the torus knot mesh
  52872. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  52873. */
  52874. static CreateTorusKnot(name: string, options: {
  52875. radius?: number;
  52876. tube?: number;
  52877. radialSegments?: number;
  52878. tubularSegments?: number;
  52879. p?: number;
  52880. q?: number;
  52881. updatable?: boolean;
  52882. sideOrientation?: number;
  52883. frontUVs?: Vector4;
  52884. backUVs?: Vector4;
  52885. }, scene?: Nullable<Scene>): Mesh;
  52886. /**
  52887. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  52888. * * 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
  52889. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  52890. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  52891. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  52892. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  52893. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  52894. * * 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
  52895. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  52896. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52897. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  52898. * @param name defines the name of the new line system
  52899. * @param options defines the options used to create the line system
  52900. * @param scene defines the hosting scene
  52901. * @returns a new line system mesh
  52902. */
  52903. static CreateLineSystem(name: string, options: {
  52904. lines: Vector3[][];
  52905. updatable?: boolean;
  52906. instance?: Nullable<LinesMesh>;
  52907. colors?: Nullable<Color4[][]>;
  52908. useVertexAlpha?: boolean;
  52909. }, scene: Nullable<Scene>): LinesMesh;
  52910. /**
  52911. * Creates a line mesh
  52912. * 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
  52913. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  52914. * * The parameter `points` is an array successive Vector3
  52915. * * 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
  52916. * * The optional parameter `colors` is an array of successive Color4, one per line point
  52917. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  52918. * * When updating an instance, remember that only point positions can change, not the number of points
  52919. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52920. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  52921. * @param name defines the name of the new line system
  52922. * @param options defines the options used to create the line system
  52923. * @param scene defines the hosting scene
  52924. * @returns a new line mesh
  52925. */
  52926. static CreateLines(name: string, options: {
  52927. points: Vector3[];
  52928. updatable?: boolean;
  52929. instance?: Nullable<LinesMesh>;
  52930. colors?: Color4[];
  52931. useVertexAlpha?: boolean;
  52932. }, scene?: Nullable<Scene>): LinesMesh;
  52933. /**
  52934. * Creates a dashed line mesh
  52935. * * 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
  52936. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  52937. * * The parameter `points` is an array successive Vector3
  52938. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  52939. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  52940. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  52941. * * 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
  52942. * * When updating an instance, remember that only point positions can change, not the number of points
  52943. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52944. * @param name defines the name of the mesh
  52945. * @param options defines the options used to create the mesh
  52946. * @param scene defines the hosting scene
  52947. * @returns the dashed line mesh
  52948. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  52949. */
  52950. static CreateDashedLines(name: string, options: {
  52951. points: Vector3[];
  52952. dashSize?: number;
  52953. gapSize?: number;
  52954. dashNb?: number;
  52955. updatable?: boolean;
  52956. instance?: LinesMesh;
  52957. }, scene?: Nullable<Scene>): LinesMesh;
  52958. /**
  52959. * 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.
  52960. * * 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.
  52961. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  52962. * * 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.
  52963. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  52964. * * 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
  52965. * * 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
  52966. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  52967. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52968. * * 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
  52969. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  52970. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52971. * @param name defines the name of the mesh
  52972. * @param options defines the options used to create the mesh
  52973. * @param scene defines the hosting scene
  52974. * @returns the extruded shape mesh
  52975. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52976. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  52977. */
  52978. static ExtrudeShape(name: string, options: {
  52979. shape: Vector3[];
  52980. path: Vector3[];
  52981. scale?: number;
  52982. rotation?: number;
  52983. cap?: number;
  52984. updatable?: boolean;
  52985. sideOrientation?: number;
  52986. frontUVs?: Vector4;
  52987. backUVs?: Vector4;
  52988. instance?: Mesh;
  52989. invertUV?: boolean;
  52990. }, scene?: Nullable<Scene>): Mesh;
  52991. /**
  52992. * Creates an custom extruded shape mesh.
  52993. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  52994. * * 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.
  52995. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  52996. * * 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
  52997. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  52998. * * 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
  52999. * * It must returns a float value that will be the scale value applied to the shape on each path point
  53000. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  53001. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  53002. * * 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
  53003. * * 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
  53004. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  53005. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53006. * * 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
  53007. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  53008. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53009. * @param name defines the name of the mesh
  53010. * @param options defines the options used to create the mesh
  53011. * @param scene defines the hosting scene
  53012. * @returns the custom extruded shape mesh
  53013. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  53014. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  53015. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  53016. */
  53017. static ExtrudeShapeCustom(name: string, options: {
  53018. shape: Vector3[];
  53019. path: Vector3[];
  53020. scaleFunction?: any;
  53021. rotationFunction?: any;
  53022. ribbonCloseArray?: boolean;
  53023. ribbonClosePath?: boolean;
  53024. cap?: number;
  53025. updatable?: boolean;
  53026. sideOrientation?: number;
  53027. frontUVs?: Vector4;
  53028. backUVs?: Vector4;
  53029. instance?: Mesh;
  53030. invertUV?: boolean;
  53031. }, scene?: Nullable<Scene>): Mesh;
  53032. /**
  53033. * Creates lathe mesh.
  53034. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  53035. * * 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
  53036. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  53037. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  53038. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  53039. * * 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
  53040. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  53041. * * 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
  53042. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53043. * * 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
  53044. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  53045. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53046. * @param name defines the name of the mesh
  53047. * @param options defines the options used to create the mesh
  53048. * @param scene defines the hosting scene
  53049. * @returns the lathe mesh
  53050. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  53051. */
  53052. static CreateLathe(name: string, options: {
  53053. shape: Vector3[];
  53054. radius?: number;
  53055. tessellation?: number;
  53056. clip?: number;
  53057. arc?: number;
  53058. closed?: boolean;
  53059. updatable?: boolean;
  53060. sideOrientation?: number;
  53061. frontUVs?: Vector4;
  53062. backUVs?: Vector4;
  53063. cap?: number;
  53064. invertUV?: boolean;
  53065. }, scene?: Nullable<Scene>): Mesh;
  53066. /**
  53067. * Creates a tiled plane mesh
  53068. * * You can set a limited pattern arrangement with the tiles
  53069. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53070. * * 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
  53071. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53072. * @param name defines the name of the mesh
  53073. * @param options defines the options used to create the mesh
  53074. * @param scene defines the hosting scene
  53075. * @returns the plane mesh
  53076. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  53077. */
  53078. static CreateTiledPlane(name: string, options: {
  53079. pattern?: number;
  53080. tileSize?: number;
  53081. tileWidth?: number;
  53082. tileHeight?: number;
  53083. size?: number;
  53084. width?: number;
  53085. height?: number;
  53086. alignHorizontal?: number;
  53087. alignVertical?: number;
  53088. sideOrientation?: number;
  53089. frontUVs?: Vector4;
  53090. backUVs?: Vector4;
  53091. updatable?: boolean;
  53092. }, scene?: Nullable<Scene>): Mesh;
  53093. /**
  53094. * Creates a plane mesh
  53095. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  53096. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  53097. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  53098. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53099. * * 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
  53100. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53101. * @param name defines the name of the mesh
  53102. * @param options defines the options used to create the mesh
  53103. * @param scene defines the hosting scene
  53104. * @returns the plane mesh
  53105. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  53106. */
  53107. static CreatePlane(name: string, options: {
  53108. size?: number;
  53109. width?: number;
  53110. height?: number;
  53111. sideOrientation?: number;
  53112. frontUVs?: Vector4;
  53113. backUVs?: Vector4;
  53114. updatable?: boolean;
  53115. sourcePlane?: Plane;
  53116. }, scene?: Nullable<Scene>): Mesh;
  53117. /**
  53118. * Creates a ground mesh
  53119. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  53120. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  53121. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53122. * @param name defines the name of the mesh
  53123. * @param options defines the options used to create the mesh
  53124. * @param scene defines the hosting scene
  53125. * @returns the ground mesh
  53126. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  53127. */
  53128. static CreateGround(name: string, options: {
  53129. width?: number;
  53130. height?: number;
  53131. subdivisions?: number;
  53132. subdivisionsX?: number;
  53133. subdivisionsY?: number;
  53134. updatable?: boolean;
  53135. }, scene?: Nullable<Scene>): Mesh;
  53136. /**
  53137. * Creates a tiled ground mesh
  53138. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  53139. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  53140. * * 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
  53141. * * 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
  53142. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  53143. * @param name defines the name of the mesh
  53144. * @param options defines the options used to create the mesh
  53145. * @param scene defines the hosting scene
  53146. * @returns the tiled ground mesh
  53147. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  53148. */
  53149. static CreateTiledGround(name: string, options: {
  53150. xmin: number;
  53151. zmin: number;
  53152. xmax: number;
  53153. zmax: number;
  53154. subdivisions?: {
  53155. w: number;
  53156. h: number;
  53157. };
  53158. precision?: {
  53159. w: number;
  53160. h: number;
  53161. };
  53162. updatable?: boolean;
  53163. }, scene?: Nullable<Scene>): Mesh;
  53164. /**
  53165. * Creates a ground mesh from a height map
  53166. * * The parameter `url` sets the URL of the height map image resource.
  53167. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  53168. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  53169. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  53170. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  53171. * * 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.
  53172. * * 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).
  53173. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  53174. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  53175. * @param name defines the name of the mesh
  53176. * @param url defines the url to the height map
  53177. * @param options defines the options used to create the mesh
  53178. * @param scene defines the hosting scene
  53179. * @returns the ground mesh
  53180. * @see https://doc.babylonjs.com/babylon101/height_map
  53181. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  53182. */
  53183. static CreateGroundFromHeightMap(name: string, url: string, options: {
  53184. width?: number;
  53185. height?: number;
  53186. subdivisions?: number;
  53187. minHeight?: number;
  53188. maxHeight?: number;
  53189. colorFilter?: Color3;
  53190. alphaFilter?: number;
  53191. updatable?: boolean;
  53192. onReady?: (mesh: GroundMesh) => void;
  53193. }, scene?: Nullable<Scene>): GroundMesh;
  53194. /**
  53195. * Creates a polygon mesh
  53196. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  53197. * * 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
  53198. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  53199. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53200. * * 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)
  53201. * * Remember you can only change the shape positions, not their number when updating a polygon
  53202. * @param name defines the name of the mesh
  53203. * @param options defines the options used to create the mesh
  53204. * @param scene defines the hosting scene
  53205. * @param earcutInjection can be used to inject your own earcut reference
  53206. * @returns the polygon mesh
  53207. */
  53208. static CreatePolygon(name: string, options: {
  53209. shape: Vector3[];
  53210. holes?: Vector3[][];
  53211. depth?: number;
  53212. faceUV?: Vector4[];
  53213. faceColors?: Color4[];
  53214. updatable?: boolean;
  53215. sideOrientation?: number;
  53216. frontUVs?: Vector4;
  53217. backUVs?: Vector4;
  53218. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  53219. /**
  53220. * Creates an extruded polygon mesh, with depth in the Y direction.
  53221. * * 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)
  53222. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  53223. * @param name defines the name of the mesh
  53224. * @param options defines the options used to create the mesh
  53225. * @param scene defines the hosting scene
  53226. * @param earcutInjection can be used to inject your own earcut reference
  53227. * @returns the polygon mesh
  53228. */
  53229. static ExtrudePolygon(name: string, options: {
  53230. shape: Vector3[];
  53231. holes?: Vector3[][];
  53232. depth?: number;
  53233. faceUV?: Vector4[];
  53234. faceColors?: Color4[];
  53235. updatable?: boolean;
  53236. sideOrientation?: number;
  53237. frontUVs?: Vector4;
  53238. backUVs?: Vector4;
  53239. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  53240. /**
  53241. * Creates a tube mesh.
  53242. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  53243. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  53244. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  53245. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  53246. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  53247. * * 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)
  53248. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  53249. * * 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
  53250. * * 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
  53251. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53252. * * 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
  53253. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  53254. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53255. * @param name defines the name of the mesh
  53256. * @param options defines the options used to create the mesh
  53257. * @param scene defines the hosting scene
  53258. * @returns the tube mesh
  53259. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  53260. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  53261. */
  53262. static CreateTube(name: string, options: {
  53263. path: Vector3[];
  53264. radius?: number;
  53265. tessellation?: number;
  53266. radiusFunction?: {
  53267. (i: number, distance: number): number;
  53268. };
  53269. cap?: number;
  53270. arc?: number;
  53271. updatable?: boolean;
  53272. sideOrientation?: number;
  53273. frontUVs?: Vector4;
  53274. backUVs?: Vector4;
  53275. instance?: Mesh;
  53276. invertUV?: boolean;
  53277. }, scene?: Nullable<Scene>): Mesh;
  53278. /**
  53279. * Creates a polyhedron mesh
  53280. * * 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
  53281. * * The parameter `size` (positive float, default 1) sets the polygon size
  53282. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  53283. * * 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`
  53284. * * 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
  53285. * * 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)`)
  53286. * * 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
  53287. * * 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
  53288. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53289. * * 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
  53290. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53291. * @param name defines the name of the mesh
  53292. * @param options defines the options used to create the mesh
  53293. * @param scene defines the hosting scene
  53294. * @returns the polyhedron mesh
  53295. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  53296. */
  53297. static CreatePolyhedron(name: string, options: {
  53298. type?: number;
  53299. size?: number;
  53300. sizeX?: number;
  53301. sizeY?: number;
  53302. sizeZ?: number;
  53303. custom?: any;
  53304. faceUV?: Vector4[];
  53305. faceColors?: Color4[];
  53306. flat?: boolean;
  53307. updatable?: boolean;
  53308. sideOrientation?: number;
  53309. frontUVs?: Vector4;
  53310. backUVs?: Vector4;
  53311. }, scene?: Nullable<Scene>): Mesh;
  53312. /**
  53313. * Creates a decal mesh.
  53314. * 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
  53315. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  53316. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  53317. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  53318. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  53319. * @param name defines the name of the mesh
  53320. * @param sourceMesh defines the mesh where the decal must be applied
  53321. * @param options defines the options used to create the mesh
  53322. * @param scene defines the hosting scene
  53323. * @returns the decal mesh
  53324. * @see https://doc.babylonjs.com/how_to/decals
  53325. */
  53326. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  53327. position?: Vector3;
  53328. normal?: Vector3;
  53329. size?: Vector3;
  53330. angle?: number;
  53331. }): Mesh;
  53332. }
  53333. }
  53334. declare module BABYLON {
  53335. /**
  53336. * A simplifier interface for future simplification implementations
  53337. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  53338. */
  53339. export interface ISimplifier {
  53340. /**
  53341. * Simplification of a given mesh according to the given settings.
  53342. * Since this requires computation, it is assumed that the function runs async.
  53343. * @param settings The settings of the simplification, including quality and distance
  53344. * @param successCallback A callback that will be called after the mesh was simplified.
  53345. * @param errorCallback in case of an error, this callback will be called. optional.
  53346. */
  53347. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  53348. }
  53349. /**
  53350. * Expected simplification settings.
  53351. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  53352. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  53353. */
  53354. export interface ISimplificationSettings {
  53355. /**
  53356. * Gets or sets the expected quality
  53357. */
  53358. quality: number;
  53359. /**
  53360. * Gets or sets the distance when this optimized version should be used
  53361. */
  53362. distance: number;
  53363. /**
  53364. * Gets an already optimized mesh
  53365. */
  53366. optimizeMesh?: boolean;
  53367. }
  53368. /**
  53369. * Class used to specify simplification options
  53370. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  53371. */
  53372. export class SimplificationSettings implements ISimplificationSettings {
  53373. /** expected quality */
  53374. quality: number;
  53375. /** distance when this optimized version should be used */
  53376. distance: number;
  53377. /** already optimized mesh */
  53378. optimizeMesh?: boolean | undefined;
  53379. /**
  53380. * Creates a SimplificationSettings
  53381. * @param quality expected quality
  53382. * @param distance distance when this optimized version should be used
  53383. * @param optimizeMesh already optimized mesh
  53384. */
  53385. constructor(
  53386. /** expected quality */
  53387. quality: number,
  53388. /** distance when this optimized version should be used */
  53389. distance: number,
  53390. /** already optimized mesh */
  53391. optimizeMesh?: boolean | undefined);
  53392. }
  53393. /**
  53394. * Interface used to define a simplification task
  53395. */
  53396. export interface ISimplificationTask {
  53397. /**
  53398. * Array of settings
  53399. */
  53400. settings: Array<ISimplificationSettings>;
  53401. /**
  53402. * Simplification type
  53403. */
  53404. simplificationType: SimplificationType;
  53405. /**
  53406. * Mesh to simplify
  53407. */
  53408. mesh: Mesh;
  53409. /**
  53410. * Callback called on success
  53411. */
  53412. successCallback?: () => void;
  53413. /**
  53414. * Defines if parallel processing can be used
  53415. */
  53416. parallelProcessing: boolean;
  53417. }
  53418. /**
  53419. * Queue used to order the simplification tasks
  53420. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  53421. */
  53422. export class SimplificationQueue {
  53423. private _simplificationArray;
  53424. /**
  53425. * Gets a boolean indicating that the process is still running
  53426. */
  53427. running: boolean;
  53428. /**
  53429. * Creates a new queue
  53430. */
  53431. constructor();
  53432. /**
  53433. * Adds a new simplification task
  53434. * @param task defines a task to add
  53435. */
  53436. addTask(task: ISimplificationTask): void;
  53437. /**
  53438. * Execute next task
  53439. */
  53440. executeNext(): void;
  53441. /**
  53442. * Execute a simplification task
  53443. * @param task defines the task to run
  53444. */
  53445. runSimplification(task: ISimplificationTask): void;
  53446. private getSimplifier;
  53447. }
  53448. /**
  53449. * The implemented types of simplification
  53450. * At the moment only Quadratic Error Decimation is implemented
  53451. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  53452. */
  53453. export enum SimplificationType {
  53454. /** Quadratic error decimation */
  53455. QUADRATIC = 0
  53456. }
  53457. }
  53458. declare module BABYLON {
  53459. interface Scene {
  53460. /** @hidden (Backing field) */
  53461. _simplificationQueue: SimplificationQueue;
  53462. /**
  53463. * Gets or sets the simplification queue attached to the scene
  53464. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  53465. */
  53466. simplificationQueue: SimplificationQueue;
  53467. }
  53468. interface Mesh {
  53469. /**
  53470. * Simplify the mesh according to the given array of settings.
  53471. * Function will return immediately and will simplify async
  53472. * @param settings a collection of simplification settings
  53473. * @param parallelProcessing should all levels calculate parallel or one after the other
  53474. * @param simplificationType the type of simplification to run
  53475. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  53476. * @returns the current mesh
  53477. */
  53478. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  53479. }
  53480. /**
  53481. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  53482. * created in a scene
  53483. */
  53484. export class SimplicationQueueSceneComponent implements ISceneComponent {
  53485. /**
  53486. * The component name helpfull to identify the component in the list of scene components.
  53487. */
  53488. readonly name: string;
  53489. /**
  53490. * The scene the component belongs to.
  53491. */
  53492. scene: Scene;
  53493. /**
  53494. * Creates a new instance of the component for the given scene
  53495. * @param scene Defines the scene to register the component in
  53496. */
  53497. constructor(scene: Scene);
  53498. /**
  53499. * Registers the component in a given scene
  53500. */
  53501. register(): void;
  53502. /**
  53503. * Rebuilds the elements related to this component in case of
  53504. * context lost for instance.
  53505. */
  53506. rebuild(): void;
  53507. /**
  53508. * Disposes the component and the associated ressources
  53509. */
  53510. dispose(): void;
  53511. private _beforeCameraUpdate;
  53512. }
  53513. }
  53514. declare module BABYLON {
  53515. /**
  53516. * Class used to enable access to IndexedDB
  53517. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  53518. */
  53519. export class Database implements IOfflineProvider {
  53520. private _callbackManifestChecked;
  53521. private _currentSceneUrl;
  53522. private _db;
  53523. private _enableSceneOffline;
  53524. private _enableTexturesOffline;
  53525. private _manifestVersionFound;
  53526. private _mustUpdateRessources;
  53527. private _hasReachedQuota;
  53528. private _isSupported;
  53529. private _idbFactory;
  53530. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  53531. private static IsUASupportingBlobStorage;
  53532. /**
  53533. * Gets a boolean indicating if Database storate is enabled (off by default)
  53534. */
  53535. static IDBStorageEnabled: boolean;
  53536. /**
  53537. * Gets a boolean indicating if scene must be saved in the database
  53538. */
  53539. readonly enableSceneOffline: boolean;
  53540. /**
  53541. * Gets a boolean indicating if textures must be saved in the database
  53542. */
  53543. readonly enableTexturesOffline: boolean;
  53544. /**
  53545. * Creates a new Database
  53546. * @param urlToScene defines the url to load the scene
  53547. * @param callbackManifestChecked defines the callback to use when manifest is checked
  53548. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  53549. */
  53550. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  53551. private static _ParseURL;
  53552. private static _ReturnFullUrlLocation;
  53553. private _checkManifestFile;
  53554. /**
  53555. * Open the database and make it available
  53556. * @param successCallback defines the callback to call on success
  53557. * @param errorCallback defines the callback to call on error
  53558. */
  53559. open(successCallback: () => void, errorCallback: () => void): void;
  53560. /**
  53561. * Loads an image from the database
  53562. * @param url defines the url to load from
  53563. * @param image defines the target DOM image
  53564. */
  53565. loadImage(url: string, image: HTMLImageElement): void;
  53566. private _loadImageFromDBAsync;
  53567. private _saveImageIntoDBAsync;
  53568. private _checkVersionFromDB;
  53569. private _loadVersionFromDBAsync;
  53570. private _saveVersionIntoDBAsync;
  53571. /**
  53572. * Loads a file from database
  53573. * @param url defines the URL to load from
  53574. * @param sceneLoaded defines a callback to call on success
  53575. * @param progressCallBack defines a callback to call when progress changed
  53576. * @param errorCallback defines a callback to call on error
  53577. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  53578. */
  53579. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  53580. private _loadFileAsync;
  53581. private _saveFileAsync;
  53582. /**
  53583. * Validates if xhr data is correct
  53584. * @param xhr defines the request to validate
  53585. * @param dataType defines the expected data type
  53586. * @returns true if data is correct
  53587. */
  53588. private static _ValidateXHRData;
  53589. }
  53590. }
  53591. declare module BABYLON {
  53592. /** @hidden */
  53593. export var gpuUpdateParticlesPixelShader: {
  53594. name: string;
  53595. shader: string;
  53596. };
  53597. }
  53598. declare module BABYLON {
  53599. /** @hidden */
  53600. export var gpuUpdateParticlesVertexShader: {
  53601. name: string;
  53602. shader: string;
  53603. };
  53604. }
  53605. declare module BABYLON {
  53606. /** @hidden */
  53607. export var clipPlaneFragmentDeclaration2: {
  53608. name: string;
  53609. shader: string;
  53610. };
  53611. }
  53612. declare module BABYLON {
  53613. /** @hidden */
  53614. export var gpuRenderParticlesPixelShader: {
  53615. name: string;
  53616. shader: string;
  53617. };
  53618. }
  53619. declare module BABYLON {
  53620. /** @hidden */
  53621. export var clipPlaneVertexDeclaration2: {
  53622. name: string;
  53623. shader: string;
  53624. };
  53625. }
  53626. declare module BABYLON {
  53627. /** @hidden */
  53628. export var gpuRenderParticlesVertexShader: {
  53629. name: string;
  53630. shader: string;
  53631. };
  53632. }
  53633. declare module BABYLON {
  53634. /**
  53635. * This represents a GPU particle system in Babylon
  53636. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  53637. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  53638. */
  53639. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  53640. /**
  53641. * The layer mask we are rendering the particles through.
  53642. */
  53643. layerMask: number;
  53644. private _capacity;
  53645. private _activeCount;
  53646. private _currentActiveCount;
  53647. private _accumulatedCount;
  53648. private _renderEffect;
  53649. private _updateEffect;
  53650. private _buffer0;
  53651. private _buffer1;
  53652. private _spriteBuffer;
  53653. private _updateVAO;
  53654. private _renderVAO;
  53655. private _targetIndex;
  53656. private _sourceBuffer;
  53657. private _targetBuffer;
  53658. private _engine;
  53659. private _currentRenderId;
  53660. private _started;
  53661. private _stopped;
  53662. private _timeDelta;
  53663. private _randomTexture;
  53664. private _randomTexture2;
  53665. private _attributesStrideSize;
  53666. private _updateEffectOptions;
  53667. private _randomTextureSize;
  53668. private _actualFrame;
  53669. private readonly _rawTextureWidth;
  53670. /**
  53671. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  53672. */
  53673. static readonly IsSupported: boolean;
  53674. /**
  53675. * An event triggered when the system is disposed.
  53676. */
  53677. onDisposeObservable: Observable<GPUParticleSystem>;
  53678. /**
  53679. * Gets the maximum number of particles active at the same time.
  53680. * @returns The max number of active particles.
  53681. */
  53682. getCapacity(): number;
  53683. /**
  53684. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  53685. * to override the particles.
  53686. */
  53687. forceDepthWrite: boolean;
  53688. /**
  53689. * Gets or set the number of active particles
  53690. */
  53691. activeParticleCount: number;
  53692. private _preWarmDone;
  53693. /**
  53694. * Is this system ready to be used/rendered
  53695. * @return true if the system is ready
  53696. */
  53697. isReady(): boolean;
  53698. /**
  53699. * Gets if the system has been started. (Note: this will still be true after stop is called)
  53700. * @returns True if it has been started, otherwise false.
  53701. */
  53702. isStarted(): boolean;
  53703. /**
  53704. * Starts the particle system and begins to emit
  53705. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  53706. */
  53707. start(delay?: number): void;
  53708. /**
  53709. * Stops the particle system.
  53710. */
  53711. stop(): void;
  53712. /**
  53713. * Remove all active particles
  53714. */
  53715. reset(): void;
  53716. /**
  53717. * Returns the string "GPUParticleSystem"
  53718. * @returns a string containing the class name
  53719. */
  53720. getClassName(): string;
  53721. private _colorGradientsTexture;
  53722. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  53723. /**
  53724. * Adds a new color gradient
  53725. * @param gradient defines the gradient to use (between 0 and 1)
  53726. * @param color1 defines the color to affect to the specified gradient
  53727. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  53728. * @returns the current particle system
  53729. */
  53730. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  53731. /**
  53732. * Remove a specific color gradient
  53733. * @param gradient defines the gradient to remove
  53734. * @returns the current particle system
  53735. */
  53736. removeColorGradient(gradient: number): GPUParticleSystem;
  53737. private _angularSpeedGradientsTexture;
  53738. private _sizeGradientsTexture;
  53739. private _velocityGradientsTexture;
  53740. private _limitVelocityGradientsTexture;
  53741. private _dragGradientsTexture;
  53742. private _addFactorGradient;
  53743. /**
  53744. * Adds a new size gradient
  53745. * @param gradient defines the gradient to use (between 0 and 1)
  53746. * @param factor defines the size factor to affect to the specified gradient
  53747. * @returns the current particle system
  53748. */
  53749. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  53750. /**
  53751. * Remove a specific size gradient
  53752. * @param gradient defines the gradient to remove
  53753. * @returns the current particle system
  53754. */
  53755. removeSizeGradient(gradient: number): GPUParticleSystem;
  53756. /**
  53757. * Adds a new angular speed gradient
  53758. * @param gradient defines the gradient to use (between 0 and 1)
  53759. * @param factor defines the angular speed to affect to the specified gradient
  53760. * @returns the current particle system
  53761. */
  53762. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  53763. /**
  53764. * Remove a specific angular speed gradient
  53765. * @param gradient defines the gradient to remove
  53766. * @returns the current particle system
  53767. */
  53768. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  53769. /**
  53770. * Adds a new velocity gradient
  53771. * @param gradient defines the gradient to use (between 0 and 1)
  53772. * @param factor defines the velocity to affect to the specified gradient
  53773. * @returns the current particle system
  53774. */
  53775. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  53776. /**
  53777. * Remove a specific velocity gradient
  53778. * @param gradient defines the gradient to remove
  53779. * @returns the current particle system
  53780. */
  53781. removeVelocityGradient(gradient: number): GPUParticleSystem;
  53782. /**
  53783. * Adds a new limit velocity gradient
  53784. * @param gradient defines the gradient to use (between 0 and 1)
  53785. * @param factor defines the limit velocity value to affect to the specified gradient
  53786. * @returns the current particle system
  53787. */
  53788. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  53789. /**
  53790. * Remove a specific limit velocity gradient
  53791. * @param gradient defines the gradient to remove
  53792. * @returns the current particle system
  53793. */
  53794. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  53795. /**
  53796. * Adds a new drag gradient
  53797. * @param gradient defines the gradient to use (between 0 and 1)
  53798. * @param factor defines the drag value to affect to the specified gradient
  53799. * @returns the current particle system
  53800. */
  53801. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  53802. /**
  53803. * Remove a specific drag gradient
  53804. * @param gradient defines the gradient to remove
  53805. * @returns the current particle system
  53806. */
  53807. removeDragGradient(gradient: number): GPUParticleSystem;
  53808. /**
  53809. * Not supported by GPUParticleSystem
  53810. * @param gradient defines the gradient to use (between 0 and 1)
  53811. * @param factor defines the emit rate value to affect to the specified gradient
  53812. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  53813. * @returns the current particle system
  53814. */
  53815. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  53816. /**
  53817. * Not supported by GPUParticleSystem
  53818. * @param gradient defines the gradient to remove
  53819. * @returns the current particle system
  53820. */
  53821. removeEmitRateGradient(gradient: number): IParticleSystem;
  53822. /**
  53823. * Not supported by GPUParticleSystem
  53824. * @param gradient defines the gradient to use (between 0 and 1)
  53825. * @param factor defines the start size value to affect to the specified gradient
  53826. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  53827. * @returns the current particle system
  53828. */
  53829. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  53830. /**
  53831. * Not supported by GPUParticleSystem
  53832. * @param gradient defines the gradient to remove
  53833. * @returns the current particle system
  53834. */
  53835. removeStartSizeGradient(gradient: number): IParticleSystem;
  53836. /**
  53837. * Not supported by GPUParticleSystem
  53838. * @param gradient defines the gradient to use (between 0 and 1)
  53839. * @param min defines the color remap minimal range
  53840. * @param max defines the color remap maximal range
  53841. * @returns the current particle system
  53842. */
  53843. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  53844. /**
  53845. * Not supported by GPUParticleSystem
  53846. * @param gradient defines the gradient to remove
  53847. * @returns the current particle system
  53848. */
  53849. removeColorRemapGradient(): IParticleSystem;
  53850. /**
  53851. * Not supported by GPUParticleSystem
  53852. * @param gradient defines the gradient to use (between 0 and 1)
  53853. * @param min defines the alpha remap minimal range
  53854. * @param max defines the alpha remap maximal range
  53855. * @returns the current particle system
  53856. */
  53857. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  53858. /**
  53859. * Not supported by GPUParticleSystem
  53860. * @param gradient defines the gradient to remove
  53861. * @returns the current particle system
  53862. */
  53863. removeAlphaRemapGradient(): IParticleSystem;
  53864. /**
  53865. * Not supported by GPUParticleSystem
  53866. * @param gradient defines the gradient to use (between 0 and 1)
  53867. * @param color defines the color to affect to the specified gradient
  53868. * @returns the current particle system
  53869. */
  53870. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  53871. /**
  53872. * Not supported by GPUParticleSystem
  53873. * @param gradient defines the gradient to remove
  53874. * @returns the current particle system
  53875. */
  53876. removeRampGradient(): IParticleSystem;
  53877. /**
  53878. * Not supported by GPUParticleSystem
  53879. * @returns the list of ramp gradients
  53880. */
  53881. getRampGradients(): Nullable<Array<Color3Gradient>>;
  53882. /**
  53883. * Not supported by GPUParticleSystem
  53884. * Gets or sets a boolean indicating that ramp gradients must be used
  53885. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  53886. */
  53887. useRampGradients: boolean;
  53888. /**
  53889. * Not supported by GPUParticleSystem
  53890. * @param gradient defines the gradient to use (between 0 and 1)
  53891. * @param factor defines the life time factor to affect to the specified gradient
  53892. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  53893. * @returns the current particle system
  53894. */
  53895. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  53896. /**
  53897. * Not supported by GPUParticleSystem
  53898. * @param gradient defines the gradient to remove
  53899. * @returns the current particle system
  53900. */
  53901. removeLifeTimeGradient(gradient: number): IParticleSystem;
  53902. /**
  53903. * Instantiates a GPU particle system.
  53904. * 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.
  53905. * @param name The name of the particle system
  53906. * @param options The options used to create the system
  53907. * @param scene The scene the particle system belongs to
  53908. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  53909. */
  53910. constructor(name: string, options: Partial<{
  53911. capacity: number;
  53912. randomTextureSize: number;
  53913. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  53914. protected _reset(): void;
  53915. private _createUpdateVAO;
  53916. private _createRenderVAO;
  53917. private _initialize;
  53918. /** @hidden */
  53919. _recreateUpdateEffect(): void;
  53920. /** @hidden */
  53921. _recreateRenderEffect(): void;
  53922. /**
  53923. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  53924. * @param preWarm defines if we are in the pre-warmimg phase
  53925. */
  53926. animate(preWarm?: boolean): void;
  53927. private _createFactorGradientTexture;
  53928. private _createSizeGradientTexture;
  53929. private _createAngularSpeedGradientTexture;
  53930. private _createVelocityGradientTexture;
  53931. private _createLimitVelocityGradientTexture;
  53932. private _createDragGradientTexture;
  53933. private _createColorGradientTexture;
  53934. /**
  53935. * Renders the particle system in its current state
  53936. * @param preWarm defines if the system should only update the particles but not render them
  53937. * @returns the current number of particles
  53938. */
  53939. render(preWarm?: boolean): number;
  53940. /**
  53941. * Rebuilds the particle system
  53942. */
  53943. rebuild(): void;
  53944. private _releaseBuffers;
  53945. private _releaseVAOs;
  53946. /**
  53947. * Disposes the particle system and free the associated resources
  53948. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  53949. */
  53950. dispose(disposeTexture?: boolean): void;
  53951. /**
  53952. * Clones the particle system.
  53953. * @param name The name of the cloned object
  53954. * @param newEmitter The new emitter to use
  53955. * @returns the cloned particle system
  53956. */
  53957. clone(name: string, newEmitter: any): GPUParticleSystem;
  53958. /**
  53959. * Serializes the particle system to a JSON object.
  53960. * @returns the JSON object
  53961. */
  53962. serialize(): any;
  53963. /**
  53964. * Parses a JSON object to create a GPU particle system.
  53965. * @param parsedParticleSystem The JSON object to parse
  53966. * @param scene The scene to create the particle system in
  53967. * @param rootUrl The root url to use to load external dependencies like texture
  53968. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  53969. * @returns the parsed GPU particle system
  53970. */
  53971. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  53972. }
  53973. }
  53974. declare module BABYLON {
  53975. /**
  53976. * Represents a set of particle systems working together to create a specific effect
  53977. */
  53978. export class ParticleSystemSet implements IDisposable {
  53979. private _emitterCreationOptions;
  53980. private _emitterNode;
  53981. /**
  53982. * Gets the particle system list
  53983. */
  53984. systems: IParticleSystem[];
  53985. /**
  53986. * Gets the emitter node used with this set
  53987. */
  53988. readonly emitterNode: Nullable<TransformNode>;
  53989. /**
  53990. * Creates a new emitter mesh as a sphere
  53991. * @param options defines the options used to create the sphere
  53992. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  53993. * @param scene defines the hosting scene
  53994. */
  53995. setEmitterAsSphere(options: {
  53996. diameter: number;
  53997. segments: number;
  53998. color: Color3;
  53999. }, renderingGroupId: number, scene: Scene): void;
  54000. /**
  54001. * Starts all particle systems of the set
  54002. * @param emitter defines an optional mesh to use as emitter for the particle systems
  54003. */
  54004. start(emitter?: AbstractMesh): void;
  54005. /**
  54006. * Release all associated resources
  54007. */
  54008. dispose(): void;
  54009. /**
  54010. * Serialize the set into a JSON compatible object
  54011. * @returns a JSON compatible representation of the set
  54012. */
  54013. serialize(): any;
  54014. /**
  54015. * Parse a new ParticleSystemSet from a serialized source
  54016. * @param data defines a JSON compatible representation of the set
  54017. * @param scene defines the hosting scene
  54018. * @param gpu defines if we want GPU particles or CPU particles
  54019. * @returns a new ParticleSystemSet
  54020. */
  54021. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  54022. }
  54023. }
  54024. declare module BABYLON {
  54025. /**
  54026. * This class is made for on one-liner static method to help creating particle system set.
  54027. */
  54028. export class ParticleHelper {
  54029. /**
  54030. * Gets or sets base Assets URL
  54031. */
  54032. static BaseAssetsUrl: string;
  54033. /**
  54034. * Create a default particle system that you can tweak
  54035. * @param emitter defines the emitter to use
  54036. * @param capacity defines the system capacity (default is 500 particles)
  54037. * @param scene defines the hosting scene
  54038. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  54039. * @returns the new Particle system
  54040. */
  54041. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  54042. /**
  54043. * This is the main static method (one-liner) of this helper to create different particle systems
  54044. * @param type This string represents the type to the particle system to create
  54045. * @param scene The scene where the particle system should live
  54046. * @param gpu If the system will use gpu
  54047. * @returns the ParticleSystemSet created
  54048. */
  54049. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  54050. /**
  54051. * Static function used to export a particle system to a ParticleSystemSet variable.
  54052. * Please note that the emitter shape is not exported
  54053. * @param systems defines the particle systems to export
  54054. * @returns the created particle system set
  54055. */
  54056. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  54057. }
  54058. }
  54059. declare module BABYLON {
  54060. interface Engine {
  54061. /**
  54062. * Create an effect to use with particle systems.
  54063. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  54064. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  54065. * @param uniformsNames defines a list of attribute names
  54066. * @param samplers defines an array of string used to represent textures
  54067. * @param defines defines the string containing the defines to use to compile the shaders
  54068. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  54069. * @param onCompiled defines a function to call when the effect creation is successful
  54070. * @param onError defines a function to call when the effect creation has failed
  54071. * @returns the new Effect
  54072. */
  54073. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  54074. }
  54075. interface Mesh {
  54076. /**
  54077. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  54078. * @returns an array of IParticleSystem
  54079. */
  54080. getEmittedParticleSystems(): IParticleSystem[];
  54081. /**
  54082. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  54083. * @returns an array of IParticleSystem
  54084. */
  54085. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  54086. }
  54087. /**
  54088. * @hidden
  54089. */
  54090. export var _IDoNeedToBeInTheBuild: number;
  54091. }
  54092. declare module BABYLON {
  54093. interface Scene {
  54094. /** @hidden (Backing field) */
  54095. _physicsEngine: Nullable<IPhysicsEngine>;
  54096. /**
  54097. * Gets the current physics engine
  54098. * @returns a IPhysicsEngine or null if none attached
  54099. */
  54100. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  54101. /**
  54102. * Enables physics to the current scene
  54103. * @param gravity defines the scene's gravity for the physics engine
  54104. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  54105. * @return a boolean indicating if the physics engine was initialized
  54106. */
  54107. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  54108. /**
  54109. * Disables and disposes the physics engine associated with the scene
  54110. */
  54111. disablePhysicsEngine(): void;
  54112. /**
  54113. * Gets a boolean indicating if there is an active physics engine
  54114. * @returns a boolean indicating if there is an active physics engine
  54115. */
  54116. isPhysicsEnabled(): boolean;
  54117. /**
  54118. * Deletes a physics compound impostor
  54119. * @param compound defines the compound to delete
  54120. */
  54121. deleteCompoundImpostor(compound: any): void;
  54122. /**
  54123. * An event triggered when physic simulation is about to be run
  54124. */
  54125. onBeforePhysicsObservable: Observable<Scene>;
  54126. /**
  54127. * An event triggered when physic simulation has been done
  54128. */
  54129. onAfterPhysicsObservable: Observable<Scene>;
  54130. }
  54131. interface AbstractMesh {
  54132. /** @hidden */
  54133. _physicsImpostor: Nullable<PhysicsImpostor>;
  54134. /**
  54135. * Gets or sets impostor used for physic simulation
  54136. * @see http://doc.babylonjs.com/features/physics_engine
  54137. */
  54138. physicsImpostor: Nullable<PhysicsImpostor>;
  54139. /**
  54140. * Gets the current physics impostor
  54141. * @see http://doc.babylonjs.com/features/physics_engine
  54142. * @returns a physics impostor or null
  54143. */
  54144. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  54145. /** Apply a physic impulse to the mesh
  54146. * @param force defines the force to apply
  54147. * @param contactPoint defines where to apply the force
  54148. * @returns the current mesh
  54149. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  54150. */
  54151. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  54152. /**
  54153. * Creates a physic joint between two meshes
  54154. * @param otherMesh defines the other mesh to use
  54155. * @param pivot1 defines the pivot to use on this mesh
  54156. * @param pivot2 defines the pivot to use on the other mesh
  54157. * @param options defines additional options (can be plugin dependent)
  54158. * @returns the current mesh
  54159. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  54160. */
  54161. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  54162. /** @hidden */
  54163. _disposePhysicsObserver: Nullable<Observer<Node>>;
  54164. }
  54165. /**
  54166. * Defines the physics engine scene component responsible to manage a physics engine
  54167. */
  54168. export class PhysicsEngineSceneComponent implements ISceneComponent {
  54169. /**
  54170. * The component name helpful to identify the component in the list of scene components.
  54171. */
  54172. readonly name: string;
  54173. /**
  54174. * The scene the component belongs to.
  54175. */
  54176. scene: Scene;
  54177. /**
  54178. * Creates a new instance of the component for the given scene
  54179. * @param scene Defines the scene to register the component in
  54180. */
  54181. constructor(scene: Scene);
  54182. /**
  54183. * Registers the component in a given scene
  54184. */
  54185. register(): void;
  54186. /**
  54187. * Rebuilds the elements related to this component in case of
  54188. * context lost for instance.
  54189. */
  54190. rebuild(): void;
  54191. /**
  54192. * Disposes the component and the associated ressources
  54193. */
  54194. dispose(): void;
  54195. }
  54196. }
  54197. declare module BABYLON {
  54198. /**
  54199. * A helper for physics simulations
  54200. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54201. */
  54202. export class PhysicsHelper {
  54203. private _scene;
  54204. private _physicsEngine;
  54205. /**
  54206. * Initializes the Physics helper
  54207. * @param scene Babylon.js scene
  54208. */
  54209. constructor(scene: Scene);
  54210. /**
  54211. * Applies a radial explosion impulse
  54212. * @param origin the origin of the explosion
  54213. * @param radiusOrEventOptions the radius or the options of radial explosion
  54214. * @param strength the explosion strength
  54215. * @param falloff possible options: Constant & Linear. Defaults to Constant
  54216. * @returns A physics radial explosion event, or null
  54217. */
  54218. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  54219. /**
  54220. * Applies a radial explosion force
  54221. * @param origin the origin of the explosion
  54222. * @param radiusOrEventOptions the radius or the options of radial explosion
  54223. * @param strength the explosion strength
  54224. * @param falloff possible options: Constant & Linear. Defaults to Constant
  54225. * @returns A physics radial explosion event, or null
  54226. */
  54227. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  54228. /**
  54229. * Creates a gravitational field
  54230. * @param origin the origin of the explosion
  54231. * @param radiusOrEventOptions the radius or the options of radial explosion
  54232. * @param strength the explosion strength
  54233. * @param falloff possible options: Constant & Linear. Defaults to Constant
  54234. * @returns A physics gravitational field event, or null
  54235. */
  54236. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  54237. /**
  54238. * Creates a physics updraft event
  54239. * @param origin the origin of the updraft
  54240. * @param radiusOrEventOptions the radius or the options of the updraft
  54241. * @param strength the strength of the updraft
  54242. * @param height the height of the updraft
  54243. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  54244. * @returns A physics updraft event, or null
  54245. */
  54246. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  54247. /**
  54248. * Creates a physics vortex event
  54249. * @param origin the of the vortex
  54250. * @param radiusOrEventOptions the radius or the options of the vortex
  54251. * @param strength the strength of the vortex
  54252. * @param height the height of the vortex
  54253. * @returns a Physics vortex event, or null
  54254. * A physics vortex event or null
  54255. */
  54256. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  54257. }
  54258. /**
  54259. * Represents a physics radial explosion event
  54260. */
  54261. class PhysicsRadialExplosionEvent {
  54262. private _scene;
  54263. private _options;
  54264. private _sphere;
  54265. private _dataFetched;
  54266. /**
  54267. * Initializes a radial explosioin event
  54268. * @param _scene BabylonJS scene
  54269. * @param _options The options for the vortex event
  54270. */
  54271. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  54272. /**
  54273. * Returns the data related to the radial explosion event (sphere).
  54274. * @returns The radial explosion event data
  54275. */
  54276. getData(): PhysicsRadialExplosionEventData;
  54277. /**
  54278. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  54279. * @param impostor A physics imposter
  54280. * @param origin the origin of the explosion
  54281. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  54282. */
  54283. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  54284. /**
  54285. * Triggers affecterd impostors callbacks
  54286. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  54287. */
  54288. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  54289. /**
  54290. * Disposes the sphere.
  54291. * @param force Specifies if the sphere should be disposed by force
  54292. */
  54293. dispose(force?: boolean): void;
  54294. /*** Helpers ***/
  54295. private _prepareSphere;
  54296. private _intersectsWithSphere;
  54297. }
  54298. /**
  54299. * Represents a gravitational field event
  54300. */
  54301. class PhysicsGravitationalFieldEvent {
  54302. private _physicsHelper;
  54303. private _scene;
  54304. private _origin;
  54305. private _options;
  54306. private _tickCallback;
  54307. private _sphere;
  54308. private _dataFetched;
  54309. /**
  54310. * Initializes the physics gravitational field event
  54311. * @param _physicsHelper A physics helper
  54312. * @param _scene BabylonJS scene
  54313. * @param _origin The origin position of the gravitational field event
  54314. * @param _options The options for the vortex event
  54315. */
  54316. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  54317. /**
  54318. * Returns the data related to the gravitational field event (sphere).
  54319. * @returns A gravitational field event
  54320. */
  54321. getData(): PhysicsGravitationalFieldEventData;
  54322. /**
  54323. * Enables the gravitational field.
  54324. */
  54325. enable(): void;
  54326. /**
  54327. * Disables the gravitational field.
  54328. */
  54329. disable(): void;
  54330. /**
  54331. * Disposes the sphere.
  54332. * @param force The force to dispose from the gravitational field event
  54333. */
  54334. dispose(force?: boolean): void;
  54335. private _tick;
  54336. }
  54337. /**
  54338. * Represents a physics updraft event
  54339. */
  54340. class PhysicsUpdraftEvent {
  54341. private _scene;
  54342. private _origin;
  54343. private _options;
  54344. private _physicsEngine;
  54345. private _originTop;
  54346. private _originDirection;
  54347. private _tickCallback;
  54348. private _cylinder;
  54349. private _cylinderPosition;
  54350. private _dataFetched;
  54351. /**
  54352. * Initializes the physics updraft event
  54353. * @param _scene BabylonJS scene
  54354. * @param _origin The origin position of the updraft
  54355. * @param _options The options for the updraft event
  54356. */
  54357. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  54358. /**
  54359. * Returns the data related to the updraft event (cylinder).
  54360. * @returns A physics updraft event
  54361. */
  54362. getData(): PhysicsUpdraftEventData;
  54363. /**
  54364. * Enables the updraft.
  54365. */
  54366. enable(): void;
  54367. /**
  54368. * Disables the updraft.
  54369. */
  54370. disable(): void;
  54371. /**
  54372. * Disposes the cylinder.
  54373. * @param force Specifies if the updraft should be disposed by force
  54374. */
  54375. dispose(force?: boolean): void;
  54376. private getImpostorHitData;
  54377. private _tick;
  54378. /*** Helpers ***/
  54379. private _prepareCylinder;
  54380. private _intersectsWithCylinder;
  54381. }
  54382. /**
  54383. * Represents a physics vortex event
  54384. */
  54385. class PhysicsVortexEvent {
  54386. private _scene;
  54387. private _origin;
  54388. private _options;
  54389. private _physicsEngine;
  54390. private _originTop;
  54391. private _tickCallback;
  54392. private _cylinder;
  54393. private _cylinderPosition;
  54394. private _dataFetched;
  54395. /**
  54396. * Initializes the physics vortex event
  54397. * @param _scene The BabylonJS scene
  54398. * @param _origin The origin position of the vortex
  54399. * @param _options The options for the vortex event
  54400. */
  54401. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  54402. /**
  54403. * Returns the data related to the vortex event (cylinder).
  54404. * @returns The physics vortex event data
  54405. */
  54406. getData(): PhysicsVortexEventData;
  54407. /**
  54408. * Enables the vortex.
  54409. */
  54410. enable(): void;
  54411. /**
  54412. * Disables the cortex.
  54413. */
  54414. disable(): void;
  54415. /**
  54416. * Disposes the sphere.
  54417. * @param force
  54418. */
  54419. dispose(force?: boolean): void;
  54420. private getImpostorHitData;
  54421. private _tick;
  54422. /*** Helpers ***/
  54423. private _prepareCylinder;
  54424. private _intersectsWithCylinder;
  54425. }
  54426. /**
  54427. * Options fot the radial explosion event
  54428. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54429. */
  54430. export class PhysicsRadialExplosionEventOptions {
  54431. /**
  54432. * The radius of the sphere for the radial explosion.
  54433. */
  54434. radius: number;
  54435. /**
  54436. * The strenth of the explosion.
  54437. */
  54438. strength: number;
  54439. /**
  54440. * The strenght of the force in correspondence to the distance of the affected object
  54441. */
  54442. falloff: PhysicsRadialImpulseFalloff;
  54443. /**
  54444. * Sphere options for the radial explosion.
  54445. */
  54446. sphere: {
  54447. segments: number;
  54448. diameter: number;
  54449. };
  54450. /**
  54451. * Sphere options for the radial explosion.
  54452. */
  54453. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  54454. }
  54455. /**
  54456. * Options fot the updraft event
  54457. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54458. */
  54459. export class PhysicsUpdraftEventOptions {
  54460. /**
  54461. * The radius of the cylinder for the vortex
  54462. */
  54463. radius: number;
  54464. /**
  54465. * The strenth of the updraft.
  54466. */
  54467. strength: number;
  54468. /**
  54469. * The height of the cylinder for the updraft.
  54470. */
  54471. height: number;
  54472. /**
  54473. * The mode for the the updraft.
  54474. */
  54475. updraftMode: PhysicsUpdraftMode;
  54476. }
  54477. /**
  54478. * Options fot the vortex event
  54479. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54480. */
  54481. export class PhysicsVortexEventOptions {
  54482. /**
  54483. * The radius of the cylinder for the vortex
  54484. */
  54485. radius: number;
  54486. /**
  54487. * The strenth of the vortex.
  54488. */
  54489. strength: number;
  54490. /**
  54491. * The height of the cylinder for the vortex.
  54492. */
  54493. height: number;
  54494. /**
  54495. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  54496. */
  54497. centripetalForceThreshold: number;
  54498. /**
  54499. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  54500. */
  54501. centripetalForceMultiplier: number;
  54502. /**
  54503. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  54504. */
  54505. centrifugalForceMultiplier: number;
  54506. /**
  54507. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  54508. */
  54509. updraftForceMultiplier: number;
  54510. }
  54511. /**
  54512. * The strenght of the force in correspondence to the distance of the affected object
  54513. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54514. */
  54515. export enum PhysicsRadialImpulseFalloff {
  54516. /** Defines that impulse is constant in strength across it's whole radius */
  54517. Constant = 0,
  54518. /** Defines that impulse gets weaker if it's further from the origin */
  54519. Linear = 1
  54520. }
  54521. /**
  54522. * The strength of the force in correspondence to the distance of the affected object
  54523. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54524. */
  54525. export enum PhysicsUpdraftMode {
  54526. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  54527. Center = 0,
  54528. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  54529. Perpendicular = 1
  54530. }
  54531. /**
  54532. * Interface for a physics hit data
  54533. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54534. */
  54535. export interface PhysicsHitData {
  54536. /**
  54537. * The force applied at the contact point
  54538. */
  54539. force: Vector3;
  54540. /**
  54541. * The contact point
  54542. */
  54543. contactPoint: Vector3;
  54544. /**
  54545. * The distance from the origin to the contact point
  54546. */
  54547. distanceFromOrigin: number;
  54548. }
  54549. /**
  54550. * Interface for radial explosion event data
  54551. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54552. */
  54553. export interface PhysicsRadialExplosionEventData {
  54554. /**
  54555. * A sphere used for the radial explosion event
  54556. */
  54557. sphere: Mesh;
  54558. }
  54559. /**
  54560. * Interface for gravitational field event data
  54561. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54562. */
  54563. export interface PhysicsGravitationalFieldEventData {
  54564. /**
  54565. * A sphere mesh used for the gravitational field event
  54566. */
  54567. sphere: Mesh;
  54568. }
  54569. /**
  54570. * Interface for updraft event data
  54571. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54572. */
  54573. export interface PhysicsUpdraftEventData {
  54574. /**
  54575. * A cylinder used for the updraft event
  54576. */
  54577. cylinder: Mesh;
  54578. }
  54579. /**
  54580. * Interface for vortex event data
  54581. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54582. */
  54583. export interface PhysicsVortexEventData {
  54584. /**
  54585. * A cylinder used for the vortex event
  54586. */
  54587. cylinder: Mesh;
  54588. }
  54589. /**
  54590. * Interface for an affected physics impostor
  54591. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54592. */
  54593. export interface PhysicsAffectedImpostorWithData {
  54594. /**
  54595. * The impostor affected by the effect
  54596. */
  54597. impostor: PhysicsImpostor;
  54598. /**
  54599. * The data about the hit/horce from the explosion
  54600. */
  54601. hitData: PhysicsHitData;
  54602. }
  54603. }
  54604. declare module BABYLON {
  54605. /** @hidden */
  54606. export var blackAndWhitePixelShader: {
  54607. name: string;
  54608. shader: string;
  54609. };
  54610. }
  54611. declare module BABYLON {
  54612. /**
  54613. * Post process used to render in black and white
  54614. */
  54615. export class BlackAndWhitePostProcess extends PostProcess {
  54616. /**
  54617. * Linear about to convert he result to black and white (default: 1)
  54618. */
  54619. degree: number;
  54620. /**
  54621. * Creates a black and white post process
  54622. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  54623. * @param name The name of the effect.
  54624. * @param options The required width/height ratio to downsize to before computing the render pass.
  54625. * @param camera The camera to apply the render pass to.
  54626. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54627. * @param engine The engine which the post process will be applied. (default: current engine)
  54628. * @param reusable If the post process can be reused on the same frame. (default: false)
  54629. */
  54630. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  54631. }
  54632. }
  54633. declare module BABYLON {
  54634. /**
  54635. * This represents a set of one or more post processes in Babylon.
  54636. * A post process can be used to apply a shader to a texture after it is rendered.
  54637. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  54638. */
  54639. export class PostProcessRenderEffect {
  54640. private _postProcesses;
  54641. private _getPostProcesses;
  54642. private _singleInstance;
  54643. private _cameras;
  54644. private _indicesForCamera;
  54645. /**
  54646. * Name of the effect
  54647. * @hidden
  54648. */
  54649. _name: string;
  54650. /**
  54651. * Instantiates a post process render effect.
  54652. * A post process can be used to apply a shader to a texture after it is rendered.
  54653. * @param engine The engine the effect is tied to
  54654. * @param name The name of the effect
  54655. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  54656. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  54657. */
  54658. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  54659. /**
  54660. * Checks if all the post processes in the effect are supported.
  54661. */
  54662. readonly isSupported: boolean;
  54663. /**
  54664. * Updates the current state of the effect
  54665. * @hidden
  54666. */
  54667. _update(): void;
  54668. /**
  54669. * Attaches the effect on cameras
  54670. * @param cameras The camera to attach to.
  54671. * @hidden
  54672. */
  54673. _attachCameras(cameras: Camera): void;
  54674. /**
  54675. * Attaches the effect on cameras
  54676. * @param cameras The camera to attach to.
  54677. * @hidden
  54678. */
  54679. _attachCameras(cameras: Camera[]): void;
  54680. /**
  54681. * Detaches the effect on cameras
  54682. * @param cameras The camera to detatch from.
  54683. * @hidden
  54684. */
  54685. _detachCameras(cameras: Camera): void;
  54686. /**
  54687. * Detatches the effect on cameras
  54688. * @param cameras The camera to detatch from.
  54689. * @hidden
  54690. */
  54691. _detachCameras(cameras: Camera[]): void;
  54692. /**
  54693. * Enables the effect on given cameras
  54694. * @param cameras The camera to enable.
  54695. * @hidden
  54696. */
  54697. _enable(cameras: Camera): void;
  54698. /**
  54699. * Enables the effect on given cameras
  54700. * @param cameras The camera to enable.
  54701. * @hidden
  54702. */
  54703. _enable(cameras: Nullable<Camera[]>): void;
  54704. /**
  54705. * Disables the effect on the given cameras
  54706. * @param cameras The camera to disable.
  54707. * @hidden
  54708. */
  54709. _disable(cameras: Camera): void;
  54710. /**
  54711. * Disables the effect on the given cameras
  54712. * @param cameras The camera to disable.
  54713. * @hidden
  54714. */
  54715. _disable(cameras: Nullable<Camera[]>): void;
  54716. /**
  54717. * Gets a list of the post processes contained in the effect.
  54718. * @param camera The camera to get the post processes on.
  54719. * @returns The list of the post processes in the effect.
  54720. */
  54721. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  54722. }
  54723. }
  54724. declare module BABYLON {
  54725. /** @hidden */
  54726. export var extractHighlightsPixelShader: {
  54727. name: string;
  54728. shader: string;
  54729. };
  54730. }
  54731. declare module BABYLON {
  54732. /**
  54733. * 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.
  54734. */
  54735. export class ExtractHighlightsPostProcess extends PostProcess {
  54736. /**
  54737. * The luminance threshold, pixels below this value will be set to black.
  54738. */
  54739. threshold: number;
  54740. /** @hidden */
  54741. _exposure: number;
  54742. /**
  54743. * Post process which has the input texture to be used when performing highlight extraction
  54744. * @hidden
  54745. */
  54746. _inputPostProcess: Nullable<PostProcess>;
  54747. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  54748. }
  54749. }
  54750. declare module BABYLON {
  54751. /** @hidden */
  54752. export var bloomMergePixelShader: {
  54753. name: string;
  54754. shader: string;
  54755. };
  54756. }
  54757. declare module BABYLON {
  54758. /**
  54759. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  54760. */
  54761. export class BloomMergePostProcess extends PostProcess {
  54762. /** Weight of the bloom to be added to the original input. */
  54763. weight: number;
  54764. /**
  54765. * Creates a new instance of @see BloomMergePostProcess
  54766. * @param name The name of the effect.
  54767. * @param originalFromInput Post process which's input will be used for the merge.
  54768. * @param blurred Blurred highlights post process which's output will be used.
  54769. * @param weight Weight of the bloom to be added to the original input.
  54770. * @param options The required width/height ratio to downsize to before computing the render pass.
  54771. * @param camera The camera to apply the render pass to.
  54772. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54773. * @param engine The engine which the post process will be applied. (default: current engine)
  54774. * @param reusable If the post process can be reused on the same frame. (default: false)
  54775. * @param textureType Type of textures used when performing the post process. (default: 0)
  54776. * @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)
  54777. */
  54778. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  54779. /** Weight of the bloom to be added to the original input. */
  54780. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  54781. }
  54782. }
  54783. declare module BABYLON {
  54784. /**
  54785. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  54786. */
  54787. export class BloomEffect extends PostProcessRenderEffect {
  54788. private bloomScale;
  54789. /**
  54790. * @hidden Internal
  54791. */
  54792. _effects: Array<PostProcess>;
  54793. /**
  54794. * @hidden Internal
  54795. */
  54796. _downscale: ExtractHighlightsPostProcess;
  54797. private _blurX;
  54798. private _blurY;
  54799. private _merge;
  54800. /**
  54801. * The luminance threshold to find bright areas of the image to bloom.
  54802. */
  54803. threshold: number;
  54804. /**
  54805. * The strength of the bloom.
  54806. */
  54807. weight: number;
  54808. /**
  54809. * Specifies the size of the bloom blur kernel, relative to the final output size
  54810. */
  54811. kernel: number;
  54812. /**
  54813. * Creates a new instance of @see BloomEffect
  54814. * @param scene The scene the effect belongs to.
  54815. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  54816. * @param bloomKernel The size of the kernel to be used when applying the blur.
  54817. * @param bloomWeight The the strength of bloom.
  54818. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  54819. * @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)
  54820. */
  54821. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  54822. /**
  54823. * Disposes each of the internal effects for a given camera.
  54824. * @param camera The camera to dispose the effect on.
  54825. */
  54826. disposeEffects(camera: Camera): void;
  54827. /**
  54828. * @hidden Internal
  54829. */
  54830. _updateEffects(): void;
  54831. /**
  54832. * Internal
  54833. * @returns if all the contained post processes are ready.
  54834. * @hidden
  54835. */
  54836. _isReady(): boolean;
  54837. }
  54838. }
  54839. declare module BABYLON {
  54840. /** @hidden */
  54841. export var chromaticAberrationPixelShader: {
  54842. name: string;
  54843. shader: string;
  54844. };
  54845. }
  54846. declare module BABYLON {
  54847. /**
  54848. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  54849. */
  54850. export class ChromaticAberrationPostProcess extends PostProcess {
  54851. /**
  54852. * The amount of seperation of rgb channels (default: 30)
  54853. */
  54854. aberrationAmount: number;
  54855. /**
  54856. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  54857. */
  54858. radialIntensity: number;
  54859. /**
  54860. * 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))
  54861. */
  54862. direction: Vector2;
  54863. /**
  54864. * 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))
  54865. */
  54866. centerPosition: Vector2;
  54867. /**
  54868. * Creates a new instance ChromaticAberrationPostProcess
  54869. * @param name The name of the effect.
  54870. * @param screenWidth The width of the screen to apply the effect on.
  54871. * @param screenHeight The height of the screen to apply the effect on.
  54872. * @param options The required width/height ratio to downsize to before computing the render pass.
  54873. * @param camera The camera to apply the render pass to.
  54874. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54875. * @param engine The engine which the post process will be applied. (default: current engine)
  54876. * @param reusable If the post process can be reused on the same frame. (default: false)
  54877. * @param textureType Type of textures used when performing the post process. (default: 0)
  54878. * @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)
  54879. */
  54880. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  54881. }
  54882. }
  54883. declare module BABYLON {
  54884. /** @hidden */
  54885. export var circleOfConfusionPixelShader: {
  54886. name: string;
  54887. shader: string;
  54888. };
  54889. }
  54890. declare module BABYLON {
  54891. /**
  54892. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  54893. */
  54894. export class CircleOfConfusionPostProcess extends PostProcess {
  54895. /**
  54896. * 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.
  54897. */
  54898. lensSize: number;
  54899. /**
  54900. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  54901. */
  54902. fStop: number;
  54903. /**
  54904. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  54905. */
  54906. focusDistance: number;
  54907. /**
  54908. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  54909. */
  54910. focalLength: number;
  54911. private _depthTexture;
  54912. /**
  54913. * Creates a new instance CircleOfConfusionPostProcess
  54914. * @param name The name of the effect.
  54915. * @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.
  54916. * @param options The required width/height ratio to downsize to before computing the render pass.
  54917. * @param camera The camera to apply the render pass to.
  54918. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54919. * @param engine The engine which the post process will be applied. (default: current engine)
  54920. * @param reusable If the post process can be reused on the same frame. (default: false)
  54921. * @param textureType Type of textures used when performing the post process. (default: 0)
  54922. * @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)
  54923. */
  54924. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  54925. /**
  54926. * 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.
  54927. */
  54928. depthTexture: RenderTargetTexture;
  54929. }
  54930. }
  54931. declare module BABYLON {
  54932. /** @hidden */
  54933. export var colorCorrectionPixelShader: {
  54934. name: string;
  54935. shader: string;
  54936. };
  54937. }
  54938. declare module BABYLON {
  54939. /**
  54940. *
  54941. * This post-process allows the modification of rendered colors by using
  54942. * a 'look-up table' (LUT). This effect is also called Color Grading.
  54943. *
  54944. * The object needs to be provided an url to a texture containing the color
  54945. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  54946. * Use an image editing software to tweak the LUT to match your needs.
  54947. *
  54948. * For an example of a color LUT, see here:
  54949. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  54950. * For explanations on color grading, see here:
  54951. * @see http://udn.epicgames.com/Three/ColorGrading.html
  54952. *
  54953. */
  54954. export class ColorCorrectionPostProcess extends PostProcess {
  54955. private _colorTableTexture;
  54956. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  54957. }
  54958. }
  54959. declare module BABYLON {
  54960. /** @hidden */
  54961. export var convolutionPixelShader: {
  54962. name: string;
  54963. shader: string;
  54964. };
  54965. }
  54966. declare module BABYLON {
  54967. /**
  54968. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  54969. * input texture to perform effects such as edge detection or sharpening
  54970. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  54971. */
  54972. export class ConvolutionPostProcess extends PostProcess {
  54973. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  54974. kernel: number[];
  54975. /**
  54976. * Creates a new instance ConvolutionPostProcess
  54977. * @param name The name of the effect.
  54978. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  54979. * @param options The required width/height ratio to downsize to before computing the render pass.
  54980. * @param camera The camera to apply the render pass to.
  54981. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54982. * @param engine The engine which the post process will be applied. (default: current engine)
  54983. * @param reusable If the post process can be reused on the same frame. (default: false)
  54984. * @param textureType Type of textures used when performing the post process. (default: 0)
  54985. */
  54986. constructor(name: string,
  54987. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  54988. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  54989. /**
  54990. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  54991. */
  54992. static EdgeDetect0Kernel: number[];
  54993. /**
  54994. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  54995. */
  54996. static EdgeDetect1Kernel: number[];
  54997. /**
  54998. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  54999. */
  55000. static EdgeDetect2Kernel: number[];
  55001. /**
  55002. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  55003. */
  55004. static SharpenKernel: number[];
  55005. /**
  55006. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  55007. */
  55008. static EmbossKernel: number[];
  55009. /**
  55010. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  55011. */
  55012. static GaussianKernel: number[];
  55013. }
  55014. }
  55015. declare module BABYLON {
  55016. /**
  55017. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  55018. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  55019. * based on samples that have a large difference in distance than the center pixel.
  55020. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  55021. */
  55022. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  55023. direction: Vector2;
  55024. /**
  55025. * Creates a new instance CircleOfConfusionPostProcess
  55026. * @param name The name of the effect.
  55027. * @param scene The scene the effect belongs to.
  55028. * @param direction The direction the blur should be applied.
  55029. * @param kernel The size of the kernel used to blur.
  55030. * @param options The required width/height ratio to downsize to before computing the render pass.
  55031. * @param camera The camera to apply the render pass to.
  55032. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  55033. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  55034. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55035. * @param engine The engine which the post process will be applied. (default: current engine)
  55036. * @param reusable If the post process can be reused on the same frame. (default: false)
  55037. * @param textureType Type of textures used when performing the post process. (default: 0)
  55038. * @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)
  55039. */
  55040. 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);
  55041. }
  55042. }
  55043. declare module BABYLON {
  55044. /** @hidden */
  55045. export var depthOfFieldMergePixelShader: {
  55046. name: string;
  55047. shader: string;
  55048. };
  55049. }
  55050. declare module BABYLON {
  55051. /**
  55052. * Options to be set when merging outputs from the default pipeline.
  55053. */
  55054. export class DepthOfFieldMergePostProcessOptions {
  55055. /**
  55056. * The original image to merge on top of
  55057. */
  55058. originalFromInput: PostProcess;
  55059. /**
  55060. * Parameters to perform the merge of the depth of field effect
  55061. */
  55062. depthOfField?: {
  55063. circleOfConfusion: PostProcess;
  55064. blurSteps: Array<PostProcess>;
  55065. };
  55066. /**
  55067. * Parameters to perform the merge of bloom effect
  55068. */
  55069. bloom?: {
  55070. blurred: PostProcess;
  55071. weight: number;
  55072. };
  55073. }
  55074. /**
  55075. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  55076. */
  55077. export class DepthOfFieldMergePostProcess extends PostProcess {
  55078. private blurSteps;
  55079. /**
  55080. * Creates a new instance of DepthOfFieldMergePostProcess
  55081. * @param name The name of the effect.
  55082. * @param originalFromInput Post process which's input will be used for the merge.
  55083. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  55084. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  55085. * @param options The required width/height ratio to downsize to before computing the render pass.
  55086. * @param camera The camera to apply the render pass to.
  55087. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55088. * @param engine The engine which the post process will be applied. (default: current engine)
  55089. * @param reusable If the post process can be reused on the same frame. (default: false)
  55090. * @param textureType Type of textures used when performing the post process. (default: 0)
  55091. * @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)
  55092. */
  55093. 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);
  55094. /**
  55095. * Updates the effect with the current post process compile time values and recompiles the shader.
  55096. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  55097. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  55098. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  55099. * @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
  55100. * @param onCompiled Called when the shader has been compiled.
  55101. * @param onError Called if there is an error when compiling a shader.
  55102. */
  55103. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  55104. }
  55105. }
  55106. declare module BABYLON {
  55107. /**
  55108. * Specifies the level of max blur that should be applied when using the depth of field effect
  55109. */
  55110. export enum DepthOfFieldEffectBlurLevel {
  55111. /**
  55112. * Subtle blur
  55113. */
  55114. Low = 0,
  55115. /**
  55116. * Medium blur
  55117. */
  55118. Medium = 1,
  55119. /**
  55120. * Large blur
  55121. */
  55122. High = 2
  55123. }
  55124. /**
  55125. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  55126. */
  55127. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  55128. private _circleOfConfusion;
  55129. /**
  55130. * @hidden Internal, blurs from high to low
  55131. */
  55132. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  55133. private _depthOfFieldBlurY;
  55134. private _dofMerge;
  55135. /**
  55136. * @hidden Internal post processes in depth of field effect
  55137. */
  55138. _effects: Array<PostProcess>;
  55139. /**
  55140. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  55141. */
  55142. focalLength: number;
  55143. /**
  55144. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  55145. */
  55146. fStop: number;
  55147. /**
  55148. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  55149. */
  55150. focusDistance: number;
  55151. /**
  55152. * 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.
  55153. */
  55154. lensSize: number;
  55155. /**
  55156. * Creates a new instance DepthOfFieldEffect
  55157. * @param scene The scene the effect belongs to.
  55158. * @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.
  55159. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  55160. * @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)
  55161. */
  55162. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  55163. /**
  55164. * Get the current class name of the current effet
  55165. * @returns "DepthOfFieldEffect"
  55166. */
  55167. getClassName(): string;
  55168. /**
  55169. * 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.
  55170. */
  55171. depthTexture: RenderTargetTexture;
  55172. /**
  55173. * Disposes each of the internal effects for a given camera.
  55174. * @param camera The camera to dispose the effect on.
  55175. */
  55176. disposeEffects(camera: Camera): void;
  55177. /**
  55178. * @hidden Internal
  55179. */
  55180. _updateEffects(): void;
  55181. /**
  55182. * Internal
  55183. * @returns if all the contained post processes are ready.
  55184. * @hidden
  55185. */
  55186. _isReady(): boolean;
  55187. }
  55188. }
  55189. declare module BABYLON {
  55190. /** @hidden */
  55191. export var displayPassPixelShader: {
  55192. name: string;
  55193. shader: string;
  55194. };
  55195. }
  55196. declare module BABYLON {
  55197. /**
  55198. * DisplayPassPostProcess which produces an output the same as it's input
  55199. */
  55200. export class DisplayPassPostProcess extends PostProcess {
  55201. /**
  55202. * Creates the DisplayPassPostProcess
  55203. * @param name The name of the effect.
  55204. * @param options The required width/height ratio to downsize to before computing the render pass.
  55205. * @param camera The camera to apply the render pass to.
  55206. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55207. * @param engine The engine which the post process will be applied. (default: current engine)
  55208. * @param reusable If the post process can be reused on the same frame. (default: false)
  55209. */
  55210. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  55211. }
  55212. }
  55213. declare module BABYLON {
  55214. /** @hidden */
  55215. export var filterPixelShader: {
  55216. name: string;
  55217. shader: string;
  55218. };
  55219. }
  55220. declare module BABYLON {
  55221. /**
  55222. * Applies a kernel filter to the image
  55223. */
  55224. export class FilterPostProcess extends PostProcess {
  55225. /** The matrix to be applied to the image */
  55226. kernelMatrix: Matrix;
  55227. /**
  55228. *
  55229. * @param name The name of the effect.
  55230. * @param kernelMatrix The matrix to be applied to the image
  55231. * @param options The required width/height ratio to downsize to before computing the render pass.
  55232. * @param camera The camera to apply the render pass to.
  55233. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55234. * @param engine The engine which the post process will be applied. (default: current engine)
  55235. * @param reusable If the post process can be reused on the same frame. (default: false)
  55236. */
  55237. constructor(name: string,
  55238. /** The matrix to be applied to the image */
  55239. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  55240. }
  55241. }
  55242. declare module BABYLON {
  55243. /** @hidden */
  55244. export var fxaaPixelShader: {
  55245. name: string;
  55246. shader: string;
  55247. };
  55248. }
  55249. declare module BABYLON {
  55250. /** @hidden */
  55251. export var fxaaVertexShader: {
  55252. name: string;
  55253. shader: string;
  55254. };
  55255. }
  55256. declare module BABYLON {
  55257. /**
  55258. * Fxaa post process
  55259. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  55260. */
  55261. export class FxaaPostProcess extends PostProcess {
  55262. /** @hidden */
  55263. texelWidth: number;
  55264. /** @hidden */
  55265. texelHeight: number;
  55266. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  55267. private _getDefines;
  55268. }
  55269. }
  55270. declare module BABYLON {
  55271. /** @hidden */
  55272. export var grainPixelShader: {
  55273. name: string;
  55274. shader: string;
  55275. };
  55276. }
  55277. declare module BABYLON {
  55278. /**
  55279. * The GrainPostProcess adds noise to the image at mid luminance levels
  55280. */
  55281. export class GrainPostProcess extends PostProcess {
  55282. /**
  55283. * The intensity of the grain added (default: 30)
  55284. */
  55285. intensity: number;
  55286. /**
  55287. * If the grain should be randomized on every frame
  55288. */
  55289. animated: boolean;
  55290. /**
  55291. * Creates a new instance of @see GrainPostProcess
  55292. * @param name The name of the effect.
  55293. * @param options The required width/height ratio to downsize to before computing the render pass.
  55294. * @param camera The camera to apply the render pass to.
  55295. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55296. * @param engine The engine which the post process will be applied. (default: current engine)
  55297. * @param reusable If the post process can be reused on the same frame. (default: false)
  55298. * @param textureType Type of textures used when performing the post process. (default: 0)
  55299. * @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)
  55300. */
  55301. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  55302. }
  55303. }
  55304. declare module BABYLON {
  55305. /** @hidden */
  55306. export var highlightsPixelShader: {
  55307. name: string;
  55308. shader: string;
  55309. };
  55310. }
  55311. declare module BABYLON {
  55312. /**
  55313. * Extracts highlights from the image
  55314. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  55315. */
  55316. export class HighlightsPostProcess extends PostProcess {
  55317. /**
  55318. * Extracts highlights from the image
  55319. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  55320. * @param name The name of the effect.
  55321. * @param options The required width/height ratio to downsize to before computing the render pass.
  55322. * @param camera The camera to apply the render pass to.
  55323. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55324. * @param engine The engine which the post process will be applied. (default: current engine)
  55325. * @param reusable If the post process can be reused on the same frame. (default: false)
  55326. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  55327. */
  55328. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  55329. }
  55330. }
  55331. declare module BABYLON {
  55332. /** @hidden */
  55333. export var mrtFragmentDeclaration: {
  55334. name: string;
  55335. shader: string;
  55336. };
  55337. }
  55338. declare module BABYLON {
  55339. /** @hidden */
  55340. export var geometryPixelShader: {
  55341. name: string;
  55342. shader: string;
  55343. };
  55344. }
  55345. declare module BABYLON {
  55346. /** @hidden */
  55347. export var geometryVertexShader: {
  55348. name: string;
  55349. shader: string;
  55350. };
  55351. }
  55352. declare module BABYLON {
  55353. /** @hidden */
  55354. interface ISavedTransformationMatrix {
  55355. world: Matrix;
  55356. viewProjection: Matrix;
  55357. }
  55358. /**
  55359. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  55360. */
  55361. export class GeometryBufferRenderer {
  55362. /**
  55363. * Constant used to retrieve the position texture index in the G-Buffer textures array
  55364. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  55365. */
  55366. static readonly POSITION_TEXTURE_TYPE: number;
  55367. /**
  55368. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  55369. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  55370. */
  55371. static readonly VELOCITY_TEXTURE_TYPE: number;
  55372. /**
  55373. * Dictionary used to store the previous transformation matrices of each rendered mesh
  55374. * in order to compute objects velocities when enableVelocity is set to "true"
  55375. * @hidden
  55376. */
  55377. _previousTransformationMatrices: {
  55378. [index: number]: ISavedTransformationMatrix;
  55379. };
  55380. /**
  55381. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  55382. * in order to compute objects velocities when enableVelocity is set to "true"
  55383. * @hidden
  55384. */
  55385. _previousBonesTransformationMatrices: {
  55386. [index: number]: Float32Array;
  55387. };
  55388. /**
  55389. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  55390. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  55391. */
  55392. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  55393. private _scene;
  55394. private _multiRenderTarget;
  55395. private _ratio;
  55396. private _enablePosition;
  55397. private _enableVelocity;
  55398. private _positionIndex;
  55399. private _velocityIndex;
  55400. protected _effect: Effect;
  55401. protected _cachedDefines: string;
  55402. /**
  55403. * Set the render list (meshes to be rendered) used in the G buffer.
  55404. */
  55405. renderList: Mesh[];
  55406. /**
  55407. * Gets wether or not G buffer are supported by the running hardware.
  55408. * This requires draw buffer supports
  55409. */
  55410. readonly isSupported: boolean;
  55411. /**
  55412. * Returns the index of the given texture type in the G-Buffer textures array
  55413. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  55414. * @returns the index of the given texture type in the G-Buffer textures array
  55415. */
  55416. getTextureIndex(textureType: number): number;
  55417. /**
  55418. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  55419. */
  55420. /**
  55421. * Sets whether or not objects positions are enabled for the G buffer.
  55422. */
  55423. enablePosition: boolean;
  55424. /**
  55425. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  55426. */
  55427. /**
  55428. * Sets wether or not objects velocities are enabled for the G buffer.
  55429. */
  55430. enableVelocity: boolean;
  55431. /**
  55432. * Gets the scene associated with the buffer.
  55433. */
  55434. readonly scene: Scene;
  55435. /**
  55436. * Gets the ratio used by the buffer during its creation.
  55437. * How big is the buffer related to the main canvas.
  55438. */
  55439. readonly ratio: number;
  55440. /** @hidden */
  55441. static _SceneComponentInitialization: (scene: Scene) => void;
  55442. /**
  55443. * Creates a new G Buffer for the scene
  55444. * @param scene The scene the buffer belongs to
  55445. * @param ratio How big is the buffer related to the main canvas.
  55446. */
  55447. constructor(scene: Scene, ratio?: number);
  55448. /**
  55449. * Checks wether everything is ready to render a submesh to the G buffer.
  55450. * @param subMesh the submesh to check readiness for
  55451. * @param useInstances is the mesh drawn using instance or not
  55452. * @returns true if ready otherwise false
  55453. */
  55454. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  55455. /**
  55456. * Gets the current underlying G Buffer.
  55457. * @returns the buffer
  55458. */
  55459. getGBuffer(): MultiRenderTarget;
  55460. /**
  55461. * Gets the number of samples used to render the buffer (anti aliasing).
  55462. */
  55463. /**
  55464. * Sets the number of samples used to render the buffer (anti aliasing).
  55465. */
  55466. samples: number;
  55467. /**
  55468. * Disposes the renderer and frees up associated resources.
  55469. */
  55470. dispose(): void;
  55471. protected _createRenderTargets(): void;
  55472. private _copyBonesTransformationMatrices;
  55473. }
  55474. }
  55475. declare module BABYLON {
  55476. interface Scene {
  55477. /** @hidden (Backing field) */
  55478. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  55479. /**
  55480. * Gets or Sets the current geometry buffer associated to the scene.
  55481. */
  55482. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  55483. /**
  55484. * Enables a GeometryBufferRender and associates it with the scene
  55485. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  55486. * @returns the GeometryBufferRenderer
  55487. */
  55488. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  55489. /**
  55490. * Disables the GeometryBufferRender associated with the scene
  55491. */
  55492. disableGeometryBufferRenderer(): void;
  55493. }
  55494. /**
  55495. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  55496. * in several rendering techniques.
  55497. */
  55498. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  55499. /**
  55500. * The component name helpful to identify the component in the list of scene components.
  55501. */
  55502. readonly name: string;
  55503. /**
  55504. * The scene the component belongs to.
  55505. */
  55506. scene: Scene;
  55507. /**
  55508. * Creates a new instance of the component for the given scene
  55509. * @param scene Defines the scene to register the component in
  55510. */
  55511. constructor(scene: Scene);
  55512. /**
  55513. * Registers the component in a given scene
  55514. */
  55515. register(): void;
  55516. /**
  55517. * Rebuilds the elements related to this component in case of
  55518. * context lost for instance.
  55519. */
  55520. rebuild(): void;
  55521. /**
  55522. * Disposes the component and the associated ressources
  55523. */
  55524. dispose(): void;
  55525. private _gatherRenderTargets;
  55526. }
  55527. }
  55528. declare module BABYLON {
  55529. /** @hidden */
  55530. export var motionBlurPixelShader: {
  55531. name: string;
  55532. shader: string;
  55533. };
  55534. }
  55535. declare module BABYLON {
  55536. /**
  55537. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  55538. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  55539. * As an example, all you have to do is to create the post-process:
  55540. * var mb = new BABYLON.MotionBlurPostProcess(
  55541. * 'mb', // The name of the effect.
  55542. * scene, // The scene containing the objects to blur according to their velocity.
  55543. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  55544. * camera // The camera to apply the render pass to.
  55545. * );
  55546. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  55547. */
  55548. export class MotionBlurPostProcess extends PostProcess {
  55549. /**
  55550. * Defines how much the image is blurred by the movement. Default value is equal to 1
  55551. */
  55552. motionStrength: number;
  55553. /**
  55554. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  55555. */
  55556. /**
  55557. * Sets the number of iterations to be used for motion blur quality
  55558. */
  55559. motionBlurSamples: number;
  55560. private _motionBlurSamples;
  55561. private _geometryBufferRenderer;
  55562. /**
  55563. * Creates a new instance MotionBlurPostProcess
  55564. * @param name The name of the effect.
  55565. * @param scene The scene containing the objects to blur according to their velocity.
  55566. * @param options The required width/height ratio to downsize to before computing the render pass.
  55567. * @param camera The camera to apply the render pass to.
  55568. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55569. * @param engine The engine which the post process will be applied. (default: current engine)
  55570. * @param reusable If the post process can be reused on the same frame. (default: false)
  55571. * @param textureType Type of textures used when performing the post process. (default: 0)
  55572. * @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)
  55573. */
  55574. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  55575. /**
  55576. * Excludes the given skinned mesh from computing bones velocities.
  55577. * 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.
  55578. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  55579. */
  55580. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  55581. /**
  55582. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  55583. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  55584. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  55585. */
  55586. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  55587. /**
  55588. * Disposes the post process.
  55589. * @param camera The camera to dispose the post process on.
  55590. */
  55591. dispose(camera?: Camera): void;
  55592. }
  55593. }
  55594. declare module BABYLON {
  55595. /** @hidden */
  55596. export var refractionPixelShader: {
  55597. name: string;
  55598. shader: string;
  55599. };
  55600. }
  55601. declare module BABYLON {
  55602. /**
  55603. * Post process which applies a refractin texture
  55604. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  55605. */
  55606. export class RefractionPostProcess extends PostProcess {
  55607. /** the base color of the refraction (used to taint the rendering) */
  55608. color: Color3;
  55609. /** simulated refraction depth */
  55610. depth: number;
  55611. /** the coefficient of the base color (0 to remove base color tainting) */
  55612. colorLevel: number;
  55613. private _refTexture;
  55614. private _ownRefractionTexture;
  55615. /**
  55616. * Gets or sets the refraction texture
  55617. * Please note that you are responsible for disposing the texture if you set it manually
  55618. */
  55619. refractionTexture: Texture;
  55620. /**
  55621. * Initializes the RefractionPostProcess
  55622. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  55623. * @param name The name of the effect.
  55624. * @param refractionTextureUrl Url of the refraction texture to use
  55625. * @param color the base color of the refraction (used to taint the rendering)
  55626. * @param depth simulated refraction depth
  55627. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  55628. * @param camera The camera to apply the render pass to.
  55629. * @param options The required width/height ratio to downsize to before computing the render pass.
  55630. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55631. * @param engine The engine which the post process will be applied. (default: current engine)
  55632. * @param reusable If the post process can be reused on the same frame. (default: false)
  55633. */
  55634. constructor(name: string, refractionTextureUrl: string,
  55635. /** the base color of the refraction (used to taint the rendering) */
  55636. color: Color3,
  55637. /** simulated refraction depth */
  55638. depth: number,
  55639. /** the coefficient of the base color (0 to remove base color tainting) */
  55640. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  55641. /**
  55642. * Disposes of the post process
  55643. * @param camera Camera to dispose post process on
  55644. */
  55645. dispose(camera: Camera): void;
  55646. }
  55647. }
  55648. declare module BABYLON {
  55649. /** @hidden */
  55650. export var sharpenPixelShader: {
  55651. name: string;
  55652. shader: string;
  55653. };
  55654. }
  55655. declare module BABYLON {
  55656. /**
  55657. * The SharpenPostProcess applies a sharpen kernel to every pixel
  55658. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  55659. */
  55660. export class SharpenPostProcess extends PostProcess {
  55661. /**
  55662. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  55663. */
  55664. colorAmount: number;
  55665. /**
  55666. * How much sharpness should be applied (default: 0.3)
  55667. */
  55668. edgeAmount: number;
  55669. /**
  55670. * Creates a new instance ConvolutionPostProcess
  55671. * @param name The name of the effect.
  55672. * @param options The required width/height ratio to downsize to before computing the render pass.
  55673. * @param camera The camera to apply the render pass to.
  55674. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55675. * @param engine The engine which the post process will be applied. (default: current engine)
  55676. * @param reusable If the post process can be reused on the same frame. (default: false)
  55677. * @param textureType Type of textures used when performing the post process. (default: 0)
  55678. * @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)
  55679. */
  55680. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  55681. }
  55682. }
  55683. declare module BABYLON {
  55684. /**
  55685. * PostProcessRenderPipeline
  55686. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  55687. */
  55688. export class PostProcessRenderPipeline {
  55689. private engine;
  55690. private _renderEffects;
  55691. private _renderEffectsForIsolatedPass;
  55692. /**
  55693. * List of inspectable custom properties (used by the Inspector)
  55694. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  55695. */
  55696. inspectableCustomProperties: IInspectable[];
  55697. /**
  55698. * @hidden
  55699. */
  55700. protected _cameras: Camera[];
  55701. /** @hidden */
  55702. _name: string;
  55703. /**
  55704. * Gets pipeline name
  55705. */
  55706. readonly name: string;
  55707. /**
  55708. * Initializes a PostProcessRenderPipeline
  55709. * @param engine engine to add the pipeline to
  55710. * @param name name of the pipeline
  55711. */
  55712. constructor(engine: Engine, name: string);
  55713. /**
  55714. * Gets the class name
  55715. * @returns "PostProcessRenderPipeline"
  55716. */
  55717. getClassName(): string;
  55718. /**
  55719. * If all the render effects in the pipeline are supported
  55720. */
  55721. readonly isSupported: boolean;
  55722. /**
  55723. * Adds an effect to the pipeline
  55724. * @param renderEffect the effect to add
  55725. */
  55726. addEffect(renderEffect: PostProcessRenderEffect): void;
  55727. /** @hidden */
  55728. _rebuild(): void;
  55729. /** @hidden */
  55730. _enableEffect(renderEffectName: string, cameras: Camera): void;
  55731. /** @hidden */
  55732. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  55733. /** @hidden */
  55734. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  55735. /** @hidden */
  55736. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  55737. /** @hidden */
  55738. _attachCameras(cameras: Camera, unique: boolean): void;
  55739. /** @hidden */
  55740. _attachCameras(cameras: Camera[], unique: boolean): void;
  55741. /** @hidden */
  55742. _detachCameras(cameras: Camera): void;
  55743. /** @hidden */
  55744. _detachCameras(cameras: Nullable<Camera[]>): void;
  55745. /** @hidden */
  55746. _update(): void;
  55747. /** @hidden */
  55748. _reset(): void;
  55749. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  55750. /**
  55751. * Disposes of the pipeline
  55752. */
  55753. dispose(): void;
  55754. }
  55755. }
  55756. declare module BABYLON {
  55757. /**
  55758. * PostProcessRenderPipelineManager class
  55759. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  55760. */
  55761. export class PostProcessRenderPipelineManager {
  55762. private _renderPipelines;
  55763. /**
  55764. * Initializes a PostProcessRenderPipelineManager
  55765. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  55766. */
  55767. constructor();
  55768. /**
  55769. * Gets the list of supported render pipelines
  55770. */
  55771. readonly supportedPipelines: PostProcessRenderPipeline[];
  55772. /**
  55773. * Adds a pipeline to the manager
  55774. * @param renderPipeline The pipeline to add
  55775. */
  55776. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  55777. /**
  55778. * Attaches a camera to the pipeline
  55779. * @param renderPipelineName The name of the pipeline to attach to
  55780. * @param cameras the camera to attach
  55781. * @param unique if the camera can be attached multiple times to the pipeline
  55782. */
  55783. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  55784. /**
  55785. * Detaches a camera from the pipeline
  55786. * @param renderPipelineName The name of the pipeline to detach from
  55787. * @param cameras the camera to detach
  55788. */
  55789. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  55790. /**
  55791. * Enables an effect by name on a pipeline
  55792. * @param renderPipelineName the name of the pipeline to enable the effect in
  55793. * @param renderEffectName the name of the effect to enable
  55794. * @param cameras the cameras that the effect should be enabled on
  55795. */
  55796. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  55797. /**
  55798. * Disables an effect by name on a pipeline
  55799. * @param renderPipelineName the name of the pipeline to disable the effect in
  55800. * @param renderEffectName the name of the effect to disable
  55801. * @param cameras the cameras that the effect should be disabled on
  55802. */
  55803. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  55804. /**
  55805. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  55806. */
  55807. update(): void;
  55808. /** @hidden */
  55809. _rebuild(): void;
  55810. /**
  55811. * Disposes of the manager and pipelines
  55812. */
  55813. dispose(): void;
  55814. }
  55815. }
  55816. declare module BABYLON {
  55817. interface Scene {
  55818. /** @hidden (Backing field) */
  55819. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  55820. /**
  55821. * Gets the postprocess render pipeline manager
  55822. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  55823. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  55824. */
  55825. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  55826. }
  55827. /**
  55828. * Defines the Render Pipeline scene component responsible to rendering pipelines
  55829. */
  55830. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  55831. /**
  55832. * The component name helpfull to identify the component in the list of scene components.
  55833. */
  55834. readonly name: string;
  55835. /**
  55836. * The scene the component belongs to.
  55837. */
  55838. scene: Scene;
  55839. /**
  55840. * Creates a new instance of the component for the given scene
  55841. * @param scene Defines the scene to register the component in
  55842. */
  55843. constructor(scene: Scene);
  55844. /**
  55845. * Registers the component in a given scene
  55846. */
  55847. register(): void;
  55848. /**
  55849. * Rebuilds the elements related to this component in case of
  55850. * context lost for instance.
  55851. */
  55852. rebuild(): void;
  55853. /**
  55854. * Disposes the component and the associated ressources
  55855. */
  55856. dispose(): void;
  55857. private _gatherRenderTargets;
  55858. }
  55859. }
  55860. declare module BABYLON {
  55861. /**
  55862. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  55863. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  55864. */
  55865. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  55866. private _scene;
  55867. private _camerasToBeAttached;
  55868. /**
  55869. * ID of the sharpen post process,
  55870. */
  55871. private readonly SharpenPostProcessId;
  55872. /**
  55873. * @ignore
  55874. * ID of the image processing post process;
  55875. */
  55876. readonly ImageProcessingPostProcessId: string;
  55877. /**
  55878. * @ignore
  55879. * ID of the Fast Approximate Anti-Aliasing post process;
  55880. */
  55881. readonly FxaaPostProcessId: string;
  55882. /**
  55883. * ID of the chromatic aberration post process,
  55884. */
  55885. private readonly ChromaticAberrationPostProcessId;
  55886. /**
  55887. * ID of the grain post process
  55888. */
  55889. private readonly GrainPostProcessId;
  55890. /**
  55891. * Sharpen post process which will apply a sharpen convolution to enhance edges
  55892. */
  55893. sharpen: SharpenPostProcess;
  55894. private _sharpenEffect;
  55895. private bloom;
  55896. /**
  55897. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  55898. */
  55899. depthOfField: DepthOfFieldEffect;
  55900. /**
  55901. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  55902. */
  55903. fxaa: FxaaPostProcess;
  55904. /**
  55905. * Image post processing pass used to perform operations such as tone mapping or color grading.
  55906. */
  55907. imageProcessing: ImageProcessingPostProcess;
  55908. /**
  55909. * Chromatic aberration post process which will shift rgb colors in the image
  55910. */
  55911. chromaticAberration: ChromaticAberrationPostProcess;
  55912. private _chromaticAberrationEffect;
  55913. /**
  55914. * Grain post process which add noise to the image
  55915. */
  55916. grain: GrainPostProcess;
  55917. private _grainEffect;
  55918. /**
  55919. * Glow post process which adds a glow to emissive areas of the image
  55920. */
  55921. private _glowLayer;
  55922. /**
  55923. * Animations which can be used to tweak settings over a period of time
  55924. */
  55925. animations: Animation[];
  55926. private _imageProcessingConfigurationObserver;
  55927. private _sharpenEnabled;
  55928. private _bloomEnabled;
  55929. private _depthOfFieldEnabled;
  55930. private _depthOfFieldBlurLevel;
  55931. private _fxaaEnabled;
  55932. private _imageProcessingEnabled;
  55933. private _defaultPipelineTextureType;
  55934. private _bloomScale;
  55935. private _chromaticAberrationEnabled;
  55936. private _grainEnabled;
  55937. private _buildAllowed;
  55938. /**
  55939. * Gets active scene
  55940. */
  55941. readonly scene: Scene;
  55942. /**
  55943. * Enable or disable the sharpen process from the pipeline
  55944. */
  55945. sharpenEnabled: boolean;
  55946. private _resizeObserver;
  55947. private _hardwareScaleLevel;
  55948. private _bloomKernel;
  55949. /**
  55950. * Specifies the size of the bloom blur kernel, relative to the final output size
  55951. */
  55952. bloomKernel: number;
  55953. /**
  55954. * Specifies the weight of the bloom in the final rendering
  55955. */
  55956. private _bloomWeight;
  55957. /**
  55958. * Specifies the luma threshold for the area that will be blurred by the bloom
  55959. */
  55960. private _bloomThreshold;
  55961. private _hdr;
  55962. /**
  55963. * The strength of the bloom.
  55964. */
  55965. bloomWeight: number;
  55966. /**
  55967. * The strength of the bloom.
  55968. */
  55969. bloomThreshold: number;
  55970. /**
  55971. * The scale of the bloom, lower value will provide better performance.
  55972. */
  55973. bloomScale: number;
  55974. /**
  55975. * Enable or disable the bloom from the pipeline
  55976. */
  55977. bloomEnabled: boolean;
  55978. private _rebuildBloom;
  55979. /**
  55980. * If the depth of field is enabled.
  55981. */
  55982. depthOfFieldEnabled: boolean;
  55983. /**
  55984. * Blur level of the depth of field effect. (Higher blur will effect performance)
  55985. */
  55986. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  55987. /**
  55988. * If the anti aliasing is enabled.
  55989. */
  55990. fxaaEnabled: boolean;
  55991. private _samples;
  55992. /**
  55993. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  55994. */
  55995. samples: number;
  55996. /**
  55997. * If image processing is enabled.
  55998. */
  55999. imageProcessingEnabled: boolean;
  56000. /**
  56001. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  56002. */
  56003. glowLayerEnabled: boolean;
  56004. /**
  56005. * Gets the glow layer (or null if not defined)
  56006. */
  56007. readonly glowLayer: Nullable<GlowLayer>;
  56008. /**
  56009. * Enable or disable the chromaticAberration process from the pipeline
  56010. */
  56011. chromaticAberrationEnabled: boolean;
  56012. /**
  56013. * Enable or disable the grain process from the pipeline
  56014. */
  56015. grainEnabled: boolean;
  56016. /**
  56017. * @constructor
  56018. * @param name - The rendering pipeline name (default: "")
  56019. * @param hdr - If high dynamic range textures should be used (default: true)
  56020. * @param scene - The scene linked to this pipeline (default: the last created scene)
  56021. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  56022. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  56023. */
  56024. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  56025. /**
  56026. * Get the class name
  56027. * @returns "DefaultRenderingPipeline"
  56028. */
  56029. getClassName(): string;
  56030. /**
  56031. * Force the compilation of the entire pipeline.
  56032. */
  56033. prepare(): void;
  56034. private _hasCleared;
  56035. private _prevPostProcess;
  56036. private _prevPrevPostProcess;
  56037. private _setAutoClearAndTextureSharing;
  56038. private _depthOfFieldSceneObserver;
  56039. private _buildPipeline;
  56040. private _disposePostProcesses;
  56041. /**
  56042. * Adds a camera to the pipeline
  56043. * @param camera the camera to be added
  56044. */
  56045. addCamera(camera: Camera): void;
  56046. /**
  56047. * Removes a camera from the pipeline
  56048. * @param camera the camera to remove
  56049. */
  56050. removeCamera(camera: Camera): void;
  56051. /**
  56052. * Dispose of the pipeline and stop all post processes
  56053. */
  56054. dispose(): void;
  56055. /**
  56056. * Serialize the rendering pipeline (Used when exporting)
  56057. * @returns the serialized object
  56058. */
  56059. serialize(): any;
  56060. /**
  56061. * Parse the serialized pipeline
  56062. * @param source Source pipeline.
  56063. * @param scene The scene to load the pipeline to.
  56064. * @param rootUrl The URL of the serialized pipeline.
  56065. * @returns An instantiated pipeline from the serialized object.
  56066. */
  56067. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  56068. }
  56069. }
  56070. declare module BABYLON {
  56071. /** @hidden */
  56072. export var lensHighlightsPixelShader: {
  56073. name: string;
  56074. shader: string;
  56075. };
  56076. }
  56077. declare module BABYLON {
  56078. /** @hidden */
  56079. export var depthOfFieldPixelShader: {
  56080. name: string;
  56081. shader: string;
  56082. };
  56083. }
  56084. declare module BABYLON {
  56085. /**
  56086. * BABYLON.JS Chromatic Aberration GLSL Shader
  56087. * Author: Olivier Guyot
  56088. * Separates very slightly R, G and B colors on the edges of the screen
  56089. * Inspired by Francois Tarlier & Martins Upitis
  56090. */
  56091. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  56092. /**
  56093. * @ignore
  56094. * The chromatic aberration PostProcess id in the pipeline
  56095. */
  56096. LensChromaticAberrationEffect: string;
  56097. /**
  56098. * @ignore
  56099. * The highlights enhancing PostProcess id in the pipeline
  56100. */
  56101. HighlightsEnhancingEffect: string;
  56102. /**
  56103. * @ignore
  56104. * The depth-of-field PostProcess id in the pipeline
  56105. */
  56106. LensDepthOfFieldEffect: string;
  56107. private _scene;
  56108. private _depthTexture;
  56109. private _grainTexture;
  56110. private _chromaticAberrationPostProcess;
  56111. private _highlightsPostProcess;
  56112. private _depthOfFieldPostProcess;
  56113. private _edgeBlur;
  56114. private _grainAmount;
  56115. private _chromaticAberration;
  56116. private _distortion;
  56117. private _highlightsGain;
  56118. private _highlightsThreshold;
  56119. private _dofDistance;
  56120. private _dofAperture;
  56121. private _dofDarken;
  56122. private _dofPentagon;
  56123. private _blurNoise;
  56124. /**
  56125. * @constructor
  56126. *
  56127. * Effect parameters are as follow:
  56128. * {
  56129. * chromatic_aberration: number; // from 0 to x (1 for realism)
  56130. * edge_blur: number; // from 0 to x (1 for realism)
  56131. * distortion: number; // from 0 to x (1 for realism)
  56132. * grain_amount: number; // from 0 to 1
  56133. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  56134. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  56135. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  56136. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  56137. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  56138. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  56139. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  56140. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  56141. * }
  56142. * Note: if an effect parameter is unset, effect is disabled
  56143. *
  56144. * @param name The rendering pipeline name
  56145. * @param parameters - An object containing all parameters (see above)
  56146. * @param scene The scene linked to this pipeline
  56147. * @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)
  56148. * @param cameras The array of cameras that the rendering pipeline will be attached to
  56149. */
  56150. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  56151. /**
  56152. * Get the class name
  56153. * @returns "LensRenderingPipeline"
  56154. */
  56155. getClassName(): string;
  56156. /**
  56157. * Gets associated scene
  56158. */
  56159. readonly scene: Scene;
  56160. /**
  56161. * Gets or sets the edge blur
  56162. */
  56163. edgeBlur: number;
  56164. /**
  56165. * Gets or sets the grain amount
  56166. */
  56167. grainAmount: number;
  56168. /**
  56169. * Gets or sets the chromatic aberration amount
  56170. */
  56171. chromaticAberration: number;
  56172. /**
  56173. * Gets or sets the depth of field aperture
  56174. */
  56175. dofAperture: number;
  56176. /**
  56177. * Gets or sets the edge distortion
  56178. */
  56179. edgeDistortion: number;
  56180. /**
  56181. * Gets or sets the depth of field distortion
  56182. */
  56183. dofDistortion: number;
  56184. /**
  56185. * Gets or sets the darken out of focus amount
  56186. */
  56187. darkenOutOfFocus: number;
  56188. /**
  56189. * Gets or sets a boolean indicating if blur noise is enabled
  56190. */
  56191. blurNoise: boolean;
  56192. /**
  56193. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  56194. */
  56195. pentagonBokeh: boolean;
  56196. /**
  56197. * Gets or sets the highlight grain amount
  56198. */
  56199. highlightsGain: number;
  56200. /**
  56201. * Gets or sets the highlight threshold
  56202. */
  56203. highlightsThreshold: number;
  56204. /**
  56205. * Sets the amount of blur at the edges
  56206. * @param amount blur amount
  56207. */
  56208. setEdgeBlur(amount: number): void;
  56209. /**
  56210. * Sets edge blur to 0
  56211. */
  56212. disableEdgeBlur(): void;
  56213. /**
  56214. * Sets the amout of grain
  56215. * @param amount Amount of grain
  56216. */
  56217. setGrainAmount(amount: number): void;
  56218. /**
  56219. * Set grain amount to 0
  56220. */
  56221. disableGrain(): void;
  56222. /**
  56223. * Sets the chromatic aberration amount
  56224. * @param amount amount of chromatic aberration
  56225. */
  56226. setChromaticAberration(amount: number): void;
  56227. /**
  56228. * Sets chromatic aberration amount to 0
  56229. */
  56230. disableChromaticAberration(): void;
  56231. /**
  56232. * Sets the EdgeDistortion amount
  56233. * @param amount amount of EdgeDistortion
  56234. */
  56235. setEdgeDistortion(amount: number): void;
  56236. /**
  56237. * Sets edge distortion to 0
  56238. */
  56239. disableEdgeDistortion(): void;
  56240. /**
  56241. * Sets the FocusDistance amount
  56242. * @param amount amount of FocusDistance
  56243. */
  56244. setFocusDistance(amount: number): void;
  56245. /**
  56246. * Disables depth of field
  56247. */
  56248. disableDepthOfField(): void;
  56249. /**
  56250. * Sets the Aperture amount
  56251. * @param amount amount of Aperture
  56252. */
  56253. setAperture(amount: number): void;
  56254. /**
  56255. * Sets the DarkenOutOfFocus amount
  56256. * @param amount amount of DarkenOutOfFocus
  56257. */
  56258. setDarkenOutOfFocus(amount: number): void;
  56259. private _pentagonBokehIsEnabled;
  56260. /**
  56261. * Creates a pentagon bokeh effect
  56262. */
  56263. enablePentagonBokeh(): void;
  56264. /**
  56265. * Disables the pentagon bokeh effect
  56266. */
  56267. disablePentagonBokeh(): void;
  56268. /**
  56269. * Enables noise blur
  56270. */
  56271. enableNoiseBlur(): void;
  56272. /**
  56273. * Disables noise blur
  56274. */
  56275. disableNoiseBlur(): void;
  56276. /**
  56277. * Sets the HighlightsGain amount
  56278. * @param amount amount of HighlightsGain
  56279. */
  56280. setHighlightsGain(amount: number): void;
  56281. /**
  56282. * Sets the HighlightsThreshold amount
  56283. * @param amount amount of HighlightsThreshold
  56284. */
  56285. setHighlightsThreshold(amount: number): void;
  56286. /**
  56287. * Disables highlights
  56288. */
  56289. disableHighlights(): void;
  56290. /**
  56291. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  56292. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  56293. */
  56294. dispose(disableDepthRender?: boolean): void;
  56295. private _createChromaticAberrationPostProcess;
  56296. private _createHighlightsPostProcess;
  56297. private _createDepthOfFieldPostProcess;
  56298. private _createGrainTexture;
  56299. }
  56300. }
  56301. declare module BABYLON {
  56302. /** @hidden */
  56303. export var ssao2PixelShader: {
  56304. name: string;
  56305. shader: string;
  56306. };
  56307. }
  56308. declare module BABYLON {
  56309. /** @hidden */
  56310. export var ssaoCombinePixelShader: {
  56311. name: string;
  56312. shader: string;
  56313. };
  56314. }
  56315. declare module BABYLON {
  56316. /**
  56317. * Render pipeline to produce ssao effect
  56318. */
  56319. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  56320. /**
  56321. * @ignore
  56322. * The PassPostProcess id in the pipeline that contains the original scene color
  56323. */
  56324. SSAOOriginalSceneColorEffect: string;
  56325. /**
  56326. * @ignore
  56327. * The SSAO PostProcess id in the pipeline
  56328. */
  56329. SSAORenderEffect: string;
  56330. /**
  56331. * @ignore
  56332. * The horizontal blur PostProcess id in the pipeline
  56333. */
  56334. SSAOBlurHRenderEffect: string;
  56335. /**
  56336. * @ignore
  56337. * The vertical blur PostProcess id in the pipeline
  56338. */
  56339. SSAOBlurVRenderEffect: string;
  56340. /**
  56341. * @ignore
  56342. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  56343. */
  56344. SSAOCombineRenderEffect: string;
  56345. /**
  56346. * The output strength of the SSAO post-process. Default value is 1.0.
  56347. */
  56348. totalStrength: number;
  56349. /**
  56350. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  56351. */
  56352. maxZ: number;
  56353. /**
  56354. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  56355. */
  56356. minZAspect: number;
  56357. private _samples;
  56358. /**
  56359. * Number of samples used for the SSAO calculations. Default value is 8
  56360. */
  56361. samples: number;
  56362. private _textureSamples;
  56363. /**
  56364. * Number of samples to use for antialiasing
  56365. */
  56366. textureSamples: number;
  56367. /**
  56368. * Ratio object used for SSAO ratio and blur ratio
  56369. */
  56370. private _ratio;
  56371. /**
  56372. * Dynamically generated sphere sampler.
  56373. */
  56374. private _sampleSphere;
  56375. /**
  56376. * Blur filter offsets
  56377. */
  56378. private _samplerOffsets;
  56379. private _expensiveBlur;
  56380. /**
  56381. * If bilateral blur should be used
  56382. */
  56383. expensiveBlur: boolean;
  56384. /**
  56385. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  56386. */
  56387. radius: number;
  56388. /**
  56389. * The base color of the SSAO post-process
  56390. * The final result is "base + ssao" between [0, 1]
  56391. */
  56392. base: number;
  56393. /**
  56394. * Support test.
  56395. */
  56396. static readonly IsSupported: boolean;
  56397. private _scene;
  56398. private _depthTexture;
  56399. private _normalTexture;
  56400. private _randomTexture;
  56401. private _originalColorPostProcess;
  56402. private _ssaoPostProcess;
  56403. private _blurHPostProcess;
  56404. private _blurVPostProcess;
  56405. private _ssaoCombinePostProcess;
  56406. private _firstUpdate;
  56407. /**
  56408. * Gets active scene
  56409. */
  56410. readonly scene: Scene;
  56411. /**
  56412. * @constructor
  56413. * @param name The rendering pipeline name
  56414. * @param scene The scene linked to this pipeline
  56415. * @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 }
  56416. * @param cameras The array of cameras that the rendering pipeline will be attached to
  56417. */
  56418. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  56419. /**
  56420. * Get the class name
  56421. * @returns "SSAO2RenderingPipeline"
  56422. */
  56423. getClassName(): string;
  56424. /**
  56425. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  56426. */
  56427. dispose(disableGeometryBufferRenderer?: boolean): void;
  56428. private _createBlurPostProcess;
  56429. /** @hidden */
  56430. _rebuild(): void;
  56431. private _bits;
  56432. private _radicalInverse_VdC;
  56433. private _hammersley;
  56434. private _hemisphereSample_uniform;
  56435. private _generateHemisphere;
  56436. private _createSSAOPostProcess;
  56437. private _createSSAOCombinePostProcess;
  56438. private _createRandomTexture;
  56439. /**
  56440. * Serialize the rendering pipeline (Used when exporting)
  56441. * @returns the serialized object
  56442. */
  56443. serialize(): any;
  56444. /**
  56445. * Parse the serialized pipeline
  56446. * @param source Source pipeline.
  56447. * @param scene The scene to load the pipeline to.
  56448. * @param rootUrl The URL of the serialized pipeline.
  56449. * @returns An instantiated pipeline from the serialized object.
  56450. */
  56451. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  56452. }
  56453. }
  56454. declare module BABYLON {
  56455. /** @hidden */
  56456. export var ssaoPixelShader: {
  56457. name: string;
  56458. shader: string;
  56459. };
  56460. }
  56461. declare module BABYLON {
  56462. /**
  56463. * Render pipeline to produce ssao effect
  56464. */
  56465. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  56466. /**
  56467. * @ignore
  56468. * The PassPostProcess id in the pipeline that contains the original scene color
  56469. */
  56470. SSAOOriginalSceneColorEffect: string;
  56471. /**
  56472. * @ignore
  56473. * The SSAO PostProcess id in the pipeline
  56474. */
  56475. SSAORenderEffect: string;
  56476. /**
  56477. * @ignore
  56478. * The horizontal blur PostProcess id in the pipeline
  56479. */
  56480. SSAOBlurHRenderEffect: string;
  56481. /**
  56482. * @ignore
  56483. * The vertical blur PostProcess id in the pipeline
  56484. */
  56485. SSAOBlurVRenderEffect: string;
  56486. /**
  56487. * @ignore
  56488. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  56489. */
  56490. SSAOCombineRenderEffect: string;
  56491. /**
  56492. * The output strength of the SSAO post-process. Default value is 1.0.
  56493. */
  56494. totalStrength: number;
  56495. /**
  56496. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  56497. */
  56498. radius: number;
  56499. /**
  56500. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  56501. * Must not be equal to fallOff and superior to fallOff.
  56502. * Default value is 0.0075
  56503. */
  56504. area: number;
  56505. /**
  56506. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  56507. * Must not be equal to area and inferior to area.
  56508. * Default value is 0.000001
  56509. */
  56510. fallOff: number;
  56511. /**
  56512. * The base color of the SSAO post-process
  56513. * The final result is "base + ssao" between [0, 1]
  56514. */
  56515. base: number;
  56516. private _scene;
  56517. private _depthTexture;
  56518. private _randomTexture;
  56519. private _originalColorPostProcess;
  56520. private _ssaoPostProcess;
  56521. private _blurHPostProcess;
  56522. private _blurVPostProcess;
  56523. private _ssaoCombinePostProcess;
  56524. private _firstUpdate;
  56525. /**
  56526. * Gets active scene
  56527. */
  56528. readonly scene: Scene;
  56529. /**
  56530. * @constructor
  56531. * @param name - The rendering pipeline name
  56532. * @param scene - The scene linked to this pipeline
  56533. * @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 }
  56534. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  56535. */
  56536. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  56537. /**
  56538. * Get the class name
  56539. * @returns "SSAORenderingPipeline"
  56540. */
  56541. getClassName(): string;
  56542. /**
  56543. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  56544. */
  56545. dispose(disableDepthRender?: boolean): void;
  56546. private _createBlurPostProcess;
  56547. /** @hidden */
  56548. _rebuild(): void;
  56549. private _createSSAOPostProcess;
  56550. private _createSSAOCombinePostProcess;
  56551. private _createRandomTexture;
  56552. }
  56553. }
  56554. declare module BABYLON {
  56555. /** @hidden */
  56556. export var standardPixelShader: {
  56557. name: string;
  56558. shader: string;
  56559. };
  56560. }
  56561. declare module BABYLON {
  56562. /**
  56563. * Standard rendering pipeline
  56564. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  56565. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  56566. */
  56567. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  56568. /**
  56569. * Public members
  56570. */
  56571. /**
  56572. * Post-process which contains the original scene color before the pipeline applies all the effects
  56573. */
  56574. originalPostProcess: Nullable<PostProcess>;
  56575. /**
  56576. * Post-process used to down scale an image x4
  56577. */
  56578. downSampleX4PostProcess: Nullable<PostProcess>;
  56579. /**
  56580. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  56581. */
  56582. brightPassPostProcess: Nullable<PostProcess>;
  56583. /**
  56584. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  56585. */
  56586. blurHPostProcesses: PostProcess[];
  56587. /**
  56588. * Post-process array storing all the vertical blur post-processes used by the pipeline
  56589. */
  56590. blurVPostProcesses: PostProcess[];
  56591. /**
  56592. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  56593. */
  56594. textureAdderPostProcess: Nullable<PostProcess>;
  56595. /**
  56596. * Post-process used to create volumetric lighting effect
  56597. */
  56598. volumetricLightPostProcess: Nullable<PostProcess>;
  56599. /**
  56600. * Post-process used to smooth the previous volumetric light post-process on the X axis
  56601. */
  56602. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  56603. /**
  56604. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  56605. */
  56606. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  56607. /**
  56608. * Post-process used to merge the volumetric light effect and the real scene color
  56609. */
  56610. volumetricLightMergePostProces: Nullable<PostProcess>;
  56611. /**
  56612. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  56613. */
  56614. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  56615. /**
  56616. * Base post-process used to calculate the average luminance of the final image for HDR
  56617. */
  56618. luminancePostProcess: Nullable<PostProcess>;
  56619. /**
  56620. * Post-processes used to create down sample post-processes in order to get
  56621. * the average luminance of the final image for HDR
  56622. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  56623. */
  56624. luminanceDownSamplePostProcesses: PostProcess[];
  56625. /**
  56626. * Post-process used to create a HDR effect (light adaptation)
  56627. */
  56628. hdrPostProcess: Nullable<PostProcess>;
  56629. /**
  56630. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  56631. */
  56632. textureAdderFinalPostProcess: Nullable<PostProcess>;
  56633. /**
  56634. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  56635. */
  56636. lensFlareFinalPostProcess: Nullable<PostProcess>;
  56637. /**
  56638. * Post-process used to merge the final HDR post-process and the real scene color
  56639. */
  56640. hdrFinalPostProcess: Nullable<PostProcess>;
  56641. /**
  56642. * Post-process used to create a lens flare effect
  56643. */
  56644. lensFlarePostProcess: Nullable<PostProcess>;
  56645. /**
  56646. * Post-process that merges the result of the lens flare post-process and the real scene color
  56647. */
  56648. lensFlareComposePostProcess: Nullable<PostProcess>;
  56649. /**
  56650. * Post-process used to create a motion blur effect
  56651. */
  56652. motionBlurPostProcess: Nullable<PostProcess>;
  56653. /**
  56654. * Post-process used to create a depth of field effect
  56655. */
  56656. depthOfFieldPostProcess: Nullable<PostProcess>;
  56657. /**
  56658. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  56659. */
  56660. fxaaPostProcess: Nullable<FxaaPostProcess>;
  56661. /**
  56662. * Represents the brightness threshold in order to configure the illuminated surfaces
  56663. */
  56664. brightThreshold: number;
  56665. /**
  56666. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  56667. */
  56668. blurWidth: number;
  56669. /**
  56670. * Sets if the blur for highlighted surfaces must be only horizontal
  56671. */
  56672. horizontalBlur: boolean;
  56673. /**
  56674. * Gets the overall exposure used by the pipeline
  56675. */
  56676. /**
  56677. * Sets the overall exposure used by the pipeline
  56678. */
  56679. exposure: number;
  56680. /**
  56681. * Texture used typically to simulate "dirty" on camera lens
  56682. */
  56683. lensTexture: Nullable<Texture>;
  56684. /**
  56685. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  56686. */
  56687. volumetricLightCoefficient: number;
  56688. /**
  56689. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  56690. */
  56691. volumetricLightPower: number;
  56692. /**
  56693. * Used the set the blur intensity to smooth the volumetric lights
  56694. */
  56695. volumetricLightBlurScale: number;
  56696. /**
  56697. * Light (spot or directional) used to generate the volumetric lights rays
  56698. * The source light must have a shadow generate so the pipeline can get its
  56699. * depth map
  56700. */
  56701. sourceLight: Nullable<SpotLight | DirectionalLight>;
  56702. /**
  56703. * For eye adaptation, represents the minimum luminance the eye can see
  56704. */
  56705. hdrMinimumLuminance: number;
  56706. /**
  56707. * For eye adaptation, represents the decrease luminance speed
  56708. */
  56709. hdrDecreaseRate: number;
  56710. /**
  56711. * For eye adaptation, represents the increase luminance speed
  56712. */
  56713. hdrIncreaseRate: number;
  56714. /**
  56715. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  56716. */
  56717. /**
  56718. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  56719. */
  56720. hdrAutoExposure: boolean;
  56721. /**
  56722. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  56723. */
  56724. lensColorTexture: Nullable<Texture>;
  56725. /**
  56726. * The overall strengh for the lens flare effect
  56727. */
  56728. lensFlareStrength: number;
  56729. /**
  56730. * Dispersion coefficient for lens flare ghosts
  56731. */
  56732. lensFlareGhostDispersal: number;
  56733. /**
  56734. * Main lens flare halo width
  56735. */
  56736. lensFlareHaloWidth: number;
  56737. /**
  56738. * Based on the lens distortion effect, defines how much the lens flare result
  56739. * is distorted
  56740. */
  56741. lensFlareDistortionStrength: number;
  56742. /**
  56743. * Lens star texture must be used to simulate rays on the flares and is available
  56744. * in the documentation
  56745. */
  56746. lensStarTexture: Nullable<Texture>;
  56747. /**
  56748. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  56749. * flare effect by taking account of the dirt texture
  56750. */
  56751. lensFlareDirtTexture: Nullable<Texture>;
  56752. /**
  56753. * Represents the focal length for the depth of field effect
  56754. */
  56755. depthOfFieldDistance: number;
  56756. /**
  56757. * Represents the blur intensity for the blurred part of the depth of field effect
  56758. */
  56759. depthOfFieldBlurWidth: number;
  56760. /**
  56761. * Gets how much the image is blurred by the movement while using the motion blur post-process
  56762. */
  56763. /**
  56764. * Sets how much the image is blurred by the movement while using the motion blur post-process
  56765. */
  56766. motionStrength: number;
  56767. /**
  56768. * Gets wether or not the motion blur post-process is object based or screen based.
  56769. */
  56770. /**
  56771. * Sets wether or not the motion blur post-process should be object based or screen based
  56772. */
  56773. objectBasedMotionBlur: boolean;
  56774. /**
  56775. * List of animations for the pipeline (IAnimatable implementation)
  56776. */
  56777. animations: Animation[];
  56778. /**
  56779. * Private members
  56780. */
  56781. private _scene;
  56782. private _currentDepthOfFieldSource;
  56783. private _basePostProcess;
  56784. private _fixedExposure;
  56785. private _currentExposure;
  56786. private _hdrAutoExposure;
  56787. private _hdrCurrentLuminance;
  56788. private _motionStrength;
  56789. private _isObjectBasedMotionBlur;
  56790. private _floatTextureType;
  56791. private _ratio;
  56792. private _bloomEnabled;
  56793. private _depthOfFieldEnabled;
  56794. private _vlsEnabled;
  56795. private _lensFlareEnabled;
  56796. private _hdrEnabled;
  56797. private _motionBlurEnabled;
  56798. private _fxaaEnabled;
  56799. private _motionBlurSamples;
  56800. private _volumetricLightStepsCount;
  56801. private _samples;
  56802. /**
  56803. * @ignore
  56804. * Specifies if the bloom pipeline is enabled
  56805. */
  56806. BloomEnabled: boolean;
  56807. /**
  56808. * @ignore
  56809. * Specifies if the depth of field pipeline is enabed
  56810. */
  56811. DepthOfFieldEnabled: boolean;
  56812. /**
  56813. * @ignore
  56814. * Specifies if the lens flare pipeline is enabed
  56815. */
  56816. LensFlareEnabled: boolean;
  56817. /**
  56818. * @ignore
  56819. * Specifies if the HDR pipeline is enabled
  56820. */
  56821. HDREnabled: boolean;
  56822. /**
  56823. * @ignore
  56824. * Specifies if the volumetric lights scattering effect is enabled
  56825. */
  56826. VLSEnabled: boolean;
  56827. /**
  56828. * @ignore
  56829. * Specifies if the motion blur effect is enabled
  56830. */
  56831. MotionBlurEnabled: boolean;
  56832. /**
  56833. * Specifies if anti-aliasing is enabled
  56834. */
  56835. fxaaEnabled: boolean;
  56836. /**
  56837. * Specifies the number of steps used to calculate the volumetric lights
  56838. * Typically in interval [50, 200]
  56839. */
  56840. volumetricLightStepsCount: number;
  56841. /**
  56842. * Specifies the number of samples used for the motion blur effect
  56843. * Typically in interval [16, 64]
  56844. */
  56845. motionBlurSamples: number;
  56846. /**
  56847. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  56848. */
  56849. samples: number;
  56850. /**
  56851. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  56852. * @constructor
  56853. * @param name The rendering pipeline name
  56854. * @param scene The scene linked to this pipeline
  56855. * @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)
  56856. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  56857. * @param cameras The array of cameras that the rendering pipeline will be attached to
  56858. */
  56859. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  56860. private _buildPipeline;
  56861. private _createDownSampleX4PostProcess;
  56862. private _createBrightPassPostProcess;
  56863. private _createBlurPostProcesses;
  56864. private _createTextureAdderPostProcess;
  56865. private _createVolumetricLightPostProcess;
  56866. private _createLuminancePostProcesses;
  56867. private _createHdrPostProcess;
  56868. private _createLensFlarePostProcess;
  56869. private _createDepthOfFieldPostProcess;
  56870. private _createMotionBlurPostProcess;
  56871. private _getDepthTexture;
  56872. private _disposePostProcesses;
  56873. /**
  56874. * Dispose of the pipeline and stop all post processes
  56875. */
  56876. dispose(): void;
  56877. /**
  56878. * Serialize the rendering pipeline (Used when exporting)
  56879. * @returns the serialized object
  56880. */
  56881. serialize(): any;
  56882. /**
  56883. * Parse the serialized pipeline
  56884. * @param source Source pipeline.
  56885. * @param scene The scene to load the pipeline to.
  56886. * @param rootUrl The URL of the serialized pipeline.
  56887. * @returns An instantiated pipeline from the serialized object.
  56888. */
  56889. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  56890. /**
  56891. * Luminance steps
  56892. */
  56893. static LuminanceSteps: number;
  56894. }
  56895. }
  56896. declare module BABYLON {
  56897. /** @hidden */
  56898. export var tonemapPixelShader: {
  56899. name: string;
  56900. shader: string;
  56901. };
  56902. }
  56903. declare module BABYLON {
  56904. /** Defines operator used for tonemapping */
  56905. export enum TonemappingOperator {
  56906. /** Hable */
  56907. Hable = 0,
  56908. /** Reinhard */
  56909. Reinhard = 1,
  56910. /** HejiDawson */
  56911. HejiDawson = 2,
  56912. /** Photographic */
  56913. Photographic = 3
  56914. }
  56915. /**
  56916. * Defines a post process to apply tone mapping
  56917. */
  56918. export class TonemapPostProcess extends PostProcess {
  56919. private _operator;
  56920. /** Defines the required exposure adjustement */
  56921. exposureAdjustment: number;
  56922. /**
  56923. * Creates a new TonemapPostProcess
  56924. * @param name defines the name of the postprocess
  56925. * @param _operator defines the operator to use
  56926. * @param exposureAdjustment defines the required exposure adjustement
  56927. * @param camera defines the camera to use (can be null)
  56928. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  56929. * @param engine defines the hosting engine (can be ignore if camera is set)
  56930. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  56931. */
  56932. constructor(name: string, _operator: TonemappingOperator,
  56933. /** Defines the required exposure adjustement */
  56934. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  56935. }
  56936. }
  56937. declare module BABYLON {
  56938. /** @hidden */
  56939. export var depthVertexShader: {
  56940. name: string;
  56941. shader: string;
  56942. };
  56943. }
  56944. declare module BABYLON {
  56945. /** @hidden */
  56946. export var volumetricLightScatteringPixelShader: {
  56947. name: string;
  56948. shader: string;
  56949. };
  56950. }
  56951. declare module BABYLON {
  56952. /** @hidden */
  56953. export var volumetricLightScatteringPassPixelShader: {
  56954. name: string;
  56955. shader: string;
  56956. };
  56957. }
  56958. declare module BABYLON {
  56959. /**
  56960. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  56961. */
  56962. export class VolumetricLightScatteringPostProcess extends PostProcess {
  56963. private _volumetricLightScatteringPass;
  56964. private _volumetricLightScatteringRTT;
  56965. private _viewPort;
  56966. private _screenCoordinates;
  56967. private _cachedDefines;
  56968. /**
  56969. * If not undefined, the mesh position is computed from the attached node position
  56970. */
  56971. attachedNode: {
  56972. position: Vector3;
  56973. };
  56974. /**
  56975. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  56976. */
  56977. customMeshPosition: Vector3;
  56978. /**
  56979. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  56980. */
  56981. useCustomMeshPosition: boolean;
  56982. /**
  56983. * If the post-process should inverse the light scattering direction
  56984. */
  56985. invert: boolean;
  56986. /**
  56987. * The internal mesh used by the post-process
  56988. */
  56989. mesh: Mesh;
  56990. /**
  56991. * @hidden
  56992. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  56993. */
  56994. useDiffuseColor: boolean;
  56995. /**
  56996. * Array containing the excluded meshes not rendered in the internal pass
  56997. */
  56998. excludedMeshes: AbstractMesh[];
  56999. /**
  57000. * Controls the overall intensity of the post-process
  57001. */
  57002. exposure: number;
  57003. /**
  57004. * Dissipates each sample's contribution in range [0, 1]
  57005. */
  57006. decay: number;
  57007. /**
  57008. * Controls the overall intensity of each sample
  57009. */
  57010. weight: number;
  57011. /**
  57012. * Controls the density of each sample
  57013. */
  57014. density: number;
  57015. /**
  57016. * @constructor
  57017. * @param name The post-process name
  57018. * @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)
  57019. * @param camera The camera that the post-process will be attached to
  57020. * @param mesh The mesh used to create the light scattering
  57021. * @param samples The post-process quality, default 100
  57022. * @param samplingModeThe post-process filtering mode
  57023. * @param engine The babylon engine
  57024. * @param reusable If the post-process is reusable
  57025. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  57026. */
  57027. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  57028. /**
  57029. * Returns the string "VolumetricLightScatteringPostProcess"
  57030. * @returns "VolumetricLightScatteringPostProcess"
  57031. */
  57032. getClassName(): string;
  57033. private _isReady;
  57034. /**
  57035. * Sets the new light position for light scattering effect
  57036. * @param position The new custom light position
  57037. */
  57038. setCustomMeshPosition(position: Vector3): void;
  57039. /**
  57040. * Returns the light position for light scattering effect
  57041. * @return Vector3 The custom light position
  57042. */
  57043. getCustomMeshPosition(): Vector3;
  57044. /**
  57045. * Disposes the internal assets and detaches the post-process from the camera
  57046. */
  57047. dispose(camera: Camera): void;
  57048. /**
  57049. * Returns the render target texture used by the post-process
  57050. * @return the render target texture used by the post-process
  57051. */
  57052. getPass(): RenderTargetTexture;
  57053. private _meshExcluded;
  57054. private _createPass;
  57055. private _updateMeshScreenCoordinates;
  57056. /**
  57057. * Creates a default mesh for the Volumeric Light Scattering post-process
  57058. * @param name The mesh name
  57059. * @param scene The scene where to create the mesh
  57060. * @return the default mesh
  57061. */
  57062. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  57063. }
  57064. }
  57065. declare module BABYLON {
  57066. interface Scene {
  57067. /** @hidden (Backing field) */
  57068. _boundingBoxRenderer: BoundingBoxRenderer;
  57069. /** @hidden (Backing field) */
  57070. _forceShowBoundingBoxes: boolean;
  57071. /**
  57072. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  57073. */
  57074. forceShowBoundingBoxes: boolean;
  57075. /**
  57076. * Gets the bounding box renderer associated with the scene
  57077. * @returns a BoundingBoxRenderer
  57078. */
  57079. getBoundingBoxRenderer(): BoundingBoxRenderer;
  57080. }
  57081. interface AbstractMesh {
  57082. /** @hidden (Backing field) */
  57083. _showBoundingBox: boolean;
  57084. /**
  57085. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  57086. */
  57087. showBoundingBox: boolean;
  57088. }
  57089. /**
  57090. * Component responsible of rendering the bounding box of the meshes in a scene.
  57091. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  57092. */
  57093. export class BoundingBoxRenderer implements ISceneComponent {
  57094. /**
  57095. * The component name helpfull to identify the component in the list of scene components.
  57096. */
  57097. readonly name: string;
  57098. /**
  57099. * The scene the component belongs to.
  57100. */
  57101. scene: Scene;
  57102. /**
  57103. * Color of the bounding box lines placed in front of an object
  57104. */
  57105. frontColor: Color3;
  57106. /**
  57107. * Color of the bounding box lines placed behind an object
  57108. */
  57109. backColor: Color3;
  57110. /**
  57111. * Defines if the renderer should show the back lines or not
  57112. */
  57113. showBackLines: boolean;
  57114. /**
  57115. * @hidden
  57116. */
  57117. renderList: SmartArray<BoundingBox>;
  57118. private _colorShader;
  57119. private _vertexBuffers;
  57120. private _indexBuffer;
  57121. private _fillIndexBuffer;
  57122. private _fillIndexData;
  57123. /**
  57124. * Instantiates a new bounding box renderer in a scene.
  57125. * @param scene the scene the renderer renders in
  57126. */
  57127. constructor(scene: Scene);
  57128. /**
  57129. * Registers the component in a given scene
  57130. */
  57131. register(): void;
  57132. private _evaluateSubMesh;
  57133. private _activeMesh;
  57134. private _prepareRessources;
  57135. private _createIndexBuffer;
  57136. /**
  57137. * Rebuilds the elements related to this component in case of
  57138. * context lost for instance.
  57139. */
  57140. rebuild(): void;
  57141. /**
  57142. * @hidden
  57143. */
  57144. reset(): void;
  57145. /**
  57146. * Render the bounding boxes of a specific rendering group
  57147. * @param renderingGroupId defines the rendering group to render
  57148. */
  57149. render(renderingGroupId: number): void;
  57150. /**
  57151. * In case of occlusion queries, we can render the occlusion bounding box through this method
  57152. * @param mesh Define the mesh to render the occlusion bounding box for
  57153. */
  57154. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  57155. /**
  57156. * Dispose and release the resources attached to this renderer.
  57157. */
  57158. dispose(): void;
  57159. }
  57160. }
  57161. declare module BABYLON {
  57162. /** @hidden */
  57163. export var depthPixelShader: {
  57164. name: string;
  57165. shader: string;
  57166. };
  57167. }
  57168. declare module BABYLON {
  57169. /**
  57170. * This represents a depth renderer in Babylon.
  57171. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  57172. */
  57173. export class DepthRenderer {
  57174. private _scene;
  57175. private _depthMap;
  57176. private _effect;
  57177. private _cachedDefines;
  57178. private _camera;
  57179. /**
  57180. * Specifiess that the depth renderer will only be used within
  57181. * the camera it is created for.
  57182. * This can help forcing its rendering during the camera processing.
  57183. */
  57184. useOnlyInActiveCamera: boolean;
  57185. /** @hidden */
  57186. static _SceneComponentInitialization: (scene: Scene) => void;
  57187. /**
  57188. * Instantiates a depth renderer
  57189. * @param scene The scene the renderer belongs to
  57190. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  57191. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  57192. */
  57193. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  57194. /**
  57195. * Creates the depth rendering effect and checks if the effect is ready.
  57196. * @param subMesh The submesh to be used to render the depth map of
  57197. * @param useInstances If multiple world instances should be used
  57198. * @returns if the depth renderer is ready to render the depth map
  57199. */
  57200. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  57201. /**
  57202. * Gets the texture which the depth map will be written to.
  57203. * @returns The depth map texture
  57204. */
  57205. getDepthMap(): RenderTargetTexture;
  57206. /**
  57207. * Disposes of the depth renderer.
  57208. */
  57209. dispose(): void;
  57210. }
  57211. }
  57212. declare module BABYLON {
  57213. interface Scene {
  57214. /** @hidden (Backing field) */
  57215. _depthRenderer: {
  57216. [id: string]: DepthRenderer;
  57217. };
  57218. /**
  57219. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  57220. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  57221. * @returns the created depth renderer
  57222. */
  57223. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  57224. /**
  57225. * Disables a depth renderer for a given camera
  57226. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  57227. */
  57228. disableDepthRenderer(camera?: Nullable<Camera>): void;
  57229. }
  57230. /**
  57231. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  57232. * in several rendering techniques.
  57233. */
  57234. export class DepthRendererSceneComponent implements ISceneComponent {
  57235. /**
  57236. * The component name helpfull to identify the component in the list of scene components.
  57237. */
  57238. readonly name: string;
  57239. /**
  57240. * The scene the component belongs to.
  57241. */
  57242. scene: Scene;
  57243. /**
  57244. * Creates a new instance of the component for the given scene
  57245. * @param scene Defines the scene to register the component in
  57246. */
  57247. constructor(scene: Scene);
  57248. /**
  57249. * Registers the component in a given scene
  57250. */
  57251. register(): void;
  57252. /**
  57253. * Rebuilds the elements related to this component in case of
  57254. * context lost for instance.
  57255. */
  57256. rebuild(): void;
  57257. /**
  57258. * Disposes the component and the associated ressources
  57259. */
  57260. dispose(): void;
  57261. private _gatherRenderTargets;
  57262. private _gatherActiveCameraRenderTargets;
  57263. }
  57264. }
  57265. declare module BABYLON {
  57266. /** @hidden */
  57267. export var outlinePixelShader: {
  57268. name: string;
  57269. shader: string;
  57270. };
  57271. }
  57272. declare module BABYLON {
  57273. /** @hidden */
  57274. export var outlineVertexShader: {
  57275. name: string;
  57276. shader: string;
  57277. };
  57278. }
  57279. declare module BABYLON {
  57280. interface Scene {
  57281. /** @hidden */
  57282. _outlineRenderer: OutlineRenderer;
  57283. /**
  57284. * Gets the outline renderer associated with the scene
  57285. * @returns a OutlineRenderer
  57286. */
  57287. getOutlineRenderer(): OutlineRenderer;
  57288. }
  57289. interface AbstractMesh {
  57290. /** @hidden (Backing field) */
  57291. _renderOutline: boolean;
  57292. /**
  57293. * Gets or sets a boolean indicating if the outline must be rendered as well
  57294. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  57295. */
  57296. renderOutline: boolean;
  57297. /** @hidden (Backing field) */
  57298. _renderOverlay: boolean;
  57299. /**
  57300. * Gets or sets a boolean indicating if the overlay must be rendered as well
  57301. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  57302. */
  57303. renderOverlay: boolean;
  57304. }
  57305. /**
  57306. * This class is responsible to draw bothe outline/overlay of meshes.
  57307. * It should not be used directly but through the available method on mesh.
  57308. */
  57309. export class OutlineRenderer implements ISceneComponent {
  57310. /**
  57311. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  57312. */
  57313. private static _StencilReference;
  57314. /**
  57315. * The name of the component. Each component must have a unique name.
  57316. */
  57317. name: string;
  57318. /**
  57319. * The scene the component belongs to.
  57320. */
  57321. scene: Scene;
  57322. /**
  57323. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  57324. */
  57325. zOffset: number;
  57326. private _engine;
  57327. private _effect;
  57328. private _cachedDefines;
  57329. private _savedDepthWrite;
  57330. /**
  57331. * Instantiates a new outline renderer. (There could be only one per scene).
  57332. * @param scene Defines the scene it belongs to
  57333. */
  57334. constructor(scene: Scene);
  57335. /**
  57336. * Register the component to one instance of a scene.
  57337. */
  57338. register(): void;
  57339. /**
  57340. * Rebuilds the elements related to this component in case of
  57341. * context lost for instance.
  57342. */
  57343. rebuild(): void;
  57344. /**
  57345. * Disposes the component and the associated ressources.
  57346. */
  57347. dispose(): void;
  57348. /**
  57349. * Renders the outline in the canvas.
  57350. * @param subMesh Defines the sumesh to render
  57351. * @param batch Defines the batch of meshes in case of instances
  57352. * @param useOverlay Defines if the rendering is for the overlay or the outline
  57353. */
  57354. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  57355. /**
  57356. * Returns whether or not the outline renderer is ready for a given submesh.
  57357. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  57358. * @param subMesh Defines the submesh to check readyness for
  57359. * @param useInstances Defines wheter wee are trying to render instances or not
  57360. * @returns true if ready otherwise false
  57361. */
  57362. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  57363. private _beforeRenderingMesh;
  57364. private _afterRenderingMesh;
  57365. }
  57366. }
  57367. declare module BABYLON {
  57368. /**
  57369. * Defines the list of states available for a task inside a AssetsManager
  57370. */
  57371. export enum AssetTaskState {
  57372. /**
  57373. * Initialization
  57374. */
  57375. INIT = 0,
  57376. /**
  57377. * Running
  57378. */
  57379. RUNNING = 1,
  57380. /**
  57381. * Done
  57382. */
  57383. DONE = 2,
  57384. /**
  57385. * Error
  57386. */
  57387. ERROR = 3
  57388. }
  57389. /**
  57390. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  57391. */
  57392. export abstract class AbstractAssetTask {
  57393. /**
  57394. * Task name
  57395. */ name: string;
  57396. /**
  57397. * Callback called when the task is successful
  57398. */
  57399. onSuccess: (task: any) => void;
  57400. /**
  57401. * Callback called when the task is not successful
  57402. */
  57403. onError: (task: any, message?: string, exception?: any) => void;
  57404. /**
  57405. * Creates a new AssetsManager
  57406. * @param name defines the name of the task
  57407. */
  57408. constructor(
  57409. /**
  57410. * Task name
  57411. */ name: string);
  57412. private _isCompleted;
  57413. private _taskState;
  57414. private _errorObject;
  57415. /**
  57416. * Get if the task is completed
  57417. */
  57418. readonly isCompleted: boolean;
  57419. /**
  57420. * Gets the current state of the task
  57421. */
  57422. readonly taskState: AssetTaskState;
  57423. /**
  57424. * Gets the current error object (if task is in error)
  57425. */
  57426. readonly errorObject: {
  57427. message?: string;
  57428. exception?: any;
  57429. };
  57430. /**
  57431. * Internal only
  57432. * @hidden
  57433. */
  57434. _setErrorObject(message?: string, exception?: any): void;
  57435. /**
  57436. * Execute the current task
  57437. * @param scene defines the scene where you want your assets to be loaded
  57438. * @param onSuccess is a callback called when the task is successfully executed
  57439. * @param onError is a callback called if an error occurs
  57440. */
  57441. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57442. /**
  57443. * Execute the current task
  57444. * @param scene defines the scene where you want your assets to be loaded
  57445. * @param onSuccess is a callback called when the task is successfully executed
  57446. * @param onError is a callback called if an error occurs
  57447. */
  57448. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57449. /**
  57450. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  57451. * This can be used with failed tasks that have the reason for failure fixed.
  57452. */
  57453. reset(): void;
  57454. private onErrorCallback;
  57455. private onDoneCallback;
  57456. }
  57457. /**
  57458. * Define the interface used by progress events raised during assets loading
  57459. */
  57460. export interface IAssetsProgressEvent {
  57461. /**
  57462. * Defines the number of remaining tasks to process
  57463. */
  57464. remainingCount: number;
  57465. /**
  57466. * Defines the total number of tasks
  57467. */
  57468. totalCount: number;
  57469. /**
  57470. * Defines the task that was just processed
  57471. */
  57472. task: AbstractAssetTask;
  57473. }
  57474. /**
  57475. * Class used to share progress information about assets loading
  57476. */
  57477. export class AssetsProgressEvent implements IAssetsProgressEvent {
  57478. /**
  57479. * Defines the number of remaining tasks to process
  57480. */
  57481. remainingCount: number;
  57482. /**
  57483. * Defines the total number of tasks
  57484. */
  57485. totalCount: number;
  57486. /**
  57487. * Defines the task that was just processed
  57488. */
  57489. task: AbstractAssetTask;
  57490. /**
  57491. * Creates a AssetsProgressEvent
  57492. * @param remainingCount defines the number of remaining tasks to process
  57493. * @param totalCount defines the total number of tasks
  57494. * @param task defines the task that was just processed
  57495. */
  57496. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  57497. }
  57498. /**
  57499. * Define a task used by AssetsManager to load meshes
  57500. */
  57501. export class MeshAssetTask extends AbstractAssetTask {
  57502. /**
  57503. * Defines the name of the task
  57504. */
  57505. name: string;
  57506. /**
  57507. * Defines the list of mesh's names you want to load
  57508. */
  57509. meshesNames: any;
  57510. /**
  57511. * Defines the root url to use as a base to load your meshes and associated resources
  57512. */
  57513. rootUrl: string;
  57514. /**
  57515. * Defines the filename of the scene to load from
  57516. */
  57517. sceneFilename: string;
  57518. /**
  57519. * Gets the list of loaded meshes
  57520. */
  57521. loadedMeshes: Array<AbstractMesh>;
  57522. /**
  57523. * Gets the list of loaded particle systems
  57524. */
  57525. loadedParticleSystems: Array<IParticleSystem>;
  57526. /**
  57527. * Gets the list of loaded skeletons
  57528. */
  57529. loadedSkeletons: Array<Skeleton>;
  57530. /**
  57531. * Gets the list of loaded animation groups
  57532. */
  57533. loadedAnimationGroups: Array<AnimationGroup>;
  57534. /**
  57535. * Callback called when the task is successful
  57536. */
  57537. onSuccess: (task: MeshAssetTask) => void;
  57538. /**
  57539. * Callback called when the task is successful
  57540. */
  57541. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  57542. /**
  57543. * Creates a new MeshAssetTask
  57544. * @param name defines the name of the task
  57545. * @param meshesNames defines the list of mesh's names you want to load
  57546. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  57547. * @param sceneFilename defines the filename of the scene to load from
  57548. */
  57549. constructor(
  57550. /**
  57551. * Defines the name of the task
  57552. */
  57553. name: string,
  57554. /**
  57555. * Defines the list of mesh's names you want to load
  57556. */
  57557. meshesNames: any,
  57558. /**
  57559. * Defines the root url to use as a base to load your meshes and associated resources
  57560. */
  57561. rootUrl: string,
  57562. /**
  57563. * Defines the filename of the scene to load from
  57564. */
  57565. sceneFilename: string);
  57566. /**
  57567. * Execute the current task
  57568. * @param scene defines the scene where you want your assets to be loaded
  57569. * @param onSuccess is a callback called when the task is successfully executed
  57570. * @param onError is a callback called if an error occurs
  57571. */
  57572. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57573. }
  57574. /**
  57575. * Define a task used by AssetsManager to load text content
  57576. */
  57577. export class TextFileAssetTask extends AbstractAssetTask {
  57578. /**
  57579. * Defines the name of the task
  57580. */
  57581. name: string;
  57582. /**
  57583. * Defines the location of the file to load
  57584. */
  57585. url: string;
  57586. /**
  57587. * Gets the loaded text string
  57588. */
  57589. text: string;
  57590. /**
  57591. * Callback called when the task is successful
  57592. */
  57593. onSuccess: (task: TextFileAssetTask) => void;
  57594. /**
  57595. * Callback called when the task is successful
  57596. */
  57597. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  57598. /**
  57599. * Creates a new TextFileAssetTask object
  57600. * @param name defines the name of the task
  57601. * @param url defines the location of the file to load
  57602. */
  57603. constructor(
  57604. /**
  57605. * Defines the name of the task
  57606. */
  57607. name: string,
  57608. /**
  57609. * Defines the location of the file to load
  57610. */
  57611. url: string);
  57612. /**
  57613. * Execute the current task
  57614. * @param scene defines the scene where you want your assets to be loaded
  57615. * @param onSuccess is a callback called when the task is successfully executed
  57616. * @param onError is a callback called if an error occurs
  57617. */
  57618. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57619. }
  57620. /**
  57621. * Define a task used by AssetsManager to load binary data
  57622. */
  57623. export class BinaryFileAssetTask extends AbstractAssetTask {
  57624. /**
  57625. * Defines the name of the task
  57626. */
  57627. name: string;
  57628. /**
  57629. * Defines the location of the file to load
  57630. */
  57631. url: string;
  57632. /**
  57633. * Gets the lodaded data (as an array buffer)
  57634. */
  57635. data: ArrayBuffer;
  57636. /**
  57637. * Callback called when the task is successful
  57638. */
  57639. onSuccess: (task: BinaryFileAssetTask) => void;
  57640. /**
  57641. * Callback called when the task is successful
  57642. */
  57643. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  57644. /**
  57645. * Creates a new BinaryFileAssetTask object
  57646. * @param name defines the name of the new task
  57647. * @param url defines the location of the file to load
  57648. */
  57649. constructor(
  57650. /**
  57651. * Defines the name of the task
  57652. */
  57653. name: string,
  57654. /**
  57655. * Defines the location of the file to load
  57656. */
  57657. url: string);
  57658. /**
  57659. * Execute the current task
  57660. * @param scene defines the scene where you want your assets to be loaded
  57661. * @param onSuccess is a callback called when the task is successfully executed
  57662. * @param onError is a callback called if an error occurs
  57663. */
  57664. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57665. }
  57666. /**
  57667. * Define a task used by AssetsManager to load images
  57668. */
  57669. export class ImageAssetTask extends AbstractAssetTask {
  57670. /**
  57671. * Defines the name of the task
  57672. */
  57673. name: string;
  57674. /**
  57675. * Defines the location of the image to load
  57676. */
  57677. url: string;
  57678. /**
  57679. * Gets the loaded images
  57680. */
  57681. image: HTMLImageElement;
  57682. /**
  57683. * Callback called when the task is successful
  57684. */
  57685. onSuccess: (task: ImageAssetTask) => void;
  57686. /**
  57687. * Callback called when the task is successful
  57688. */
  57689. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  57690. /**
  57691. * Creates a new ImageAssetTask
  57692. * @param name defines the name of the task
  57693. * @param url defines the location of the image to load
  57694. */
  57695. constructor(
  57696. /**
  57697. * Defines the name of the task
  57698. */
  57699. name: string,
  57700. /**
  57701. * Defines the location of the image to load
  57702. */
  57703. url: string);
  57704. /**
  57705. * Execute the current task
  57706. * @param scene defines the scene where you want your assets to be loaded
  57707. * @param onSuccess is a callback called when the task is successfully executed
  57708. * @param onError is a callback called if an error occurs
  57709. */
  57710. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57711. }
  57712. /**
  57713. * Defines the interface used by texture loading tasks
  57714. */
  57715. export interface ITextureAssetTask<TEX extends BaseTexture> {
  57716. /**
  57717. * Gets the loaded texture
  57718. */
  57719. texture: TEX;
  57720. }
  57721. /**
  57722. * Define a task used by AssetsManager to load 2D textures
  57723. */
  57724. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  57725. /**
  57726. * Defines the name of the task
  57727. */
  57728. name: string;
  57729. /**
  57730. * Defines the location of the file to load
  57731. */
  57732. url: string;
  57733. /**
  57734. * Defines if mipmap should not be generated (default is false)
  57735. */
  57736. noMipmap?: boolean | undefined;
  57737. /**
  57738. * Defines if texture must be inverted on Y axis (default is false)
  57739. */
  57740. invertY?: boolean | undefined;
  57741. /**
  57742. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  57743. */
  57744. samplingMode: number;
  57745. /**
  57746. * Gets the loaded texture
  57747. */
  57748. texture: Texture;
  57749. /**
  57750. * Callback called when the task is successful
  57751. */
  57752. onSuccess: (task: TextureAssetTask) => void;
  57753. /**
  57754. * Callback called when the task is successful
  57755. */
  57756. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  57757. /**
  57758. * Creates a new TextureAssetTask object
  57759. * @param name defines the name of the task
  57760. * @param url defines the location of the file to load
  57761. * @param noMipmap defines if mipmap should not be generated (default is false)
  57762. * @param invertY defines if texture must be inverted on Y axis (default is false)
  57763. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  57764. */
  57765. constructor(
  57766. /**
  57767. * Defines the name of the task
  57768. */
  57769. name: string,
  57770. /**
  57771. * Defines the location of the file to load
  57772. */
  57773. url: string,
  57774. /**
  57775. * Defines if mipmap should not be generated (default is false)
  57776. */
  57777. noMipmap?: boolean | undefined,
  57778. /**
  57779. * Defines if texture must be inverted on Y axis (default is false)
  57780. */
  57781. invertY?: boolean | undefined,
  57782. /**
  57783. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  57784. */
  57785. samplingMode?: number);
  57786. /**
  57787. * Execute the current task
  57788. * @param scene defines the scene where you want your assets to be loaded
  57789. * @param onSuccess is a callback called when the task is successfully executed
  57790. * @param onError is a callback called if an error occurs
  57791. */
  57792. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57793. }
  57794. /**
  57795. * Define a task used by AssetsManager to load cube textures
  57796. */
  57797. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  57798. /**
  57799. * Defines the name of the task
  57800. */
  57801. name: string;
  57802. /**
  57803. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  57804. */
  57805. url: string;
  57806. /**
  57807. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  57808. */
  57809. extensions?: string[] | undefined;
  57810. /**
  57811. * Defines if mipmaps should not be generated (default is false)
  57812. */
  57813. noMipmap?: boolean | undefined;
  57814. /**
  57815. * Defines the explicit list of files (undefined by default)
  57816. */
  57817. files?: string[] | undefined;
  57818. /**
  57819. * Gets the loaded texture
  57820. */
  57821. texture: CubeTexture;
  57822. /**
  57823. * Callback called when the task is successful
  57824. */
  57825. onSuccess: (task: CubeTextureAssetTask) => void;
  57826. /**
  57827. * Callback called when the task is successful
  57828. */
  57829. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  57830. /**
  57831. * Creates a new CubeTextureAssetTask
  57832. * @param name defines the name of the task
  57833. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  57834. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  57835. * @param noMipmap defines if mipmaps should not be generated (default is false)
  57836. * @param files defines the explicit list of files (undefined by default)
  57837. */
  57838. constructor(
  57839. /**
  57840. * Defines the name of the task
  57841. */
  57842. name: string,
  57843. /**
  57844. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  57845. */
  57846. url: string,
  57847. /**
  57848. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  57849. */
  57850. extensions?: string[] | undefined,
  57851. /**
  57852. * Defines if mipmaps should not be generated (default is false)
  57853. */
  57854. noMipmap?: boolean | undefined,
  57855. /**
  57856. * Defines the explicit list of files (undefined by default)
  57857. */
  57858. files?: string[] | undefined);
  57859. /**
  57860. * Execute the current task
  57861. * @param scene defines the scene where you want your assets to be loaded
  57862. * @param onSuccess is a callback called when the task is successfully executed
  57863. * @param onError is a callback called if an error occurs
  57864. */
  57865. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57866. }
  57867. /**
  57868. * Define a task used by AssetsManager to load HDR cube textures
  57869. */
  57870. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  57871. /**
  57872. * Defines the name of the task
  57873. */
  57874. name: string;
  57875. /**
  57876. * Defines the location of the file to load
  57877. */
  57878. url: string;
  57879. /**
  57880. * Defines the desired size (the more it increases the longer the generation will be)
  57881. */
  57882. size: number;
  57883. /**
  57884. * Defines if mipmaps should not be generated (default is false)
  57885. */
  57886. noMipmap: boolean;
  57887. /**
  57888. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  57889. */
  57890. generateHarmonics: boolean;
  57891. /**
  57892. * 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)
  57893. */
  57894. gammaSpace: boolean;
  57895. /**
  57896. * Internal Use Only
  57897. */
  57898. reserved: boolean;
  57899. /**
  57900. * Gets the loaded texture
  57901. */
  57902. texture: HDRCubeTexture;
  57903. /**
  57904. * Callback called when the task is successful
  57905. */
  57906. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  57907. /**
  57908. * Callback called when the task is successful
  57909. */
  57910. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  57911. /**
  57912. * Creates a new HDRCubeTextureAssetTask object
  57913. * @param name defines the name of the task
  57914. * @param url defines the location of the file to load
  57915. * @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.
  57916. * @param noMipmap defines if mipmaps should not be generated (default is false)
  57917. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  57918. * @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)
  57919. * @param reserved Internal use only
  57920. */
  57921. constructor(
  57922. /**
  57923. * Defines the name of the task
  57924. */
  57925. name: string,
  57926. /**
  57927. * Defines the location of the file to load
  57928. */
  57929. url: string,
  57930. /**
  57931. * Defines the desired size (the more it increases the longer the generation will be)
  57932. */
  57933. size: number,
  57934. /**
  57935. * Defines if mipmaps should not be generated (default is false)
  57936. */
  57937. noMipmap?: boolean,
  57938. /**
  57939. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  57940. */
  57941. generateHarmonics?: boolean,
  57942. /**
  57943. * 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)
  57944. */
  57945. gammaSpace?: boolean,
  57946. /**
  57947. * Internal Use Only
  57948. */
  57949. reserved?: boolean);
  57950. /**
  57951. * Execute the current task
  57952. * @param scene defines the scene where you want your assets to be loaded
  57953. * @param onSuccess is a callback called when the task is successfully executed
  57954. * @param onError is a callback called if an error occurs
  57955. */
  57956. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57957. }
  57958. /**
  57959. * Define a task used by AssetsManager to load Equirectangular cube textures
  57960. */
  57961. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  57962. /**
  57963. * Defines the name of the task
  57964. */
  57965. name: string;
  57966. /**
  57967. * Defines the location of the file to load
  57968. */
  57969. url: string;
  57970. /**
  57971. * Defines the desired size (the more it increases the longer the generation will be)
  57972. */
  57973. size: number;
  57974. /**
  57975. * Defines if mipmaps should not be generated (default is false)
  57976. */
  57977. noMipmap: boolean;
  57978. /**
  57979. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  57980. * but the standard material would require them in Gamma space) (default is true)
  57981. */
  57982. gammaSpace: boolean;
  57983. /**
  57984. * Gets the loaded texture
  57985. */
  57986. texture: EquiRectangularCubeTexture;
  57987. /**
  57988. * Callback called when the task is successful
  57989. */
  57990. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  57991. /**
  57992. * Callback called when the task is successful
  57993. */
  57994. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  57995. /**
  57996. * Creates a new EquiRectangularCubeTextureAssetTask object
  57997. * @param name defines the name of the task
  57998. * @param url defines the location of the file to load
  57999. * @param size defines the desired size (the more it increases the longer the generation will be)
  58000. * If the size is omitted this implies you are using a preprocessed cubemap.
  58001. * @param noMipmap defines if mipmaps should not be generated (default is false)
  58002. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  58003. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  58004. * (default is true)
  58005. */
  58006. constructor(
  58007. /**
  58008. * Defines the name of the task
  58009. */
  58010. name: string,
  58011. /**
  58012. * Defines the location of the file to load
  58013. */
  58014. url: string,
  58015. /**
  58016. * Defines the desired size (the more it increases the longer the generation will be)
  58017. */
  58018. size: number,
  58019. /**
  58020. * Defines if mipmaps should not be generated (default is false)
  58021. */
  58022. noMipmap?: boolean,
  58023. /**
  58024. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  58025. * but the standard material would require them in Gamma space) (default is true)
  58026. */
  58027. gammaSpace?: boolean);
  58028. /**
  58029. * Execute the current task
  58030. * @param scene defines the scene where you want your assets to be loaded
  58031. * @param onSuccess is a callback called when the task is successfully executed
  58032. * @param onError is a callback called if an error occurs
  58033. */
  58034. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  58035. }
  58036. /**
  58037. * This class can be used to easily import assets into a scene
  58038. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  58039. */
  58040. export class AssetsManager {
  58041. private _scene;
  58042. private _isLoading;
  58043. protected _tasks: AbstractAssetTask[];
  58044. protected _waitingTasksCount: number;
  58045. protected _totalTasksCount: number;
  58046. /**
  58047. * Callback called when all tasks are processed
  58048. */
  58049. onFinish: (tasks: AbstractAssetTask[]) => void;
  58050. /**
  58051. * Callback called when a task is successful
  58052. */
  58053. onTaskSuccess: (task: AbstractAssetTask) => void;
  58054. /**
  58055. * Callback called when a task had an error
  58056. */
  58057. onTaskError: (task: AbstractAssetTask) => void;
  58058. /**
  58059. * Callback called when a task is done (whatever the result is)
  58060. */
  58061. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  58062. /**
  58063. * Observable called when all tasks are processed
  58064. */
  58065. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  58066. /**
  58067. * Observable called when a task had an error
  58068. */
  58069. onTaskErrorObservable: Observable<AbstractAssetTask>;
  58070. /**
  58071. * Observable called when all tasks were executed
  58072. */
  58073. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  58074. /**
  58075. * Observable called when a task is done (whatever the result is)
  58076. */
  58077. onProgressObservable: Observable<IAssetsProgressEvent>;
  58078. /**
  58079. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  58080. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  58081. */
  58082. useDefaultLoadingScreen: boolean;
  58083. /**
  58084. * Creates a new AssetsManager
  58085. * @param scene defines the scene to work on
  58086. */
  58087. constructor(scene: Scene);
  58088. /**
  58089. * Add a MeshAssetTask to the list of active tasks
  58090. * @param taskName defines the name of the new task
  58091. * @param meshesNames defines the name of meshes to load
  58092. * @param rootUrl defines the root url to use to locate files
  58093. * @param sceneFilename defines the filename of the scene file
  58094. * @returns a new MeshAssetTask object
  58095. */
  58096. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  58097. /**
  58098. * Add a TextFileAssetTask to the list of active tasks
  58099. * @param taskName defines the name of the new task
  58100. * @param url defines the url of the file to load
  58101. * @returns a new TextFileAssetTask object
  58102. */
  58103. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  58104. /**
  58105. * Add a BinaryFileAssetTask to the list of active tasks
  58106. * @param taskName defines the name of the new task
  58107. * @param url defines the url of the file to load
  58108. * @returns a new BinaryFileAssetTask object
  58109. */
  58110. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  58111. /**
  58112. * Add a ImageAssetTask to the list of active tasks
  58113. * @param taskName defines the name of the new task
  58114. * @param url defines the url of the file to load
  58115. * @returns a new ImageAssetTask object
  58116. */
  58117. addImageTask(taskName: string, url: string): ImageAssetTask;
  58118. /**
  58119. * Add a TextureAssetTask to the list of active tasks
  58120. * @param taskName defines the name of the new task
  58121. * @param url defines the url of the file to load
  58122. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  58123. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  58124. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  58125. * @returns a new TextureAssetTask object
  58126. */
  58127. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  58128. /**
  58129. * Add a CubeTextureAssetTask to the list of active tasks
  58130. * @param taskName defines the name of the new task
  58131. * @param url defines the url of the file to load
  58132. * @param extensions defines the extension to use to load the cube map (can be null)
  58133. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  58134. * @param files defines the list of files to load (can be null)
  58135. * @returns a new CubeTextureAssetTask object
  58136. */
  58137. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  58138. /**
  58139. *
  58140. * Add a HDRCubeTextureAssetTask to the list of active tasks
  58141. * @param taskName defines the name of the new task
  58142. * @param url defines the url of the file to load
  58143. * @param size defines the size you want for the cubemap (can be null)
  58144. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  58145. * @param generateHarmonics defines if you want to automatically generate (true by default)
  58146. * @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)
  58147. * @param reserved Internal use only
  58148. * @returns a new HDRCubeTextureAssetTask object
  58149. */
  58150. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  58151. /**
  58152. *
  58153. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  58154. * @param taskName defines the name of the new task
  58155. * @param url defines the url of the file to load
  58156. * @param size defines the size you want for the cubemap (can be null)
  58157. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  58158. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  58159. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  58160. * @returns a new EquiRectangularCubeTextureAssetTask object
  58161. */
  58162. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  58163. /**
  58164. * Remove a task from the assets manager.
  58165. * @param task the task to remove
  58166. */
  58167. removeTask(task: AbstractAssetTask): void;
  58168. private _decreaseWaitingTasksCount;
  58169. private _runTask;
  58170. /**
  58171. * Reset the AssetsManager and remove all tasks
  58172. * @return the current instance of the AssetsManager
  58173. */
  58174. reset(): AssetsManager;
  58175. /**
  58176. * Start the loading process
  58177. * @return the current instance of the AssetsManager
  58178. */
  58179. load(): AssetsManager;
  58180. /**
  58181. * Start the loading process as an async operation
  58182. * @return a promise returning the list of failed tasks
  58183. */
  58184. loadAsync(): Promise<void>;
  58185. }
  58186. }
  58187. declare module BABYLON {
  58188. /**
  58189. * Wrapper class for promise with external resolve and reject.
  58190. */
  58191. export class Deferred<T> {
  58192. /**
  58193. * The promise associated with this deferred object.
  58194. */
  58195. readonly promise: Promise<T>;
  58196. private _resolve;
  58197. private _reject;
  58198. /**
  58199. * The resolve method of the promise associated with this deferred object.
  58200. */
  58201. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  58202. /**
  58203. * The reject method of the promise associated with this deferred object.
  58204. */
  58205. readonly reject: (reason?: any) => void;
  58206. /**
  58207. * Constructor for this deferred object.
  58208. */
  58209. constructor();
  58210. }
  58211. }
  58212. declare module BABYLON {
  58213. /**
  58214. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  58215. */
  58216. export class MeshExploder {
  58217. private _centerMesh;
  58218. private _meshes;
  58219. private _meshesOrigins;
  58220. private _toCenterVectors;
  58221. private _scaledDirection;
  58222. private _newPosition;
  58223. private _centerPosition;
  58224. /**
  58225. * Explodes meshes from a center mesh.
  58226. * @param meshes The meshes to explode.
  58227. * @param centerMesh The mesh to be center of explosion.
  58228. */
  58229. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  58230. private _setCenterMesh;
  58231. /**
  58232. * Get class name
  58233. * @returns "MeshExploder"
  58234. */
  58235. getClassName(): string;
  58236. /**
  58237. * "Exploded meshes"
  58238. * @returns Array of meshes with the centerMesh at index 0.
  58239. */
  58240. getMeshes(): Array<Mesh>;
  58241. /**
  58242. * Explodes meshes giving a specific direction
  58243. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  58244. */
  58245. explode(direction?: number): void;
  58246. }
  58247. }
  58248. declare module BABYLON {
  58249. /**
  58250. * Class used to help managing file picking and drag'n'drop
  58251. */
  58252. export class FilesInput {
  58253. /**
  58254. * List of files ready to be loaded
  58255. */
  58256. static readonly FilesToLoad: {
  58257. [key: string]: File;
  58258. };
  58259. /**
  58260. * Callback called when a file is processed
  58261. */
  58262. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  58263. private _engine;
  58264. private _currentScene;
  58265. private _sceneLoadedCallback;
  58266. private _progressCallback;
  58267. private _additionalRenderLoopLogicCallback;
  58268. private _textureLoadingCallback;
  58269. private _startingProcessingFilesCallback;
  58270. private _onReloadCallback;
  58271. private _errorCallback;
  58272. private _elementToMonitor;
  58273. private _sceneFileToLoad;
  58274. private _filesToLoad;
  58275. /**
  58276. * Creates a new FilesInput
  58277. * @param engine defines the rendering engine
  58278. * @param scene defines the hosting scene
  58279. * @param sceneLoadedCallback callback called when scene is loaded
  58280. * @param progressCallback callback called to track progress
  58281. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  58282. * @param textureLoadingCallback callback called when a texture is loading
  58283. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  58284. * @param onReloadCallback callback called when a reload is requested
  58285. * @param errorCallback callback call if an error occurs
  58286. */
  58287. 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);
  58288. private _dragEnterHandler;
  58289. private _dragOverHandler;
  58290. private _dropHandler;
  58291. /**
  58292. * Calls this function to listen to drag'n'drop events on a specific DOM element
  58293. * @param elementToMonitor defines the DOM element to track
  58294. */
  58295. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  58296. /**
  58297. * Release all associated resources
  58298. */
  58299. dispose(): void;
  58300. private renderFunction;
  58301. private drag;
  58302. private drop;
  58303. private _traverseFolder;
  58304. private _processFiles;
  58305. /**
  58306. * Load files from a drop event
  58307. * @param event defines the drop event to use as source
  58308. */
  58309. loadFiles(event: any): void;
  58310. private _processReload;
  58311. /**
  58312. * Reload the current scene from the loaded files
  58313. */
  58314. reload(): void;
  58315. }
  58316. }
  58317. declare module BABYLON {
  58318. /**
  58319. * Defines the root class used to create scene optimization to use with SceneOptimizer
  58320. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58321. */
  58322. export class SceneOptimization {
  58323. /**
  58324. * Defines the priority of this optimization (0 by default which means first in the list)
  58325. */
  58326. priority: number;
  58327. /**
  58328. * Gets a string describing the action executed by the current optimization
  58329. * @returns description string
  58330. */
  58331. getDescription(): string;
  58332. /**
  58333. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58334. * @param scene defines the current scene where to apply this optimization
  58335. * @param optimizer defines the current optimizer
  58336. * @returns true if everything that can be done was applied
  58337. */
  58338. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58339. /**
  58340. * Creates the SceneOptimization object
  58341. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  58342. * @param desc defines the description associated with the optimization
  58343. */
  58344. constructor(
  58345. /**
  58346. * Defines the priority of this optimization (0 by default which means first in the list)
  58347. */
  58348. priority?: number);
  58349. }
  58350. /**
  58351. * Defines an optimization used to reduce the size of render target textures
  58352. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58353. */
  58354. export class TextureOptimization extends SceneOptimization {
  58355. /**
  58356. * Defines the priority of this optimization (0 by default which means first in the list)
  58357. */
  58358. priority: number;
  58359. /**
  58360. * 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
  58361. */
  58362. maximumSize: number;
  58363. /**
  58364. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  58365. */
  58366. step: number;
  58367. /**
  58368. * Gets a string describing the action executed by the current optimization
  58369. * @returns description string
  58370. */
  58371. getDescription(): string;
  58372. /**
  58373. * Creates the TextureOptimization object
  58374. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  58375. * @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
  58376. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  58377. */
  58378. constructor(
  58379. /**
  58380. * Defines the priority of this optimization (0 by default which means first in the list)
  58381. */
  58382. priority?: number,
  58383. /**
  58384. * 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
  58385. */
  58386. maximumSize?: number,
  58387. /**
  58388. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  58389. */
  58390. step?: number);
  58391. /**
  58392. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58393. * @param scene defines the current scene where to apply this optimization
  58394. * @param optimizer defines the current optimizer
  58395. * @returns true if everything that can be done was applied
  58396. */
  58397. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58398. }
  58399. /**
  58400. * Defines an optimization used to increase or decrease the rendering resolution
  58401. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58402. */
  58403. export class HardwareScalingOptimization extends SceneOptimization {
  58404. /**
  58405. * Defines the priority of this optimization (0 by default which means first in the list)
  58406. */
  58407. priority: number;
  58408. /**
  58409. * Defines the maximum scale to use (2 by default)
  58410. */
  58411. maximumScale: number;
  58412. /**
  58413. * Defines the step to use between two passes (0.5 by default)
  58414. */
  58415. step: number;
  58416. private _currentScale;
  58417. private _directionOffset;
  58418. /**
  58419. * Gets a string describing the action executed by the current optimization
  58420. * @return description string
  58421. */
  58422. getDescription(): string;
  58423. /**
  58424. * Creates the HardwareScalingOptimization object
  58425. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  58426. * @param maximumScale defines the maximum scale to use (2 by default)
  58427. * @param step defines the step to use between two passes (0.5 by default)
  58428. */
  58429. constructor(
  58430. /**
  58431. * Defines the priority of this optimization (0 by default which means first in the list)
  58432. */
  58433. priority?: number,
  58434. /**
  58435. * Defines the maximum scale to use (2 by default)
  58436. */
  58437. maximumScale?: number,
  58438. /**
  58439. * Defines the step to use between two passes (0.5 by default)
  58440. */
  58441. step?: number);
  58442. /**
  58443. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58444. * @param scene defines the current scene where to apply this optimization
  58445. * @param optimizer defines the current optimizer
  58446. * @returns true if everything that can be done was applied
  58447. */
  58448. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58449. }
  58450. /**
  58451. * Defines an optimization used to remove shadows
  58452. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58453. */
  58454. export class ShadowsOptimization extends SceneOptimization {
  58455. /**
  58456. * Gets a string describing the action executed by the current optimization
  58457. * @return description string
  58458. */
  58459. getDescription(): string;
  58460. /**
  58461. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58462. * @param scene defines the current scene where to apply this optimization
  58463. * @param optimizer defines the current optimizer
  58464. * @returns true if everything that can be done was applied
  58465. */
  58466. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58467. }
  58468. /**
  58469. * Defines an optimization used to turn post-processes off
  58470. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58471. */
  58472. export class PostProcessesOptimization extends SceneOptimization {
  58473. /**
  58474. * Gets a string describing the action executed by the current optimization
  58475. * @return description string
  58476. */
  58477. getDescription(): string;
  58478. /**
  58479. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58480. * @param scene defines the current scene where to apply this optimization
  58481. * @param optimizer defines the current optimizer
  58482. * @returns true if everything that can be done was applied
  58483. */
  58484. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58485. }
  58486. /**
  58487. * Defines an optimization used to turn lens flares off
  58488. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58489. */
  58490. export class LensFlaresOptimization extends SceneOptimization {
  58491. /**
  58492. * Gets a string describing the action executed by the current optimization
  58493. * @return description string
  58494. */
  58495. getDescription(): string;
  58496. /**
  58497. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58498. * @param scene defines the current scene where to apply this optimization
  58499. * @param optimizer defines the current optimizer
  58500. * @returns true if everything that can be done was applied
  58501. */
  58502. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58503. }
  58504. /**
  58505. * Defines an optimization based on user defined callback.
  58506. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58507. */
  58508. export class CustomOptimization extends SceneOptimization {
  58509. /**
  58510. * Callback called to apply the custom optimization.
  58511. */
  58512. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  58513. /**
  58514. * Callback called to get custom description
  58515. */
  58516. onGetDescription: () => string;
  58517. /**
  58518. * Gets a string describing the action executed by the current optimization
  58519. * @returns description string
  58520. */
  58521. getDescription(): string;
  58522. /**
  58523. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58524. * @param scene defines the current scene where to apply this optimization
  58525. * @param optimizer defines the current optimizer
  58526. * @returns true if everything that can be done was applied
  58527. */
  58528. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58529. }
  58530. /**
  58531. * Defines an optimization used to turn particles off
  58532. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58533. */
  58534. export class ParticlesOptimization extends SceneOptimization {
  58535. /**
  58536. * Gets a string describing the action executed by the current optimization
  58537. * @return description string
  58538. */
  58539. getDescription(): string;
  58540. /**
  58541. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58542. * @param scene defines the current scene where to apply this optimization
  58543. * @param optimizer defines the current optimizer
  58544. * @returns true if everything that can be done was applied
  58545. */
  58546. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58547. }
  58548. /**
  58549. * Defines an optimization used to turn render targets off
  58550. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58551. */
  58552. export class RenderTargetsOptimization extends SceneOptimization {
  58553. /**
  58554. * Gets a string describing the action executed by the current optimization
  58555. * @return description string
  58556. */
  58557. getDescription(): string;
  58558. /**
  58559. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58560. * @param scene defines the current scene where to apply this optimization
  58561. * @param optimizer defines the current optimizer
  58562. * @returns true if everything that can be done was applied
  58563. */
  58564. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58565. }
  58566. /**
  58567. * Defines an optimization used to merge meshes with compatible materials
  58568. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58569. */
  58570. export class MergeMeshesOptimization extends SceneOptimization {
  58571. private static _UpdateSelectionTree;
  58572. /**
  58573. * Gets or sets a boolean which defines if optimization octree has to be updated
  58574. */
  58575. /**
  58576. * Gets or sets a boolean which defines if optimization octree has to be updated
  58577. */
  58578. static UpdateSelectionTree: boolean;
  58579. /**
  58580. * Gets a string describing the action executed by the current optimization
  58581. * @return description string
  58582. */
  58583. getDescription(): string;
  58584. private _canBeMerged;
  58585. /**
  58586. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58587. * @param scene defines the current scene where to apply this optimization
  58588. * @param optimizer defines the current optimizer
  58589. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  58590. * @returns true if everything that can be done was applied
  58591. */
  58592. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  58593. }
  58594. /**
  58595. * Defines a list of options used by SceneOptimizer
  58596. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58597. */
  58598. export class SceneOptimizerOptions {
  58599. /**
  58600. * Defines the target frame rate to reach (60 by default)
  58601. */
  58602. targetFrameRate: number;
  58603. /**
  58604. * Defines the interval between two checkes (2000ms by default)
  58605. */
  58606. trackerDuration: number;
  58607. /**
  58608. * Gets the list of optimizations to apply
  58609. */
  58610. optimizations: SceneOptimization[];
  58611. /**
  58612. * Creates a new list of options used by SceneOptimizer
  58613. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  58614. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  58615. */
  58616. constructor(
  58617. /**
  58618. * Defines the target frame rate to reach (60 by default)
  58619. */
  58620. targetFrameRate?: number,
  58621. /**
  58622. * Defines the interval between two checkes (2000ms by default)
  58623. */
  58624. trackerDuration?: number);
  58625. /**
  58626. * Add a new optimization
  58627. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  58628. * @returns the current SceneOptimizerOptions
  58629. */
  58630. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  58631. /**
  58632. * Add a new custom optimization
  58633. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  58634. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  58635. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  58636. * @returns the current SceneOptimizerOptions
  58637. */
  58638. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  58639. /**
  58640. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  58641. * @param targetFrameRate defines the target frame rate (60 by default)
  58642. * @returns a SceneOptimizerOptions object
  58643. */
  58644. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  58645. /**
  58646. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  58647. * @param targetFrameRate defines the target frame rate (60 by default)
  58648. * @returns a SceneOptimizerOptions object
  58649. */
  58650. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  58651. /**
  58652. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  58653. * @param targetFrameRate defines the target frame rate (60 by default)
  58654. * @returns a SceneOptimizerOptions object
  58655. */
  58656. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  58657. }
  58658. /**
  58659. * Class used to run optimizations in order to reach a target frame rate
  58660. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58661. */
  58662. export class SceneOptimizer implements IDisposable {
  58663. private _isRunning;
  58664. private _options;
  58665. private _scene;
  58666. private _currentPriorityLevel;
  58667. private _targetFrameRate;
  58668. private _trackerDuration;
  58669. private _currentFrameRate;
  58670. private _sceneDisposeObserver;
  58671. private _improvementMode;
  58672. /**
  58673. * Defines an observable called when the optimizer reaches the target frame rate
  58674. */
  58675. onSuccessObservable: Observable<SceneOptimizer>;
  58676. /**
  58677. * Defines an observable called when the optimizer enables an optimization
  58678. */
  58679. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  58680. /**
  58681. * Defines an observable called when the optimizer is not able to reach the target frame rate
  58682. */
  58683. onFailureObservable: Observable<SceneOptimizer>;
  58684. /**
  58685. * Gets a boolean indicating if the optimizer is in improvement mode
  58686. */
  58687. readonly isInImprovementMode: boolean;
  58688. /**
  58689. * Gets the current priority level (0 at start)
  58690. */
  58691. readonly currentPriorityLevel: number;
  58692. /**
  58693. * Gets the current frame rate checked by the SceneOptimizer
  58694. */
  58695. readonly currentFrameRate: number;
  58696. /**
  58697. * Gets or sets the current target frame rate (60 by default)
  58698. */
  58699. /**
  58700. * Gets or sets the current target frame rate (60 by default)
  58701. */
  58702. targetFrameRate: number;
  58703. /**
  58704. * Gets or sets the current interval between two checks (every 2000ms by default)
  58705. */
  58706. /**
  58707. * Gets or sets the current interval between two checks (every 2000ms by default)
  58708. */
  58709. trackerDuration: number;
  58710. /**
  58711. * Gets the list of active optimizations
  58712. */
  58713. readonly optimizations: SceneOptimization[];
  58714. /**
  58715. * Creates a new SceneOptimizer
  58716. * @param scene defines the scene to work on
  58717. * @param options defines the options to use with the SceneOptimizer
  58718. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  58719. * @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)
  58720. */
  58721. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  58722. /**
  58723. * Stops the current optimizer
  58724. */
  58725. stop(): void;
  58726. /**
  58727. * Reset the optimizer to initial step (current priority level = 0)
  58728. */
  58729. reset(): void;
  58730. /**
  58731. * Start the optimizer. By default it will try to reach a specific framerate
  58732. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  58733. */
  58734. start(): void;
  58735. private _checkCurrentState;
  58736. /**
  58737. * Release all resources
  58738. */
  58739. dispose(): void;
  58740. /**
  58741. * Helper function to create a SceneOptimizer with one single line of code
  58742. * @param scene defines the scene to work on
  58743. * @param options defines the options to use with the SceneOptimizer
  58744. * @param onSuccess defines a callback to call on success
  58745. * @param onFailure defines a callback to call on failure
  58746. * @returns the new SceneOptimizer object
  58747. */
  58748. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  58749. }
  58750. }
  58751. declare module BABYLON {
  58752. /**
  58753. * Class used to serialize a scene into a string
  58754. */
  58755. export class SceneSerializer {
  58756. /**
  58757. * Clear cache used by a previous serialization
  58758. */
  58759. static ClearCache(): void;
  58760. /**
  58761. * Serialize a scene into a JSON compatible object
  58762. * @param scene defines the scene to serialize
  58763. * @returns a JSON compatible object
  58764. */
  58765. static Serialize(scene: Scene): any;
  58766. /**
  58767. * Serialize a mesh into a JSON compatible object
  58768. * @param toSerialize defines the mesh to serialize
  58769. * @param withParents defines if parents must be serialized as well
  58770. * @param withChildren defines if children must be serialized as well
  58771. * @returns a JSON compatible object
  58772. */
  58773. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  58774. }
  58775. }
  58776. declare module BABYLON {
  58777. /**
  58778. * Class used to host texture specific utilities
  58779. */
  58780. export class TextureTools {
  58781. /**
  58782. * Uses the GPU to create a copy texture rescaled at a given size
  58783. * @param texture Texture to copy from
  58784. * @param width defines the desired width
  58785. * @param height defines the desired height
  58786. * @param useBilinearMode defines if bilinear mode has to be used
  58787. * @return the generated texture
  58788. */
  58789. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  58790. }
  58791. }
  58792. declare module BABYLON {
  58793. /**
  58794. * This represents the different options avilable for the video capture.
  58795. */
  58796. export interface VideoRecorderOptions {
  58797. /** Defines the mime type of the video */
  58798. mimeType: string;
  58799. /** Defines the video the video should be recorded at */
  58800. fps: number;
  58801. /** Defines the chunk size for the recording data */
  58802. recordChunckSize: number;
  58803. /** The audio tracks to attach to the record */
  58804. audioTracks?: MediaStreamTrack[];
  58805. }
  58806. /**
  58807. * This can helps recording videos from BabylonJS.
  58808. * This is based on the available WebRTC functionalities of the browser.
  58809. *
  58810. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  58811. */
  58812. export class VideoRecorder {
  58813. private static readonly _defaultOptions;
  58814. /**
  58815. * Returns wehther or not the VideoRecorder is available in your browser.
  58816. * @param engine Defines the Babylon Engine to check the support for
  58817. * @returns true if supported otherwise false
  58818. */
  58819. static IsSupported(engine: Engine): boolean;
  58820. private readonly _options;
  58821. private _canvas;
  58822. private _mediaRecorder;
  58823. private _recordedChunks;
  58824. private _fileName;
  58825. private _resolve;
  58826. private _reject;
  58827. /**
  58828. * True wether a recording is already in progress.
  58829. */
  58830. readonly isRecording: boolean;
  58831. /**
  58832. * Create a new VideoCapture object which can help converting what you see in Babylon to
  58833. * a video file.
  58834. * @param engine Defines the BabylonJS Engine you wish to record
  58835. * @param options Defines options that can be used to customized the capture
  58836. */
  58837. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  58838. /**
  58839. * Stops the current recording before the default capture timeout passed in the startRecording
  58840. * functions.
  58841. */
  58842. stopRecording(): void;
  58843. /**
  58844. * Starts recording the canvas for a max duration specified in parameters.
  58845. * @param fileName Defines the name of the file to be downloaded when the recording stop. If null no automatic download will start and you can rely on the promise to get the data back.
  58846. * @param maxDuration Defines the maximum recording time in seconds.
  58847. * It default to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  58848. * @return a promise callback at the end of the recording with the video data in Blob.
  58849. */
  58850. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  58851. /**
  58852. * Releases internal resources used during the recording.
  58853. */
  58854. dispose(): void;
  58855. private _handleDataAvailable;
  58856. private _handleError;
  58857. private _handleStop;
  58858. }
  58859. }
  58860. declare module BABYLON {
  58861. /**
  58862. * Class containing a set of static utilities functions for screenshots
  58863. */
  58864. export class ScreenshotTools {
  58865. /**
  58866. * Captures a screenshot of the current rendering
  58867. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  58868. * @param engine defines the rendering engine
  58869. * @param camera defines the source camera
  58870. * @param size This parameter can be set to a single number or to an object with the
  58871. * following (optional) properties: precision, width, height. If a single number is passed,
  58872. * it will be used for both width and height. If an object is passed, the screenshot size
  58873. * will be derived from the parameters. The precision property is a multiplier allowing
  58874. * rendering at a higher or lower resolution
  58875. * @param successCallback defines the callback receives a single parameter which contains the
  58876. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  58877. * src parameter of an <img> to display it
  58878. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  58879. * Check your browser for supported MIME types
  58880. */
  58881. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  58882. /**
  58883. * Generates an image screenshot from the specified camera.
  58884. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  58885. * @param engine The engine to use for rendering
  58886. * @param camera The camera to use for rendering
  58887. * @param size This parameter can be set to a single number or to an object with the
  58888. * following (optional) properties: precision, width, height. If a single number is passed,
  58889. * it will be used for both width and height. If an object is passed, the screenshot size
  58890. * will be derived from the parameters. The precision property is a multiplier allowing
  58891. * rendering at a higher or lower resolution
  58892. * @param successCallback The callback receives a single parameter which contains the
  58893. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  58894. * src parameter of an <img> to display it
  58895. * @param mimeType The MIME type of the screenshot image (default: image/png).
  58896. * Check your browser for supported MIME types
  58897. * @param samples Texture samples (default: 1)
  58898. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  58899. * @param fileName A name for for the downloaded file.
  58900. */
  58901. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  58902. }
  58903. }
  58904. declare module BABYLON {
  58905. /**
  58906. * A cursor which tracks a point on a path
  58907. */
  58908. export class PathCursor {
  58909. private path;
  58910. /**
  58911. * Stores path cursor callbacks for when an onchange event is triggered
  58912. */
  58913. private _onchange;
  58914. /**
  58915. * The value of the path cursor
  58916. */
  58917. value: number;
  58918. /**
  58919. * The animation array of the path cursor
  58920. */
  58921. animations: Animation[];
  58922. /**
  58923. * Initializes the path cursor
  58924. * @param path The path to track
  58925. */
  58926. constructor(path: Path2);
  58927. /**
  58928. * Gets the cursor point on the path
  58929. * @returns A point on the path cursor at the cursor location
  58930. */
  58931. getPoint(): Vector3;
  58932. /**
  58933. * Moves the cursor ahead by the step amount
  58934. * @param step The amount to move the cursor forward
  58935. * @returns This path cursor
  58936. */
  58937. moveAhead(step?: number): PathCursor;
  58938. /**
  58939. * Moves the cursor behind by the step amount
  58940. * @param step The amount to move the cursor back
  58941. * @returns This path cursor
  58942. */
  58943. moveBack(step?: number): PathCursor;
  58944. /**
  58945. * Moves the cursor by the step amount
  58946. * If the step amount is greater than one, an exception is thrown
  58947. * @param step The amount to move the cursor
  58948. * @returns This path cursor
  58949. */
  58950. move(step: number): PathCursor;
  58951. /**
  58952. * Ensures that the value is limited between zero and one
  58953. * @returns This path cursor
  58954. */
  58955. private ensureLimits;
  58956. /**
  58957. * Runs onchange callbacks on change (used by the animation engine)
  58958. * @returns This path cursor
  58959. */
  58960. private raiseOnChange;
  58961. /**
  58962. * Executes a function on change
  58963. * @param f A path cursor onchange callback
  58964. * @returns This path cursor
  58965. */
  58966. onchange(f: (cursor: PathCursor) => void): PathCursor;
  58967. }
  58968. }
  58969. declare module BABYLON {
  58970. /** @hidden */
  58971. export var blurPixelShader: {
  58972. name: string;
  58973. shader: string;
  58974. };
  58975. }
  58976. declare module BABYLON {
  58977. /** @hidden */
  58978. export var bones300Declaration: {
  58979. name: string;
  58980. shader: string;
  58981. };
  58982. }
  58983. declare module BABYLON {
  58984. /** @hidden */
  58985. export var instances300Declaration: {
  58986. name: string;
  58987. shader: string;
  58988. };
  58989. }
  58990. declare module BABYLON {
  58991. /** @hidden */
  58992. export var pointCloudVertexDeclaration: {
  58993. name: string;
  58994. shader: string;
  58995. };
  58996. }
  58997. // Mixins
  58998. interface Window {
  58999. mozIndexedDB: IDBFactory;
  59000. webkitIndexedDB: IDBFactory;
  59001. msIndexedDB: IDBFactory;
  59002. webkitURL: typeof URL;
  59003. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  59004. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  59005. WebGLRenderingContext: WebGLRenderingContext;
  59006. MSGesture: MSGesture;
  59007. CANNON: any;
  59008. AudioContext: AudioContext;
  59009. webkitAudioContext: AudioContext;
  59010. PointerEvent: any;
  59011. Math: Math;
  59012. Uint8Array: Uint8ArrayConstructor;
  59013. Float32Array: Float32ArrayConstructor;
  59014. mozURL: typeof URL;
  59015. msURL: typeof URL;
  59016. VRFrameData: any; // WebVR, from specs 1.1
  59017. DracoDecoderModule: any;
  59018. setImmediate(handler: (...args: any[]) => void): number;
  59019. }
  59020. interface HTMLCanvasElement {
  59021. requestPointerLock(): void;
  59022. msRequestPointerLock?(): void;
  59023. mozRequestPointerLock?(): void;
  59024. webkitRequestPointerLock?(): void;
  59025. /** Track wether a record is in progress */
  59026. isRecording: boolean;
  59027. /** Capture Stream method defined by some browsers */
  59028. captureStream(fps?: number): MediaStream;
  59029. }
  59030. interface CanvasRenderingContext2D {
  59031. msImageSmoothingEnabled: boolean;
  59032. }
  59033. interface MouseEvent {
  59034. mozMovementX: number;
  59035. mozMovementY: number;
  59036. webkitMovementX: number;
  59037. webkitMovementY: number;
  59038. msMovementX: number;
  59039. msMovementY: number;
  59040. }
  59041. interface Navigator {
  59042. mozGetVRDevices: (any: any) => any;
  59043. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  59044. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  59045. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  59046. webkitGetGamepads(): Gamepad[];
  59047. msGetGamepads(): Gamepad[];
  59048. webkitGamepads(): Gamepad[];
  59049. }
  59050. interface HTMLVideoElement {
  59051. mozSrcObject: any;
  59052. }
  59053. interface Math {
  59054. fround(x: number): number;
  59055. imul(a: number, b: number): number;
  59056. }
  59057. interface WebGLRenderingContext {
  59058. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  59059. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  59060. vertexAttribDivisor(index: number, divisor: number): void;
  59061. createVertexArray(): any;
  59062. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  59063. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  59064. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  59065. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  59066. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  59067. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  59068. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  59069. // Queries
  59070. createQuery(): WebGLQuery;
  59071. deleteQuery(query: WebGLQuery): void;
  59072. beginQuery(target: number, query: WebGLQuery): void;
  59073. endQuery(target: number): void;
  59074. getQueryParameter(query: WebGLQuery, pname: number): any;
  59075. getQuery(target: number, pname: number): any;
  59076. MAX_SAMPLES: number;
  59077. RGBA8: number;
  59078. READ_FRAMEBUFFER: number;
  59079. DRAW_FRAMEBUFFER: number;
  59080. UNIFORM_BUFFER: number;
  59081. HALF_FLOAT_OES: number;
  59082. RGBA16F: number;
  59083. RGBA32F: number;
  59084. R32F: number;
  59085. RG32F: number;
  59086. RGB32F: number;
  59087. R16F: number;
  59088. RG16F: number;
  59089. RGB16F: number;
  59090. RED: number;
  59091. RG: number;
  59092. R8: number;
  59093. RG8: number;
  59094. UNSIGNED_INT_24_8: number;
  59095. DEPTH24_STENCIL8: number;
  59096. /* Multiple Render Targets */
  59097. drawBuffers(buffers: number[]): void;
  59098. readBuffer(src: number): void;
  59099. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  59100. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  59101. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  59102. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  59103. // Occlusion Query
  59104. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  59105. ANY_SAMPLES_PASSED: number;
  59106. QUERY_RESULT_AVAILABLE: number;
  59107. QUERY_RESULT: number;
  59108. }
  59109. interface WebGLProgram {
  59110. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  59111. }
  59112. interface EXT_disjoint_timer_query {
  59113. QUERY_COUNTER_BITS_EXT: number;
  59114. TIME_ELAPSED_EXT: number;
  59115. TIMESTAMP_EXT: number;
  59116. GPU_DISJOINT_EXT: number;
  59117. QUERY_RESULT_EXT: number;
  59118. QUERY_RESULT_AVAILABLE_EXT: number;
  59119. queryCounterEXT(query: WebGLQuery, target: number): void;
  59120. createQueryEXT(): WebGLQuery;
  59121. beginQueryEXT(target: number, query: WebGLQuery): void;
  59122. endQueryEXT(target: number): void;
  59123. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  59124. deleteQueryEXT(query: WebGLQuery): void;
  59125. }
  59126. interface WebGLUniformLocation {
  59127. _currentState: any;
  59128. }
  59129. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  59130. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  59131. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  59132. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  59133. interface WebGLRenderingContext {
  59134. readonly RASTERIZER_DISCARD: number;
  59135. readonly DEPTH_COMPONENT24: number;
  59136. readonly TEXTURE_3D: number;
  59137. readonly TEXTURE_2D_ARRAY: number;
  59138. readonly TEXTURE_COMPARE_FUNC: number;
  59139. readonly TEXTURE_COMPARE_MODE: number;
  59140. readonly COMPARE_REF_TO_TEXTURE: number;
  59141. readonly TEXTURE_WRAP_R: number;
  59142. readonly HALF_FLOAT: number;
  59143. readonly RGB8: number;
  59144. readonly RED_INTEGER: number;
  59145. readonly RG_INTEGER: number;
  59146. readonly RGB_INTEGER: number;
  59147. readonly RGBA_INTEGER: number;
  59148. readonly R8_SNORM: number;
  59149. readonly RG8_SNORM: number;
  59150. readonly RGB8_SNORM: number;
  59151. readonly RGBA8_SNORM: number;
  59152. readonly R8I: number;
  59153. readonly RG8I: number;
  59154. readonly RGB8I: number;
  59155. readonly RGBA8I: number;
  59156. readonly R8UI: number;
  59157. readonly RG8UI: number;
  59158. readonly RGB8UI: number;
  59159. readonly RGBA8UI: number;
  59160. readonly R16I: number;
  59161. readonly RG16I: number;
  59162. readonly RGB16I: number;
  59163. readonly RGBA16I: number;
  59164. readonly R16UI: number;
  59165. readonly RG16UI: number;
  59166. readonly RGB16UI: number;
  59167. readonly RGBA16UI: number;
  59168. readonly R32I: number;
  59169. readonly RG32I: number;
  59170. readonly RGB32I: number;
  59171. readonly RGBA32I: number;
  59172. readonly R32UI: number;
  59173. readonly RG32UI: number;
  59174. readonly RGB32UI: number;
  59175. readonly RGBA32UI: number;
  59176. readonly RGB10_A2UI: number;
  59177. readonly R11F_G11F_B10F: number;
  59178. readonly RGB9_E5: number;
  59179. readonly RGB10_A2: number;
  59180. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  59181. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  59182. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  59183. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  59184. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  59185. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  59186. 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;
  59187. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  59188. readonly TRANSFORM_FEEDBACK: number;
  59189. readonly INTERLEAVED_ATTRIBS: number;
  59190. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  59191. createTransformFeedback(): WebGLTransformFeedback;
  59192. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  59193. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  59194. beginTransformFeedback(primitiveMode: number): void;
  59195. endTransformFeedback(): void;
  59196. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  59197. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  59198. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  59199. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  59200. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  59201. }
  59202. interface ImageBitmap {
  59203. readonly width: number;
  59204. readonly height: number;
  59205. close(): void;
  59206. }
  59207. interface WebGLQuery extends WebGLObject {
  59208. }
  59209. declare var WebGLQuery: {
  59210. prototype: WebGLQuery;
  59211. new(): WebGLQuery;
  59212. };
  59213. interface WebGLSampler extends WebGLObject {
  59214. }
  59215. declare var WebGLSampler: {
  59216. prototype: WebGLSampler;
  59217. new(): WebGLSampler;
  59218. };
  59219. interface WebGLSync extends WebGLObject {
  59220. }
  59221. declare var WebGLSync: {
  59222. prototype: WebGLSync;
  59223. new(): WebGLSync;
  59224. };
  59225. interface WebGLTransformFeedback extends WebGLObject {
  59226. }
  59227. declare var WebGLTransformFeedback: {
  59228. prototype: WebGLTransformFeedback;
  59229. new(): WebGLTransformFeedback;
  59230. };
  59231. interface WebGLVertexArrayObject extends WebGLObject {
  59232. }
  59233. declare var WebGLVertexArrayObject: {
  59234. prototype: WebGLVertexArrayObject;
  59235. new(): WebGLVertexArrayObject;
  59236. };
  59237. // Type definitions for WebVR API
  59238. // Project: https://w3c.github.io/webvr/
  59239. // Definitions by: six a <https://github.com/lostfictions>
  59240. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  59241. interface VRDisplay extends EventTarget {
  59242. /**
  59243. * Dictionary of capabilities describing the VRDisplay.
  59244. */
  59245. readonly capabilities: VRDisplayCapabilities;
  59246. /**
  59247. * z-depth defining the far plane of the eye view frustum
  59248. * enables mapping of values in the render target depth
  59249. * attachment to scene coordinates. Initially set to 10000.0.
  59250. */
  59251. depthFar: number;
  59252. /**
  59253. * z-depth defining the near plane of the eye view frustum
  59254. * enables mapping of values in the render target depth
  59255. * attachment to scene coordinates. Initially set to 0.01.
  59256. */
  59257. depthNear: number;
  59258. /**
  59259. * An identifier for this distinct VRDisplay. Used as an
  59260. * association point in the Gamepad API.
  59261. */
  59262. readonly displayId: number;
  59263. /**
  59264. * A display name, a user-readable name identifying it.
  59265. */
  59266. readonly displayName: string;
  59267. readonly isConnected: boolean;
  59268. readonly isPresenting: boolean;
  59269. /**
  59270. * If this VRDisplay supports room-scale experiences, the optional
  59271. * stage attribute contains details on the room-scale parameters.
  59272. */
  59273. readonly stageParameters: VRStageParameters | null;
  59274. /**
  59275. * Passing the value returned by `requestAnimationFrame` to
  59276. * `cancelAnimationFrame` will unregister the callback.
  59277. * @param handle Define the hanle of the request to cancel
  59278. */
  59279. cancelAnimationFrame(handle: number): void;
  59280. /**
  59281. * Stops presenting to the VRDisplay.
  59282. * @returns a promise to know when it stopped
  59283. */
  59284. exitPresent(): Promise<void>;
  59285. /**
  59286. * Return the current VREyeParameters for the given eye.
  59287. * @param whichEye Define the eye we want the parameter for
  59288. * @returns the eye parameters
  59289. */
  59290. getEyeParameters(whichEye: string): VREyeParameters;
  59291. /**
  59292. * Populates the passed VRFrameData with the information required to render
  59293. * the current frame.
  59294. * @param frameData Define the data structure to populate
  59295. * @returns true if ok otherwise false
  59296. */
  59297. getFrameData(frameData: VRFrameData): boolean;
  59298. /**
  59299. * Get the layers currently being presented.
  59300. * @returns the list of VR layers
  59301. */
  59302. getLayers(): VRLayer[];
  59303. /**
  59304. * Return a VRPose containing the future predicted pose of the VRDisplay
  59305. * when the current frame will be presented. The value returned will not
  59306. * change until JavaScript has returned control to the browser.
  59307. *
  59308. * The VRPose will contain the position, orientation, velocity,
  59309. * and acceleration of each of these properties.
  59310. * @returns the pose object
  59311. */
  59312. getPose(): VRPose;
  59313. /**
  59314. * Return the current instantaneous pose of the VRDisplay, with no
  59315. * prediction applied.
  59316. * @returns the current instantaneous pose
  59317. */
  59318. getImmediatePose(): VRPose;
  59319. /**
  59320. * The callback passed to `requestAnimationFrame` will be called
  59321. * any time a new frame should be rendered. When the VRDisplay is
  59322. * presenting the callback will be called at the native refresh
  59323. * rate of the HMD. When not presenting this function acts
  59324. * identically to how window.requestAnimationFrame acts. Content should
  59325. * make no assumptions of frame rate or vsync behavior as the HMD runs
  59326. * asynchronously from other displays and at differing refresh rates.
  59327. * @param callback Define the eaction to run next frame
  59328. * @returns the request handle it
  59329. */
  59330. requestAnimationFrame(callback: FrameRequestCallback): number;
  59331. /**
  59332. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  59333. * Repeat calls while already presenting will update the VRLayers being displayed.
  59334. * @param layers Define the list of layer to present
  59335. * @returns a promise to know when the request has been fulfilled
  59336. */
  59337. requestPresent(layers: VRLayer[]): Promise<void>;
  59338. /**
  59339. * Reset the pose for this display, treating its current position and
  59340. * orientation as the "origin/zero" values. VRPose.position,
  59341. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  59342. * updated when calling resetPose(). This should be called in only
  59343. * sitting-space experiences.
  59344. */
  59345. resetPose(): void;
  59346. /**
  59347. * The VRLayer provided to the VRDisplay will be captured and presented
  59348. * in the HMD. Calling this function has the same effect on the source
  59349. * canvas as any other operation that uses its source image, and canvases
  59350. * created without preserveDrawingBuffer set to true will be cleared.
  59351. * @param pose Define the pose to submit
  59352. */
  59353. submitFrame(pose?: VRPose): void;
  59354. }
  59355. declare var VRDisplay: {
  59356. prototype: VRDisplay;
  59357. new(): VRDisplay;
  59358. };
  59359. interface VRLayer {
  59360. leftBounds?: number[] | Float32Array | null;
  59361. rightBounds?: number[] | Float32Array | null;
  59362. source?: HTMLCanvasElement | null;
  59363. }
  59364. interface VRDisplayCapabilities {
  59365. readonly canPresent: boolean;
  59366. readonly hasExternalDisplay: boolean;
  59367. readonly hasOrientation: boolean;
  59368. readonly hasPosition: boolean;
  59369. readonly maxLayers: number;
  59370. }
  59371. interface VREyeParameters {
  59372. /** @deprecated */
  59373. readonly fieldOfView: VRFieldOfView;
  59374. readonly offset: Float32Array;
  59375. readonly renderHeight: number;
  59376. readonly renderWidth: number;
  59377. }
  59378. interface VRFieldOfView {
  59379. readonly downDegrees: number;
  59380. readonly leftDegrees: number;
  59381. readonly rightDegrees: number;
  59382. readonly upDegrees: number;
  59383. }
  59384. interface VRFrameData {
  59385. readonly leftProjectionMatrix: Float32Array;
  59386. readonly leftViewMatrix: Float32Array;
  59387. readonly pose: VRPose;
  59388. readonly rightProjectionMatrix: Float32Array;
  59389. readonly rightViewMatrix: Float32Array;
  59390. readonly timestamp: number;
  59391. }
  59392. interface VRPose {
  59393. readonly angularAcceleration: Float32Array | null;
  59394. readonly angularVelocity: Float32Array | null;
  59395. readonly linearAcceleration: Float32Array | null;
  59396. readonly linearVelocity: Float32Array | null;
  59397. readonly orientation: Float32Array | null;
  59398. readonly position: Float32Array | null;
  59399. readonly timestamp: number;
  59400. }
  59401. interface VRStageParameters {
  59402. sittingToStandingTransform?: Float32Array;
  59403. sizeX?: number;
  59404. sizeY?: number;
  59405. }
  59406. interface Navigator {
  59407. getVRDisplays(): Promise<VRDisplay[]>;
  59408. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  59409. }
  59410. interface Window {
  59411. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  59412. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  59413. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  59414. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  59415. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  59416. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  59417. }
  59418. interface Gamepad {
  59419. readonly displayId: number;
  59420. }
  59421. interface XRDevice {
  59422. requestSession(options: XRSessionCreationOptions): Promise<XRSession>;
  59423. supportsSession(options: XRSessionCreationOptions): Promise<void>;
  59424. }
  59425. interface XRSession {
  59426. getInputSources(): Array<any>;
  59427. baseLayer: XRWebGLLayer;
  59428. requestFrameOfReference(type: string): Promise<void>;
  59429. requestHitTest(origin: Float32Array, direction: Float32Array, frameOfReference: any): any;
  59430. end(): Promise<void>;
  59431. requestAnimationFrame: Function;
  59432. addEventListener: Function;
  59433. }
  59434. interface XRSessionCreationOptions {
  59435. outputContext?: WebGLRenderingContext | null;
  59436. immersive?: boolean;
  59437. environmentIntegration?: boolean;
  59438. }
  59439. interface XRLayer {
  59440. getViewport: Function;
  59441. framebufferWidth: number;
  59442. framebufferHeight: number;
  59443. }
  59444. interface XRView {
  59445. projectionMatrix: Float32Array;
  59446. }
  59447. interface XRFrame {
  59448. getDevicePose: Function;
  59449. getInputPose: Function;
  59450. views: Array<XRView>;
  59451. baseLayer: XRLayer;
  59452. }
  59453. interface XRFrameOfReference {
  59454. }
  59455. interface XRWebGLLayer extends XRLayer {
  59456. framebuffer: WebGLFramebuffer;
  59457. }
  59458. declare var XRWebGLLayer: {
  59459. prototype: XRWebGLLayer;
  59460. new(session: XRSession, context?: WebGLRenderingContext): XRWebGLLayer;
  59461. };
  59462. declare module BABYLON.GUI {
  59463. /**
  59464. * Class used to specific a value and its associated unit
  59465. */
  59466. export class ValueAndUnit {
  59467. /** defines the unit to store */
  59468. unit: number;
  59469. /** defines a boolean indicating if the value can be negative */
  59470. negativeValueAllowed: boolean;
  59471. private _value;
  59472. private _originalUnit;
  59473. /**
  59474. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  59475. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  59476. */
  59477. ignoreAdaptiveScaling: boolean;
  59478. /**
  59479. * Creates a new ValueAndUnit
  59480. * @param value defines the value to store
  59481. * @param unit defines the unit to store
  59482. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  59483. */
  59484. constructor(value: number,
  59485. /** defines the unit to store */
  59486. unit?: number,
  59487. /** defines a boolean indicating if the value can be negative */
  59488. negativeValueAllowed?: boolean);
  59489. /** Gets a boolean indicating if the value is a percentage */
  59490. readonly isPercentage: boolean;
  59491. /** Gets a boolean indicating if the value is store as pixel */
  59492. readonly isPixel: boolean;
  59493. /** Gets direct internal value */
  59494. readonly internalValue: number;
  59495. /**
  59496. * Gets value as pixel
  59497. * @param host defines the root host
  59498. * @param refValue defines the reference value for percentages
  59499. * @returns the value as pixel
  59500. */
  59501. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  59502. /**
  59503. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  59504. * @param value defines the value to store
  59505. * @param unit defines the unit to store
  59506. * @returns the current ValueAndUnit
  59507. */
  59508. updateInPlace(value: number, unit?: number): ValueAndUnit;
  59509. /**
  59510. * Gets the value accordingly to its unit
  59511. * @param host defines the root host
  59512. * @returns the value
  59513. */
  59514. getValue(host: AdvancedDynamicTexture): number;
  59515. /**
  59516. * Gets a string representation of the value
  59517. * @param host defines the root host
  59518. * @param decimals defines an optional number of decimals to display
  59519. * @returns a string
  59520. */
  59521. toString(host: AdvancedDynamicTexture, decimals?: number): string;
  59522. /**
  59523. * Store a value parsed from a string
  59524. * @param source defines the source string
  59525. * @returns true if the value was successfully parsed
  59526. */
  59527. fromString(source: string | number): boolean;
  59528. private static _Regex;
  59529. private static _UNITMODE_PERCENTAGE;
  59530. private static _UNITMODE_PIXEL;
  59531. /** UNITMODE_PERCENTAGE */
  59532. static readonly UNITMODE_PERCENTAGE: number;
  59533. /** UNITMODE_PIXEL */
  59534. static readonly UNITMODE_PIXEL: number;
  59535. }
  59536. }
  59537. declare module BABYLON.GUI {
  59538. /**
  59539. * Define a style used by control to automatically setup properties based on a template.
  59540. * Only support font related properties so far
  59541. */
  59542. export class Style implements BABYLON.IDisposable {
  59543. private _fontFamily;
  59544. private _fontStyle;
  59545. private _fontWeight;
  59546. /** @hidden */
  59547. _host: AdvancedDynamicTexture;
  59548. /** @hidden */
  59549. _fontSize: ValueAndUnit;
  59550. /**
  59551. * BABYLON.Observable raised when the style values are changed
  59552. */
  59553. onChangedObservable: BABYLON.Observable<Style>;
  59554. /**
  59555. * Creates a new style object
  59556. * @param host defines the AdvancedDynamicTexture which hosts this style
  59557. */
  59558. constructor(host: AdvancedDynamicTexture);
  59559. /**
  59560. * Gets or sets the font size
  59561. */
  59562. fontSize: string | number;
  59563. /**
  59564. * Gets or sets the font family
  59565. */
  59566. fontFamily: string;
  59567. /**
  59568. * Gets or sets the font style
  59569. */
  59570. fontStyle: string;
  59571. /** Gets or sets font weight */
  59572. fontWeight: string;
  59573. /** Dispose all associated resources */
  59574. dispose(): void;
  59575. }
  59576. }
  59577. declare module BABYLON.GUI {
  59578. /**
  59579. * Class used to transport BABYLON.Vector2 information for pointer events
  59580. */
  59581. export class Vector2WithInfo extends BABYLON.Vector2 {
  59582. /** defines the current mouse button index */
  59583. buttonIndex: number;
  59584. /**
  59585. * Creates a new Vector2WithInfo
  59586. * @param source defines the vector2 data to transport
  59587. * @param buttonIndex defines the current mouse button index
  59588. */
  59589. constructor(source: BABYLON.Vector2,
  59590. /** defines the current mouse button index */
  59591. buttonIndex?: number);
  59592. }
  59593. /** Class used to provide 2D matrix features */
  59594. export class Matrix2D {
  59595. /** Gets the internal array of 6 floats used to store matrix data */
  59596. m: Float32Array;
  59597. /**
  59598. * Creates a new matrix
  59599. * @param m00 defines value for (0, 0)
  59600. * @param m01 defines value for (0, 1)
  59601. * @param m10 defines value for (1, 0)
  59602. * @param m11 defines value for (1, 1)
  59603. * @param m20 defines value for (2, 0)
  59604. * @param m21 defines value for (2, 1)
  59605. */
  59606. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  59607. /**
  59608. * Fills the matrix from direct values
  59609. * @param m00 defines value for (0, 0)
  59610. * @param m01 defines value for (0, 1)
  59611. * @param m10 defines value for (1, 0)
  59612. * @param m11 defines value for (1, 1)
  59613. * @param m20 defines value for (2, 0)
  59614. * @param m21 defines value for (2, 1)
  59615. * @returns the current modified matrix
  59616. */
  59617. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  59618. /**
  59619. * Gets matrix determinant
  59620. * @returns the determinant
  59621. */
  59622. determinant(): number;
  59623. /**
  59624. * Inverses the matrix and stores it in a target matrix
  59625. * @param result defines the target matrix
  59626. * @returns the current matrix
  59627. */
  59628. invertToRef(result: Matrix2D): Matrix2D;
  59629. /**
  59630. * Multiplies the current matrix with another one
  59631. * @param other defines the second operand
  59632. * @param result defines the target matrix
  59633. * @returns the current matrix
  59634. */
  59635. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  59636. /**
  59637. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  59638. * @param x defines the x coordinate to transform
  59639. * @param y defines the x coordinate to transform
  59640. * @param result defines the target vector2
  59641. * @returns the current matrix
  59642. */
  59643. transformCoordinates(x: number, y: number, result: BABYLON.Vector2): Matrix2D;
  59644. /**
  59645. * Creates an identity matrix
  59646. * @returns a new matrix
  59647. */
  59648. static Identity(): Matrix2D;
  59649. /**
  59650. * Creates a translation matrix and stores it in a target matrix
  59651. * @param x defines the x coordinate of the translation
  59652. * @param y defines the y coordinate of the translation
  59653. * @param result defines the target matrix
  59654. */
  59655. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  59656. /**
  59657. * Creates a scaling matrix and stores it in a target matrix
  59658. * @param x defines the x coordinate of the scaling
  59659. * @param y defines the y coordinate of the scaling
  59660. * @param result defines the target matrix
  59661. */
  59662. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  59663. /**
  59664. * Creates a rotation matrix and stores it in a target matrix
  59665. * @param angle defines the rotation angle
  59666. * @param result defines the target matrix
  59667. */
  59668. static RotationToRef(angle: number, result: Matrix2D): void;
  59669. private static _TempPreTranslationMatrix;
  59670. private static _TempPostTranslationMatrix;
  59671. private static _TempRotationMatrix;
  59672. private static _TempScalingMatrix;
  59673. private static _TempCompose0;
  59674. private static _TempCompose1;
  59675. private static _TempCompose2;
  59676. /**
  59677. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  59678. * @param tx defines the x coordinate of the translation
  59679. * @param ty defines the y coordinate of the translation
  59680. * @param angle defines the rotation angle
  59681. * @param scaleX defines the x coordinate of the scaling
  59682. * @param scaleY defines the y coordinate of the scaling
  59683. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  59684. * @param result defines the target matrix
  59685. */
  59686. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: BABYLON.Nullable<Matrix2D>, result: Matrix2D): void;
  59687. }
  59688. }
  59689. declare module BABYLON.GUI {
  59690. /**
  59691. * Class used to store 2D control sizes
  59692. */
  59693. export class Measure {
  59694. /** defines left coordinate */
  59695. left: number;
  59696. /** defines top coordinate */
  59697. top: number;
  59698. /** defines width dimension */
  59699. width: number;
  59700. /** defines height dimension */
  59701. height: number;
  59702. /**
  59703. * Creates a new measure
  59704. * @param left defines left coordinate
  59705. * @param top defines top coordinate
  59706. * @param width defines width dimension
  59707. * @param height defines height dimension
  59708. */
  59709. constructor(
  59710. /** defines left coordinate */
  59711. left: number,
  59712. /** defines top coordinate */
  59713. top: number,
  59714. /** defines width dimension */
  59715. width: number,
  59716. /** defines height dimension */
  59717. height: number);
  59718. /**
  59719. * Copy from another measure
  59720. * @param other defines the other measure to copy from
  59721. */
  59722. copyFrom(other: Measure): void;
  59723. /**
  59724. * Copy from a group of 4 floats
  59725. * @param left defines left coordinate
  59726. * @param top defines top coordinate
  59727. * @param width defines width dimension
  59728. * @param height defines height dimension
  59729. */
  59730. copyFromFloats(left: number, top: number, width: number, height: number): void;
  59731. /**
  59732. * Computes the axis aligned bounding box measure for two given measures
  59733. * @param a Input measure
  59734. * @param b Input measure
  59735. * @param result the resulting bounding measure
  59736. */
  59737. static CombineToRef(a: Measure, b: Measure, result: Measure): void;
  59738. /**
  59739. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  59740. * @param transform the matrix to transform the measure before computing the AABB
  59741. * @param result the resulting AABB
  59742. */
  59743. transformToRef(transform: Matrix2D, result: Measure): void;
  59744. /**
  59745. * Check equality between this measure and another one
  59746. * @param other defines the other measures
  59747. * @returns true if both measures are equals
  59748. */
  59749. isEqualsTo(other: Measure): boolean;
  59750. /**
  59751. * Creates an empty measure
  59752. * @returns a new measure
  59753. */
  59754. static Empty(): Measure;
  59755. }
  59756. }
  59757. declare module BABYLON.GUI {
  59758. /**
  59759. * Interface used to define a control that can receive focus
  59760. */
  59761. export interface IFocusableControl {
  59762. /**
  59763. * Function called when the control receives the focus
  59764. */
  59765. onFocus(): void;
  59766. /**
  59767. * Function called when the control loses the focus
  59768. */
  59769. onBlur(): void;
  59770. /**
  59771. * Function called to let the control handle keyboard events
  59772. * @param evt defines the current keyboard event
  59773. */
  59774. processKeyboard(evt: KeyboardEvent): void;
  59775. /**
  59776. * Function called to get the list of controls that should not steal the focus from this control
  59777. * @returns an array of controls
  59778. */
  59779. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  59780. }
  59781. /**
  59782. * Class used to create texture to support 2D GUI elements
  59783. * @see http://doc.babylonjs.com/how_to/gui
  59784. */
  59785. export class AdvancedDynamicTexture extends BABYLON.DynamicTexture {
  59786. private _isDirty;
  59787. private _renderObserver;
  59788. private _resizeObserver;
  59789. private _preKeyboardObserver;
  59790. private _pointerMoveObserver;
  59791. private _pointerObserver;
  59792. private _canvasPointerOutObserver;
  59793. private _background;
  59794. /** @hidden */
  59795. _rootContainer: Container;
  59796. /** @hidden */
  59797. _lastPickedControl: Control;
  59798. /** @hidden */
  59799. _lastControlOver: {
  59800. [pointerId: number]: Control;
  59801. };
  59802. /** @hidden */
  59803. _lastControlDown: {
  59804. [pointerId: number]: Control;
  59805. };
  59806. /** @hidden */
  59807. _capturingControl: {
  59808. [pointerId: number]: Control;
  59809. };
  59810. /** @hidden */
  59811. _shouldBlockPointer: boolean;
  59812. /** @hidden */
  59813. _layerToDispose: BABYLON.Nullable<BABYLON.Layer>;
  59814. /** @hidden */
  59815. _linkedControls: Control[];
  59816. private _isFullscreen;
  59817. private _fullscreenViewport;
  59818. private _idealWidth;
  59819. private _idealHeight;
  59820. private _useSmallestIdeal;
  59821. private _renderAtIdealSize;
  59822. private _focusedControl;
  59823. private _blockNextFocusCheck;
  59824. private _renderScale;
  59825. private _rootCanvas;
  59826. private _cursorChanged;
  59827. /**
  59828. * Define type to string to ensure compatibility across browsers
  59829. * Safari doesn't support DataTransfer constructor
  59830. */
  59831. private _clipboardData;
  59832. /**
  59833. * BABYLON.Observable event triggered each time an clipboard event is received from the rendering canvas
  59834. */
  59835. onClipboardObservable: BABYLON.Observable<BABYLON.ClipboardInfo>;
  59836. /**
  59837. * BABYLON.Observable event triggered each time a pointer down is intercepted by a control
  59838. */
  59839. onControlPickedObservable: BABYLON.Observable<Control>;
  59840. /**
  59841. * BABYLON.Observable event triggered before layout is evaluated
  59842. */
  59843. onBeginLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  59844. /**
  59845. * BABYLON.Observable event triggered after the layout was evaluated
  59846. */
  59847. onEndLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  59848. /**
  59849. * BABYLON.Observable event triggered before the texture is rendered
  59850. */
  59851. onBeginRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  59852. /**
  59853. * BABYLON.Observable event triggered after the texture was rendered
  59854. */
  59855. onEndRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  59856. /**
  59857. * Gets or sets a boolean defining if alpha is stored as premultiplied
  59858. */
  59859. premulAlpha: boolean;
  59860. /**
  59861. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  59862. * Useful when you want more antialiasing
  59863. */
  59864. renderScale: number;
  59865. /** Gets or sets the background color */
  59866. background: string;
  59867. /**
  59868. * Gets or sets the ideal width used to design controls.
  59869. * The GUI will then rescale everything accordingly
  59870. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  59871. */
  59872. idealWidth: number;
  59873. /**
  59874. * Gets or sets the ideal height used to design controls.
  59875. * The GUI will then rescale everything accordingly
  59876. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  59877. */
  59878. idealHeight: number;
  59879. /**
  59880. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  59881. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  59882. */
  59883. useSmallestIdeal: boolean;
  59884. /**
  59885. * Gets or sets a boolean indicating if adaptive scaling must be used
  59886. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  59887. */
  59888. renderAtIdealSize: boolean;
  59889. /**
  59890. * Gets the underlying layer used to render the texture when in fullscreen mode
  59891. */
  59892. readonly layer: BABYLON.Nullable<BABYLON.Layer>;
  59893. /**
  59894. * Gets the root container control
  59895. */
  59896. readonly rootContainer: Container;
  59897. /**
  59898. * Returns an array containing the root container.
  59899. * This is mostly used to let the Inspector introspects the ADT
  59900. * @returns an array containing the rootContainer
  59901. */
  59902. getChildren(): Array<Container>;
  59903. /**
  59904. * Will return all controls that are inside this texture
  59905. * @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
  59906. * @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
  59907. * @return all child controls
  59908. */
  59909. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  59910. /**
  59911. * Gets or sets the current focused control
  59912. */
  59913. focusedControl: BABYLON.Nullable<IFocusableControl>;
  59914. /**
  59915. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  59916. */
  59917. isForeground: boolean;
  59918. /**
  59919. * Gets or set information about clipboardData
  59920. */
  59921. clipboardData: string;
  59922. /**
  59923. * Creates a new AdvancedDynamicTexture
  59924. * @param name defines the name of the texture
  59925. * @param width defines the width of the texture
  59926. * @param height defines the height of the texture
  59927. * @param scene defines the hosting scene
  59928. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  59929. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  59930. */
  59931. constructor(name: string, width: number | undefined, height: number | undefined, scene: BABYLON.Nullable<BABYLON.Scene>, generateMipMaps?: boolean, samplingMode?: number);
  59932. /**
  59933. * Get the current class name of the texture useful for serialization or dynamic coding.
  59934. * @returns "AdvancedDynamicTexture"
  59935. */
  59936. getClassName(): string;
  59937. /**
  59938. * Function used to execute a function on all controls
  59939. * @param func defines the function to execute
  59940. * @param container defines the container where controls belong. If null the root container will be used
  59941. */
  59942. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  59943. private _useInvalidateRectOptimization;
  59944. /**
  59945. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  59946. */
  59947. useInvalidateRectOptimization: boolean;
  59948. private _invalidatedRectangle;
  59949. /**
  59950. * Invalidates a rectangle area on the gui texture
  59951. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  59952. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  59953. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  59954. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  59955. */
  59956. invalidateRect(invalidMinX: number, invalidMinY: number, invalidMaxX: number, invalidMaxY: number): void;
  59957. /**
  59958. * Marks the texture as dirty forcing a complete update
  59959. */
  59960. markAsDirty(): void;
  59961. /**
  59962. * Helper function used to create a new style
  59963. * @returns a new style
  59964. * @see http://doc.babylonjs.com/how_to/gui#styles
  59965. */
  59966. createStyle(): Style;
  59967. /**
  59968. * Adds a new control to the root container
  59969. * @param control defines the control to add
  59970. * @returns the current texture
  59971. */
  59972. addControl(control: Control): AdvancedDynamicTexture;
  59973. /**
  59974. * Removes a control from the root container
  59975. * @param control defines the control to remove
  59976. * @returns the current texture
  59977. */
  59978. removeControl(control: Control): AdvancedDynamicTexture;
  59979. /**
  59980. * Release all resources
  59981. */
  59982. dispose(): void;
  59983. private _onResize;
  59984. /** @hidden */
  59985. _getGlobalViewport(scene: BABYLON.Scene): BABYLON.Viewport;
  59986. /**
  59987. * Get screen coordinates for a vector3
  59988. * @param position defines the position to project
  59989. * @param worldMatrix defines the world matrix to use
  59990. * @returns the projected position
  59991. */
  59992. getProjectedPosition(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector2;
  59993. private _checkUpdate;
  59994. private _clearMeasure;
  59995. private _render;
  59996. /** @hidden */
  59997. _changeCursor(cursor: string): void;
  59998. /** @hidden */
  59999. _registerLastControlDown(control: Control, pointerId: number): void;
  60000. private _doPicking;
  60001. /** @hidden */
  60002. _cleanControlAfterRemovalFromList(list: {
  60003. [pointerId: number]: Control;
  60004. }, control: Control): void;
  60005. /** @hidden */
  60006. _cleanControlAfterRemoval(control: Control): void;
  60007. /** Attach to all scene events required to support pointer events */
  60008. attach(): void;
  60009. /** @hidden */
  60010. private onClipboardCopy;
  60011. /** @hidden */
  60012. private onClipboardCut;
  60013. /** @hidden */
  60014. private onClipboardPaste;
  60015. /**
  60016. * Register the clipboard Events onto the canvas
  60017. */
  60018. registerClipboardEvents(): void;
  60019. /**
  60020. * Unregister the clipboard Events from the canvas
  60021. */
  60022. unRegisterClipboardEvents(): void;
  60023. /**
  60024. * Connect the texture to a hosting mesh to enable interactions
  60025. * @param mesh defines the mesh to attach to
  60026. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  60027. */
  60028. attachToMesh(mesh: BABYLON.AbstractMesh, supportPointerMove?: boolean): void;
  60029. /**
  60030. * Move the focus to a specific control
  60031. * @param control defines the control which will receive the focus
  60032. */
  60033. moveFocusToControl(control: IFocusableControl): void;
  60034. private _manageFocus;
  60035. private _attachToOnPointerOut;
  60036. /**
  60037. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  60038. * @param mesh defines the mesh which will receive the texture
  60039. * @param width defines the texture width (1024 by default)
  60040. * @param height defines the texture height (1024 by default)
  60041. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  60042. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  60043. * @returns a new AdvancedDynamicTexture
  60044. */
  60045. static CreateForMesh(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, onlyAlphaTesting?: boolean): AdvancedDynamicTexture;
  60046. /**
  60047. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  60048. * In this mode the texture will rely on a layer for its rendering.
  60049. * This allows it to be treated like any other layer.
  60050. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  60051. * LayerMask is set through advancedTexture.layer.layerMask
  60052. * @param name defines name for the texture
  60053. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  60054. * @param scene defines the hsoting scene
  60055. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  60056. * @returns a new AdvancedDynamicTexture
  60057. */
  60058. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: BABYLON.Nullable<BABYLON.Scene>, sampling?: number): AdvancedDynamicTexture;
  60059. }
  60060. }
  60061. declare module BABYLON.GUI {
  60062. /**
  60063. * Root class used for all 2D controls
  60064. * @see http://doc.babylonjs.com/how_to/gui#controls
  60065. */
  60066. export class Control {
  60067. /** defines the name of the control */
  60068. name?: string | undefined;
  60069. /**
  60070. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  60071. */
  60072. static AllowAlphaInheritance: boolean;
  60073. private _alpha;
  60074. private _alphaSet;
  60075. private _zIndex;
  60076. /** @hidden */
  60077. _host: AdvancedDynamicTexture;
  60078. /** Gets or sets the control parent */
  60079. parent: BABYLON.Nullable<Container>;
  60080. /** @hidden */
  60081. _currentMeasure: Measure;
  60082. private _fontFamily;
  60083. private _fontStyle;
  60084. private _fontWeight;
  60085. private _fontSize;
  60086. private _font;
  60087. /** @hidden */
  60088. _width: ValueAndUnit;
  60089. /** @hidden */
  60090. _height: ValueAndUnit;
  60091. /** @hidden */
  60092. protected _fontOffset: {
  60093. ascent: number;
  60094. height: number;
  60095. descent: number;
  60096. };
  60097. private _color;
  60098. private _style;
  60099. private _styleObserver;
  60100. /** @hidden */
  60101. protected _horizontalAlignment: number;
  60102. /** @hidden */
  60103. protected _verticalAlignment: number;
  60104. /** @hidden */
  60105. protected _isDirty: boolean;
  60106. /** @hidden */
  60107. protected _wasDirty: boolean;
  60108. /** @hidden */
  60109. _tempParentMeasure: Measure;
  60110. /** @hidden */
  60111. _prevCurrentMeasureTransformedIntoGlobalSpace: Measure;
  60112. /** @hidden */
  60113. protected _cachedParentMeasure: Measure;
  60114. private _paddingLeft;
  60115. private _paddingRight;
  60116. private _paddingTop;
  60117. private _paddingBottom;
  60118. /** @hidden */
  60119. _left: ValueAndUnit;
  60120. /** @hidden */
  60121. _top: ValueAndUnit;
  60122. private _scaleX;
  60123. private _scaleY;
  60124. private _rotation;
  60125. private _transformCenterX;
  60126. private _transformCenterY;
  60127. /** @hidden */
  60128. _transformMatrix: Matrix2D;
  60129. /** @hidden */
  60130. protected _invertTransformMatrix: Matrix2D;
  60131. /** @hidden */
  60132. protected _transformedPosition: BABYLON.Vector2;
  60133. private _isMatrixDirty;
  60134. private _cachedOffsetX;
  60135. private _cachedOffsetY;
  60136. private _isVisible;
  60137. private _isHighlighted;
  60138. /** @hidden */
  60139. _linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  60140. private _fontSet;
  60141. private _dummyVector2;
  60142. private _downCount;
  60143. private _enterCount;
  60144. private _doNotRender;
  60145. private _downPointerIds;
  60146. protected _isEnabled: boolean;
  60147. protected _disabledColor: string;
  60148. /** @hidden */
  60149. protected _rebuildLayout: boolean;
  60150. /** @hidden */
  60151. _isClipped: boolean;
  60152. /** @hidden */
  60153. _tag: any;
  60154. /**
  60155. * 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
  60156. */
  60157. uniqueId: number;
  60158. /**
  60159. * Gets or sets an object used to store user defined information for the node
  60160. */
  60161. metadata: any;
  60162. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  60163. isHitTestVisible: boolean;
  60164. /** Gets or sets a boolean indicating if the control can block pointer events */
  60165. isPointerBlocker: boolean;
  60166. /** Gets or sets a boolean indicating if the control can be focusable */
  60167. isFocusInvisible: boolean;
  60168. /**
  60169. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  60170. * 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
  60171. */
  60172. clipChildren: boolean;
  60173. /**
  60174. * Gets or sets a boolean indicating that control content must be clipped
  60175. * 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
  60176. */
  60177. clipContent: boolean;
  60178. /**
  60179. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  60180. */
  60181. useBitmapCache: boolean;
  60182. private _cacheData;
  60183. private _shadowOffsetX;
  60184. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  60185. shadowOffsetX: number;
  60186. private _shadowOffsetY;
  60187. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  60188. shadowOffsetY: number;
  60189. private _shadowBlur;
  60190. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  60191. shadowBlur: number;
  60192. private _shadowColor;
  60193. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  60194. shadowColor: string;
  60195. /** Gets or sets the cursor to use when the control is hovered */
  60196. hoverCursor: string;
  60197. /** @hidden */
  60198. protected _linkOffsetX: ValueAndUnit;
  60199. /** @hidden */
  60200. protected _linkOffsetY: ValueAndUnit;
  60201. /** Gets the control type name */
  60202. readonly typeName: string;
  60203. /**
  60204. * Get the current class name of the control.
  60205. * @returns current class name
  60206. */
  60207. getClassName(): string;
  60208. /**
  60209. * An event triggered when the pointer move over the control.
  60210. */
  60211. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector2>;
  60212. /**
  60213. * An event triggered when the pointer move out of the control.
  60214. */
  60215. onPointerOutObservable: BABYLON.Observable<Control>;
  60216. /**
  60217. * An event triggered when the pointer taps the control
  60218. */
  60219. onPointerDownObservable: BABYLON.Observable<Vector2WithInfo>;
  60220. /**
  60221. * An event triggered when pointer up
  60222. */
  60223. onPointerUpObservable: BABYLON.Observable<Vector2WithInfo>;
  60224. /**
  60225. * An event triggered when a control is clicked on
  60226. */
  60227. onPointerClickObservable: BABYLON.Observable<Vector2WithInfo>;
  60228. /**
  60229. * An event triggered when pointer enters the control
  60230. */
  60231. onPointerEnterObservable: BABYLON.Observable<Control>;
  60232. /**
  60233. * An event triggered when the control is marked as dirty
  60234. */
  60235. onDirtyObservable: BABYLON.Observable<Control>;
  60236. /**
  60237. * An event triggered before drawing the control
  60238. */
  60239. onBeforeDrawObservable: BABYLON.Observable<Control>;
  60240. /**
  60241. * An event triggered after the control was drawn
  60242. */
  60243. onAfterDrawObservable: BABYLON.Observable<Control>;
  60244. /**
  60245. * Get the hosting AdvancedDynamicTexture
  60246. */
  60247. readonly host: AdvancedDynamicTexture;
  60248. /** Gets or set information about font offsets (used to render and align text) */
  60249. fontOffset: {
  60250. ascent: number;
  60251. height: number;
  60252. descent: number;
  60253. };
  60254. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  60255. alpha: number;
  60256. /**
  60257. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  60258. */
  60259. isHighlighted: boolean;
  60260. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  60261. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  60262. */
  60263. scaleX: number;
  60264. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  60265. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  60266. */
  60267. scaleY: number;
  60268. /** Gets or sets the rotation angle (0 by default)
  60269. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  60270. */
  60271. rotation: number;
  60272. /** Gets or sets the transformation center on Y axis (0 by default)
  60273. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  60274. */
  60275. transformCenterY: number;
  60276. /** Gets or sets the transformation center on X axis (0 by default)
  60277. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  60278. */
  60279. transformCenterX: number;
  60280. /**
  60281. * Gets or sets the horizontal alignment
  60282. * @see http://doc.babylonjs.com/how_to/gui#alignments
  60283. */
  60284. horizontalAlignment: number;
  60285. /**
  60286. * Gets or sets the vertical alignment
  60287. * @see http://doc.babylonjs.com/how_to/gui#alignments
  60288. */
  60289. verticalAlignment: number;
  60290. /**
  60291. * Gets or sets control width
  60292. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  60293. */
  60294. width: string | number;
  60295. /**
  60296. * Gets or sets the control width in pixel
  60297. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  60298. */
  60299. widthInPixels: number;
  60300. /**
  60301. * Gets or sets control height
  60302. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  60303. */
  60304. height: string | number;
  60305. /**
  60306. * Gets or sets control height in pixel
  60307. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  60308. */
  60309. heightInPixels: number;
  60310. /** Gets or set font family */
  60311. fontFamily: string;
  60312. /** Gets or sets font style */
  60313. fontStyle: string;
  60314. /** Gets or sets font weight */
  60315. fontWeight: string;
  60316. /**
  60317. * Gets or sets style
  60318. * @see http://doc.babylonjs.com/how_to/gui#styles
  60319. */
  60320. style: BABYLON.Nullable<Style>;
  60321. /** @hidden */
  60322. readonly _isFontSizeInPercentage: boolean;
  60323. /** Gets or sets font size in pixels */
  60324. fontSizeInPixels: number;
  60325. /** Gets or sets font size */
  60326. fontSize: string | number;
  60327. /** Gets or sets foreground color */
  60328. color: string;
  60329. /** Gets or sets z index which is used to reorder controls on the z axis */
  60330. zIndex: number;
  60331. /** Gets or sets a boolean indicating if the control can be rendered */
  60332. notRenderable: boolean;
  60333. /** Gets or sets a boolean indicating if the control is visible */
  60334. isVisible: boolean;
  60335. /** Gets a boolean indicating that the control needs to update its rendering */
  60336. readonly isDirty: boolean;
  60337. /**
  60338. * Gets the current linked mesh (or null if none)
  60339. */
  60340. readonly linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  60341. /**
  60342. * Gets or sets a value indicating the padding to use on the left of the control
  60343. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  60344. */
  60345. paddingLeft: string | number;
  60346. /**
  60347. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  60348. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  60349. */
  60350. paddingLeftInPixels: number;
  60351. /**
  60352. * Gets or sets a value indicating the padding to use on the right of the control
  60353. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  60354. */
  60355. paddingRight: string | number;
  60356. /**
  60357. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  60358. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  60359. */
  60360. paddingRightInPixels: number;
  60361. /**
  60362. * Gets or sets a value indicating the padding to use on the top of the control
  60363. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  60364. */
  60365. paddingTop: string | number;
  60366. /**
  60367. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  60368. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  60369. */
  60370. paddingTopInPixels: number;
  60371. /**
  60372. * Gets or sets a value indicating the padding to use on the bottom of the control
  60373. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  60374. */
  60375. paddingBottom: string | number;
  60376. /**
  60377. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  60378. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  60379. */
  60380. paddingBottomInPixels: number;
  60381. /**
  60382. * Gets or sets a value indicating the left coordinate of the control
  60383. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  60384. */
  60385. left: string | number;
  60386. /**
  60387. * Gets or sets a value indicating the left coordinate in pixels of the control
  60388. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  60389. */
  60390. leftInPixels: number;
  60391. /**
  60392. * Gets or sets a value indicating the top coordinate of the control
  60393. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  60394. */
  60395. top: string | number;
  60396. /**
  60397. * Gets or sets a value indicating the top coordinate in pixels of the control
  60398. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  60399. */
  60400. topInPixels: number;
  60401. /**
  60402. * Gets or sets a value indicating the offset on X axis to the linked mesh
  60403. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  60404. */
  60405. linkOffsetX: string | number;
  60406. /**
  60407. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  60408. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  60409. */
  60410. linkOffsetXInPixels: number;
  60411. /**
  60412. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  60413. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  60414. */
  60415. linkOffsetY: string | number;
  60416. /**
  60417. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  60418. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  60419. */
  60420. linkOffsetYInPixels: number;
  60421. /** Gets the center coordinate on X axis */
  60422. readonly centerX: number;
  60423. /** Gets the center coordinate on Y axis */
  60424. readonly centerY: number;
  60425. /** Gets or sets if control is Enabled*/
  60426. isEnabled: boolean;
  60427. /** Gets or sets background color of control if it's disabled*/
  60428. disabledColor: string;
  60429. /**
  60430. * Creates a new control
  60431. * @param name defines the name of the control
  60432. */
  60433. constructor(
  60434. /** defines the name of the control */
  60435. name?: string | undefined);
  60436. /** @hidden */
  60437. protected _getTypeName(): string;
  60438. /**
  60439. * Gets the first ascendant in the hierarchy of the given type
  60440. * @param className defines the required type
  60441. * @returns the ascendant or null if not found
  60442. */
  60443. getAscendantOfClass(className: string): BABYLON.Nullable<Control>;
  60444. /** @hidden */
  60445. _resetFontCache(): void;
  60446. /**
  60447. * Determines if a container is an ascendant of the current control
  60448. * @param container defines the container to look for
  60449. * @returns true if the container is one of the ascendant of the control
  60450. */
  60451. isAscendant(container: Control): boolean;
  60452. /**
  60453. * Gets coordinates in local control space
  60454. * @param globalCoordinates defines the coordinates to transform
  60455. * @returns the new coordinates in local space
  60456. */
  60457. getLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  60458. /**
  60459. * Gets coordinates in local control space
  60460. * @param globalCoordinates defines the coordinates to transform
  60461. * @param result defines the target vector2 where to store the result
  60462. * @returns the current control
  60463. */
  60464. getLocalCoordinatesToRef(globalCoordinates: BABYLON.Vector2, result: BABYLON.Vector2): Control;
  60465. /**
  60466. * Gets coordinates in parent local control space
  60467. * @param globalCoordinates defines the coordinates to transform
  60468. * @returns the new coordinates in parent local space
  60469. */
  60470. getParentLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  60471. /**
  60472. * Move the current control to a vector3 position projected onto the screen.
  60473. * @param position defines the target position
  60474. * @param scene defines the hosting scene
  60475. */
  60476. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene): void;
  60477. /** @hidden */
  60478. _getDescendants(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  60479. /**
  60480. * Will return all controls that have this control as ascendant
  60481. * @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
  60482. * @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
  60483. * @return all child controls
  60484. */
  60485. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  60486. /**
  60487. * Link current control with a target mesh
  60488. * @param mesh defines the mesh to link with
  60489. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  60490. */
  60491. linkWithMesh(mesh: BABYLON.Nullable<BABYLON.AbstractMesh>): void;
  60492. /** @hidden */
  60493. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3): void;
  60494. /** @hidden */
  60495. _offsetLeft(offset: number): void;
  60496. /** @hidden */
  60497. _offsetTop(offset: number): void;
  60498. /** @hidden */
  60499. _markMatrixAsDirty(): void;
  60500. /** @hidden */
  60501. _flagDescendantsAsMatrixDirty(): void;
  60502. /** @hidden */
  60503. _intersectsRect(rect: Measure): boolean;
  60504. /** @hidden */
  60505. protected invalidateRect(): void;
  60506. /** @hidden */
  60507. _markAsDirty(force?: boolean): void;
  60508. /** @hidden */
  60509. _markAllAsDirty(): void;
  60510. /** @hidden */
  60511. _link(host: AdvancedDynamicTexture): void;
  60512. /** @hidden */
  60513. protected _transform(context?: CanvasRenderingContext2D): void;
  60514. /** @hidden */
  60515. _renderHighlight(context: CanvasRenderingContext2D): void;
  60516. /** @hidden */
  60517. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  60518. /** @hidden */
  60519. protected _applyStates(context: CanvasRenderingContext2D): void;
  60520. /** @hidden */
  60521. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  60522. /** @hidden */
  60523. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  60524. protected _evaluateClippingState(parentMeasure: Measure): void;
  60525. /** @hidden */
  60526. _measure(): void;
  60527. /** @hidden */
  60528. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  60529. /** @hidden */
  60530. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  60531. /** @hidden */
  60532. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  60533. /** @hidden */
  60534. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  60535. private static _ClipMeasure;
  60536. private _tmpMeasureA;
  60537. private _clip;
  60538. /** @hidden */
  60539. _render(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): boolean;
  60540. /** @hidden */
  60541. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  60542. /**
  60543. * Tests if a given coordinates belong to the current control
  60544. * @param x defines x coordinate to test
  60545. * @param y defines y coordinate to test
  60546. * @returns true if the coordinates are inside the control
  60547. */
  60548. contains(x: number, y: number): boolean;
  60549. /** @hidden */
  60550. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  60551. /** @hidden */
  60552. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  60553. /** @hidden */
  60554. _onPointerEnter(target: Control): boolean;
  60555. /** @hidden */
  60556. _onPointerOut(target: Control, force?: boolean): void;
  60557. /** @hidden */
  60558. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  60559. /** @hidden */
  60560. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  60561. /** @hidden */
  60562. _forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  60563. /** @hidden */
  60564. _processObservables(type: number, x: number, y: number, pointerId: number, buttonIndex: number): boolean;
  60565. private _prepareFont;
  60566. /** Releases associated resources */
  60567. dispose(): void;
  60568. private static _HORIZONTAL_ALIGNMENT_LEFT;
  60569. private static _HORIZONTAL_ALIGNMENT_RIGHT;
  60570. private static _HORIZONTAL_ALIGNMENT_CENTER;
  60571. private static _VERTICAL_ALIGNMENT_TOP;
  60572. private static _VERTICAL_ALIGNMENT_BOTTOM;
  60573. private static _VERTICAL_ALIGNMENT_CENTER;
  60574. /** HORIZONTAL_ALIGNMENT_LEFT */
  60575. static readonly HORIZONTAL_ALIGNMENT_LEFT: number;
  60576. /** HORIZONTAL_ALIGNMENT_RIGHT */
  60577. static readonly HORIZONTAL_ALIGNMENT_RIGHT: number;
  60578. /** HORIZONTAL_ALIGNMENT_CENTER */
  60579. static readonly HORIZONTAL_ALIGNMENT_CENTER: number;
  60580. /** VERTICAL_ALIGNMENT_TOP */
  60581. static readonly VERTICAL_ALIGNMENT_TOP: number;
  60582. /** VERTICAL_ALIGNMENT_BOTTOM */
  60583. static readonly VERTICAL_ALIGNMENT_BOTTOM: number;
  60584. /** VERTICAL_ALIGNMENT_CENTER */
  60585. static readonly VERTICAL_ALIGNMENT_CENTER: number;
  60586. private static _FontHeightSizes;
  60587. /** @hidden */
  60588. static _GetFontOffset(font: string): {
  60589. ascent: number;
  60590. height: number;
  60591. descent: number;
  60592. };
  60593. /**
  60594. * Creates a stack panel that can be used to render headers
  60595. * @param control defines the control to associate with the header
  60596. * @param text defines the text of the header
  60597. * @param size defines the size of the header
  60598. * @param options defines options used to configure the header
  60599. * @returns a new StackPanel
  60600. * @ignore
  60601. * @hidden
  60602. */
  60603. static AddHeader: (control: Control, text: string, size: string | number, options: {
  60604. isHorizontal: boolean;
  60605. controlFirst: boolean;
  60606. }) => any;
  60607. /** @hidden */
  60608. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  60609. }
  60610. }
  60611. declare module BABYLON.GUI {
  60612. /**
  60613. * Root class for 2D containers
  60614. * @see http://doc.babylonjs.com/how_to/gui#containers
  60615. */
  60616. export class Container extends Control {
  60617. name?: string | undefined;
  60618. /** @hidden */
  60619. protected _children: Control[];
  60620. /** @hidden */
  60621. protected _measureForChildren: Measure;
  60622. /** @hidden */
  60623. protected _background: string;
  60624. /** @hidden */
  60625. protected _adaptWidthToChildren: boolean;
  60626. /** @hidden */
  60627. protected _adaptHeightToChildren: boolean;
  60628. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  60629. adaptHeightToChildren: boolean;
  60630. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  60631. adaptWidthToChildren: boolean;
  60632. /** Gets or sets background color */
  60633. background: string;
  60634. /** Gets the list of children */
  60635. readonly children: Control[];
  60636. /**
  60637. * Creates a new Container
  60638. * @param name defines the name of the container
  60639. */
  60640. constructor(name?: string | undefined);
  60641. protected _getTypeName(): string;
  60642. _flagDescendantsAsMatrixDirty(): void;
  60643. /**
  60644. * Gets a child using its name
  60645. * @param name defines the child name to look for
  60646. * @returns the child control if found
  60647. */
  60648. getChildByName(name: string): BABYLON.Nullable<Control>;
  60649. /**
  60650. * Gets a child using its type and its name
  60651. * @param name defines the child name to look for
  60652. * @param type defines the child type to look for
  60653. * @returns the child control if found
  60654. */
  60655. getChildByType(name: string, type: string): BABYLON.Nullable<Control>;
  60656. /**
  60657. * Search for a specific control in children
  60658. * @param control defines the control to look for
  60659. * @returns true if the control is in child list
  60660. */
  60661. containsControl(control: Control): boolean;
  60662. /**
  60663. * Adds a new control to the current container
  60664. * @param control defines the control to add
  60665. * @returns the current container
  60666. */
  60667. addControl(control: BABYLON.Nullable<Control>): Container;
  60668. /**
  60669. * Removes all controls from the current container
  60670. * @returns the current container
  60671. */
  60672. clearControls(): Container;
  60673. /**
  60674. * Removes a control from the current container
  60675. * @param control defines the control to remove
  60676. * @returns the current container
  60677. */
  60678. removeControl(control: Control): Container;
  60679. /** @hidden */
  60680. _reOrderControl(control: Control): void;
  60681. /** @hidden */
  60682. _offsetLeft(offset: number): void;
  60683. /** @hidden */
  60684. _offsetTop(offset: number): void;
  60685. /** @hidden */
  60686. _markAllAsDirty(): void;
  60687. /** @hidden */
  60688. protected _localDraw(context: CanvasRenderingContext2D): void;
  60689. /** @hidden */
  60690. _link(host: AdvancedDynamicTexture): void;
  60691. /** @hidden */
  60692. protected _beforeLayout(): void;
  60693. /** @hidden */
  60694. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  60695. /** @hidden */
  60696. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  60697. protected _postMeasure(): void;
  60698. /** @hidden */
  60699. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  60700. /** @hidden */
  60701. _getDescendants(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  60702. /** @hidden */
  60703. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  60704. /** @hidden */
  60705. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  60706. /** Releases associated resources */
  60707. dispose(): void;
  60708. }
  60709. }
  60710. declare module BABYLON.GUI {
  60711. /** Class used to create rectangle container */
  60712. export class Rectangle extends Container {
  60713. name?: string | undefined;
  60714. private _thickness;
  60715. private _cornerRadius;
  60716. /** Gets or sets border thickness */
  60717. thickness: number;
  60718. /** Gets or sets the corner radius angle */
  60719. cornerRadius: number;
  60720. /**
  60721. * Creates a new Rectangle
  60722. * @param name defines the control name
  60723. */
  60724. constructor(name?: string | undefined);
  60725. protected _getTypeName(): string;
  60726. protected _localDraw(context: CanvasRenderingContext2D): void;
  60727. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  60728. private _drawRoundedRect;
  60729. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  60730. }
  60731. }
  60732. declare module BABYLON.GUI {
  60733. /**
  60734. * Enum that determines the text-wrapping mode to use.
  60735. */
  60736. export enum TextWrapping {
  60737. /**
  60738. * Clip the text when it's larger than Control.width; this is the default mode.
  60739. */
  60740. Clip = 0,
  60741. /**
  60742. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  60743. */
  60744. WordWrap = 1,
  60745. /**
  60746. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  60747. */
  60748. Ellipsis = 2
  60749. }
  60750. /**
  60751. * Class used to create text block control
  60752. */
  60753. export class TextBlock extends Control {
  60754. /**
  60755. * Defines the name of the control
  60756. */
  60757. name?: string | undefined;
  60758. private _text;
  60759. private _textWrapping;
  60760. private _textHorizontalAlignment;
  60761. private _textVerticalAlignment;
  60762. private _lines;
  60763. private _resizeToFit;
  60764. private _lineSpacing;
  60765. private _outlineWidth;
  60766. private _outlineColor;
  60767. /**
  60768. * An event triggered after the text is changed
  60769. */
  60770. onTextChangedObservable: BABYLON.Observable<TextBlock>;
  60771. /**
  60772. * An event triggered after the text was broken up into lines
  60773. */
  60774. onLinesReadyObservable: BABYLON.Observable<TextBlock>;
  60775. /**
  60776. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  60777. */
  60778. readonly lines: any[];
  60779. /**
  60780. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  60781. */
  60782. /**
  60783. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  60784. */
  60785. resizeToFit: boolean;
  60786. /**
  60787. * Gets or sets a boolean indicating if text must be wrapped
  60788. */
  60789. /**
  60790. * Gets or sets a boolean indicating if text must be wrapped
  60791. */
  60792. textWrapping: TextWrapping | boolean;
  60793. /**
  60794. * Gets or sets text to display
  60795. */
  60796. /**
  60797. * Gets or sets text to display
  60798. */
  60799. text: string;
  60800. /**
  60801. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  60802. */
  60803. /**
  60804. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  60805. */
  60806. textHorizontalAlignment: number;
  60807. /**
  60808. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  60809. */
  60810. /**
  60811. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  60812. */
  60813. textVerticalAlignment: number;
  60814. /**
  60815. * Gets or sets line spacing value
  60816. */
  60817. /**
  60818. * Gets or sets line spacing value
  60819. */
  60820. lineSpacing: string | number;
  60821. /**
  60822. * Gets or sets outlineWidth of the text to display
  60823. */
  60824. /**
  60825. * Gets or sets outlineWidth of the text to display
  60826. */
  60827. outlineWidth: number;
  60828. /**
  60829. * Gets or sets outlineColor of the text to display
  60830. */
  60831. /**
  60832. * Gets or sets outlineColor of the text to display
  60833. */
  60834. outlineColor: string;
  60835. /**
  60836. * Creates a new TextBlock object
  60837. * @param name defines the name of the control
  60838. * @param text defines the text to display (emptry string by default)
  60839. */
  60840. constructor(
  60841. /**
  60842. * Defines the name of the control
  60843. */
  60844. name?: string | undefined, text?: string);
  60845. protected _getTypeName(): string;
  60846. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  60847. private _drawText;
  60848. /** @hidden */
  60849. _draw(context: CanvasRenderingContext2D): void;
  60850. protected _applyStates(context: CanvasRenderingContext2D): void;
  60851. protected _breakLines(refWidth: number, context: CanvasRenderingContext2D): object[];
  60852. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  60853. protected _parseLineEllipsis(line: string | undefined, width: number, context: CanvasRenderingContext2D): object;
  60854. protected _parseLineWordWrap(line: string | undefined, width: number, context: CanvasRenderingContext2D): object[];
  60855. protected _renderLines(context: CanvasRenderingContext2D): void;
  60856. /**
  60857. * Given a width constraint applied on the text block, find the expected height
  60858. * @returns expected height
  60859. */
  60860. computeExpectedHeight(): number;
  60861. dispose(): void;
  60862. }
  60863. }
  60864. declare module BABYLON.GUI {
  60865. /**
  60866. * Class used to create 2D images
  60867. */
  60868. export class Image extends Control {
  60869. name?: string | undefined;
  60870. private static _WorkingCanvas;
  60871. private _domImage;
  60872. private _imageWidth;
  60873. private _imageHeight;
  60874. private _loaded;
  60875. private _stretch;
  60876. private _source;
  60877. private _autoScale;
  60878. private _sourceLeft;
  60879. private _sourceTop;
  60880. private _sourceWidth;
  60881. private _sourceHeight;
  60882. private _cellWidth;
  60883. private _cellHeight;
  60884. private _cellId;
  60885. private _populateNinePatchSlicesFromImage;
  60886. private _sliceLeft;
  60887. private _sliceRight;
  60888. private _sliceTop;
  60889. private _sliceBottom;
  60890. private _detectPointerOnOpaqueOnly;
  60891. /**
  60892. * BABYLON.Observable notified when the content is loaded
  60893. */
  60894. onImageLoadedObservable: BABYLON.Observable<Image>;
  60895. /**
  60896. * Gets a boolean indicating that the content is loaded
  60897. */
  60898. readonly isLoaded: boolean;
  60899. /**
  60900. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  60901. */
  60902. populateNinePatchSlicesFromImage: boolean;
  60903. /**
  60904. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  60905. * Beware using this as this will comsume more memory as the image has to be stored twice
  60906. */
  60907. detectPointerOnOpaqueOnly: boolean;
  60908. /**
  60909. * Gets or sets the left value for slicing (9-patch)
  60910. */
  60911. sliceLeft: number;
  60912. /**
  60913. * Gets or sets the right value for slicing (9-patch)
  60914. */
  60915. sliceRight: number;
  60916. /**
  60917. * Gets or sets the top value for slicing (9-patch)
  60918. */
  60919. sliceTop: number;
  60920. /**
  60921. * Gets or sets the bottom value for slicing (9-patch)
  60922. */
  60923. sliceBottom: number;
  60924. /**
  60925. * Gets or sets the left coordinate in the source image
  60926. */
  60927. sourceLeft: number;
  60928. /**
  60929. * Gets or sets the top coordinate in the source image
  60930. */
  60931. sourceTop: number;
  60932. /**
  60933. * Gets or sets the width to capture in the source image
  60934. */
  60935. sourceWidth: number;
  60936. /**
  60937. * Gets or sets the height to capture in the source image
  60938. */
  60939. sourceHeight: number;
  60940. /**
  60941. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  60942. * @see http://doc.babylonjs.com/how_to/gui#image
  60943. */
  60944. autoScale: boolean;
  60945. /** Gets or sets the streching mode used by the image */
  60946. stretch: number;
  60947. /**
  60948. * Gets or sets the internal DOM image used to render the control
  60949. */
  60950. domImage: HTMLImageElement;
  60951. private _onImageLoaded;
  60952. private _extractNinePatchSliceDataFromImage;
  60953. /**
  60954. * Gets or sets image source url
  60955. */
  60956. source: BABYLON.Nullable<string>;
  60957. /**
  60958. * Gets or sets the cell width to use when animation sheet is enabled
  60959. * @see http://doc.babylonjs.com/how_to/gui#image
  60960. */
  60961. cellWidth: number;
  60962. /**
  60963. * Gets or sets the cell height to use when animation sheet is enabled
  60964. * @see http://doc.babylonjs.com/how_to/gui#image
  60965. */
  60966. cellHeight: number;
  60967. /**
  60968. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  60969. * @see http://doc.babylonjs.com/how_to/gui#image
  60970. */
  60971. cellId: number;
  60972. /**
  60973. * Creates a new Image
  60974. * @param name defines the control name
  60975. * @param url defines the image url
  60976. */
  60977. constructor(name?: string | undefined, url?: BABYLON.Nullable<string>);
  60978. /**
  60979. * Tests if a given coordinates belong to the current control
  60980. * @param x defines x coordinate to test
  60981. * @param y defines y coordinate to test
  60982. * @returns true if the coordinates are inside the control
  60983. */
  60984. contains(x: number, y: number): boolean;
  60985. protected _getTypeName(): string;
  60986. /** Force the control to synchronize with its content */
  60987. synchronizeSizeWithContent(): void;
  60988. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  60989. private _prepareWorkingCanvasForOpaqueDetection;
  60990. private _drawImage;
  60991. _draw(context: CanvasRenderingContext2D): void;
  60992. private _renderCornerPatch;
  60993. private _renderNinePatch;
  60994. dispose(): void;
  60995. /** STRETCH_NONE */
  60996. static readonly STRETCH_NONE: number;
  60997. /** STRETCH_FILL */
  60998. static readonly STRETCH_FILL: number;
  60999. /** STRETCH_UNIFORM */
  61000. static readonly STRETCH_UNIFORM: number;
  61001. /** STRETCH_EXTEND */
  61002. static readonly STRETCH_EXTEND: number;
  61003. /** NINE_PATCH */
  61004. static readonly STRETCH_NINE_PATCH: number;
  61005. }
  61006. }
  61007. declare module BABYLON.GUI {
  61008. /**
  61009. * Class used to create 2D buttons
  61010. */
  61011. export class Button extends Rectangle {
  61012. name?: string | undefined;
  61013. /**
  61014. * Function called to generate a pointer enter animation
  61015. */
  61016. pointerEnterAnimation: () => void;
  61017. /**
  61018. * Function called to generate a pointer out animation
  61019. */
  61020. pointerOutAnimation: () => void;
  61021. /**
  61022. * Function called to generate a pointer down animation
  61023. */
  61024. pointerDownAnimation: () => void;
  61025. /**
  61026. * Function called to generate a pointer up animation
  61027. */
  61028. pointerUpAnimation: () => void;
  61029. private _image;
  61030. /**
  61031. * Returns the image part of the button (if any)
  61032. */
  61033. readonly image: BABYLON.Nullable<Image>;
  61034. private _textBlock;
  61035. /**
  61036. * Returns the image part of the button (if any)
  61037. */
  61038. readonly textBlock: BABYLON.Nullable<TextBlock>;
  61039. /**
  61040. * Creates a new Button
  61041. * @param name defines the name of the button
  61042. */
  61043. constructor(name?: string | undefined);
  61044. protected _getTypeName(): string;
  61045. /** @hidden */
  61046. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  61047. /** @hidden */
  61048. _onPointerEnter(target: Control): boolean;
  61049. /** @hidden */
  61050. _onPointerOut(target: Control, force?: boolean): void;
  61051. /** @hidden */
  61052. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  61053. /** @hidden */
  61054. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  61055. /**
  61056. * Creates a new button made with an image and a text
  61057. * @param name defines the name of the button
  61058. * @param text defines the text of the button
  61059. * @param imageUrl defines the url of the image
  61060. * @returns a new Button
  61061. */
  61062. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  61063. /**
  61064. * Creates a new button made with an image
  61065. * @param name defines the name of the button
  61066. * @param imageUrl defines the url of the image
  61067. * @returns a new Button
  61068. */
  61069. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  61070. /**
  61071. * Creates a new button made with a text
  61072. * @param name defines the name of the button
  61073. * @param text defines the text of the button
  61074. * @returns a new Button
  61075. */
  61076. static CreateSimpleButton(name: string, text: string): Button;
  61077. /**
  61078. * Creates a new button made with an image and a centered text
  61079. * @param name defines the name of the button
  61080. * @param text defines the text of the button
  61081. * @param imageUrl defines the url of the image
  61082. * @returns a new Button
  61083. */
  61084. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  61085. }
  61086. }
  61087. declare module BABYLON.GUI {
  61088. /**
  61089. * Class used to create a 2D stack panel container
  61090. */
  61091. export class StackPanel extends Container {
  61092. name?: string | undefined;
  61093. private _isVertical;
  61094. private _manualWidth;
  61095. private _manualHeight;
  61096. private _doNotTrackManualChanges;
  61097. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  61098. isVertical: boolean;
  61099. /**
  61100. * Gets or sets panel width.
  61101. * This value should not be set when in horizontal mode as it will be computed automatically
  61102. */
  61103. width: string | number;
  61104. /**
  61105. * Gets or sets panel height.
  61106. * This value should not be set when in vertical mode as it will be computed automatically
  61107. */
  61108. height: string | number;
  61109. /**
  61110. * Creates a new StackPanel
  61111. * @param name defines control name
  61112. */
  61113. constructor(name?: string | undefined);
  61114. protected _getTypeName(): string;
  61115. /** @hidden */
  61116. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  61117. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  61118. protected _postMeasure(): void;
  61119. }
  61120. }
  61121. declare module BABYLON.GUI {
  61122. /**
  61123. * Class used to represent a 2D checkbox
  61124. */
  61125. export class Checkbox extends Control {
  61126. name?: string | undefined;
  61127. private _isChecked;
  61128. private _background;
  61129. private _checkSizeRatio;
  61130. private _thickness;
  61131. /** Gets or sets border thickness */
  61132. thickness: number;
  61133. /**
  61134. * BABYLON.Observable raised when isChecked property changes
  61135. */
  61136. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  61137. /** Gets or sets a value indicating the ratio between overall size and check size */
  61138. checkSizeRatio: number;
  61139. /** Gets or sets background color */
  61140. background: string;
  61141. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  61142. isChecked: boolean;
  61143. /**
  61144. * Creates a new CheckBox
  61145. * @param name defines the control name
  61146. */
  61147. constructor(name?: string | undefined);
  61148. protected _getTypeName(): string;
  61149. /** @hidden */
  61150. _draw(context: CanvasRenderingContext2D): void;
  61151. /** @hidden */
  61152. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  61153. /**
  61154. * Utility function to easily create a checkbox with a header
  61155. * @param title defines the label to use for the header
  61156. * @param onValueChanged defines the callback to call when value changes
  61157. * @returns a StackPanel containing the checkbox and a textBlock
  61158. */
  61159. static AddCheckBoxWithHeader(title: string, onValueChanged: (value: boolean) => void): StackPanel;
  61160. }
  61161. }
  61162. declare module BABYLON.GUI {
  61163. /**
  61164. * Class used to store key control properties
  61165. */
  61166. export class KeyPropertySet {
  61167. /** Width */
  61168. width?: string;
  61169. /** Height */
  61170. height?: string;
  61171. /** Left padding */
  61172. paddingLeft?: string;
  61173. /** Right padding */
  61174. paddingRight?: string;
  61175. /** Top padding */
  61176. paddingTop?: string;
  61177. /** Bottom padding */
  61178. paddingBottom?: string;
  61179. /** Foreground color */
  61180. color?: string;
  61181. /** Background color */
  61182. background?: string;
  61183. }
  61184. /**
  61185. * Class used to create virtual keyboard
  61186. */
  61187. export class VirtualKeyboard extends StackPanel {
  61188. /** BABYLON.Observable raised when a key is pressed */
  61189. onKeyPressObservable: BABYLON.Observable<string>;
  61190. /** Gets or sets default key button width */
  61191. defaultButtonWidth: string;
  61192. /** Gets or sets default key button height */
  61193. defaultButtonHeight: string;
  61194. /** Gets or sets default key button left padding */
  61195. defaultButtonPaddingLeft: string;
  61196. /** Gets or sets default key button right padding */
  61197. defaultButtonPaddingRight: string;
  61198. /** Gets or sets default key button top padding */
  61199. defaultButtonPaddingTop: string;
  61200. /** Gets or sets default key button bottom padding */
  61201. defaultButtonPaddingBottom: string;
  61202. /** Gets or sets default key button foreground color */
  61203. defaultButtonColor: string;
  61204. /** Gets or sets default key button background color */
  61205. defaultButtonBackground: string;
  61206. /** Gets or sets shift button foreground color */
  61207. shiftButtonColor: string;
  61208. /** Gets or sets shift button thickness*/
  61209. selectedShiftThickness: number;
  61210. /** Gets shift key state */
  61211. shiftState: number;
  61212. protected _getTypeName(): string;
  61213. private _createKey;
  61214. /**
  61215. * Adds a new row of keys
  61216. * @param keys defines the list of keys to add
  61217. * @param propertySets defines the associated property sets
  61218. */
  61219. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  61220. /**
  61221. * Set the shift key to a specific state
  61222. * @param shiftState defines the new shift state
  61223. */
  61224. applyShiftState(shiftState: number): void;
  61225. private _currentlyConnectedInputText;
  61226. private _connectedInputTexts;
  61227. private _onKeyPressObserver;
  61228. /** Gets the input text control currently attached to the keyboard */
  61229. readonly connectedInputText: BABYLON.Nullable<InputText>;
  61230. /**
  61231. * Connects the keyboard with an input text control
  61232. *
  61233. * @param input defines the target control
  61234. */
  61235. connect(input: InputText): void;
  61236. /**
  61237. * Disconnects the keyboard from connected InputText controls
  61238. *
  61239. * @param input optionally defines a target control, otherwise all are disconnected
  61240. */
  61241. disconnect(input?: InputText): void;
  61242. private _removeConnectedInputObservables;
  61243. /**
  61244. * Release all resources
  61245. */
  61246. dispose(): void;
  61247. /**
  61248. * Creates a new keyboard using a default layout
  61249. *
  61250. * @param name defines control name
  61251. * @returns a new VirtualKeyboard
  61252. */
  61253. static CreateDefaultLayout(name?: string): VirtualKeyboard;
  61254. }
  61255. }
  61256. declare module BABYLON.GUI {
  61257. /**
  61258. * Class used to create input text control
  61259. */
  61260. export class InputText extends Control implements IFocusableControl {
  61261. name?: string | undefined;
  61262. private _text;
  61263. private _placeholderText;
  61264. private _background;
  61265. private _focusedBackground;
  61266. private _focusedColor;
  61267. private _placeholderColor;
  61268. private _thickness;
  61269. private _margin;
  61270. private _autoStretchWidth;
  61271. private _maxWidth;
  61272. private _isFocused;
  61273. private _blinkTimeout;
  61274. private _blinkIsEven;
  61275. private _cursorOffset;
  61276. private _scrollLeft;
  61277. private _textWidth;
  61278. private _clickedCoordinate;
  61279. private _deadKey;
  61280. private _addKey;
  61281. private _currentKey;
  61282. private _isTextHighlightOn;
  61283. private _textHighlightColor;
  61284. private _highligherOpacity;
  61285. private _highlightedText;
  61286. private _startHighlightIndex;
  61287. private _endHighlightIndex;
  61288. private _cursorIndex;
  61289. private _onFocusSelectAll;
  61290. private _isPointerDown;
  61291. private _onClipboardObserver;
  61292. private _onPointerDblTapObserver;
  61293. /** @hidden */
  61294. _connectedVirtualKeyboard: BABYLON.Nullable<VirtualKeyboard>;
  61295. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  61296. promptMessage: string;
  61297. /** BABYLON.Observable raised when the text changes */
  61298. onTextChangedObservable: BABYLON.Observable<InputText>;
  61299. /** BABYLON.Observable raised just before an entered character is to be added */
  61300. onBeforeKeyAddObservable: BABYLON.Observable<InputText>;
  61301. /** BABYLON.Observable raised when the control gets the focus */
  61302. onFocusObservable: BABYLON.Observable<InputText>;
  61303. /** BABYLON.Observable raised when the control loses the focus */
  61304. onBlurObservable: BABYLON.Observable<InputText>;
  61305. /**Observable raised when the text is highlighted */
  61306. onTextHighlightObservable: BABYLON.Observable<InputText>;
  61307. /**Observable raised when copy event is triggered */
  61308. onTextCopyObservable: BABYLON.Observable<InputText>;
  61309. /** BABYLON.Observable raised when cut event is triggered */
  61310. onTextCutObservable: BABYLON.Observable<InputText>;
  61311. /** BABYLON.Observable raised when paste event is triggered */
  61312. onTextPasteObservable: BABYLON.Observable<InputText>;
  61313. /** BABYLON.Observable raised when a key event was processed */
  61314. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  61315. /** Gets or sets the maximum width allowed by the control */
  61316. maxWidth: string | number;
  61317. /** Gets the maximum width allowed by the control in pixels */
  61318. readonly maxWidthInPixels: number;
  61319. /** Gets or sets the text highlighter transparency; default: 0.4 */
  61320. highligherOpacity: number;
  61321. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  61322. onFocusSelectAll: boolean;
  61323. /** Gets or sets the text hightlight color */
  61324. textHighlightColor: string;
  61325. /** Gets or sets control margin */
  61326. margin: string;
  61327. /** Gets control margin in pixels */
  61328. readonly marginInPixels: number;
  61329. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  61330. autoStretchWidth: boolean;
  61331. /** Gets or sets border thickness */
  61332. thickness: number;
  61333. /** Gets or sets the background color when focused */
  61334. focusedBackground: string;
  61335. /** Gets or sets the background color when focused */
  61336. focusedColor: string;
  61337. /** Gets or sets the background color */
  61338. background: string;
  61339. /** Gets or sets the placeholder color */
  61340. placeholderColor: string;
  61341. /** Gets or sets the text displayed when the control is empty */
  61342. placeholderText: string;
  61343. /** Gets or sets the dead key flag */
  61344. deadKey: boolean;
  61345. /** Gets or sets the highlight text */
  61346. highlightedText: string;
  61347. /** Gets or sets if the current key should be added */
  61348. addKey: boolean;
  61349. /** Gets or sets the value of the current key being entered */
  61350. currentKey: string;
  61351. /** Gets or sets the text displayed in the control */
  61352. text: string;
  61353. /** Gets or sets control width */
  61354. width: string | number;
  61355. /**
  61356. * Creates a new InputText
  61357. * @param name defines the control name
  61358. * @param text defines the text of the control
  61359. */
  61360. constructor(name?: string | undefined, text?: string);
  61361. /** @hidden */
  61362. onBlur(): void;
  61363. /** @hidden */
  61364. onFocus(): void;
  61365. protected _getTypeName(): string;
  61366. /**
  61367. * Function called to get the list of controls that should not steal the focus from this control
  61368. * @returns an array of controls
  61369. */
  61370. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  61371. /** @hidden */
  61372. processKey(keyCode: number, key?: string, evt?: KeyboardEvent): void;
  61373. /** @hidden */
  61374. private _updateValueFromCursorIndex;
  61375. /** @hidden */
  61376. private _processDblClick;
  61377. /** @hidden */
  61378. private _selectAllText;
  61379. /**
  61380. * Handles the keyboard event
  61381. * @param evt Defines the KeyboardEvent
  61382. */
  61383. processKeyboard(evt: KeyboardEvent): void;
  61384. /** @hidden */
  61385. private _onCopyText;
  61386. /** @hidden */
  61387. private _onCutText;
  61388. /** @hidden */
  61389. private _onPasteText;
  61390. _draw(context: CanvasRenderingContext2D): void;
  61391. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  61392. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  61393. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  61394. protected _beforeRenderText(text: string): string;
  61395. dispose(): void;
  61396. }
  61397. }
  61398. declare module BABYLON.GUI {
  61399. /**
  61400. * Class used to create a 2D grid container
  61401. */
  61402. export class Grid extends Container {
  61403. name?: string | undefined;
  61404. private _rowDefinitions;
  61405. private _columnDefinitions;
  61406. private _cells;
  61407. private _childControls;
  61408. /**
  61409. * Gets the number of columns
  61410. */
  61411. readonly columnCount: number;
  61412. /**
  61413. * Gets the number of rows
  61414. */
  61415. readonly rowCount: number;
  61416. /** Gets the list of children */
  61417. readonly children: Control[];
  61418. /** Gets the list of cells (e.g. the containers) */
  61419. readonly cells: {
  61420. [key: string]: Container;
  61421. };
  61422. /**
  61423. * Gets the definition of a specific row
  61424. * @param index defines the index of the row
  61425. * @returns the row definition
  61426. */
  61427. getRowDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  61428. /**
  61429. * Gets the definition of a specific column
  61430. * @param index defines the index of the column
  61431. * @returns the column definition
  61432. */
  61433. getColumnDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  61434. /**
  61435. * Adds a new row to the grid
  61436. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  61437. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  61438. * @returns the current grid
  61439. */
  61440. addRowDefinition(height: number, isPixel?: boolean): Grid;
  61441. /**
  61442. * Adds a new column to the grid
  61443. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  61444. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  61445. * @returns the current grid
  61446. */
  61447. addColumnDefinition(width: number, isPixel?: boolean): Grid;
  61448. /**
  61449. * Update a row definition
  61450. * @param index defines the index of the row to update
  61451. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  61452. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  61453. * @returns the current grid
  61454. */
  61455. setRowDefinition(index: number, height: number, isPixel?: boolean): Grid;
  61456. /**
  61457. * Update a column definition
  61458. * @param index defines the index of the column to update
  61459. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  61460. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  61461. * @returns the current grid
  61462. */
  61463. setColumnDefinition(index: number, width: number, isPixel?: boolean): Grid;
  61464. /**
  61465. * Gets the list of children stored in a specific cell
  61466. * @param row defines the row to check
  61467. * @param column defines the column to check
  61468. * @returns the list of controls
  61469. */
  61470. getChildrenAt(row: number, column: number): BABYLON.Nullable<Array<Control>>;
  61471. /**
  61472. * Gets a string representing the child cell info (row x column)
  61473. * @param child defines the control to get info from
  61474. * @returns a string containing the child cell info (row x column)
  61475. */
  61476. getChildCellInfo(child: Control): string;
  61477. private _removeCell;
  61478. private _offsetCell;
  61479. /**
  61480. * Remove a column definition at specified index
  61481. * @param index defines the index of the column to remove
  61482. * @returns the current grid
  61483. */
  61484. removeColumnDefinition(index: number): Grid;
  61485. /**
  61486. * Remove a row definition at specified index
  61487. * @param index defines the index of the row to remove
  61488. * @returns the current grid
  61489. */
  61490. removeRowDefinition(index: number): Grid;
  61491. /**
  61492. * Adds a new control to the current grid
  61493. * @param control defines the control to add
  61494. * @param row defines the row where to add the control (0 by default)
  61495. * @param column defines the column where to add the control (0 by default)
  61496. * @returns the current grid
  61497. */
  61498. addControl(control: Control, row?: number, column?: number): Grid;
  61499. /**
  61500. * Removes a control from the current container
  61501. * @param control defines the control to remove
  61502. * @returns the current container
  61503. */
  61504. removeControl(control: Control): Container;
  61505. /**
  61506. * Creates a new Grid
  61507. * @param name defines control name
  61508. */
  61509. constructor(name?: string | undefined);
  61510. protected _getTypeName(): string;
  61511. protected _getGridDefinitions(definitionCallback: (lefts: number[], tops: number[], widths: number[], heights: number[]) => void): void;
  61512. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  61513. _flagDescendantsAsMatrixDirty(): void;
  61514. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  61515. /** Releases associated resources */
  61516. dispose(): void;
  61517. }
  61518. }
  61519. declare module BABYLON.GUI {
  61520. /** Class used to create color pickers */
  61521. export class ColorPicker extends Control {
  61522. name?: string | undefined;
  61523. private static _Epsilon;
  61524. private _colorWheelCanvas;
  61525. private _value;
  61526. private _tmpColor;
  61527. private _pointerStartedOnSquare;
  61528. private _pointerStartedOnWheel;
  61529. private _squareLeft;
  61530. private _squareTop;
  61531. private _squareSize;
  61532. private _h;
  61533. private _s;
  61534. private _v;
  61535. private _lastPointerDownID;
  61536. /**
  61537. * BABYLON.Observable raised when the value changes
  61538. */
  61539. onValueChangedObservable: BABYLON.Observable<BABYLON.Color3>;
  61540. /** Gets or sets the color of the color picker */
  61541. value: BABYLON.Color3;
  61542. /**
  61543. * Gets or sets control width
  61544. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  61545. */
  61546. width: string | number;
  61547. /**
  61548. * Gets or sets control height
  61549. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  61550. */
  61551. /** Gets or sets control height */
  61552. height: string | number;
  61553. /** Gets or sets control size */
  61554. size: string | number;
  61555. /**
  61556. * Creates a new ColorPicker
  61557. * @param name defines the control name
  61558. */
  61559. constructor(name?: string | undefined);
  61560. protected _getTypeName(): string;
  61561. /** @hidden */
  61562. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  61563. private _updateSquareProps;
  61564. private _drawGradientSquare;
  61565. private _drawCircle;
  61566. private _createColorWheelCanvas;
  61567. /** @hidden */
  61568. _draw(context: CanvasRenderingContext2D): void;
  61569. private _pointerIsDown;
  61570. private _updateValueFromPointer;
  61571. private _isPointOnSquare;
  61572. private _isPointOnWheel;
  61573. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  61574. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  61575. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  61576. /**
  61577. * This function expands the color picker by creating a color picker dialog with manual
  61578. * color value input and the ability to save colors into an array to be used later in
  61579. * subsequent launches of the dialogue.
  61580. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  61581. * @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.
  61582. * @returns picked color as a hex string and the saved colors array as hex strings.
  61583. */
  61584. static ShowPickerDialogAsync(advancedTexture: AdvancedDynamicTexture, options: {
  61585. pickerWidth?: string;
  61586. pickerHeight?: string;
  61587. headerHeight?: string;
  61588. lastColor?: string;
  61589. swatchLimit?: number;
  61590. numSwatchesPerLine?: number;
  61591. savedColors?: Array<string>;
  61592. }): Promise<{
  61593. savedColors?: string[];
  61594. pickedColor: string;
  61595. }>;
  61596. }
  61597. }
  61598. declare module BABYLON.GUI {
  61599. /** Class used to create 2D ellipse containers */
  61600. export class Ellipse extends Container {
  61601. name?: string | undefined;
  61602. private _thickness;
  61603. /** Gets or sets border thickness */
  61604. thickness: number;
  61605. /**
  61606. * Creates a new Ellipse
  61607. * @param name defines the control name
  61608. */
  61609. constructor(name?: string | undefined);
  61610. protected _getTypeName(): string;
  61611. protected _localDraw(context: CanvasRenderingContext2D): void;
  61612. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  61613. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  61614. }
  61615. }
  61616. declare module BABYLON.GUI {
  61617. /**
  61618. * Class used to create a password control
  61619. */
  61620. export class InputPassword extends InputText {
  61621. protected _beforeRenderText(text: string): string;
  61622. }
  61623. }
  61624. declare module BABYLON.GUI {
  61625. /** Class used to render 2D lines */
  61626. export class Line extends Control {
  61627. name?: string | undefined;
  61628. private _lineWidth;
  61629. private _x1;
  61630. private _y1;
  61631. private _x2;
  61632. private _y2;
  61633. private _dash;
  61634. private _connectedControl;
  61635. private _connectedControlDirtyObserver;
  61636. /** Gets or sets the dash pattern */
  61637. dash: Array<number>;
  61638. /** Gets or sets the control connected with the line end */
  61639. connectedControl: Control;
  61640. /** Gets or sets start coordinates on X axis */
  61641. x1: string | number;
  61642. /** Gets or sets start coordinates on Y axis */
  61643. y1: string | number;
  61644. /** Gets or sets end coordinates on X axis */
  61645. x2: string | number;
  61646. /** Gets or sets end coordinates on Y axis */
  61647. y2: string | number;
  61648. /** Gets or sets line width */
  61649. lineWidth: number;
  61650. /** Gets or sets horizontal alignment */
  61651. horizontalAlignment: number;
  61652. /** Gets or sets vertical alignment */
  61653. verticalAlignment: number;
  61654. private readonly _effectiveX2;
  61655. private readonly _effectiveY2;
  61656. /**
  61657. * Creates a new Line
  61658. * @param name defines the control name
  61659. */
  61660. constructor(name?: string | undefined);
  61661. protected _getTypeName(): string;
  61662. _draw(context: CanvasRenderingContext2D): void;
  61663. _measure(): void;
  61664. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  61665. /**
  61666. * Move one end of the line given 3D cartesian coordinates.
  61667. * @param position Targeted world position
  61668. * @param scene BABYLON.Scene
  61669. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  61670. */
  61671. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene, end?: boolean): void;
  61672. /**
  61673. * Move one end of the line to a position in screen absolute space.
  61674. * @param projectedPosition Position in screen absolute space (X, Y)
  61675. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  61676. */
  61677. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3, end?: boolean): void;
  61678. }
  61679. }
  61680. declare module BABYLON.GUI {
  61681. /**
  61682. * Class used to store a point for a MultiLine object.
  61683. * The point can be pure 2D coordinates, a mesh or a control
  61684. */
  61685. export class MultiLinePoint {
  61686. private _multiLine;
  61687. private _x;
  61688. private _y;
  61689. private _control;
  61690. private _mesh;
  61691. private _controlObserver;
  61692. private _meshObserver;
  61693. /** @hidden */
  61694. _point: BABYLON.Vector2;
  61695. /**
  61696. * Creates a new MultiLinePoint
  61697. * @param multiLine defines the source MultiLine object
  61698. */
  61699. constructor(multiLine: MultiLine);
  61700. /** Gets or sets x coordinate */
  61701. x: string | number;
  61702. /** Gets or sets y coordinate */
  61703. y: string | number;
  61704. /** Gets or sets the control associated with this point */
  61705. control: BABYLON.Nullable<Control>;
  61706. /** Gets or sets the mesh associated with this point */
  61707. mesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  61708. /** Resets links */
  61709. resetLinks(): void;
  61710. /**
  61711. * Gets a translation vector
  61712. * @returns the translation vector
  61713. */
  61714. translate(): BABYLON.Vector2;
  61715. private _translatePoint;
  61716. /** Release associated resources */
  61717. dispose(): void;
  61718. }
  61719. }
  61720. declare module BABYLON.GUI {
  61721. /**
  61722. * Class used to create multi line control
  61723. */
  61724. export class MultiLine extends Control {
  61725. name?: string | undefined;
  61726. private _lineWidth;
  61727. private _dash;
  61728. private _points;
  61729. private _minX;
  61730. private _minY;
  61731. private _maxX;
  61732. private _maxY;
  61733. /**
  61734. * Creates a new MultiLine
  61735. * @param name defines the control name
  61736. */
  61737. constructor(name?: string | undefined);
  61738. /** Gets or sets dash pattern */
  61739. dash: Array<number>;
  61740. /**
  61741. * Gets point stored at specified index
  61742. * @param index defines the index to look for
  61743. * @returns the requested point if found
  61744. */
  61745. getAt(index: number): MultiLinePoint;
  61746. /** Function called when a point is updated */
  61747. onPointUpdate: () => void;
  61748. /**
  61749. * Adds new points to the point collection
  61750. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  61751. * @returns the list of created MultiLinePoint
  61752. */
  61753. add(...items: (AbstractMesh | Control | {
  61754. x: string | number;
  61755. y: string | number;
  61756. })[]): MultiLinePoint[];
  61757. /**
  61758. * Adds a new point to the point collection
  61759. * @param item defines the item (mesh, control or 2d coordiantes) to add
  61760. * @returns the created MultiLinePoint
  61761. */
  61762. push(item?: (AbstractMesh | Control | {
  61763. x: string | number;
  61764. y: string | number;
  61765. })): MultiLinePoint;
  61766. /**
  61767. * Remove a specific value or point from the active point collection
  61768. * @param value defines the value or point to remove
  61769. */
  61770. remove(value: number | MultiLinePoint): void;
  61771. /**
  61772. * Resets this object to initial state (no point)
  61773. */
  61774. reset(): void;
  61775. /**
  61776. * Resets all links
  61777. */
  61778. resetLinks(): void;
  61779. /** Gets or sets line width */
  61780. lineWidth: number;
  61781. horizontalAlignment: number;
  61782. verticalAlignment: number;
  61783. protected _getTypeName(): string;
  61784. _draw(context: CanvasRenderingContext2D): void;
  61785. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  61786. _measure(): void;
  61787. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  61788. dispose(): void;
  61789. }
  61790. }
  61791. declare module BABYLON.GUI {
  61792. /**
  61793. * Class used to create radio button controls
  61794. */
  61795. export class RadioButton extends Control {
  61796. name?: string | undefined;
  61797. private _isChecked;
  61798. private _background;
  61799. private _checkSizeRatio;
  61800. private _thickness;
  61801. /** Gets or sets border thickness */
  61802. thickness: number;
  61803. /** Gets or sets group name */
  61804. group: string;
  61805. /** BABYLON.Observable raised when isChecked is changed */
  61806. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  61807. /** Gets or sets a value indicating the ratio between overall size and check size */
  61808. checkSizeRatio: number;
  61809. /** Gets or sets background color */
  61810. background: string;
  61811. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  61812. isChecked: boolean;
  61813. /**
  61814. * Creates a new RadioButton
  61815. * @param name defines the control name
  61816. */
  61817. constructor(name?: string | undefined);
  61818. protected _getTypeName(): string;
  61819. _draw(context: CanvasRenderingContext2D): void;
  61820. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  61821. /**
  61822. * Utility function to easily create a radio button with a header
  61823. * @param title defines the label to use for the header
  61824. * @param group defines the group to use for the radio button
  61825. * @param isChecked defines the initial state of the radio button
  61826. * @param onValueChanged defines the callback to call when value changes
  61827. * @returns a StackPanel containing the radio button and a textBlock
  61828. */
  61829. static AddRadioButtonWithHeader(title: string, group: string, isChecked: boolean, onValueChanged: (button: RadioButton, value: boolean) => void): StackPanel;
  61830. }
  61831. }
  61832. declare module BABYLON.GUI {
  61833. /**
  61834. * Class used to create slider controls
  61835. */
  61836. export class BaseSlider extends Control {
  61837. name?: string | undefined;
  61838. protected _thumbWidth: ValueAndUnit;
  61839. private _minimum;
  61840. private _maximum;
  61841. private _value;
  61842. private _isVertical;
  61843. protected _barOffset: ValueAndUnit;
  61844. private _isThumbClamped;
  61845. protected _displayThumb: boolean;
  61846. private _step;
  61847. private _lastPointerDownID;
  61848. protected _effectiveBarOffset: number;
  61849. protected _renderLeft: number;
  61850. protected _renderTop: number;
  61851. protected _renderWidth: number;
  61852. protected _renderHeight: number;
  61853. protected _backgroundBoxLength: number;
  61854. protected _backgroundBoxThickness: number;
  61855. protected _effectiveThumbThickness: number;
  61856. /** BABYLON.Observable raised when the sldier value changes */
  61857. onValueChangedObservable: BABYLON.Observable<number>;
  61858. /** Gets or sets a boolean indicating if the thumb must be rendered */
  61859. displayThumb: boolean;
  61860. /** Gets or sets a step to apply to values (0 by default) */
  61861. step: number;
  61862. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  61863. barOffset: string | number;
  61864. /** Gets main bar offset in pixels*/
  61865. readonly barOffsetInPixels: number;
  61866. /** Gets or sets thumb width */
  61867. thumbWidth: string | number;
  61868. /** Gets thumb width in pixels */
  61869. readonly thumbWidthInPixels: number;
  61870. /** Gets or sets minimum value */
  61871. minimum: number;
  61872. /** Gets or sets maximum value */
  61873. maximum: number;
  61874. /** Gets or sets current value */
  61875. value: number;
  61876. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  61877. isVertical: boolean;
  61878. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  61879. isThumbClamped: boolean;
  61880. /**
  61881. * Creates a new BaseSlider
  61882. * @param name defines the control name
  61883. */
  61884. constructor(name?: string | undefined);
  61885. protected _getTypeName(): string;
  61886. protected _getThumbPosition(): number;
  61887. protected _getThumbThickness(type: string): number;
  61888. protected _prepareRenderingData(type: string): void;
  61889. private _pointerIsDown;
  61890. /** @hidden */
  61891. protected _updateValueFromPointer(x: number, y: number): void;
  61892. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  61893. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  61894. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  61895. }
  61896. }
  61897. declare module BABYLON.GUI {
  61898. /**
  61899. * Class used to create slider controls
  61900. */
  61901. export class Slider extends BaseSlider {
  61902. name?: string | undefined;
  61903. private _background;
  61904. private _borderColor;
  61905. private _isThumbCircle;
  61906. protected _displayValueBar: boolean;
  61907. /** Gets or sets a boolean indicating if the value bar must be rendered */
  61908. displayValueBar: boolean;
  61909. /** Gets or sets border color */
  61910. borderColor: string;
  61911. /** Gets or sets background color */
  61912. background: string;
  61913. /** Gets or sets a boolean indicating if the thumb should be round or square */
  61914. isThumbCircle: boolean;
  61915. /**
  61916. * Creates a new Slider
  61917. * @param name defines the control name
  61918. */
  61919. constructor(name?: string | undefined);
  61920. protected _getTypeName(): string;
  61921. _draw(context: CanvasRenderingContext2D): void;
  61922. }
  61923. }
  61924. declare module BABYLON.GUI {
  61925. /** Class used to create a RadioGroup
  61926. * which contains groups of radio buttons
  61927. */
  61928. export class SelectorGroup {
  61929. /** name of SelectorGroup */
  61930. name: string;
  61931. private _groupPanel;
  61932. private _selectors;
  61933. private _groupHeader;
  61934. /**
  61935. * Creates a new SelectorGroup
  61936. * @param name of group, used as a group heading
  61937. */
  61938. constructor(
  61939. /** name of SelectorGroup */
  61940. name: string);
  61941. /** Gets the groupPanel of the SelectorGroup */
  61942. readonly groupPanel: StackPanel;
  61943. /** Gets the selectors array */
  61944. readonly selectors: StackPanel[];
  61945. /** Gets and sets the group header */
  61946. header: string;
  61947. /** @hidden */
  61948. private _addGroupHeader;
  61949. /** @hidden*/
  61950. _getSelector(selectorNb: number): StackPanel | undefined;
  61951. /** Removes the selector at the given position
  61952. * @param selectorNb the position of the selector within the group
  61953. */
  61954. removeSelector(selectorNb: number): void;
  61955. }
  61956. /** Class used to create a CheckboxGroup
  61957. * which contains groups of checkbox buttons
  61958. */
  61959. export class CheckboxGroup extends SelectorGroup {
  61960. /** Adds a checkbox as a control
  61961. * @param text is the label for the selector
  61962. * @param func is the function called when the Selector is checked
  61963. * @param checked is true when Selector is checked
  61964. */
  61965. addCheckbox(text: string, func?: (s: boolean) => void, checked?: boolean): void;
  61966. /** @hidden */
  61967. _setSelectorLabel(selectorNb: number, label: string): void;
  61968. /** @hidden */
  61969. _setSelectorLabelColor(selectorNb: number, color: string): void;
  61970. /** @hidden */
  61971. _setSelectorButtonColor(selectorNb: number, color: string): void;
  61972. /** @hidden */
  61973. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  61974. }
  61975. /** Class used to create a RadioGroup
  61976. * which contains groups of radio buttons
  61977. */
  61978. export class RadioGroup extends SelectorGroup {
  61979. private _selectNb;
  61980. /** Adds a radio button as a control
  61981. * @param label is the label for the selector
  61982. * @param func is the function called when the Selector is checked
  61983. * @param checked is true when Selector is checked
  61984. */
  61985. addRadio(label: string, func?: (n: number) => void, checked?: boolean): void;
  61986. /** @hidden */
  61987. _setSelectorLabel(selectorNb: number, label: string): void;
  61988. /** @hidden */
  61989. _setSelectorLabelColor(selectorNb: number, color: string): void;
  61990. /** @hidden */
  61991. _setSelectorButtonColor(selectorNb: number, color: string): void;
  61992. /** @hidden */
  61993. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  61994. }
  61995. /** Class used to create a SliderGroup
  61996. * which contains groups of slider buttons
  61997. */
  61998. export class SliderGroup extends SelectorGroup {
  61999. /**
  62000. * Adds a slider to the SelectorGroup
  62001. * @param label is the label for the SliderBar
  62002. * @param func is the function called when the Slider moves
  62003. * @param unit is a string describing the units used, eg degrees or metres
  62004. * @param min is the minimum value for the Slider
  62005. * @param max is the maximum value for the Slider
  62006. * @param value is the start value for the Slider between min and max
  62007. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  62008. */
  62009. addSlider(label: string, func?: (v: number) => void, unit?: string, min?: number, max?: number, value?: number, onValueChange?: (v: number) => number): void;
  62010. /** @hidden */
  62011. _setSelectorLabel(selectorNb: number, label: string): void;
  62012. /** @hidden */
  62013. _setSelectorLabelColor(selectorNb: number, color: string): void;
  62014. /** @hidden */
  62015. _setSelectorButtonColor(selectorNb: number, color: string): void;
  62016. /** @hidden */
  62017. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  62018. }
  62019. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  62020. * @see http://doc.babylonjs.com/how_to/selector
  62021. */
  62022. export class SelectionPanel extends Rectangle {
  62023. /** name of SelectionPanel */
  62024. name: string;
  62025. /** an array of SelectionGroups */
  62026. groups: SelectorGroup[];
  62027. private _panel;
  62028. private _buttonColor;
  62029. private _buttonBackground;
  62030. private _headerColor;
  62031. private _barColor;
  62032. private _barHeight;
  62033. private _spacerHeight;
  62034. private _labelColor;
  62035. private _groups;
  62036. private _bars;
  62037. /**
  62038. * Creates a new SelectionPanel
  62039. * @param name of SelectionPanel
  62040. * @param groups is an array of SelectionGroups
  62041. */
  62042. constructor(
  62043. /** name of SelectionPanel */
  62044. name: string,
  62045. /** an array of SelectionGroups */
  62046. groups?: SelectorGroup[]);
  62047. protected _getTypeName(): string;
  62048. /** Gets or sets the headerColor */
  62049. headerColor: string;
  62050. private _setHeaderColor;
  62051. /** Gets or sets the button color */
  62052. buttonColor: string;
  62053. private _setbuttonColor;
  62054. /** Gets or sets the label color */
  62055. labelColor: string;
  62056. private _setLabelColor;
  62057. /** Gets or sets the button background */
  62058. buttonBackground: string;
  62059. private _setButtonBackground;
  62060. /** Gets or sets the color of separator bar */
  62061. barColor: string;
  62062. private _setBarColor;
  62063. /** Gets or sets the height of separator bar */
  62064. barHeight: string;
  62065. private _setBarHeight;
  62066. /** Gets or sets the height of spacers*/
  62067. spacerHeight: string;
  62068. private _setSpacerHeight;
  62069. /** Adds a bar between groups */
  62070. private _addSpacer;
  62071. /** Add a group to the selection panel
  62072. * @param group is the selector group to add
  62073. */
  62074. addGroup(group: SelectorGroup): void;
  62075. /** Remove the group from the given position
  62076. * @param groupNb is the position of the group in the list
  62077. */
  62078. removeGroup(groupNb: number): void;
  62079. /** Change a group header label
  62080. * @param label is the new group header label
  62081. * @param groupNb is the number of the group to relabel
  62082. * */
  62083. setHeaderName(label: string, groupNb: number): void;
  62084. /** Change selector label to the one given
  62085. * @param label is the new selector label
  62086. * @param groupNb is the number of the groupcontaining the selector
  62087. * @param selectorNb is the number of the selector within a group to relabel
  62088. * */
  62089. relabel(label: string, groupNb: number, selectorNb: number): void;
  62090. /** For a given group position remove the selector at the given position
  62091. * @param groupNb is the number of the group to remove the selector from
  62092. * @param selectorNb is the number of the selector within the group
  62093. */
  62094. removeFromGroupSelector(groupNb: number, selectorNb: number): void;
  62095. /** For a given group position of correct type add a checkbox button
  62096. * @param groupNb is the number of the group to remove the selector from
  62097. * @param label is the label for the selector
  62098. * @param func is the function called when the Selector is checked
  62099. * @param checked is true when Selector is checked
  62100. */
  62101. addToGroupCheckbox(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  62102. /** For a given group position of correct type add a radio button
  62103. * @param groupNb is the number of the group to remove the selector from
  62104. * @param label is the label for the selector
  62105. * @param func is the function called when the Selector is checked
  62106. * @param checked is true when Selector is checked
  62107. */
  62108. addToGroupRadio(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  62109. /**
  62110. * For a given slider group add a slider
  62111. * @param groupNb is the number of the group to add the slider to
  62112. * @param label is the label for the Slider
  62113. * @param func is the function called when the Slider moves
  62114. * @param unit is a string describing the units used, eg degrees or metres
  62115. * @param min is the minimum value for the Slider
  62116. * @param max is the maximum value for the Slider
  62117. * @param value is the start value for the Slider between min and max
  62118. * @param onVal is the function used to format the value displayed, eg radians to degrees
  62119. */
  62120. addToGroupSlider(groupNb: number, label: string, func?: () => void, unit?: string, min?: number, max?: number, value?: number, onVal?: (v: number) => number): void;
  62121. }
  62122. }
  62123. declare module BABYLON.GUI {
  62124. /**
  62125. * Class used to hold a the container for ScrollViewer
  62126. * @hidden
  62127. */
  62128. export class _ScrollViewerWindow extends Container {
  62129. parentClientWidth: number;
  62130. parentClientHeight: number;
  62131. /**
  62132. * Creates a new ScrollViewerWindow
  62133. * @param name of ScrollViewerWindow
  62134. */
  62135. constructor(name?: string);
  62136. protected _getTypeName(): string;
  62137. /** @hidden */
  62138. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  62139. protected _postMeasure(): void;
  62140. }
  62141. }
  62142. declare module BABYLON.GUI {
  62143. /**
  62144. * Class used to create slider controls
  62145. */
  62146. export class ScrollBar extends BaseSlider {
  62147. name?: string | undefined;
  62148. private _background;
  62149. private _borderColor;
  62150. private _thumbMeasure;
  62151. /** Gets or sets border color */
  62152. borderColor: string;
  62153. /** Gets or sets background color */
  62154. background: string;
  62155. /**
  62156. * Creates a new Slider
  62157. * @param name defines the control name
  62158. */
  62159. constructor(name?: string | undefined);
  62160. protected _getTypeName(): string;
  62161. protected _getThumbThickness(): number;
  62162. _draw(context: CanvasRenderingContext2D): void;
  62163. private _first;
  62164. private _originX;
  62165. private _originY;
  62166. /** @hidden */
  62167. protected _updateValueFromPointer(x: number, y: number): void;
  62168. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  62169. }
  62170. }
  62171. declare module BABYLON.GUI {
  62172. /**
  62173. * Class used to hold a viewer window and sliders in a grid
  62174. */
  62175. export class ScrollViewer extends Rectangle {
  62176. private _grid;
  62177. private _horizontalBarSpace;
  62178. private _verticalBarSpace;
  62179. private _dragSpace;
  62180. private _horizontalBar;
  62181. private _verticalBar;
  62182. private _barColor;
  62183. private _barBackground;
  62184. private _barSize;
  62185. private _endLeft;
  62186. private _endTop;
  62187. private _window;
  62188. private _pointerIsOver;
  62189. private _wheelPrecision;
  62190. private _onPointerObserver;
  62191. private _clientWidth;
  62192. private _clientHeight;
  62193. /**
  62194. * Gets the horizontal scrollbar
  62195. */
  62196. readonly horizontalBar: ScrollBar;
  62197. /**
  62198. * Gets the vertical scrollbar
  62199. */
  62200. readonly verticalBar: ScrollBar;
  62201. /**
  62202. * Adds a new control to the current container
  62203. * @param control defines the control to add
  62204. * @returns the current container
  62205. */
  62206. addControl(control: BABYLON.Nullable<Control>): Container;
  62207. /**
  62208. * Removes a control from the current container
  62209. * @param control defines the control to remove
  62210. * @returns the current container
  62211. */
  62212. removeControl(control: Control): Container;
  62213. /** Gets the list of children */
  62214. readonly children: Control[];
  62215. _flagDescendantsAsMatrixDirty(): void;
  62216. /**
  62217. * Creates a new ScrollViewer
  62218. * @param name of ScrollViewer
  62219. */
  62220. constructor(name?: string);
  62221. /** Reset the scroll viewer window to initial size */
  62222. resetWindow(): void;
  62223. protected _getTypeName(): string;
  62224. private _buildClientSizes;
  62225. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  62226. protected _postMeasure(): void;
  62227. /**
  62228. * Gets or sets the mouse wheel precision
  62229. * from 0 to 1 with a default value of 0.05
  62230. * */
  62231. wheelPrecision: number;
  62232. /** Gets or sets the bar color */
  62233. barColor: string;
  62234. /** Gets or sets the size of the bar */
  62235. barSize: number;
  62236. /** Gets or sets the bar background */
  62237. barBackground: string;
  62238. /** @hidden */
  62239. private _updateScroller;
  62240. _link(host: AdvancedDynamicTexture): void;
  62241. /** @hidden */
  62242. private _attachWheel;
  62243. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  62244. /** Releases associated resources */
  62245. dispose(): void;
  62246. }
  62247. }
  62248. declare module BABYLON.GUI {
  62249. /** Class used to render a grid */
  62250. export class DisplayGrid extends Control {
  62251. name?: string | undefined;
  62252. private _cellWidth;
  62253. private _cellHeight;
  62254. private _minorLineTickness;
  62255. private _minorLineColor;
  62256. private _majorLineTickness;
  62257. private _majorLineColor;
  62258. private _majorLineFrequency;
  62259. private _background;
  62260. private _displayMajorLines;
  62261. private _displayMinorLines;
  62262. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  62263. displayMinorLines: boolean;
  62264. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  62265. displayMajorLines: boolean;
  62266. /** Gets or sets background color (Black by default) */
  62267. background: string;
  62268. /** Gets or sets the width of each cell (20 by default) */
  62269. cellWidth: number;
  62270. /** Gets or sets the height of each cell (20 by default) */
  62271. cellHeight: number;
  62272. /** Gets or sets the tickness of minor lines (1 by default) */
  62273. minorLineTickness: number;
  62274. /** Gets or sets the color of minor lines (DarkGray by default) */
  62275. minorLineColor: string;
  62276. /** Gets or sets the tickness of major lines (2 by default) */
  62277. majorLineTickness: number;
  62278. /** Gets or sets the color of major lines (White by default) */
  62279. majorLineColor: string;
  62280. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  62281. majorLineFrequency: number;
  62282. /**
  62283. * Creates a new GridDisplayRectangle
  62284. * @param name defines the control name
  62285. */
  62286. constructor(name?: string | undefined);
  62287. _draw(context: CanvasRenderingContext2D): void;
  62288. protected _getTypeName(): string;
  62289. }
  62290. }
  62291. declare module BABYLON.GUI {
  62292. /**
  62293. * Class used to create slider controls based on images
  62294. */
  62295. export class ImageBasedSlider extends BaseSlider {
  62296. name?: string | undefined;
  62297. private _backgroundImage;
  62298. private _thumbImage;
  62299. private _valueBarImage;
  62300. private _tempMeasure;
  62301. displayThumb: boolean;
  62302. /**
  62303. * Gets or sets the image used to render the background
  62304. */
  62305. backgroundImage: Image;
  62306. /**
  62307. * Gets or sets the image used to render the value bar
  62308. */
  62309. valueBarImage: Image;
  62310. /**
  62311. * Gets or sets the image used to render the thumb
  62312. */
  62313. thumbImage: Image;
  62314. /**
  62315. * Creates a new ImageBasedSlider
  62316. * @param name defines the control name
  62317. */
  62318. constructor(name?: string | undefined);
  62319. protected _getTypeName(): string;
  62320. _draw(context: CanvasRenderingContext2D): void;
  62321. }
  62322. }
  62323. declare module BABYLON.GUI {
  62324. /**
  62325. * Forcing an export so that this code will execute
  62326. * @hidden
  62327. */
  62328. const name = "Statics";
  62329. }
  62330. declare module BABYLON.GUI {
  62331. /**
  62332. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  62333. */
  62334. export class AdvancedDynamicTextureInstrumentation implements BABYLON.IDisposable {
  62335. /**
  62336. * Define the instrumented AdvancedDynamicTexture.
  62337. */
  62338. texture: AdvancedDynamicTexture;
  62339. private _captureRenderTime;
  62340. private _renderTime;
  62341. private _captureLayoutTime;
  62342. private _layoutTime;
  62343. private _onBeginRenderObserver;
  62344. private _onEndRenderObserver;
  62345. private _onBeginLayoutObserver;
  62346. private _onEndLayoutObserver;
  62347. /**
  62348. * Gets the perf counter used to capture render time
  62349. */
  62350. readonly renderTimeCounter: BABYLON.PerfCounter;
  62351. /**
  62352. * Gets the perf counter used to capture layout time
  62353. */
  62354. readonly layoutTimeCounter: BABYLON.PerfCounter;
  62355. /**
  62356. * Enable or disable the render time capture
  62357. */
  62358. captureRenderTime: boolean;
  62359. /**
  62360. * Enable or disable the layout time capture
  62361. */
  62362. captureLayoutTime: boolean;
  62363. /**
  62364. * Instantiates a new advanced dynamic texture instrumentation.
  62365. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  62366. * @param texture Defines the AdvancedDynamicTexture to instrument
  62367. */
  62368. constructor(
  62369. /**
  62370. * Define the instrumented AdvancedDynamicTexture.
  62371. */
  62372. texture: AdvancedDynamicTexture);
  62373. /**
  62374. * Dispose and release associated resources.
  62375. */
  62376. dispose(): void;
  62377. }
  62378. }
  62379. declare module BABYLON.GUI {
  62380. /**
  62381. * Class used to create containers for controls
  62382. */
  62383. export class Container3D extends Control3D {
  62384. private _blockLayout;
  62385. /**
  62386. * Gets the list of child controls
  62387. */
  62388. protected _children: Control3D[];
  62389. /**
  62390. * Gets the list of child controls
  62391. */
  62392. readonly children: Array<Control3D>;
  62393. /**
  62394. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  62395. * This is helpful to optimize layout operation when adding multiple children in a row
  62396. */
  62397. blockLayout: boolean;
  62398. /**
  62399. * Creates a new container
  62400. * @param name defines the container name
  62401. */
  62402. constructor(name?: string);
  62403. /**
  62404. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  62405. * @returns the current container
  62406. */
  62407. updateLayout(): Container3D;
  62408. /**
  62409. * Gets a boolean indicating if the given control is in the children of this control
  62410. * @param control defines the control to check
  62411. * @returns true if the control is in the child list
  62412. */
  62413. containsControl(control: Control3D): boolean;
  62414. /**
  62415. * Adds a control to the children of this control
  62416. * @param control defines the control to add
  62417. * @returns the current container
  62418. */
  62419. addControl(control: Control3D): Container3D;
  62420. /**
  62421. * This function will be called everytime a new control is added
  62422. */
  62423. protected _arrangeChildren(): void;
  62424. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  62425. /**
  62426. * Removes a control from the children of this control
  62427. * @param control defines the control to remove
  62428. * @returns the current container
  62429. */
  62430. removeControl(control: Control3D): Container3D;
  62431. protected _getTypeName(): string;
  62432. /**
  62433. * Releases all associated resources
  62434. */
  62435. dispose(): void;
  62436. /** Control rotation will remain unchanged */
  62437. static readonly UNSET_ORIENTATION: number;
  62438. /** Control will rotate to make it look at sphere central axis */
  62439. static readonly FACEORIGIN_ORIENTATION: number;
  62440. /** Control will rotate to make it look back at sphere central axis */
  62441. static readonly FACEORIGINREVERSED_ORIENTATION: number;
  62442. /** Control will rotate to look at z axis (0, 0, 1) */
  62443. static readonly FACEFORWARD_ORIENTATION: number;
  62444. /** Control will rotate to look at negative z axis (0, 0, -1) */
  62445. static readonly FACEFORWARDREVERSED_ORIENTATION: number;
  62446. }
  62447. }
  62448. declare module BABYLON.GUI {
  62449. /**
  62450. * Class used to manage 3D user interface
  62451. * @see http://doc.babylonjs.com/how_to/gui3d
  62452. */
  62453. export class GUI3DManager implements BABYLON.IDisposable {
  62454. private _scene;
  62455. private _sceneDisposeObserver;
  62456. private _utilityLayer;
  62457. private _rootContainer;
  62458. private _pointerObserver;
  62459. private _pointerOutObserver;
  62460. /** @hidden */
  62461. _lastPickedControl: Control3D;
  62462. /** @hidden */
  62463. _lastControlOver: {
  62464. [pointerId: number]: Control3D;
  62465. };
  62466. /** @hidden */
  62467. _lastControlDown: {
  62468. [pointerId: number]: Control3D;
  62469. };
  62470. /**
  62471. * BABYLON.Observable raised when the point picked by the pointer events changed
  62472. */
  62473. onPickedPointChangedObservable: BABYLON.Observable<BABYLON.Nullable<BABYLON.Vector3>>;
  62474. /** @hidden */
  62475. _sharedMaterials: {
  62476. [key: string]: BABYLON.Material;
  62477. };
  62478. /** Gets the hosting scene */
  62479. readonly scene: BABYLON.Scene;
  62480. /** Gets associated utility layer */
  62481. readonly utilityLayer: BABYLON.Nullable<BABYLON.UtilityLayerRenderer>;
  62482. /**
  62483. * Creates a new GUI3DManager
  62484. * @param scene
  62485. */
  62486. constructor(scene?: BABYLON.Scene);
  62487. private _handlePointerOut;
  62488. private _doPicking;
  62489. /**
  62490. * Gets the root container
  62491. */
  62492. readonly rootContainer: Container3D;
  62493. /**
  62494. * Gets a boolean indicating if the given control is in the root child list
  62495. * @param control defines the control to check
  62496. * @returns true if the control is in the root child list
  62497. */
  62498. containsControl(control: Control3D): boolean;
  62499. /**
  62500. * Adds a control to the root child list
  62501. * @param control defines the control to add
  62502. * @returns the current manager
  62503. */
  62504. addControl(control: Control3D): GUI3DManager;
  62505. /**
  62506. * Removes a control from the root child list
  62507. * @param control defines the control to remove
  62508. * @returns the current container
  62509. */
  62510. removeControl(control: Control3D): GUI3DManager;
  62511. /**
  62512. * Releases all associated resources
  62513. */
  62514. dispose(): void;
  62515. }
  62516. }
  62517. declare module BABYLON.GUI {
  62518. /**
  62519. * Class used to transport BABYLON.Vector3 information for pointer events
  62520. */
  62521. export class Vector3WithInfo extends BABYLON.Vector3 {
  62522. /** defines the current mouse button index */
  62523. buttonIndex: number;
  62524. /**
  62525. * Creates a new Vector3WithInfo
  62526. * @param source defines the vector3 data to transport
  62527. * @param buttonIndex defines the current mouse button index
  62528. */
  62529. constructor(source: BABYLON.Vector3,
  62530. /** defines the current mouse button index */
  62531. buttonIndex?: number);
  62532. }
  62533. }
  62534. declare module BABYLON.GUI {
  62535. /**
  62536. * Class used as base class for controls
  62537. */
  62538. export class Control3D implements BABYLON.IDisposable, BABYLON.IBehaviorAware<Control3D> {
  62539. /** Defines the control name */
  62540. name?: string | undefined;
  62541. /** @hidden */
  62542. _host: GUI3DManager;
  62543. private _node;
  62544. private _downCount;
  62545. private _enterCount;
  62546. private _downPointerIds;
  62547. private _isVisible;
  62548. /** Gets or sets the control position in world space */
  62549. position: BABYLON.Vector3;
  62550. /** Gets or sets the control scaling in world space */
  62551. scaling: BABYLON.Vector3;
  62552. /** Callback used to start pointer enter animation */
  62553. pointerEnterAnimation: () => void;
  62554. /** Callback used to start pointer out animation */
  62555. pointerOutAnimation: () => void;
  62556. /** Callback used to start pointer down animation */
  62557. pointerDownAnimation: () => void;
  62558. /** Callback used to start pointer up animation */
  62559. pointerUpAnimation: () => void;
  62560. /**
  62561. * An event triggered when the pointer move over the control
  62562. */
  62563. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector3>;
  62564. /**
  62565. * An event triggered when the pointer move out of the control
  62566. */
  62567. onPointerOutObservable: BABYLON.Observable<Control3D>;
  62568. /**
  62569. * An event triggered when the pointer taps the control
  62570. */
  62571. onPointerDownObservable: BABYLON.Observable<Vector3WithInfo>;
  62572. /**
  62573. * An event triggered when pointer is up
  62574. */
  62575. onPointerUpObservable: BABYLON.Observable<Vector3WithInfo>;
  62576. /**
  62577. * An event triggered when a control is clicked on (with a mouse)
  62578. */
  62579. onPointerClickObservable: BABYLON.Observable<Vector3WithInfo>;
  62580. /**
  62581. * An event triggered when pointer enters the control
  62582. */
  62583. onPointerEnterObservable: BABYLON.Observable<Control3D>;
  62584. /**
  62585. * Gets or sets the parent container
  62586. */
  62587. parent: BABYLON.Nullable<Container3D>;
  62588. private _behaviors;
  62589. /**
  62590. * Gets the list of attached behaviors
  62591. * @see http://doc.babylonjs.com/features/behaviour
  62592. */
  62593. readonly behaviors: BABYLON.Behavior<Control3D>[];
  62594. /**
  62595. * Attach a behavior to the control
  62596. * @see http://doc.babylonjs.com/features/behaviour
  62597. * @param behavior defines the behavior to attach
  62598. * @returns the current control
  62599. */
  62600. addBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  62601. /**
  62602. * Remove an attached behavior
  62603. * @see http://doc.babylonjs.com/features/behaviour
  62604. * @param behavior defines the behavior to attach
  62605. * @returns the current control
  62606. */
  62607. removeBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  62608. /**
  62609. * Gets an attached behavior by name
  62610. * @param name defines the name of the behavior to look for
  62611. * @see http://doc.babylonjs.com/features/behaviour
  62612. * @returns null if behavior was not found else the requested behavior
  62613. */
  62614. getBehaviorByName(name: string): BABYLON.Nullable<BABYLON.Behavior<Control3D>>;
  62615. /** Gets or sets a boolean indicating if the control is visible */
  62616. isVisible: boolean;
  62617. /**
  62618. * Creates a new control
  62619. * @param name defines the control name
  62620. */
  62621. constructor(
  62622. /** Defines the control name */
  62623. name?: string | undefined);
  62624. /**
  62625. * Gets a string representing the class name
  62626. */
  62627. readonly typeName: string;
  62628. /**
  62629. * Get the current class name of the control.
  62630. * @returns current class name
  62631. */
  62632. getClassName(): string;
  62633. protected _getTypeName(): string;
  62634. /**
  62635. * Gets the transform node used by this control
  62636. */
  62637. readonly node: BABYLON.Nullable<BABYLON.TransformNode>;
  62638. /**
  62639. * Gets the mesh used to render this control
  62640. */
  62641. readonly mesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  62642. /**
  62643. * Link the control as child of the given node
  62644. * @param node defines the node to link to. Use null to unlink the control
  62645. * @returns the current control
  62646. */
  62647. linkToTransformNode(node: BABYLON.Nullable<BABYLON.TransformNode>): Control3D;
  62648. /** @hidden **/
  62649. _prepareNode(scene: BABYLON.Scene): void;
  62650. /**
  62651. * Node creation.
  62652. * Can be overriden by children
  62653. * @param scene defines the scene where the node must be attached
  62654. * @returns the attached node or null if none. Must return a BABYLON.Mesh or BABYLON.AbstractMesh if there is an atttached visible object
  62655. */
  62656. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  62657. /**
  62658. * Affect a material to the given mesh
  62659. * @param mesh defines the mesh which will represent the control
  62660. */
  62661. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  62662. /** @hidden */
  62663. _onPointerMove(target: Control3D, coordinates: BABYLON.Vector3): void;
  62664. /** @hidden */
  62665. _onPointerEnter(target: Control3D): boolean;
  62666. /** @hidden */
  62667. _onPointerOut(target: Control3D): void;
  62668. /** @hidden */
  62669. _onPointerDown(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  62670. /** @hidden */
  62671. _onPointerUp(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  62672. /** @hidden */
  62673. forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  62674. /** @hidden */
  62675. _processObservables(type: number, pickedPoint: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  62676. /** @hidden */
  62677. _disposeNode(): void;
  62678. /**
  62679. * Releases all associated resources
  62680. */
  62681. dispose(): void;
  62682. }
  62683. }
  62684. declare module BABYLON.GUI {
  62685. /**
  62686. * Class used as a root to all buttons
  62687. */
  62688. export class AbstractButton3D extends Control3D {
  62689. /**
  62690. * Creates a new button
  62691. * @param name defines the control name
  62692. */
  62693. constructor(name?: string);
  62694. protected _getTypeName(): string;
  62695. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  62696. }
  62697. }
  62698. declare module BABYLON.GUI {
  62699. /**
  62700. * Class used to create a button in 3D
  62701. */
  62702. export class Button3D extends AbstractButton3D {
  62703. /** @hidden */
  62704. protected _currentMaterial: BABYLON.Material;
  62705. private _facadeTexture;
  62706. private _content;
  62707. private _contentResolution;
  62708. private _contentScaleRatio;
  62709. /**
  62710. * Gets or sets the texture resolution used to render content (512 by default)
  62711. */
  62712. contentResolution: BABYLON.int;
  62713. /**
  62714. * Gets or sets the texture scale ratio used to render content (2 by default)
  62715. */
  62716. contentScaleRatio: number;
  62717. protected _disposeFacadeTexture(): void;
  62718. protected _resetContent(): void;
  62719. /**
  62720. * Creates a new button
  62721. * @param name defines the control name
  62722. */
  62723. constructor(name?: string);
  62724. /**
  62725. * Gets or sets the GUI 2D content used to display the button's facade
  62726. */
  62727. content: Control;
  62728. /**
  62729. * Apply the facade texture (created from the content property).
  62730. * This function can be overloaded by child classes
  62731. * @param facadeTexture defines the AdvancedDynamicTexture to use
  62732. */
  62733. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  62734. protected _getTypeName(): string;
  62735. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  62736. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  62737. /**
  62738. * Releases all associated resources
  62739. */
  62740. dispose(): void;
  62741. }
  62742. }
  62743. declare module BABYLON.GUI {
  62744. /**
  62745. * Abstract class used to create a container panel deployed on the surface of a volume
  62746. */
  62747. export abstract class VolumeBasedPanel extends Container3D {
  62748. private _columns;
  62749. private _rows;
  62750. private _rowThenColum;
  62751. private _orientation;
  62752. protected _cellWidth: number;
  62753. protected _cellHeight: number;
  62754. /**
  62755. * Gets or sets the distance between elements
  62756. */
  62757. margin: number;
  62758. /**
  62759. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  62760. * | Value | Type | Description |
  62761. * | ----- | ----------------------------------- | ----------- |
  62762. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  62763. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  62764. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  62765. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  62766. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  62767. */
  62768. orientation: number;
  62769. /**
  62770. * Gets or sets the number of columns requested (10 by default).
  62771. * The panel will automatically compute the number of rows based on number of child controls.
  62772. */
  62773. columns: BABYLON.int;
  62774. /**
  62775. * Gets or sets a the number of rows requested.
  62776. * The panel will automatically compute the number of columns based on number of child controls.
  62777. */
  62778. rows: BABYLON.int;
  62779. /**
  62780. * Creates new VolumeBasedPanel
  62781. */
  62782. constructor();
  62783. protected _arrangeChildren(): void;
  62784. /** Child classes must implement this function to provide correct control positioning */
  62785. protected abstract _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  62786. /** Child classes can implement this function to provide additional processing */
  62787. protected _finalProcessing(): void;
  62788. }
  62789. }
  62790. declare module BABYLON.GUI {
  62791. /**
  62792. * Class used to create a container panel deployed on the surface of a cylinder
  62793. */
  62794. export class CylinderPanel extends VolumeBasedPanel {
  62795. private _radius;
  62796. /**
  62797. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  62798. */
  62799. radius: BABYLON.float;
  62800. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  62801. private _cylindricalMapping;
  62802. }
  62803. }
  62804. declare module BABYLON.GUI {
  62805. /** @hidden */
  62806. export var fluentVertexShader: {
  62807. name: string;
  62808. shader: string;
  62809. };
  62810. }
  62811. declare module BABYLON.GUI {
  62812. /** @hidden */
  62813. export var fluentPixelShader: {
  62814. name: string;
  62815. shader: string;
  62816. };
  62817. }
  62818. declare module BABYLON.GUI {
  62819. /** @hidden */
  62820. export class FluentMaterialDefines extends BABYLON.MaterialDefines {
  62821. INNERGLOW: boolean;
  62822. BORDER: boolean;
  62823. HOVERLIGHT: boolean;
  62824. TEXTURE: boolean;
  62825. constructor();
  62826. }
  62827. /**
  62828. * Class used to render controls with fluent desgin
  62829. */
  62830. export class FluentMaterial extends BABYLON.PushMaterial {
  62831. /**
  62832. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  62833. */
  62834. innerGlowColorIntensity: number;
  62835. /**
  62836. * Gets or sets the inner glow color (white by default)
  62837. */
  62838. innerGlowColor: BABYLON.Color3;
  62839. /**
  62840. * Gets or sets alpha value (default is 1.0)
  62841. */
  62842. alpha: number;
  62843. /**
  62844. * Gets or sets the albedo color (Default is BABYLON.Color3(0.3, 0.35, 0.4))
  62845. */
  62846. albedoColor: BABYLON.Color3;
  62847. /**
  62848. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  62849. */
  62850. renderBorders: boolean;
  62851. /**
  62852. * Gets or sets border width (default is 0.5)
  62853. */
  62854. borderWidth: number;
  62855. /**
  62856. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  62857. */
  62858. edgeSmoothingValue: number;
  62859. /**
  62860. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  62861. */
  62862. borderMinValue: number;
  62863. /**
  62864. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  62865. */
  62866. renderHoverLight: boolean;
  62867. /**
  62868. * Gets or sets the radius used to render the hover light (default is 1.0)
  62869. */
  62870. hoverRadius: number;
  62871. /**
  62872. * Gets or sets the color used to render the hover light (default is BABYLON.Color4(0.3, 0.3, 0.3, 1.0))
  62873. */
  62874. hoverColor: BABYLON.Color4;
  62875. /**
  62876. * Gets or sets the hover light position in world space (default is BABYLON.Vector3.Zero())
  62877. */
  62878. hoverPosition: BABYLON.Vector3;
  62879. private _albedoTexture;
  62880. /** Gets or sets the texture to use for albedo color */
  62881. albedoTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  62882. /**
  62883. * Creates a new Fluent material
  62884. * @param name defines the name of the material
  62885. * @param scene defines the hosting scene
  62886. */
  62887. constructor(name: string, scene: BABYLON.Scene);
  62888. needAlphaBlending(): boolean;
  62889. needAlphaTesting(): boolean;
  62890. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  62891. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  62892. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  62893. getActiveTextures(): BABYLON.BaseTexture[];
  62894. hasTexture(texture: BABYLON.BaseTexture): boolean;
  62895. dispose(forceDisposeEffect?: boolean): void;
  62896. clone(name: string): FluentMaterial;
  62897. serialize(): any;
  62898. getClassName(): string;
  62899. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FluentMaterial;
  62900. }
  62901. }
  62902. declare module BABYLON.GUI {
  62903. /**
  62904. * Class used to create a holographic button in 3D
  62905. */
  62906. export class HolographicButton extends Button3D {
  62907. private _backPlate;
  62908. private _textPlate;
  62909. private _frontPlate;
  62910. private _text;
  62911. private _imageUrl;
  62912. private _shareMaterials;
  62913. private _frontMaterial;
  62914. private _backMaterial;
  62915. private _plateMaterial;
  62916. private _pickedPointObserver;
  62917. private _tooltipFade;
  62918. private _tooltipTextBlock;
  62919. private _tooltipTexture;
  62920. private _tooltipMesh;
  62921. private _tooltipHoverObserver;
  62922. private _tooltipOutObserver;
  62923. private _disposeTooltip;
  62924. /**
  62925. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  62926. */
  62927. tooltipText: BABYLON.Nullable<string>;
  62928. /**
  62929. * Gets or sets text for the button
  62930. */
  62931. text: string;
  62932. /**
  62933. * Gets or sets the image url for the button
  62934. */
  62935. imageUrl: string;
  62936. /**
  62937. * Gets the back material used by this button
  62938. */
  62939. readonly backMaterial: FluentMaterial;
  62940. /**
  62941. * Gets the front material used by this button
  62942. */
  62943. readonly frontMaterial: FluentMaterial;
  62944. /**
  62945. * Gets the plate material used by this button
  62946. */
  62947. readonly plateMaterial: BABYLON.StandardMaterial;
  62948. /**
  62949. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  62950. */
  62951. readonly shareMaterials: boolean;
  62952. /**
  62953. * Creates a new button
  62954. * @param name defines the control name
  62955. */
  62956. constructor(name?: string, shareMaterials?: boolean);
  62957. protected _getTypeName(): string;
  62958. private _rebuildContent;
  62959. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  62960. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  62961. private _createBackMaterial;
  62962. private _createFrontMaterial;
  62963. private _createPlateMaterial;
  62964. protected _affectMaterial(mesh: BABYLON.Mesh): void;
  62965. /**
  62966. * Releases all associated resources
  62967. */
  62968. dispose(): void;
  62969. }
  62970. }
  62971. declare module BABYLON.GUI {
  62972. /**
  62973. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  62974. */
  62975. export class MeshButton3D extends Button3D {
  62976. /** @hidden */
  62977. protected _currentMesh: BABYLON.Mesh;
  62978. /**
  62979. * Creates a new 3D button based on a mesh
  62980. * @param mesh mesh to become a 3D button
  62981. * @param name defines the control name
  62982. */
  62983. constructor(mesh: BABYLON.Mesh, name?: string);
  62984. protected _getTypeName(): string;
  62985. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  62986. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  62987. }
  62988. }
  62989. declare module BABYLON.GUI {
  62990. /**
  62991. * Class used to create a container panel deployed on the surface of a plane
  62992. */
  62993. export class PlanePanel extends VolumeBasedPanel {
  62994. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  62995. }
  62996. }
  62997. declare module BABYLON.GUI {
  62998. /**
  62999. * Class used to create a container panel where items get randomized planar mapping
  63000. */
  63001. export class ScatterPanel extends VolumeBasedPanel {
  63002. private _iteration;
  63003. /**
  63004. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  63005. */
  63006. iteration: BABYLON.float;
  63007. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  63008. private _scatterMapping;
  63009. protected _finalProcessing(): void;
  63010. }
  63011. }
  63012. declare module BABYLON.GUI {
  63013. /**
  63014. * Class used to create a container panel deployed on the surface of a sphere
  63015. */
  63016. export class SpherePanel extends VolumeBasedPanel {
  63017. private _radius;
  63018. /**
  63019. * Gets or sets the radius of the sphere where to project controls (5 by default)
  63020. */
  63021. radius: BABYLON.float;
  63022. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  63023. private _sphericalMapping;
  63024. }
  63025. }
  63026. declare module BABYLON.GUI {
  63027. /**
  63028. * Class used to create a stack panel in 3D on XY plane
  63029. */
  63030. export class StackPanel3D extends Container3D {
  63031. private _isVertical;
  63032. /**
  63033. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  63034. */
  63035. isVertical: boolean;
  63036. /**
  63037. * Gets or sets the distance between elements
  63038. */
  63039. margin: number;
  63040. /**
  63041. * Creates new StackPanel
  63042. * @param isVertical
  63043. */
  63044. constructor(isVertical?: boolean);
  63045. protected _arrangeChildren(): void;
  63046. }
  63047. }
  63048. declare module BABYLON {
  63049. /**
  63050. * Mode that determines the coordinate system to use.
  63051. */
  63052. export enum GLTFLoaderCoordinateSystemMode {
  63053. /**
  63054. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  63055. */
  63056. AUTO = 0,
  63057. /**
  63058. * Sets the useRightHandedSystem flag on the scene.
  63059. */
  63060. FORCE_RIGHT_HANDED = 1
  63061. }
  63062. /**
  63063. * Mode that determines what animations will start.
  63064. */
  63065. export enum GLTFLoaderAnimationStartMode {
  63066. /**
  63067. * No animation will start.
  63068. */
  63069. NONE = 0,
  63070. /**
  63071. * The first animation will start.
  63072. */
  63073. FIRST = 1,
  63074. /**
  63075. * All animations will start.
  63076. */
  63077. ALL = 2
  63078. }
  63079. /**
  63080. * Interface that contains the data for the glTF asset.
  63081. */
  63082. export interface IGLTFLoaderData {
  63083. /**
  63084. * Object that represents the glTF JSON.
  63085. */
  63086. json: Object;
  63087. /**
  63088. * The BIN chunk of a binary glTF.
  63089. */
  63090. bin: Nullable<ArrayBufferView>;
  63091. }
  63092. /**
  63093. * Interface for extending the loader.
  63094. */
  63095. export interface IGLTFLoaderExtension {
  63096. /**
  63097. * The name of this extension.
  63098. */
  63099. readonly name: string;
  63100. /**
  63101. * Defines whether this extension is enabled.
  63102. */
  63103. enabled: boolean;
  63104. }
  63105. /**
  63106. * Loader state.
  63107. */
  63108. export enum GLTFLoaderState {
  63109. /**
  63110. * The asset is loading.
  63111. */
  63112. LOADING = 0,
  63113. /**
  63114. * The asset is ready for rendering.
  63115. */
  63116. READY = 1,
  63117. /**
  63118. * The asset is completely loaded.
  63119. */
  63120. COMPLETE = 2
  63121. }
  63122. /** @hidden */
  63123. export interface IGLTFLoader extends IDisposable {
  63124. readonly state: Nullable<GLTFLoaderState>;
  63125. importMeshAsync: (meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<{
  63126. meshes: AbstractMesh[];
  63127. particleSystems: IParticleSystem[];
  63128. skeletons: Skeleton[];
  63129. animationGroups: AnimationGroup[];
  63130. }>;
  63131. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  63132. }
  63133. /**
  63134. * File loader for loading glTF files into a scene.
  63135. */
  63136. export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  63137. /** @hidden */
  63138. static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  63139. /** @hidden */
  63140. static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  63141. /**
  63142. * Raised when the asset has been parsed
  63143. */
  63144. onParsedObservable: Observable<IGLTFLoaderData>;
  63145. private _onParsedObserver;
  63146. /**
  63147. * Raised when the asset has been parsed
  63148. */
  63149. onParsed: (loaderData: IGLTFLoaderData) => void;
  63150. /**
  63151. * 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.
  63152. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  63153. * Defaults to true.
  63154. * @hidden
  63155. */
  63156. static IncrementalLoading: boolean;
  63157. /**
  63158. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  63159. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  63160. * @hidden
  63161. */
  63162. static HomogeneousCoordinates: boolean;
  63163. /**
  63164. * The coordinate system mode. Defaults to AUTO.
  63165. */
  63166. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  63167. /**
  63168. * The animation start mode. Defaults to FIRST.
  63169. */
  63170. animationStartMode: GLTFLoaderAnimationStartMode;
  63171. /**
  63172. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  63173. */
  63174. compileMaterials: boolean;
  63175. /**
  63176. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  63177. */
  63178. useClipPlane: boolean;
  63179. /**
  63180. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  63181. */
  63182. compileShadowGenerators: boolean;
  63183. /**
  63184. * Defines if the Alpha blended materials are only applied as coverage.
  63185. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  63186. * If true, no extra effects are applied to transparent pixels.
  63187. */
  63188. transparencyAsCoverage: boolean;
  63189. /**
  63190. * Function called before loading a url referenced by the asset.
  63191. */
  63192. preprocessUrlAsync: (url: string) => Promise<string>;
  63193. /**
  63194. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  63195. */
  63196. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  63197. private _onMeshLoadedObserver;
  63198. /**
  63199. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  63200. */
  63201. onMeshLoaded: (mesh: AbstractMesh) => void;
  63202. /**
  63203. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  63204. */
  63205. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  63206. private _onTextureLoadedObserver;
  63207. /**
  63208. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  63209. */
  63210. onTextureLoaded: (texture: BaseTexture) => void;
  63211. /**
  63212. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  63213. */
  63214. readonly onMaterialLoadedObservable: Observable<Material>;
  63215. private _onMaterialLoadedObserver;
  63216. /**
  63217. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  63218. */
  63219. onMaterialLoaded: (material: Material) => void;
  63220. /**
  63221. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  63222. */
  63223. readonly onCameraLoadedObservable: Observable<Camera>;
  63224. private _onCameraLoadedObserver;
  63225. /**
  63226. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  63227. */
  63228. onCameraLoaded: (camera: Camera) => void;
  63229. /**
  63230. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  63231. * For assets with LODs, raised when all of the LODs are complete.
  63232. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  63233. */
  63234. readonly onCompleteObservable: Observable<void>;
  63235. private _onCompleteObserver;
  63236. /**
  63237. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  63238. * For assets with LODs, raised when all of the LODs are complete.
  63239. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  63240. */
  63241. onComplete: () => void;
  63242. /**
  63243. * Observable raised when an error occurs.
  63244. */
  63245. readonly onErrorObservable: Observable<any>;
  63246. private _onErrorObserver;
  63247. /**
  63248. * Callback raised when an error occurs.
  63249. */
  63250. onError: (reason: any) => void;
  63251. /**
  63252. * Observable raised after the loader is disposed.
  63253. */
  63254. readonly onDisposeObservable: Observable<void>;
  63255. private _onDisposeObserver;
  63256. /**
  63257. * Callback raised after the loader is disposed.
  63258. */
  63259. onDispose: () => void;
  63260. /**
  63261. * Observable raised after a loader extension is created.
  63262. * Set additional options for a loader extension in this event.
  63263. */
  63264. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  63265. private _onExtensionLoadedObserver;
  63266. /**
  63267. * Callback raised after a loader extension is created.
  63268. */
  63269. onExtensionLoaded: (extension: IGLTFLoaderExtension) => void;
  63270. /**
  63271. * Defines if the loader logging is enabled.
  63272. */
  63273. loggingEnabled: boolean;
  63274. /**
  63275. * Defines if the loader should capture performance counters.
  63276. */
  63277. capturePerformanceCounters: boolean;
  63278. /**
  63279. * Defines if the loader should validate the asset.
  63280. */
  63281. validate: boolean;
  63282. /**
  63283. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  63284. */
  63285. readonly onValidatedObservable: Observable<BABYLON.GLTF2.IGLTFValidationResults>;
  63286. private _onValidatedObserver;
  63287. /**
  63288. * Callback raised after a loader extension is created.
  63289. */
  63290. onValidated: (results: BABYLON.GLTF2.IGLTFValidationResults) => void;
  63291. private _loader;
  63292. /**
  63293. * Name of the loader ("gltf")
  63294. */
  63295. name: string;
  63296. /**
  63297. * Supported file extensions of the loader (.gltf, .glb)
  63298. */
  63299. extensions: ISceneLoaderPluginExtensions;
  63300. /**
  63301. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  63302. */
  63303. dispose(): void;
  63304. /** @hidden */
  63305. _clear(): void;
  63306. /**
  63307. * Imports one or more meshes from the loaded glTF data and adds them to the scene
  63308. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  63309. * @param scene the scene the meshes should be added to
  63310. * @param data the glTF data to load
  63311. * @param rootUrl root url to load from
  63312. * @param onProgress event that fires when loading progress has occured
  63313. * @param fileName Defines the name of the file to load
  63314. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  63315. */
  63316. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  63317. meshes: AbstractMesh[];
  63318. particleSystems: IParticleSystem[];
  63319. skeletons: Skeleton[];
  63320. animationGroups: AnimationGroup[];
  63321. }>;
  63322. /**
  63323. * Imports all objects from the loaded glTF data and adds them to the scene
  63324. * @param scene the scene the objects should be added to
  63325. * @param data the glTF data to load
  63326. * @param rootUrl root url to load from
  63327. * @param onProgress event that fires when loading progress has occured
  63328. * @param fileName Defines the name of the file to load
  63329. * @returns a promise which completes when objects have been loaded to the scene
  63330. */
  63331. loadAsync(scene: Scene, data: string | ArrayBuffer, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  63332. /**
  63333. * Load into an asset container.
  63334. * @param scene The scene to load into
  63335. * @param data The data to import
  63336. * @param rootUrl The root url for scene and resources
  63337. * @param onProgress The callback when the load progresses
  63338. * @param fileName Defines the name of the file to load
  63339. * @returns The loaded asset container
  63340. */
  63341. loadAssetContainerAsync(scene: Scene, data: string | ArrayBuffer, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  63342. /**
  63343. * If the data string can be loaded directly.
  63344. * @param data string contianing the file data
  63345. * @returns if the data can be loaded directly
  63346. */
  63347. canDirectLoad(data: string): boolean;
  63348. /**
  63349. * Rewrites a url by combining a root url and response url.
  63350. */
  63351. rewriteRootURL: (rootUrl: string, responseURL?: string) => string;
  63352. /**
  63353. * Instantiates a glTF file loader plugin.
  63354. * @returns the created plugin
  63355. */
  63356. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  63357. /**
  63358. * The loader state or null if the loader is not active.
  63359. */
  63360. readonly loaderState: Nullable<GLTFLoaderState>;
  63361. /**
  63362. * Returns a promise that resolves when the asset is completely loaded.
  63363. * @returns a promise that resolves when the asset is completely loaded.
  63364. */
  63365. whenCompleteAsync(): Promise<void>;
  63366. private _parseAsync;
  63367. private _validateAsync;
  63368. private _getLoader;
  63369. private _unpackBinary;
  63370. private _unpackBinaryV1;
  63371. private _unpackBinaryV2;
  63372. private static _parseVersion;
  63373. private static _compareVersion;
  63374. private static _decodeBufferToText;
  63375. private static readonly _logSpaces;
  63376. private _logIndentLevel;
  63377. private _loggingEnabled;
  63378. /** @hidden */
  63379. _log: (message: string) => void;
  63380. /** @hidden */
  63381. _logOpen(message: string): void;
  63382. /** @hidden */
  63383. _logClose(): void;
  63384. private _logEnabled;
  63385. private _logDisabled;
  63386. private _capturePerformanceCounters;
  63387. /** @hidden */
  63388. _startPerformanceCounter: (counterName: string) => void;
  63389. /** @hidden */
  63390. _endPerformanceCounter: (counterName: string) => void;
  63391. private _startPerformanceCounterEnabled;
  63392. private _startPerformanceCounterDisabled;
  63393. private _endPerformanceCounterEnabled;
  63394. private _endPerformanceCounterDisabled;
  63395. }
  63396. }
  63397. declare module BABYLON.GLTF1 {
  63398. /**
  63399. * Enums
  63400. * @hidden
  63401. */
  63402. export enum EComponentType {
  63403. BYTE = 5120,
  63404. UNSIGNED_BYTE = 5121,
  63405. SHORT = 5122,
  63406. UNSIGNED_SHORT = 5123,
  63407. FLOAT = 5126
  63408. }
  63409. /** @hidden */
  63410. export enum EShaderType {
  63411. FRAGMENT = 35632,
  63412. VERTEX = 35633
  63413. }
  63414. /** @hidden */
  63415. export enum EParameterType {
  63416. BYTE = 5120,
  63417. UNSIGNED_BYTE = 5121,
  63418. SHORT = 5122,
  63419. UNSIGNED_SHORT = 5123,
  63420. INT = 5124,
  63421. UNSIGNED_INT = 5125,
  63422. FLOAT = 5126,
  63423. FLOAT_VEC2 = 35664,
  63424. FLOAT_VEC3 = 35665,
  63425. FLOAT_VEC4 = 35666,
  63426. INT_VEC2 = 35667,
  63427. INT_VEC3 = 35668,
  63428. INT_VEC4 = 35669,
  63429. BOOL = 35670,
  63430. BOOL_VEC2 = 35671,
  63431. BOOL_VEC3 = 35672,
  63432. BOOL_VEC4 = 35673,
  63433. FLOAT_MAT2 = 35674,
  63434. FLOAT_MAT3 = 35675,
  63435. FLOAT_MAT4 = 35676,
  63436. SAMPLER_2D = 35678
  63437. }
  63438. /** @hidden */
  63439. export enum ETextureWrapMode {
  63440. CLAMP_TO_EDGE = 33071,
  63441. MIRRORED_REPEAT = 33648,
  63442. REPEAT = 10497
  63443. }
  63444. /** @hidden */
  63445. export enum ETextureFilterType {
  63446. NEAREST = 9728,
  63447. LINEAR = 9728,
  63448. NEAREST_MIPMAP_NEAREST = 9984,
  63449. LINEAR_MIPMAP_NEAREST = 9985,
  63450. NEAREST_MIPMAP_LINEAR = 9986,
  63451. LINEAR_MIPMAP_LINEAR = 9987
  63452. }
  63453. /** @hidden */
  63454. export enum ETextureFormat {
  63455. ALPHA = 6406,
  63456. RGB = 6407,
  63457. RGBA = 6408,
  63458. LUMINANCE = 6409,
  63459. LUMINANCE_ALPHA = 6410
  63460. }
  63461. /** @hidden */
  63462. export enum ECullingType {
  63463. FRONT = 1028,
  63464. BACK = 1029,
  63465. FRONT_AND_BACK = 1032
  63466. }
  63467. /** @hidden */
  63468. export enum EBlendingFunction {
  63469. ZERO = 0,
  63470. ONE = 1,
  63471. SRC_COLOR = 768,
  63472. ONE_MINUS_SRC_COLOR = 769,
  63473. DST_COLOR = 774,
  63474. ONE_MINUS_DST_COLOR = 775,
  63475. SRC_ALPHA = 770,
  63476. ONE_MINUS_SRC_ALPHA = 771,
  63477. DST_ALPHA = 772,
  63478. ONE_MINUS_DST_ALPHA = 773,
  63479. CONSTANT_COLOR = 32769,
  63480. ONE_MINUS_CONSTANT_COLOR = 32770,
  63481. CONSTANT_ALPHA = 32771,
  63482. ONE_MINUS_CONSTANT_ALPHA = 32772,
  63483. SRC_ALPHA_SATURATE = 776
  63484. }
  63485. /** @hidden */
  63486. export interface IGLTFProperty {
  63487. extensions?: {
  63488. [key: string]: any;
  63489. };
  63490. extras?: Object;
  63491. }
  63492. /** @hidden */
  63493. export interface IGLTFChildRootProperty extends IGLTFProperty {
  63494. name?: string;
  63495. }
  63496. /** @hidden */
  63497. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  63498. bufferView: string;
  63499. byteOffset: number;
  63500. byteStride: number;
  63501. count: number;
  63502. type: string;
  63503. componentType: EComponentType;
  63504. max?: number[];
  63505. min?: number[];
  63506. name?: string;
  63507. }
  63508. /** @hidden */
  63509. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  63510. buffer: string;
  63511. byteOffset: number;
  63512. byteLength: number;
  63513. byteStride: number;
  63514. target?: number;
  63515. }
  63516. /** @hidden */
  63517. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  63518. uri: string;
  63519. byteLength?: number;
  63520. type?: string;
  63521. }
  63522. /** @hidden */
  63523. export interface IGLTFShader extends IGLTFChildRootProperty {
  63524. uri: string;
  63525. type: EShaderType;
  63526. }
  63527. /** @hidden */
  63528. export interface IGLTFProgram extends IGLTFChildRootProperty {
  63529. attributes: string[];
  63530. fragmentShader: string;
  63531. vertexShader: string;
  63532. }
  63533. /** @hidden */
  63534. export interface IGLTFTechniqueParameter {
  63535. type: number;
  63536. count?: number;
  63537. semantic?: string;
  63538. node?: string;
  63539. value?: number | boolean | string | Array<any>;
  63540. source?: string;
  63541. babylonValue?: any;
  63542. }
  63543. /** @hidden */
  63544. export interface IGLTFTechniqueCommonProfile {
  63545. lightingModel: string;
  63546. texcoordBindings: Object;
  63547. parameters?: Array<any>;
  63548. }
  63549. /** @hidden */
  63550. export interface IGLTFTechniqueStatesFunctions {
  63551. blendColor?: number[];
  63552. blendEquationSeparate?: number[];
  63553. blendFuncSeparate?: number[];
  63554. colorMask: boolean[];
  63555. cullFace: number[];
  63556. }
  63557. /** @hidden */
  63558. export interface IGLTFTechniqueStates {
  63559. enable: number[];
  63560. functions: IGLTFTechniqueStatesFunctions;
  63561. }
  63562. /** @hidden */
  63563. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  63564. parameters: {
  63565. [key: string]: IGLTFTechniqueParameter;
  63566. };
  63567. program: string;
  63568. attributes: {
  63569. [key: string]: string;
  63570. };
  63571. uniforms: {
  63572. [key: string]: string;
  63573. };
  63574. states: IGLTFTechniqueStates;
  63575. }
  63576. /** @hidden */
  63577. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  63578. technique?: string;
  63579. values: string[];
  63580. }
  63581. /** @hidden */
  63582. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  63583. attributes: {
  63584. [key: string]: string;
  63585. };
  63586. indices: string;
  63587. material: string;
  63588. mode?: number;
  63589. }
  63590. /** @hidden */
  63591. export interface IGLTFMesh extends IGLTFChildRootProperty {
  63592. primitives: IGLTFMeshPrimitive[];
  63593. }
  63594. /** @hidden */
  63595. export interface IGLTFImage extends IGLTFChildRootProperty {
  63596. uri: string;
  63597. }
  63598. /** @hidden */
  63599. export interface IGLTFSampler extends IGLTFChildRootProperty {
  63600. magFilter?: number;
  63601. minFilter?: number;
  63602. wrapS?: number;
  63603. wrapT?: number;
  63604. }
  63605. /** @hidden */
  63606. export interface IGLTFTexture extends IGLTFChildRootProperty {
  63607. sampler: string;
  63608. source: string;
  63609. format?: ETextureFormat;
  63610. internalFormat?: ETextureFormat;
  63611. target?: number;
  63612. type?: number;
  63613. babylonTexture?: Texture;
  63614. }
  63615. /** @hidden */
  63616. export interface IGLTFAmbienLight {
  63617. color?: number[];
  63618. }
  63619. /** @hidden */
  63620. export interface IGLTFDirectionalLight {
  63621. color?: number[];
  63622. }
  63623. /** @hidden */
  63624. export interface IGLTFPointLight {
  63625. color?: number[];
  63626. constantAttenuation?: number;
  63627. linearAttenuation?: number;
  63628. quadraticAttenuation?: number;
  63629. }
  63630. /** @hidden */
  63631. export interface IGLTFSpotLight {
  63632. color?: number[];
  63633. constantAttenuation?: number;
  63634. fallOfAngle?: number;
  63635. fallOffExponent?: number;
  63636. linearAttenuation?: number;
  63637. quadraticAttenuation?: number;
  63638. }
  63639. /** @hidden */
  63640. export interface IGLTFLight extends IGLTFChildRootProperty {
  63641. type: string;
  63642. }
  63643. /** @hidden */
  63644. export interface IGLTFCameraOrthographic {
  63645. xmag: number;
  63646. ymag: number;
  63647. zfar: number;
  63648. znear: number;
  63649. }
  63650. /** @hidden */
  63651. export interface IGLTFCameraPerspective {
  63652. aspectRatio: number;
  63653. yfov: number;
  63654. zfar: number;
  63655. znear: number;
  63656. }
  63657. /** @hidden */
  63658. export interface IGLTFCamera extends IGLTFChildRootProperty {
  63659. type: string;
  63660. }
  63661. /** @hidden */
  63662. export interface IGLTFAnimationChannelTarget {
  63663. id: string;
  63664. path: string;
  63665. }
  63666. /** @hidden */
  63667. export interface IGLTFAnimationChannel {
  63668. sampler: string;
  63669. target: IGLTFAnimationChannelTarget;
  63670. }
  63671. /** @hidden */
  63672. export interface IGLTFAnimationSampler {
  63673. input: string;
  63674. output: string;
  63675. interpolation?: string;
  63676. }
  63677. /** @hidden */
  63678. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  63679. channels?: IGLTFAnimationChannel[];
  63680. parameters?: {
  63681. [key: string]: string;
  63682. };
  63683. samplers?: {
  63684. [key: string]: IGLTFAnimationSampler;
  63685. };
  63686. }
  63687. /** @hidden */
  63688. export interface IGLTFNodeInstanceSkin {
  63689. skeletons: string[];
  63690. skin: string;
  63691. meshes: string[];
  63692. }
  63693. /** @hidden */
  63694. export interface IGLTFSkins extends IGLTFChildRootProperty {
  63695. bindShapeMatrix: number[];
  63696. inverseBindMatrices: string;
  63697. jointNames: string[];
  63698. babylonSkeleton?: Skeleton;
  63699. }
  63700. /** @hidden */
  63701. export interface IGLTFNode extends IGLTFChildRootProperty {
  63702. camera?: string;
  63703. children: string[];
  63704. skin?: string;
  63705. jointName?: string;
  63706. light?: string;
  63707. matrix: number[];
  63708. mesh?: string;
  63709. meshes?: string[];
  63710. rotation?: number[];
  63711. scale?: number[];
  63712. translation?: number[];
  63713. babylonNode?: Node;
  63714. }
  63715. /** @hidden */
  63716. export interface IGLTFScene extends IGLTFChildRootProperty {
  63717. nodes: string[];
  63718. }
  63719. /** @hidden */
  63720. export interface IGLTFRuntime {
  63721. extensions: {
  63722. [key: string]: any;
  63723. };
  63724. accessors: {
  63725. [key: string]: IGLTFAccessor;
  63726. };
  63727. buffers: {
  63728. [key: string]: IGLTFBuffer;
  63729. };
  63730. bufferViews: {
  63731. [key: string]: IGLTFBufferView;
  63732. };
  63733. meshes: {
  63734. [key: string]: IGLTFMesh;
  63735. };
  63736. lights: {
  63737. [key: string]: IGLTFLight;
  63738. };
  63739. cameras: {
  63740. [key: string]: IGLTFCamera;
  63741. };
  63742. nodes: {
  63743. [key: string]: IGLTFNode;
  63744. };
  63745. images: {
  63746. [key: string]: IGLTFImage;
  63747. };
  63748. textures: {
  63749. [key: string]: IGLTFTexture;
  63750. };
  63751. shaders: {
  63752. [key: string]: IGLTFShader;
  63753. };
  63754. programs: {
  63755. [key: string]: IGLTFProgram;
  63756. };
  63757. samplers: {
  63758. [key: string]: IGLTFSampler;
  63759. };
  63760. techniques: {
  63761. [key: string]: IGLTFTechnique;
  63762. };
  63763. materials: {
  63764. [key: string]: IGLTFMaterial;
  63765. };
  63766. animations: {
  63767. [key: string]: IGLTFAnimation;
  63768. };
  63769. skins: {
  63770. [key: string]: IGLTFSkins;
  63771. };
  63772. currentScene?: Object;
  63773. scenes: {
  63774. [key: string]: IGLTFScene;
  63775. };
  63776. extensionsUsed: string[];
  63777. extensionsRequired?: string[];
  63778. buffersCount: number;
  63779. shaderscount: number;
  63780. scene: Scene;
  63781. rootUrl: string;
  63782. loadedBufferCount: number;
  63783. loadedBufferViews: {
  63784. [name: string]: ArrayBufferView;
  63785. };
  63786. loadedShaderCount: number;
  63787. importOnlyMeshes: boolean;
  63788. importMeshesNames?: string[];
  63789. dummyNodes: Node[];
  63790. }
  63791. /** @hidden */
  63792. export interface INodeToRoot {
  63793. bone: Bone;
  63794. node: IGLTFNode;
  63795. id: string;
  63796. }
  63797. /** @hidden */
  63798. export interface IJointNode {
  63799. node: IGLTFNode;
  63800. id: string;
  63801. }
  63802. }
  63803. declare module BABYLON.GLTF1 {
  63804. /**
  63805. * Utils functions for GLTF
  63806. * @hidden
  63807. */
  63808. export class GLTFUtils {
  63809. /**
  63810. * Sets the given "parameter" matrix
  63811. * @param scene: the Scene object
  63812. * @param source: the source node where to pick the matrix
  63813. * @param parameter: the GLTF technique parameter
  63814. * @param uniformName: the name of the shader's uniform
  63815. * @param shaderMaterial: the shader material
  63816. */
  63817. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  63818. /**
  63819. * Sets the given "parameter" matrix
  63820. * @param shaderMaterial: the shader material
  63821. * @param uniform: the name of the shader's uniform
  63822. * @param value: the value of the uniform
  63823. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  63824. */
  63825. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  63826. /**
  63827. * Returns the wrap mode of the texture
  63828. * @param mode: the mode value
  63829. */
  63830. static GetWrapMode(mode: number): number;
  63831. /**
  63832. * Returns the byte stride giving an accessor
  63833. * @param accessor: the GLTF accessor objet
  63834. */
  63835. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  63836. /**
  63837. * Returns the texture filter mode giving a mode value
  63838. * @param mode: the filter mode value
  63839. */
  63840. static GetTextureFilterMode(mode: number): ETextureFilterType;
  63841. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  63842. /**
  63843. * Returns a buffer from its accessor
  63844. * @param gltfRuntime: the GLTF runtime
  63845. * @param accessor: the GLTF accessor
  63846. */
  63847. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  63848. /**
  63849. * Decodes a buffer view into a string
  63850. * @param view: the buffer view
  63851. */
  63852. static DecodeBufferToText(view: ArrayBufferView): string;
  63853. /**
  63854. * Returns the default material of gltf. Related to
  63855. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  63856. * @param scene: the Babylon.js scene
  63857. */
  63858. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  63859. private static _DefaultMaterial;
  63860. }
  63861. }
  63862. declare module BABYLON.GLTF1 {
  63863. /**
  63864. * Implementation of the base glTF spec
  63865. * @hidden
  63866. */
  63867. export class GLTFLoaderBase {
  63868. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  63869. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  63870. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  63871. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  63872. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  63873. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  63874. }
  63875. /**
  63876. * glTF V1 Loader
  63877. * @hidden
  63878. */
  63879. export class GLTFLoader implements IGLTFLoader {
  63880. static Extensions: {
  63881. [name: string]: GLTFLoaderExtension;
  63882. };
  63883. static RegisterExtension(extension: GLTFLoaderExtension): void;
  63884. state: Nullable<GLTFLoaderState>;
  63885. dispose(): void;
  63886. private _importMeshAsync;
  63887. /**
  63888. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  63889. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  63890. * @param scene the scene the meshes should be added to
  63891. * @param data gltf data containing information of the meshes in a loaded file
  63892. * @param rootUrl root url to load from
  63893. * @param onProgress event that fires when loading progress has occured
  63894. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  63895. */
  63896. importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<{
  63897. meshes: AbstractMesh[];
  63898. particleSystems: IParticleSystem[];
  63899. skeletons: Skeleton[];
  63900. animationGroups: AnimationGroup[];
  63901. }>;
  63902. private _loadAsync;
  63903. /**
  63904. * Imports all objects from a loaded gltf file and adds them to the scene
  63905. * @param scene the scene the objects should be added to
  63906. * @param data gltf data containing information of the meshes in a loaded file
  63907. * @param rootUrl root url to load from
  63908. * @param onProgress event that fires when loading progress has occured
  63909. * @returns a promise which completes when objects have been loaded to the scene
  63910. */
  63911. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<void>;
  63912. private _loadShadersAsync;
  63913. private _loadBuffersAsync;
  63914. private _createNodes;
  63915. }
  63916. /** @hidden */
  63917. export abstract class GLTFLoaderExtension {
  63918. private _name;
  63919. constructor(name: string);
  63920. readonly name: string;
  63921. /**
  63922. * Defines an override for loading the runtime
  63923. * Return true to stop further extensions from loading the runtime
  63924. */
  63925. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  63926. /**
  63927. * Defines an onverride for creating gltf runtime
  63928. * Return true to stop further extensions from creating the runtime
  63929. */
  63930. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  63931. /**
  63932. * Defines an override for loading buffers
  63933. * Return true to stop further extensions from loading this buffer
  63934. */
  63935. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  63936. /**
  63937. * Defines an override for loading texture buffers
  63938. * Return true to stop further extensions from loading this texture data
  63939. */
  63940. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  63941. /**
  63942. * Defines an override for creating textures
  63943. * Return true to stop further extensions from loading this texture
  63944. */
  63945. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  63946. /**
  63947. * Defines an override for loading shader strings
  63948. * Return true to stop further extensions from loading this shader data
  63949. */
  63950. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  63951. /**
  63952. * Defines an override for loading materials
  63953. * Return true to stop further extensions from loading this material
  63954. */
  63955. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  63956. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  63957. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  63958. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  63959. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  63960. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  63961. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  63962. private static LoadTextureBufferAsync;
  63963. private static CreateTextureAsync;
  63964. private static ApplyExtensions;
  63965. }
  63966. }
  63967. declare module BABYLON.GLTF1 {
  63968. /** @hidden */
  63969. export class GLTFBinaryExtension extends GLTFLoaderExtension {
  63970. private _bin;
  63971. constructor();
  63972. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  63973. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  63974. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  63975. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  63976. }
  63977. }
  63978. declare module BABYLON.GLTF1 {
  63979. /** @hidden */
  63980. export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  63981. constructor();
  63982. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  63983. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  63984. private _loadTexture;
  63985. }
  63986. }
  63987. declare module BABYLON.GLTF2.Loader {
  63988. /**
  63989. * Loader interface with an index field.
  63990. */
  63991. export interface IArrayItem {
  63992. /**
  63993. * The index of this item in the array.
  63994. */
  63995. index: number;
  63996. }
  63997. /**
  63998. * Loader interface with additional members.
  63999. */
  64000. export interface IAccessor extends BABYLON.GLTF2.IAccessor, IArrayItem {
  64001. /** @hidden */
  64002. _data?: Promise<ArrayBufferView>;
  64003. /** @hidden */
  64004. _babylonVertexBuffer?: Promise<VertexBuffer>;
  64005. }
  64006. /**
  64007. * Loader interface with additional members.
  64008. */
  64009. export interface IAnimationChannel extends BABYLON.GLTF2.IAnimationChannel, IArrayItem {
  64010. }
  64011. /** @hidden */
  64012. export interface _IAnimationSamplerData {
  64013. input: Float32Array;
  64014. interpolation: BABYLON.GLTF2.AnimationSamplerInterpolation;
  64015. output: Float32Array;
  64016. }
  64017. /**
  64018. * Loader interface with additional members.
  64019. */
  64020. export interface IAnimationSampler extends BABYLON.GLTF2.IAnimationSampler, IArrayItem {
  64021. /** @hidden */
  64022. _data?: Promise<_IAnimationSamplerData>;
  64023. }
  64024. /**
  64025. * Loader interface with additional members.
  64026. */
  64027. export interface IAnimation extends BABYLON.GLTF2.IAnimation, IArrayItem {
  64028. channels: IAnimationChannel[];
  64029. samplers: IAnimationSampler[];
  64030. /** @hidden */
  64031. _babylonAnimationGroup?: AnimationGroup;
  64032. }
  64033. /**
  64034. * Loader interface with additional members.
  64035. */
  64036. export interface IBuffer extends BABYLON.GLTF2.IBuffer, IArrayItem {
  64037. /** @hidden */
  64038. _data?: Promise<ArrayBufferView>;
  64039. }
  64040. /**
  64041. * Loader interface with additional members.
  64042. */
  64043. export interface IBufferView extends BABYLON.GLTF2.IBufferView, IArrayItem {
  64044. /** @hidden */
  64045. _data?: Promise<ArrayBufferView>;
  64046. /** @hidden */
  64047. _babylonBuffer?: Promise<Buffer>;
  64048. }
  64049. /**
  64050. * Loader interface with additional members.
  64051. */
  64052. export interface ICamera extends BABYLON.GLTF2.ICamera, IArrayItem {
  64053. }
  64054. /**
  64055. * Loader interface with additional members.
  64056. */
  64057. export interface IImage extends BABYLON.GLTF2.IImage, IArrayItem {
  64058. /** @hidden */
  64059. _data?: Promise<ArrayBufferView>;
  64060. }
  64061. /**
  64062. * Loader interface with additional members.
  64063. */
  64064. export interface IMaterialNormalTextureInfo extends BABYLON.GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  64065. }
  64066. /**
  64067. * Loader interface with additional members.
  64068. */
  64069. export interface IMaterialOcclusionTextureInfo extends BABYLON.GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  64070. }
  64071. /**
  64072. * Loader interface with additional members.
  64073. */
  64074. export interface IMaterialPbrMetallicRoughness extends BABYLON.GLTF2.IMaterialPbrMetallicRoughness {
  64075. baseColorTexture?: ITextureInfo;
  64076. metallicRoughnessTexture?: ITextureInfo;
  64077. }
  64078. /**
  64079. * Loader interface with additional members.
  64080. */
  64081. export interface IMaterial extends BABYLON.GLTF2.IMaterial, IArrayItem {
  64082. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  64083. normalTexture?: IMaterialNormalTextureInfo;
  64084. occlusionTexture?: IMaterialOcclusionTextureInfo;
  64085. emissiveTexture?: ITextureInfo;
  64086. /** @hidden */
  64087. _data?: {
  64088. [babylonDrawMode: number]: {
  64089. babylonMaterial: Material;
  64090. babylonMeshes: AbstractMesh[];
  64091. promise: Promise<void>;
  64092. };
  64093. };
  64094. }
  64095. /**
  64096. * Loader interface with additional members.
  64097. */
  64098. export interface IMesh extends BABYLON.GLTF2.IMesh, IArrayItem {
  64099. primitives: IMeshPrimitive[];
  64100. }
  64101. /**
  64102. * Loader interface with additional members.
  64103. */
  64104. export interface IMeshPrimitive extends BABYLON.GLTF2.IMeshPrimitive, IArrayItem {
  64105. /** @hidden */
  64106. _instanceData?: {
  64107. babylonSourceMesh: Mesh;
  64108. promise: Promise<any>;
  64109. };
  64110. }
  64111. /**
  64112. * Loader interface with additional members.
  64113. */
  64114. export interface INode extends BABYLON.GLTF2.INode, IArrayItem {
  64115. /**
  64116. * The parent glTF node.
  64117. */
  64118. parent?: INode;
  64119. /** @hidden */
  64120. _babylonTransformNode?: TransformNode;
  64121. /** @hidden */
  64122. _primitiveBabylonMeshes?: AbstractMesh[];
  64123. /** @hidden */
  64124. _babylonBones?: Bone[];
  64125. /** @hidden */
  64126. _numMorphTargets?: number;
  64127. }
  64128. /** @hidden */
  64129. export interface _ISamplerData {
  64130. noMipMaps: boolean;
  64131. samplingMode: number;
  64132. wrapU: number;
  64133. wrapV: number;
  64134. }
  64135. /**
  64136. * Loader interface with additional members.
  64137. */
  64138. export interface ISampler extends BABYLON.GLTF2.ISampler, IArrayItem {
  64139. /** @hidden */
  64140. _data?: _ISamplerData;
  64141. }
  64142. /**
  64143. * Loader interface with additional members.
  64144. */
  64145. export interface IScene extends BABYLON.GLTF2.IScene, IArrayItem {
  64146. }
  64147. /**
  64148. * Loader interface with additional members.
  64149. */
  64150. export interface ISkin extends BABYLON.GLTF2.ISkin, IArrayItem {
  64151. /** @hidden */
  64152. _data?: {
  64153. babylonSkeleton: Skeleton;
  64154. promise: Promise<void>;
  64155. };
  64156. }
  64157. /**
  64158. * Loader interface with additional members.
  64159. */
  64160. export interface ITexture extends BABYLON.GLTF2.ITexture, IArrayItem {
  64161. }
  64162. /**
  64163. * Loader interface with additional members.
  64164. */
  64165. export interface ITextureInfo extends BABYLON.GLTF2.ITextureInfo {
  64166. }
  64167. /**
  64168. * Loader interface with additional members.
  64169. */
  64170. export interface IGLTF extends BABYLON.GLTF2.IGLTF {
  64171. accessors?: IAccessor[];
  64172. animations?: IAnimation[];
  64173. buffers?: IBuffer[];
  64174. bufferViews?: IBufferView[];
  64175. cameras?: ICamera[];
  64176. images?: IImage[];
  64177. materials?: IMaterial[];
  64178. meshes?: IMesh[];
  64179. nodes?: INode[];
  64180. samplers?: ISampler[];
  64181. scenes?: IScene[];
  64182. skins?: ISkin[];
  64183. textures?: ITexture[];
  64184. }
  64185. }
  64186. declare module BABYLON.GLTF2 {
  64187. /**
  64188. * Interface for a glTF loader extension.
  64189. */
  64190. export interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  64191. /**
  64192. * Called after the loader state changes to LOADING.
  64193. */
  64194. onLoading?(): void;
  64195. /**
  64196. * Called after the loader state changes to READY.
  64197. */
  64198. onReady?(): void;
  64199. /**
  64200. * Define this method to modify the default behavior when loading scenes.
  64201. * @param context The context when loading the asset
  64202. * @param scene The glTF scene property
  64203. * @returns A promise that resolves when the load is complete or null if not handled
  64204. */
  64205. loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
  64206. /**
  64207. * Define this method to modify the default behavior when loading nodes.
  64208. * @param context The context when loading the asset
  64209. * @param node The glTF node property
  64210. * @param assign A function called synchronously after parsing the glTF properties
  64211. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  64212. */
  64213. loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  64214. /**
  64215. * Define this method to modify the default behavior when loading cameras.
  64216. * @param context The context when loading the asset
  64217. * @param camera The glTF camera property
  64218. * @param assign A function called synchronously after parsing the glTF properties
  64219. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  64220. */
  64221. loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  64222. /**
  64223. * @hidden Define this method to modify the default behavior when loading vertex data for mesh primitives.
  64224. * @param context The context when loading the asset
  64225. * @param primitive The glTF mesh primitive property
  64226. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  64227. */
  64228. _loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  64229. /**
  64230. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  64231. * @param context The context when loading the asset
  64232. * @param name The mesh name when loading the asset
  64233. * @param node The glTF node when loading the asset
  64234. * @param mesh The glTF mesh when loading the asset
  64235. * @param primitive The glTF mesh primitive property
  64236. * @param assign A function called synchronously after parsing the glTF properties
  64237. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  64238. */
  64239. _loadMeshPrimitiveAsync?(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  64240. /**
  64241. * @hidden Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  64242. * @param context The context when loading the asset
  64243. * @param material The glTF material property
  64244. * @param assign A function called synchronously after parsing the glTF properties
  64245. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  64246. */
  64247. _loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  64248. /**
  64249. * Define this method to modify the default behavior when creating materials.
  64250. * @param context The context when loading the asset
  64251. * @param material The glTF material property
  64252. * @param babylonDrawMode The draw mode for the Babylon material
  64253. * @returns The Babylon material or null if not handled
  64254. */
  64255. createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  64256. /**
  64257. * Define this method to modify the default behavior when loading material properties.
  64258. * @param context The context when loading the asset
  64259. * @param material The glTF material property
  64260. * @param babylonMaterial The Babylon material
  64261. * @returns A promise that resolves when the load is complete or null if not handled
  64262. */
  64263. loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  64264. /**
  64265. * Define this method to modify the default behavior when loading texture infos.
  64266. * @param context The context when loading the asset
  64267. * @param textureInfo The glTF texture info property
  64268. * @param assign A function called synchronously after parsing the glTF properties
  64269. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  64270. */
  64271. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  64272. /**
  64273. * Define this method to modify the default behavior when loading animations.
  64274. * @param context The context when loading the asset
  64275. * @param animation The glTF animation property
  64276. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  64277. */
  64278. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  64279. /**
  64280. * @hidden Define this method to modify the default behavior when loading skins.
  64281. * @param context The context when loading the asset
  64282. * @param node The glTF node property
  64283. * @param skin The glTF skin property
  64284. * @returns A promise that resolves when the load is complete or null if not handled
  64285. */
  64286. _loadSkinAsync?(context: string, node: INode, skin: ISkin): Nullable<Promise<void>>;
  64287. /**
  64288. * @hidden Define this method to modify the default behavior when loading uris.
  64289. * @param context The context when loading the asset
  64290. * @param property The glTF property associated with the uri
  64291. * @param uri The uri to load
  64292. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  64293. */
  64294. _loadUriAsync?(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  64295. }
  64296. }
  64297. declare module BABYLON.GLTF2 {
  64298. /**
  64299. * Helper class for working with arrays when loading the glTF asset
  64300. */
  64301. export class ArrayItem {
  64302. /**
  64303. * Gets an item from the given array.
  64304. * @param context The context when loading the asset
  64305. * @param array The array to get the item from
  64306. * @param index The index to the array
  64307. * @returns The array item
  64308. */
  64309. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  64310. /**
  64311. * Assign an `index` field to each item of the given array.
  64312. * @param array The array of items
  64313. */
  64314. static Assign(array?: BABYLON.GLTF2.Loader.IArrayItem[]): void;
  64315. }
  64316. /**
  64317. * The glTF 2.0 loader
  64318. */
  64319. export class GLTFLoader implements IGLTFLoader {
  64320. /** @hidden */
  64321. _completePromises: Promise<any>[];
  64322. private _disposed;
  64323. private _parent;
  64324. private _state;
  64325. private _extensions;
  64326. private _rootUrl;
  64327. private _fileName;
  64328. private _uniqueRootUrl;
  64329. private _gltf;
  64330. private _babylonScene;
  64331. private _rootBabylonMesh;
  64332. private _defaultBabylonMaterialData;
  64333. private _progressCallback?;
  64334. private _requests;
  64335. private static readonly _DefaultSampler;
  64336. private static _ExtensionNames;
  64337. private static _ExtensionFactories;
  64338. /**
  64339. * Registers a loader extension.
  64340. * @param name The name of the loader extension.
  64341. * @param factory The factory function that creates the loader extension.
  64342. */
  64343. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  64344. /**
  64345. * Unregisters a loader extension.
  64346. * @param name The name of the loader extenion.
  64347. * @returns A boolean indicating whether the extension has been unregistered
  64348. */
  64349. static UnregisterExtension(name: string): boolean;
  64350. /**
  64351. * Gets the loader state.
  64352. */
  64353. readonly state: Nullable<GLTFLoaderState>;
  64354. /**
  64355. * The glTF object parsed from the JSON.
  64356. */
  64357. readonly gltf: IGLTF;
  64358. /**
  64359. * The Babylon scene when loading the asset.
  64360. */
  64361. readonly babylonScene: Scene;
  64362. /**
  64363. * The root Babylon mesh when loading the asset.
  64364. */
  64365. readonly rootBabylonMesh: Mesh;
  64366. /** @hidden */
  64367. constructor(parent: GLTFFileLoader);
  64368. /** @hidden */
  64369. dispose(): void;
  64370. /** @hidden */
  64371. importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  64372. meshes: AbstractMesh[];
  64373. particleSystems: IParticleSystem[];
  64374. skeletons: Skeleton[];
  64375. animationGroups: AnimationGroup[];
  64376. }>;
  64377. /** @hidden */
  64378. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  64379. private _loadAsync;
  64380. private _loadData;
  64381. private _setupData;
  64382. private _loadExtensions;
  64383. private _checkExtensions;
  64384. private _setState;
  64385. private _createRootNode;
  64386. /**
  64387. * Loads a glTF scene.
  64388. * @param context The context when loading the asset
  64389. * @param scene The glTF scene property
  64390. * @returns A promise that resolves when the load is complete
  64391. */
  64392. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  64393. private _forEachPrimitive;
  64394. private _getMeshes;
  64395. private _getSkeletons;
  64396. private _getAnimationGroups;
  64397. private _startAnimations;
  64398. /**
  64399. * Loads a glTF node.
  64400. * @param context The context when loading the asset
  64401. * @param node The glTF node property
  64402. * @param assign A function called synchronously after parsing the glTF properties
  64403. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  64404. */
  64405. loadNodeAsync(context: string, node: INode, assign?: (babylonTransformNode: TransformNode) => void): Promise<TransformNode>;
  64406. private _loadMeshAsync;
  64407. /**
  64408. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  64409. * @param context The context when loading the asset
  64410. * @param name The mesh name when loading the asset
  64411. * @param node The glTF node when loading the asset
  64412. * @param mesh The glTF mesh when loading the asset
  64413. * @param primitive The glTF mesh primitive property
  64414. * @param assign A function called synchronously after parsing the glTF properties
  64415. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  64416. */
  64417. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  64418. private _loadVertexDataAsync;
  64419. private _createMorphTargets;
  64420. private _loadMorphTargetsAsync;
  64421. private _loadMorphTargetVertexDataAsync;
  64422. private static _LoadTransform;
  64423. private _loadSkinAsync;
  64424. private _loadBones;
  64425. private _loadBone;
  64426. private _loadSkinInverseBindMatricesDataAsync;
  64427. private _updateBoneMatrices;
  64428. private _getNodeMatrix;
  64429. /**
  64430. * Loads a glTF camera.
  64431. * @param context The context when loading the asset
  64432. * @param camera The glTF camera property
  64433. * @param assign A function called synchronously after parsing the glTF properties
  64434. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  64435. */
  64436. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  64437. private _loadAnimationsAsync;
  64438. /**
  64439. * Loads a glTF animation.
  64440. * @param context The context when loading the asset
  64441. * @param animation The glTF animation property
  64442. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  64443. */
  64444. loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
  64445. /**
  64446. * @hidden Loads a glTF animation channel.
  64447. * @param context The context when loading the asset
  64448. * @param animationContext The context of the animation when loading the asset
  64449. * @param animation The glTF animation property
  64450. * @param channel The glTF animation channel property
  64451. * @param babylonAnimationGroup The babylon animation group property
  64452. * @param animationTargetOverride The babylon animation channel target override property. My be null.
  64453. * @returns A void promise when the channel load is complete
  64454. */
  64455. _loadAnimationChannelAsync(context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: AnimationGroup, animationTargetOverride?: Nullable<IAnimatable>): Promise<void>;
  64456. private _loadAnimationSamplerAsync;
  64457. private _loadBufferAsync;
  64458. /**
  64459. * Loads a glTF buffer view.
  64460. * @param context The context when loading the asset
  64461. * @param bufferView The glTF buffer view property
  64462. * @returns A promise that resolves with the loaded data when the load is complete
  64463. */
  64464. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  64465. private _loadIndicesAccessorAsync;
  64466. private _loadFloatAccessorAsync;
  64467. private _loadVertexBufferViewAsync;
  64468. private _loadVertexAccessorAsync;
  64469. private _loadMaterialMetallicRoughnessPropertiesAsync;
  64470. /** @hidden */
  64471. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  64472. private _createDefaultMaterial;
  64473. /**
  64474. * Creates a Babylon material from a glTF material.
  64475. * @param context The context when loading the asset
  64476. * @param material The glTF material property
  64477. * @param babylonDrawMode The draw mode for the Babylon material
  64478. * @returns The Babylon material
  64479. */
  64480. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  64481. /**
  64482. * Loads properties from a glTF material into a Babylon material.
  64483. * @param context The context when loading the asset
  64484. * @param material The glTF material property
  64485. * @param babylonMaterial The Babylon material
  64486. * @returns A promise that resolves when the load is complete
  64487. */
  64488. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  64489. /**
  64490. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  64491. * @param context The context when loading the asset
  64492. * @param material The glTF material property
  64493. * @param babylonMaterial The Babylon material
  64494. * @returns A promise that resolves when the load is complete
  64495. */
  64496. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  64497. /**
  64498. * Loads the alpha properties from a glTF material into a Babylon material.
  64499. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  64500. * @param context The context when loading the asset
  64501. * @param material The glTF material property
  64502. * @param babylonMaterial The Babylon material
  64503. */
  64504. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  64505. /**
  64506. * Loads a glTF texture info.
  64507. * @param context The context when loading the asset
  64508. * @param textureInfo The glTF texture info property
  64509. * @param assign A function called synchronously after parsing the glTF properties
  64510. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  64511. */
  64512. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  64513. private _loadTextureAsync;
  64514. private _loadSampler;
  64515. /**
  64516. * Loads a glTF image.
  64517. * @param context The context when loading the asset
  64518. * @param image The glTF image property
  64519. * @returns A promise that resolves with the loaded data when the load is complete
  64520. */
  64521. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  64522. /**
  64523. * Loads a glTF uri.
  64524. * @param context The context when loading the asset
  64525. * @param property The glTF property associated with the uri
  64526. * @param uri The base64 or relative uri
  64527. * @returns A promise that resolves with the loaded data when the load is complete
  64528. */
  64529. loadUriAsync(context: string, property: IProperty, uri: string): Promise<ArrayBufferView>;
  64530. private _onProgress;
  64531. /**
  64532. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  64533. * @param babylonObject the Babylon object with metadata
  64534. * @param pointer the JSON pointer
  64535. */
  64536. static AddPointerMetadata(babylonObject: {
  64537. metadata: any;
  64538. }, pointer: string): void;
  64539. private static _GetTextureWrapMode;
  64540. private static _GetTextureSamplingMode;
  64541. private static _GetTypedArray;
  64542. private static _GetNumComponents;
  64543. private static _ValidateUri;
  64544. private static _GetDrawMode;
  64545. private _compileMaterialsAsync;
  64546. private _compileShadowGeneratorsAsync;
  64547. private _forEachExtensions;
  64548. private _applyExtensions;
  64549. private _extensionsOnLoading;
  64550. private _extensionsOnReady;
  64551. private _extensionsLoadSceneAsync;
  64552. private _extensionsLoadNodeAsync;
  64553. private _extensionsLoadCameraAsync;
  64554. private _extensionsLoadVertexDataAsync;
  64555. private _extensionsLoadMeshPrimitiveAsync;
  64556. private _extensionsLoadMaterialAsync;
  64557. private _extensionsCreateMaterial;
  64558. private _extensionsLoadMaterialPropertiesAsync;
  64559. private _extensionsLoadTextureInfoAsync;
  64560. private _extensionsLoadAnimationAsync;
  64561. private _extensionsLoadSkinAsync;
  64562. private _extensionsLoadUriAsync;
  64563. /**
  64564. * Helper method called by a loader extension to load an glTF extension.
  64565. * @param context The context when loading the asset
  64566. * @param property The glTF property to load the extension from
  64567. * @param extensionName The name of the extension to load
  64568. * @param actionAsync The action to run
  64569. * @returns The promise returned by actionAsync or null if the extension does not exist
  64570. */
  64571. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  64572. /**
  64573. * Helper method called by a loader extension to load a glTF extra.
  64574. * @param context The context when loading the asset
  64575. * @param property The glTF property to load the extra from
  64576. * @param extensionName The name of the extension to load
  64577. * @param actionAsync The action to run
  64578. * @returns The promise returned by actionAsync or null if the extra does not exist
  64579. */
  64580. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  64581. /**
  64582. * Increments the indentation level and logs a message.
  64583. * @param message The message to log
  64584. */
  64585. logOpen(message: string): void;
  64586. /**
  64587. * Decrements the indentation level.
  64588. */
  64589. logClose(): void;
  64590. /**
  64591. * Logs a message
  64592. * @param message The message to log
  64593. */
  64594. log(message: string): void;
  64595. /**
  64596. * Starts a performance counter.
  64597. * @param counterName The name of the performance counter
  64598. */
  64599. startPerformanceCounter(counterName: string): void;
  64600. /**
  64601. * Ends a performance counter.
  64602. * @param counterName The name of the performance counter
  64603. */
  64604. endPerformanceCounter(counterName: string): void;
  64605. }
  64606. }
  64607. declare module BABYLON.GLTF2.Loader.Extensions {
  64608. /**
  64609. * [Specification](https://github.com/KhronosGroup/glTF/blob/eb3e32332042e04691a5f35103f8c261e50d8f1e/extensions/2.0/Khronos/EXT_lights_image_based/README.md) (Experimental)
  64610. */
  64611. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  64612. /** The name of this extension. */
  64613. readonly name: string;
  64614. /** Defines whether this extension is enabled. */
  64615. enabled: boolean;
  64616. private _loader;
  64617. private _lights?;
  64618. /** @hidden */
  64619. constructor(loader: GLTFLoader);
  64620. /** @hidden */
  64621. dispose(): void;
  64622. /** @hidden */
  64623. onLoading(): void;
  64624. /** @hidden */
  64625. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  64626. private _loadLightAsync;
  64627. }
  64628. }
  64629. declare module BABYLON.GLTF2.Loader.Extensions {
  64630. /**
  64631. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  64632. */
  64633. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  64634. /** The name of this extension. */
  64635. readonly name: string;
  64636. /** The draco compression used to decode vertex data or DracoCompression.Default if not defined */
  64637. dracoCompression?: DracoCompression;
  64638. /** Defines whether this extension is enabled. */
  64639. enabled: boolean;
  64640. private _loader;
  64641. /** @hidden */
  64642. constructor(loader: GLTFLoader);
  64643. /** @hidden */
  64644. dispose(): void;
  64645. /** @hidden */
  64646. _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  64647. }
  64648. }
  64649. declare module BABYLON.GLTF2.Loader.Extensions {
  64650. /**
  64651. * [Specification](https://github.com/KhronosGroup/glTF/blob/1048d162a44dbcb05aefc1874bfd423cf60135a6/extensions/2.0/Khronos/KHR_lights_punctual/README.md) (Experimental)
  64652. */
  64653. export class KHR_lights implements IGLTFLoaderExtension {
  64654. /** The name of this extension. */
  64655. readonly name: string;
  64656. /** Defines whether this extension is enabled. */
  64657. enabled: boolean;
  64658. private _loader;
  64659. private _lights?;
  64660. /** @hidden */
  64661. constructor(loader: GLTFLoader);
  64662. /** @hidden */
  64663. dispose(): void;
  64664. /** @hidden */
  64665. onLoading(): void;
  64666. /** @hidden */
  64667. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  64668. }
  64669. }
  64670. declare module BABYLON.GLTF2.Loader.Extensions {
  64671. /**
  64672. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  64673. */
  64674. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  64675. /** The name of this extension. */
  64676. readonly name: string;
  64677. /** Defines whether this extension is enabled. */
  64678. enabled: boolean;
  64679. private _loader;
  64680. /** @hidden */
  64681. constructor(loader: GLTFLoader);
  64682. /** @hidden */
  64683. dispose(): void;
  64684. /** @hidden */
  64685. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  64686. private _loadSpecularGlossinessPropertiesAsync;
  64687. }
  64688. }
  64689. declare module BABYLON.GLTF2.Loader.Extensions {
  64690. /**
  64691. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  64692. */
  64693. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  64694. /** The name of this extension. */
  64695. readonly name: string;
  64696. /** Defines whether this extension is enabled. */
  64697. enabled: boolean;
  64698. private _loader;
  64699. /** @hidden */
  64700. constructor(loader: GLTFLoader);
  64701. /** @hidden */
  64702. dispose(): void;
  64703. /** @hidden */
  64704. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  64705. private _loadUnlitPropertiesAsync;
  64706. }
  64707. }
  64708. declare module BABYLON.GLTF2.Loader.Extensions {
  64709. /**
  64710. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform/README.md)
  64711. */
  64712. export class KHR_texture_transform implements IGLTFLoaderExtension {
  64713. /** The name of this extension. */
  64714. readonly name: string;
  64715. /** Defines whether this extension is enabled. */
  64716. enabled: boolean;
  64717. private _loader;
  64718. /** @hidden */
  64719. constructor(loader: GLTFLoader);
  64720. /** @hidden */
  64721. dispose(): void;
  64722. /** @hidden */
  64723. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  64724. }
  64725. }
  64726. declare module BABYLON.GLTF2.Loader.Extensions {
  64727. /**
  64728. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  64729. */
  64730. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  64731. /** The name of this extension. */
  64732. readonly name: string;
  64733. /** Defines whether this extension is enabled. */
  64734. enabled: boolean;
  64735. private _loader;
  64736. private _clips;
  64737. private _emitters;
  64738. /** @hidden */
  64739. constructor(loader: GLTFLoader);
  64740. /** @hidden */
  64741. dispose(): void;
  64742. /** @hidden */
  64743. onLoading(): void;
  64744. /** @hidden */
  64745. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  64746. /** @hidden */
  64747. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  64748. /** @hidden */
  64749. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  64750. private _loadClipAsync;
  64751. private _loadEmitterAsync;
  64752. private _getEventAction;
  64753. private _loadAnimationEventAsync;
  64754. }
  64755. }
  64756. declare module BABYLON.GLTF2.Loader.Extensions {
  64757. /**
  64758. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  64759. */
  64760. export class MSFT_lod implements IGLTFLoaderExtension {
  64761. /** The name of this extension. */
  64762. readonly name: string;
  64763. /** Defines whether this extension is enabled. */
  64764. enabled: boolean;
  64765. /**
  64766. * Maximum number of LODs to load, starting from the lowest LOD.
  64767. */
  64768. maxLODsToLoad: number;
  64769. /**
  64770. * Observable raised when all node LODs of one level are loaded.
  64771. * The event data is the index of the loaded LOD starting from zero.
  64772. * Dispose the loader to cancel the loading of the next level of LODs.
  64773. */
  64774. onNodeLODsLoadedObservable: Observable<number>;
  64775. /**
  64776. * Observable raised when all material LODs of one level are loaded.
  64777. * The event data is the index of the loaded LOD starting from zero.
  64778. * Dispose the loader to cancel the loading of the next level of LODs.
  64779. */
  64780. onMaterialLODsLoadedObservable: Observable<number>;
  64781. private _loader;
  64782. private _nodeIndexLOD;
  64783. private _nodeSignalLODs;
  64784. private _nodePromiseLODs;
  64785. private _materialIndexLOD;
  64786. private _materialSignalLODs;
  64787. private _materialPromiseLODs;
  64788. /** @hidden */
  64789. constructor(loader: GLTFLoader);
  64790. /** @hidden */
  64791. dispose(): void;
  64792. /** @hidden */
  64793. onReady(): void;
  64794. /** @hidden */
  64795. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  64796. /** @hidden */
  64797. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  64798. /** @hidden */
  64799. _loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  64800. /**
  64801. * Gets an array of LOD properties from lowest to highest.
  64802. */
  64803. private _getLODs;
  64804. private _disposeUnusedMaterials;
  64805. }
  64806. }
  64807. declare module BABYLON.GLTF2.Loader.Extensions {
  64808. /** @hidden */
  64809. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  64810. readonly name: string;
  64811. enabled: boolean;
  64812. private _loader;
  64813. constructor(loader: GLTFLoader);
  64814. dispose(): void;
  64815. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  64816. }
  64817. }
  64818. declare module BABYLON.GLTF2.Loader.Extensions {
  64819. /** @hidden */
  64820. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  64821. readonly name: string;
  64822. enabled: boolean;
  64823. private _loader;
  64824. constructor(loader: GLTFLoader);
  64825. dispose(): void;
  64826. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  64827. }
  64828. }
  64829. declare module BABYLON {
  64830. /**
  64831. * Class reading and parsing the MTL file bundled with the obj file.
  64832. */
  64833. export class MTLFileLoader {
  64834. /**
  64835. * All material loaded from the mtl will be set here
  64836. */
  64837. materials: StandardMaterial[];
  64838. /**
  64839. * This function will read the mtl file and create each material described inside
  64840. * This function could be improve by adding :
  64841. * -some component missing (Ni, Tf...)
  64842. * -including the specific options available
  64843. *
  64844. * @param scene defines the scene the material will be created in
  64845. * @param data defines the mtl data to parse
  64846. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  64847. */
  64848. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string): void;
  64849. /**
  64850. * Gets the texture for the material.
  64851. *
  64852. * If the material is imported from input file,
  64853. * We sanitize the url to ensure it takes the textre from aside the material.
  64854. *
  64855. * @param rootUrl The root url to load from
  64856. * @param value The value stored in the mtl
  64857. * @return The Texture
  64858. */
  64859. private static _getTexture;
  64860. }
  64861. /**
  64862. * Options for loading OBJ/MTL files
  64863. */
  64864. type MeshLoadOptions = {
  64865. /**
  64866. * Defines if UVs are optimized by default during load.
  64867. */
  64868. OptimizeWithUV: boolean;
  64869. /**
  64870. * Defines custom scaling of UV coordinates of loaded meshes.
  64871. */
  64872. UVScaling: Vector2;
  64873. /**
  64874. * Invert model on y-axis (does a model scaling inversion)
  64875. */
  64876. InvertY: boolean;
  64877. /**
  64878. * Invert Y-Axis of referenced textures on load
  64879. */
  64880. InvertTextureY: boolean;
  64881. /**
  64882. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  64883. */
  64884. ImportVertexColors: boolean;
  64885. /**
  64886. * Compute the normals for the model, even if normals are present in the file.
  64887. */
  64888. ComputeNormals: boolean;
  64889. /**
  64890. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  64891. */
  64892. SkipMaterials: boolean;
  64893. /**
  64894. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  64895. */
  64896. MaterialLoadingFailsSilently: boolean;
  64897. };
  64898. /**
  64899. * OBJ file type loader.
  64900. * This is a babylon scene loader plugin.
  64901. */
  64902. export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  64903. /**
  64904. * Defines if UVs are optimized by default during load.
  64905. */
  64906. static OPTIMIZE_WITH_UV: boolean;
  64907. /**
  64908. * Invert model on y-axis (does a model scaling inversion)
  64909. */
  64910. static INVERT_Y: boolean;
  64911. /**
  64912. * Invert Y-Axis of referenced textures on load
  64913. */
  64914. static INVERT_TEXTURE_Y: boolean;
  64915. /**
  64916. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  64917. */
  64918. static IMPORT_VERTEX_COLORS: boolean;
  64919. /**
  64920. * Compute the normals for the model, even if normals are present in the file.
  64921. */
  64922. static COMPUTE_NORMALS: boolean;
  64923. /**
  64924. * Defines custom scaling of UV coordinates of loaded meshes.
  64925. */
  64926. static UV_SCALING: Vector2;
  64927. /**
  64928. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  64929. */
  64930. static SKIP_MATERIALS: boolean;
  64931. /**
  64932. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  64933. *
  64934. * Defaults to true for backwards compatibility.
  64935. */
  64936. static MATERIAL_LOADING_FAILS_SILENTLY: boolean;
  64937. /**
  64938. * Defines the name of the plugin.
  64939. */
  64940. name: string;
  64941. /**
  64942. * Defines the extension the plugin is able to load.
  64943. */
  64944. extensions: string;
  64945. /** @hidden */
  64946. obj: RegExp;
  64947. /** @hidden */
  64948. group: RegExp;
  64949. /** @hidden */
  64950. mtllib: RegExp;
  64951. /** @hidden */
  64952. usemtl: RegExp;
  64953. /** @hidden */
  64954. smooth: RegExp;
  64955. /** @hidden */
  64956. vertexPattern: RegExp;
  64957. /** @hidden */
  64958. normalPattern: RegExp;
  64959. /** @hidden */
  64960. uvPattern: RegExp;
  64961. /** @hidden */
  64962. facePattern1: RegExp;
  64963. /** @hidden */
  64964. facePattern2: RegExp;
  64965. /** @hidden */
  64966. facePattern3: RegExp;
  64967. /** @hidden */
  64968. facePattern4: RegExp;
  64969. /** @hidden */
  64970. facePattern5: RegExp;
  64971. private _meshLoadOptions;
  64972. /**
  64973. * Creates loader for .OBJ files
  64974. *
  64975. * @param meshLoadOptions options for loading and parsing OBJ/MTL files.
  64976. */
  64977. constructor(meshLoadOptions?: MeshLoadOptions);
  64978. private static readonly currentMeshLoadOptions;
  64979. /**
  64980. * Calls synchronously the MTL file attached to this obj.
  64981. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  64982. * Without this function materials are not displayed in the first frame (but displayed after).
  64983. * In consequence it is impossible to get material information in your HTML file
  64984. *
  64985. * @param url The URL of the MTL file
  64986. * @param rootUrl
  64987. * @param onSuccess Callback function to be called when the MTL file is loaded
  64988. * @private
  64989. */
  64990. private _loadMTL;
  64991. /**
  64992. * Instantiates a OBJ file loader plugin.
  64993. * @returns the created plugin
  64994. */
  64995. createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
  64996. /**
  64997. * If the data string can be loaded directly.
  64998. *
  64999. * @param data string containing the file data
  65000. * @returns if the data can be loaded directly
  65001. */
  65002. canDirectLoad(data: string): boolean;
  65003. /**
  65004. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  65005. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  65006. * @param scene the scene the meshes should be added to
  65007. * @param data the OBJ data to load
  65008. * @param rootUrl root url to load from
  65009. * @param onProgress event that fires when loading progress has occured
  65010. * @param fileName Defines the name of the file to load
  65011. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  65012. */
  65013. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  65014. meshes: AbstractMesh[];
  65015. particleSystems: IParticleSystem[];
  65016. skeletons: Skeleton[];
  65017. animationGroups: AnimationGroup[];
  65018. }>;
  65019. /**
  65020. * Imports all objects from the loaded OBJ data and adds them to the scene
  65021. * @param scene the scene the objects should be added to
  65022. * @param data the OBJ data to load
  65023. * @param rootUrl root url to load from
  65024. * @param onProgress event that fires when loading progress has occured
  65025. * @param fileName Defines the name of the file to load
  65026. * @returns a promise which completes when objects have been loaded to the scene
  65027. */
  65028. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  65029. /**
  65030. * Load into an asset container.
  65031. * @param scene The scene to load into
  65032. * @param data The data to import
  65033. * @param rootUrl The root url for scene and resources
  65034. * @param onProgress The callback when the load progresses
  65035. * @param fileName Defines the name of the file to load
  65036. * @returns The loaded asset container
  65037. */
  65038. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  65039. /**
  65040. * Read the OBJ file and create an Array of meshes.
  65041. * Each mesh contains all information given by the OBJ and the MTL file.
  65042. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  65043. *
  65044. * @param meshesNames
  65045. * @param scene Scene The scene where are displayed the data
  65046. * @param data String The content of the obj file
  65047. * @param rootUrl String The path to the folder
  65048. * @returns Array<AbstractMesh>
  65049. * @private
  65050. */
  65051. private _parseSolid;
  65052. }
  65053. }
  65054. declare module BABYLON {
  65055. /**
  65056. * STL file type loader.
  65057. * This is a babylon scene loader plugin.
  65058. */
  65059. export class STLFileLoader implements ISceneLoaderPlugin {
  65060. /** @hidden */
  65061. solidPattern: RegExp;
  65062. /** @hidden */
  65063. facetsPattern: RegExp;
  65064. /** @hidden */
  65065. normalPattern: RegExp;
  65066. /** @hidden */
  65067. vertexPattern: RegExp;
  65068. /**
  65069. * Defines the name of the plugin.
  65070. */
  65071. name: string;
  65072. /**
  65073. * Defines the extensions the stl loader is able to load.
  65074. * force data to come in as an ArrayBuffer
  65075. * we'll convert to string if it looks like it's an ASCII .stl
  65076. */
  65077. extensions: ISceneLoaderPluginExtensions;
  65078. /**
  65079. * Import meshes into a scene.
  65080. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  65081. * @param scene The scene to import into
  65082. * @param data The data to import
  65083. * @param rootUrl The root url for scene and resources
  65084. * @param meshes The meshes array to import into
  65085. * @param particleSystems The particle systems array to import into
  65086. * @param skeletons The skeletons array to import into
  65087. * @param onError The callback when import fails
  65088. * @returns True if successful or false otherwise
  65089. */
  65090. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  65091. /**
  65092. * Load into a scene.
  65093. * @param scene The scene to load into
  65094. * @param data The data to import
  65095. * @param rootUrl The root url for scene and resources
  65096. * @param onError The callback when import fails
  65097. * @returns true if successful or false otherwise
  65098. */
  65099. load(scene: Scene, data: any, rootUrl: string): boolean;
  65100. /**
  65101. * Load into an asset container.
  65102. * @param scene The scene to load into
  65103. * @param data The data to import
  65104. * @param rootUrl The root url for scene and resources
  65105. * @param onError The callback when import fails
  65106. * @returns The loaded asset container
  65107. */
  65108. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  65109. private _isBinary;
  65110. private _parseBinary;
  65111. private _parseASCII;
  65112. }
  65113. }
  65114. declare module BABYLON {
  65115. /**
  65116. * Class for generating OBJ data from a Babylon scene.
  65117. */
  65118. export class OBJExport {
  65119. /**
  65120. * Exports the geometry of a Mesh array in .OBJ file format (text)
  65121. * @param mesh defines the list of meshes to serialize
  65122. * @param materials defines if materials should be exported
  65123. * @param matlibname defines the name of the associated mtl file
  65124. * @param globalposition defines if the exported positions are globals or local to the exported mesh
  65125. * @returns the OBJ content
  65126. */
  65127. static OBJ(mesh: Mesh[], materials?: boolean, matlibname?: string, globalposition?: boolean): string;
  65128. /**
  65129. * Exports the material(s) of a mesh in .MTL file format (text)
  65130. * @param mesh defines the mesh to extract the material from
  65131. * @returns the mtl content
  65132. */
  65133. static MTL(mesh: Mesh): string;
  65134. }
  65135. }
  65136. declare module BABYLON {
  65137. /** @hidden */
  65138. export var __IGLTFExporterExtension: number;
  65139. /**
  65140. * Interface for extending the exporter
  65141. * @hidden
  65142. */
  65143. export interface IGLTFExporterExtension {
  65144. /**
  65145. * The name of this extension
  65146. */
  65147. readonly name: string;
  65148. /**
  65149. * Defines whether this extension is enabled
  65150. */
  65151. enabled: boolean;
  65152. /**
  65153. * Defines whether this extension is required
  65154. */
  65155. required: boolean;
  65156. }
  65157. }
  65158. declare module BABYLON.GLTF2.Exporter {
  65159. /** @hidden */
  65160. export var __IGLTFExporterExtensionV2: number;
  65161. /**
  65162. * Interface for a glTF exporter extension
  65163. * @hidden
  65164. */
  65165. export interface IGLTFExporterExtensionV2 extends IGLTFExporterExtension, IDisposable {
  65166. /**
  65167. * Define this method to modify the default behavior before exporting a texture
  65168. * @param context The context when loading the asset
  65169. * @param babylonTexture The glTF texture info property
  65170. * @param mimeType The mime-type of the generated image
  65171. * @returns A promise that resolves with the exported glTF texture info when the export is complete, or null if not handled
  65172. */
  65173. preExportTextureAsync?(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Nullable<Promise<Texture>>;
  65174. /**
  65175. * Define this method to modify the default behavior when exporting texture info
  65176. * @param context The context when loading the asset
  65177. * @param meshPrimitive glTF mesh primitive
  65178. * @param babylonSubMesh Babylon submesh
  65179. * @param binaryWriter glTF serializer binary writer instance
  65180. * @returns nullable IMeshPrimitive promise
  65181. */
  65182. postExportMeshPrimitiveAsync?(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Nullable<Promise<IMeshPrimitive>>;
  65183. /**
  65184. * Define this method to modify the default behavior when exporting a node
  65185. * @param context The context when exporting the node
  65186. * @param node glTF node
  65187. * @param babylonNode BabylonJS node
  65188. * @returns nullable INode promise
  65189. */
  65190. postExportNodeAsync?(context: string, node: INode, babylonNode: Node): Nullable<Promise<INode>>;
  65191. /**
  65192. * Called after the exporter state changes to EXPORTING
  65193. */
  65194. onExporting?(): void;
  65195. }
  65196. }
  65197. declare module BABYLON.GLTF2.Exporter {
  65198. /**
  65199. * Utility methods for working with glTF material conversion properties. This class should only be used internally
  65200. * @hidden
  65201. */
  65202. export class _GLTFMaterialExporter {
  65203. /**
  65204. * Represents the dielectric specular values for R, G and B
  65205. */
  65206. private static readonly _DielectricSpecular;
  65207. /**
  65208. * Allows the maximum specular power to be defined for material calculations
  65209. */
  65210. private static readonly _MaxSpecularPower;
  65211. /**
  65212. * Mapping to store textures
  65213. */
  65214. private _textureMap;
  65215. /**
  65216. * Numeric tolerance value
  65217. */
  65218. private static readonly _Epsilon;
  65219. /**
  65220. * Reference to the glTF Exporter
  65221. */
  65222. private _exporter;
  65223. constructor(exporter: _Exporter);
  65224. /**
  65225. * Specifies if two colors are approximately equal in value
  65226. * @param color1 first color to compare to
  65227. * @param color2 second color to compare to
  65228. * @param epsilon threshold value
  65229. */
  65230. private static FuzzyEquals;
  65231. /**
  65232. * Gets the materials from a Babylon scene and converts them to glTF materials
  65233. * @param scene babylonjs scene
  65234. * @param mimeType texture mime type
  65235. * @param images array of images
  65236. * @param textures array of textures
  65237. * @param materials array of materials
  65238. * @param imageData mapping of texture names to base64 textures
  65239. * @param hasTextureCoords specifies if texture coordinates are present on the material
  65240. */
  65241. _convertMaterialsToGLTFAsync(babylonMaterials: Material[], mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  65242. /**
  65243. * Makes a copy of the glTF material without the texture parameters
  65244. * @param originalMaterial original glTF material
  65245. * @returns glTF material without texture parameters
  65246. */
  65247. _stripTexturesFromMaterial(originalMaterial: IMaterial): IMaterial;
  65248. /**
  65249. * Specifies if the material has any texture parameters present
  65250. * @param material glTF Material
  65251. * @returns boolean specifying if texture parameters are present
  65252. */
  65253. _hasTexturesPresent(material: IMaterial): boolean;
  65254. /**
  65255. * Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material
  65256. * @param babylonStandardMaterial
  65257. * @returns glTF Metallic Roughness Material representation
  65258. */
  65259. _convertToGLTFPBRMetallicRoughness(babylonStandardMaterial: StandardMaterial): IMaterialPbrMetallicRoughness;
  65260. /**
  65261. * Computes the metallic factor
  65262. * @param diffuse diffused value
  65263. * @param specular specular value
  65264. * @param oneMinusSpecularStrength one minus the specular strength
  65265. * @returns metallic value
  65266. */
  65267. static _SolveMetallic(diffuse: number, specular: number, oneMinusSpecularStrength: number): number;
  65268. /**
  65269. * Gets the glTF alpha mode from the Babylon Material
  65270. * @param babylonMaterial Babylon Material
  65271. * @returns The Babylon alpha mode value
  65272. */
  65273. _getAlphaMode(babylonMaterial: Material): MaterialAlphaMode;
  65274. /**
  65275. * Converts a Babylon Standard Material to a glTF Material
  65276. * @param babylonStandardMaterial BJS Standard Material
  65277. * @param mimeType mime type to use for the textures
  65278. * @param images array of glTF image interfaces
  65279. * @param textures array of glTF texture interfaces
  65280. * @param materials array of glTF material interfaces
  65281. * @param imageData map of image file name to data
  65282. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  65283. */
  65284. _convertStandardMaterialAsync(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  65285. /**
  65286. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  65287. * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
  65288. * @param mimeType mime type to use for the textures
  65289. * @param images array of glTF image interfaces
  65290. * @param textures array of glTF texture interfaces
  65291. * @param materials array of glTF material interfaces
  65292. * @param imageData map of image file name to data
  65293. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  65294. */
  65295. _convertPBRMetallicRoughnessMaterialAsync(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  65296. /**
  65297. * Converts an image typed array buffer to a base64 image
  65298. * @param buffer typed array buffer
  65299. * @param width width of the image
  65300. * @param height height of the image
  65301. * @param mimeType mimetype of the image
  65302. * @returns base64 image string
  65303. */
  65304. private _createBase64FromCanvasAsync;
  65305. /**
  65306. * Generates a white texture based on the specified width and height
  65307. * @param width width of the texture in pixels
  65308. * @param height height of the texture in pixels
  65309. * @param scene babylonjs scene
  65310. * @returns white texture
  65311. */
  65312. private _createWhiteTexture;
  65313. /**
  65314. * 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
  65315. * @param texture1 first texture to resize
  65316. * @param texture2 second texture to resize
  65317. * @param scene babylonjs scene
  65318. * @returns resized textures or null
  65319. */
  65320. private _resizeTexturesToSameDimensions;
  65321. /**
  65322. * Converts an array of pixels to a Float32Array
  65323. * Throws an error if the pixel format is not supported
  65324. * @param pixels - array buffer containing pixel values
  65325. * @returns Float32 of pixels
  65326. */
  65327. private _convertPixelArrayToFloat32;
  65328. /**
  65329. * Convert Specular Glossiness Textures to Metallic Roughness
  65330. * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
  65331. * @link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows-bjs/js/babylon.pbrUtilities.js
  65332. * @param diffuseTexture texture used to store diffuse information
  65333. * @param specularGlossinessTexture texture used to store specular and glossiness information
  65334. * @param factors specular glossiness material factors
  65335. * @param mimeType the mime type to use for the texture
  65336. * @returns pbr metallic roughness interface or null
  65337. */
  65338. private _convertSpecularGlossinessTexturesToMetallicRoughnessAsync;
  65339. /**
  65340. * Converts specular glossiness material properties to metallic roughness
  65341. * @param specularGlossiness interface with specular glossiness material properties
  65342. * @returns interface with metallic roughness material properties
  65343. */
  65344. private _convertSpecularGlossinessToMetallicRoughness;
  65345. /**
  65346. * Calculates the surface reflectance, independent of lighting conditions
  65347. * @param color Color source to calculate brightness from
  65348. * @returns number representing the perceived brightness, or zero if color is undefined
  65349. */
  65350. private _getPerceivedBrightness;
  65351. /**
  65352. * Returns the maximum color component value
  65353. * @param color
  65354. * @returns maximum color component value, or zero if color is null or undefined
  65355. */
  65356. private _getMaxComponent;
  65357. /**
  65358. * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
  65359. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  65360. * @param mimeType mime type to use for the textures
  65361. * @param images array of glTF image interfaces
  65362. * @param textures array of glTF texture interfaces
  65363. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  65364. * @param imageData map of image file name to data
  65365. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  65366. * @returns glTF PBR Metallic Roughness factors
  65367. */
  65368. private _convertMetalRoughFactorsToMetallicRoughnessAsync;
  65369. private _getGLTFTextureSampler;
  65370. private _getGLTFTextureWrapMode;
  65371. private _getGLTFTextureWrapModesSampler;
  65372. /**
  65373. * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
  65374. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  65375. * @param mimeType mime type to use for the textures
  65376. * @param images array of glTF image interfaces
  65377. * @param textures array of glTF texture interfaces
  65378. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  65379. * @param imageData map of image file name to data
  65380. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  65381. * @returns glTF PBR Metallic Roughness factors
  65382. */
  65383. private _convertSpecGlossFactorsToMetallicRoughnessAsync;
  65384. /**
  65385. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  65386. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  65387. * @param mimeType mime type to use for the textures
  65388. * @param images array of glTF image interfaces
  65389. * @param textures array of glTF texture interfaces
  65390. * @param materials array of glTF material interfaces
  65391. * @param imageData map of image file name to data
  65392. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  65393. */
  65394. _convertPBRMaterialAsync(babylonPBRMaterial: PBRMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  65395. private setMetallicRoughnessPbrMaterial;
  65396. private getPixelsFromTexture;
  65397. /**
  65398. * Extracts a texture from a Babylon texture into file data and glTF data
  65399. * @param babylonTexture Babylon texture to extract
  65400. * @param mimeType Mime Type of the babylonTexture
  65401. * @return glTF texture info, or null if the texture format is not supported
  65402. */
  65403. _exportTextureAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  65404. _exportTextureInfoAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  65405. /**
  65406. * Builds a texture from base64 string
  65407. * @param base64Texture base64 texture string
  65408. * @param baseTextureName Name to use for the texture
  65409. * @param mimeType image mime type for the texture
  65410. * @param images array of images
  65411. * @param textures array of textures
  65412. * @param imageData map of image data
  65413. * @returns glTF texture info, or null if the texture format is not supported
  65414. */
  65415. private _getTextureInfoFromBase64;
  65416. }
  65417. }
  65418. declare module BABYLON {
  65419. /**
  65420. * Class for holding and downloading glTF file data
  65421. */
  65422. export class GLTFData {
  65423. /**
  65424. * Object which contains the file name as the key and its data as the value
  65425. */
  65426. glTFFiles: {
  65427. [fileName: string]: string | Blob;
  65428. };
  65429. /**
  65430. * Initializes the glTF file object
  65431. */
  65432. constructor();
  65433. /**
  65434. * Downloads the glTF data as files based on their names and data
  65435. */
  65436. downloadFiles(): void;
  65437. }
  65438. }
  65439. declare module BABYLON {
  65440. /**
  65441. * Holds a collection of exporter options and parameters
  65442. */
  65443. export interface IExportOptions {
  65444. /**
  65445. * Function which indicates whether a babylon node should be exported or not
  65446. * @param node source Babylon node. It is used to check whether it should be exported to glTF or not
  65447. * @returns boolean, which indicates whether the node should be exported (true) or not (false)
  65448. */
  65449. shouldExportNode?(node: Node): boolean;
  65450. /**
  65451. * The sample rate to bake animation curves
  65452. */
  65453. animationSampleRate?: number;
  65454. /**
  65455. * Begin serialization without waiting for the scene to be ready
  65456. */
  65457. exportWithoutWaitingForScene?: boolean;
  65458. }
  65459. /**
  65460. * Class for generating glTF data from a Babylon scene.
  65461. */
  65462. export class GLTF2Export {
  65463. /**
  65464. * Exports the geometry of the scene to .gltf file format asynchronously
  65465. * @param scene Babylon scene with scene hierarchy information
  65466. * @param filePrefix File prefix to use when generating the glTF file
  65467. * @param options Exporter options
  65468. * @returns Returns an object with a .gltf file and associates texture names
  65469. * as keys and their data and paths as values
  65470. */
  65471. static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  65472. private static _PreExportAsync;
  65473. private static _PostExportAsync;
  65474. /**
  65475. * Exports the geometry of the scene to .glb file format asychronously
  65476. * @param scene Babylon scene with scene hierarchy information
  65477. * @param filePrefix File prefix to use when generating glb file
  65478. * @param options Exporter options
  65479. * @returns Returns an object with a .glb filename as key and data as value
  65480. */
  65481. static GLBAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  65482. }
  65483. }
  65484. declare module BABYLON.GLTF2.Exporter {
  65485. /**
  65486. * @hidden
  65487. */
  65488. export class _GLTFUtilities {
  65489. /**
  65490. * Creates a buffer view based on the supplied arguments
  65491. * @param bufferIndex index value of the specified buffer
  65492. * @param byteOffset byte offset value
  65493. * @param byteLength byte length of the bufferView
  65494. * @param byteStride byte distance between conequential elements
  65495. * @param name name of the buffer view
  65496. * @returns bufferView for glTF
  65497. */
  65498. static _CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number, name?: string): IBufferView;
  65499. /**
  65500. * Creates an accessor based on the supplied arguments
  65501. * @param bufferviewIndex The index of the bufferview referenced by this accessor
  65502. * @param name The name of the accessor
  65503. * @param type The type of the accessor
  65504. * @param componentType The datatype of components in the attribute
  65505. * @param count The number of attributes referenced by this accessor
  65506. * @param byteOffset The offset relative to the start of the bufferView in bytes
  65507. * @param min Minimum value of each component in this attribute
  65508. * @param max Maximum value of each component in this attribute
  65509. * @returns accessor for glTF
  65510. */
  65511. static _CreateAccessor(bufferviewIndex: number, name: string, type: AccessorType, componentType: AccessorComponentType, count: number, byteOffset: Nullable<number>, min: Nullable<number[]>, max: Nullable<number[]>): IAccessor;
  65512. /**
  65513. * Calculates the minimum and maximum values of an array of position floats
  65514. * @param positions Positions array of a mesh
  65515. * @param vertexStart Starting vertex offset to calculate min and max values
  65516. * @param vertexCount Number of vertices to check for min and max values
  65517. * @returns min number array and max number array
  65518. */
  65519. static _CalculateMinMaxPositions(positions: FloatArray, vertexStart: number, vertexCount: number, convertToRightHandedSystem: boolean): {
  65520. min: number[];
  65521. max: number[];
  65522. };
  65523. /**
  65524. * Converts a new right-handed Vector3
  65525. * @param vector vector3 array
  65526. * @returns right-handed Vector3
  65527. */
  65528. static _GetRightHandedPositionVector3(vector: Vector3): Vector3;
  65529. /**
  65530. * Converts a Vector3 to right-handed
  65531. * @param vector Vector3 to convert to right-handed
  65532. */
  65533. static _GetRightHandedPositionVector3FromRef(vector: Vector3): void;
  65534. /**
  65535. * Converts a three element number array to right-handed
  65536. * @param vector number array to convert to right-handed
  65537. */
  65538. static _GetRightHandedPositionArray3FromRef(vector: number[]): void;
  65539. /**
  65540. * Converts a new right-handed Vector3
  65541. * @param vector vector3 array
  65542. * @returns right-handed Vector3
  65543. */
  65544. static _GetRightHandedNormalVector3(vector: Vector3): Vector3;
  65545. /**
  65546. * Converts a Vector3 to right-handed
  65547. * @param vector Vector3 to convert to right-handed
  65548. */
  65549. static _GetRightHandedNormalVector3FromRef(vector: Vector3): void;
  65550. /**
  65551. * Converts a three element number array to right-handed
  65552. * @param vector number array to convert to right-handed
  65553. */
  65554. static _GetRightHandedNormalArray3FromRef(vector: number[]): void;
  65555. /**
  65556. * Converts a Vector4 to right-handed
  65557. * @param vector Vector4 to convert to right-handed
  65558. */
  65559. static _GetRightHandedVector4FromRef(vector: Vector4): void;
  65560. /**
  65561. * Converts a Vector4 to right-handed
  65562. * @param vector Vector4 to convert to right-handed
  65563. */
  65564. static _GetRightHandedArray4FromRef(vector: number[]): void;
  65565. /**
  65566. * Converts a Quaternion to right-handed
  65567. * @param quaternion Source quaternion to convert to right-handed
  65568. */
  65569. static _GetRightHandedQuaternionFromRef(quaternion: Quaternion): void;
  65570. /**
  65571. * Converts a Quaternion to right-handed
  65572. * @param quaternion Source quaternion to convert to right-handed
  65573. */
  65574. static _GetRightHandedQuaternionArrayFromRef(quaternion: number[]): void;
  65575. static _NormalizeTangentFromRef(tangent: Vector4): void;
  65576. }
  65577. }
  65578. declare module BABYLON.GLTF2.Exporter {
  65579. /**
  65580. * Converts Babylon Scene into glTF 2.0.
  65581. * @hidden
  65582. */
  65583. export class _Exporter {
  65584. /**
  65585. * Stores the glTF to export
  65586. */
  65587. _glTF: IGLTF;
  65588. /**
  65589. * Stores all generated buffer views, which represents views into the main glTF buffer data
  65590. */
  65591. _bufferViews: IBufferView[];
  65592. /**
  65593. * Stores all the generated accessors, which is used for accessing the data within the buffer views in glTF
  65594. */
  65595. _accessors: IAccessor[];
  65596. /**
  65597. * Stores all the generated nodes, which contains transform and/or mesh information per node
  65598. */
  65599. private _nodes;
  65600. /**
  65601. * Stores all the generated glTF scenes, which stores multiple node hierarchies
  65602. */
  65603. private _scenes;
  65604. /**
  65605. * Stores all the generated mesh information, each containing a set of primitives to render in glTF
  65606. */
  65607. private _meshes;
  65608. /**
  65609. * Stores all the generated material information, which represents the appearance of each primitive
  65610. */
  65611. _materials: IMaterial[];
  65612. _materialMap: {
  65613. [materialID: number]: number;
  65614. };
  65615. /**
  65616. * Stores all the generated texture information, which is referenced by glTF materials
  65617. */
  65618. _textures: ITexture[];
  65619. /**
  65620. * Stores all the generated image information, which is referenced by glTF textures
  65621. */
  65622. _images: IImage[];
  65623. /**
  65624. * Stores all the texture samplers
  65625. */
  65626. _samplers: ISampler[];
  65627. /**
  65628. * Stores all the generated animation samplers, which is referenced by glTF animations
  65629. */
  65630. /**
  65631. * Stores the animations for glTF models
  65632. */
  65633. private _animations;
  65634. /**
  65635. * Stores the total amount of bytes stored in the glTF buffer
  65636. */
  65637. private _totalByteLength;
  65638. /**
  65639. * Stores a reference to the Babylon scene containing the source geometry and material information
  65640. */
  65641. _babylonScene: Scene;
  65642. /**
  65643. * Stores a map of the image data, where the key is the file name and the value
  65644. * is the image data
  65645. */
  65646. _imageData: {
  65647. [fileName: string]: {
  65648. data: Uint8Array;
  65649. mimeType: ImageMimeType;
  65650. };
  65651. };
  65652. /**
  65653. * Stores a map of the unique id of a node to its index in the node array
  65654. */
  65655. private _nodeMap;
  65656. /**
  65657. * Specifies if the Babylon scene should be converted to right-handed on export
  65658. */
  65659. _convertToRightHandedSystem: boolean;
  65660. /**
  65661. * Baked animation sample rate
  65662. */
  65663. private _animationSampleRate;
  65664. /**
  65665. * Callback which specifies if a node should be exported or not
  65666. */
  65667. private _shouldExportNode;
  65668. private _localEngine;
  65669. _glTFMaterialExporter: _GLTFMaterialExporter;
  65670. private _extensions;
  65671. private static _ExtensionNames;
  65672. private static _ExtensionFactories;
  65673. private _applyExtensions;
  65674. _extensionsPreExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Nullable<Promise<BaseTexture>>;
  65675. _extensionsPostExportMeshPrimitiveAsync(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Nullable<Promise<IMeshPrimitive>>;
  65676. _extensionsPostExportNodeAsync(context: string, node: INode, babylonNode: Node): Nullable<Promise<INode>>;
  65677. private _forEachExtensions;
  65678. private _extensionsOnExporting;
  65679. /**
  65680. * Load glTF serializer extensions
  65681. */
  65682. private _loadExtensions;
  65683. /**
  65684. * Creates a glTF Exporter instance, which can accept optional exporter options
  65685. * @param babylonScene Babylon scene object
  65686. * @param options Options to modify the behavior of the exporter
  65687. */
  65688. constructor(babylonScene: Scene, options?: IExportOptions);
  65689. /**
  65690. * Registers a glTF exporter extension
  65691. * @param name Name of the extension to export
  65692. * @param factory The factory function that creates the exporter extension
  65693. */
  65694. static RegisterExtension(name: string, factory: (exporter: _Exporter) => IGLTFExporterExtensionV2): void;
  65695. /**
  65696. * Un-registers an exporter extension
  65697. * @param name The name fo the exporter extension
  65698. * @returns A boolean indicating whether the extension has been un-registered
  65699. */
  65700. static UnregisterExtension(name: string): boolean;
  65701. /**
  65702. * Lazy load a local engine with premultiplied alpha set to false
  65703. */
  65704. _getLocalEngine(): Engine;
  65705. private reorderIndicesBasedOnPrimitiveMode;
  65706. /**
  65707. * Reorders the vertex attribute data based on the primitive mode. This is necessary when indices are not available and the winding order is
  65708. * clock-wise during export to glTF
  65709. * @param submesh BabylonJS submesh
  65710. * @param primitiveMode Primitive mode of the mesh
  65711. * @param sideOrientation the winding order of the submesh
  65712. * @param vertexBufferKind The type of vertex attribute
  65713. * @param meshAttributeArray The vertex attribute data
  65714. * @param byteOffset The offset to the binary data
  65715. * @param binaryWriter The binary data for the glTF file
  65716. */
  65717. private reorderVertexAttributeDataBasedOnPrimitiveMode;
  65718. /**
  65719. * Reorders the vertex attributes in the correct triangle mode order . This is necessary when indices are not available and the winding order is
  65720. * clock-wise during export to glTF
  65721. * @param submesh BabylonJS submesh
  65722. * @param primitiveMode Primitive mode of the mesh
  65723. * @param sideOrientation the winding order of the submesh
  65724. * @param vertexBufferKind The type of vertex attribute
  65725. * @param meshAttributeArray The vertex attribute data
  65726. * @param byteOffset The offset to the binary data
  65727. * @param binaryWriter The binary data for the glTF file
  65728. */
  65729. private reorderTriangleFillMode;
  65730. /**
  65731. * Reorders the vertex attributes in the correct triangle strip order. This is necessary when indices are not available and the winding order is
  65732. * clock-wise during export to glTF
  65733. * @param submesh BabylonJS submesh
  65734. * @param primitiveMode Primitive mode of the mesh
  65735. * @param sideOrientation the winding order of the submesh
  65736. * @param vertexBufferKind The type of vertex attribute
  65737. * @param meshAttributeArray The vertex attribute data
  65738. * @param byteOffset The offset to the binary data
  65739. * @param binaryWriter The binary data for the glTF file
  65740. */
  65741. private reorderTriangleStripDrawMode;
  65742. /**
  65743. * Reorders the vertex attributes in the correct triangle fan order. This is necessary when indices are not available and the winding order is
  65744. * clock-wise during export to glTF
  65745. * @param submesh BabylonJS submesh
  65746. * @param primitiveMode Primitive mode of the mesh
  65747. * @param sideOrientation the winding order of the submesh
  65748. * @param vertexBufferKind The type of vertex attribute
  65749. * @param meshAttributeArray The vertex attribute data
  65750. * @param byteOffset The offset to the binary data
  65751. * @param binaryWriter The binary data for the glTF file
  65752. */
  65753. private reorderTriangleFanMode;
  65754. /**
  65755. * Writes the vertex attribute data to binary
  65756. * @param vertices The vertices to write to the binary writer
  65757. * @param byteOffset The offset into the binary writer to overwrite binary data
  65758. * @param vertexAttributeKind The vertex attribute type
  65759. * @param meshAttributeArray The vertex attribute data
  65760. * @param binaryWriter The writer containing the binary data
  65761. */
  65762. private writeVertexAttributeData;
  65763. /**
  65764. * Writes mesh attribute data to a data buffer
  65765. * Returns the bytelength of the data
  65766. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  65767. * @param meshAttributeArray Array containing the attribute data
  65768. * @param binaryWriter The buffer to write the binary data to
  65769. * @param indices Used to specify the order of the vertex data
  65770. */
  65771. writeAttributeData(vertexBufferKind: string, meshAttributeArray: FloatArray, byteStride: number, binaryWriter: _BinaryWriter): void;
  65772. /**
  65773. * Generates glTF json data
  65774. * @param shouldUseGlb Indicates whether the json should be written for a glb file
  65775. * @param glTFPrefix Text to use when prefixing a glTF file
  65776. * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false)
  65777. * @returns json data as string
  65778. */
  65779. private generateJSON;
  65780. /**
  65781. * Generates data for .gltf and .bin files based on the glTF prefix string
  65782. * @param glTFPrefix Text to use when prefixing a glTF file
  65783. * @returns GLTFData with glTF file data
  65784. */
  65785. _generateGLTFAsync(glTFPrefix: string): Promise<GLTFData>;
  65786. /**
  65787. * Creates a binary buffer for glTF
  65788. * @returns array buffer for binary data
  65789. */
  65790. private _generateBinaryAsync;
  65791. /**
  65792. * Pads the number to a multiple of 4
  65793. * @param num number to pad
  65794. * @returns padded number
  65795. */
  65796. private _getPadding;
  65797. /**
  65798. * Generates a glb file from the json and binary data
  65799. * Returns an object with the glb file name as the key and data as the value
  65800. * @param glTFPrefix
  65801. * @returns object with glb filename as key and data as value
  65802. */
  65803. _generateGLBAsync(glTFPrefix: string): Promise<GLTFData>;
  65804. /**
  65805. * Sets the TRS for each node
  65806. * @param node glTF Node for storing the transformation data
  65807. * @param babylonTransformNode Babylon mesh used as the source for the transformation data
  65808. */
  65809. private setNodeTransformation;
  65810. private getVertexBufferFromMesh;
  65811. /**
  65812. * Creates a bufferview based on the vertices type for the Babylon mesh
  65813. * @param kind Indicates the type of vertices data
  65814. * @param babylonTransformNode The Babylon mesh to get the vertices data from
  65815. * @param binaryWriter The buffer to write the bufferview data to
  65816. */
  65817. private createBufferViewKind;
  65818. /**
  65819. * The primitive mode of the Babylon mesh
  65820. * @param babylonMesh The BabylonJS mesh
  65821. */
  65822. private getMeshPrimitiveMode;
  65823. /**
  65824. * Sets the primitive mode of the glTF mesh primitive
  65825. * @param meshPrimitive glTF mesh primitive
  65826. * @param primitiveMode The primitive mode
  65827. */
  65828. private setPrimitiveMode;
  65829. /**
  65830. * Sets the vertex attribute accessor based of the glTF mesh primitive
  65831. * @param meshPrimitive glTF mesh primitive
  65832. * @param attributeKind vertex attribute
  65833. * @returns boolean specifying if uv coordinates are present
  65834. */
  65835. private setAttributeKind;
  65836. /**
  65837. * Sets data for the primitive attributes of each submesh
  65838. * @param mesh glTF Mesh object to store the primitive attribute information
  65839. * @param babylonTransformNode Babylon mesh to get the primitive attribute data from
  65840. * @param binaryWriter Buffer to write the attribute data to
  65841. */
  65842. private setPrimitiveAttributesAsync;
  65843. /**
  65844. * Creates a glTF scene based on the array of meshes
  65845. * Returns the the total byte offset
  65846. * @param babylonScene Babylon scene to get the mesh data from
  65847. * @param binaryWriter Buffer to write binary data to
  65848. */
  65849. private createSceneAsync;
  65850. /**
  65851. * Creates a mapping of Node unique id to node index and handles animations
  65852. * @param babylonScene Babylon Scene
  65853. * @param nodes Babylon transform nodes
  65854. * @param shouldExportNode Callback specifying if a transform node should be exported
  65855. * @param binaryWriter Buffer to write binary data to
  65856. * @returns Node mapping of unique id to index
  65857. */
  65858. private createNodeMapAndAnimationsAsync;
  65859. /**
  65860. * Creates a glTF node from a Babylon mesh
  65861. * @param babylonMesh Source Babylon mesh
  65862. * @param binaryWriter Buffer for storing geometry data
  65863. * @returns glTF node
  65864. */
  65865. private createNodeAsync;
  65866. }
  65867. /**
  65868. * @hidden
  65869. *
  65870. * Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically
  65871. */
  65872. export class _BinaryWriter {
  65873. /**
  65874. * Array buffer which stores all binary data
  65875. */
  65876. private _arrayBuffer;
  65877. /**
  65878. * View of the array buffer
  65879. */
  65880. private _dataView;
  65881. /**
  65882. * byte offset of data in array buffer
  65883. */
  65884. private _byteOffset;
  65885. /**
  65886. * Initialize binary writer with an initial byte length
  65887. * @param byteLength Initial byte length of the array buffer
  65888. */
  65889. constructor(byteLength: number);
  65890. /**
  65891. * Resize the array buffer to the specified byte length
  65892. * @param byteLength
  65893. */
  65894. private resizeBuffer;
  65895. /**
  65896. * Get an array buffer with the length of the byte offset
  65897. * @returns ArrayBuffer resized to the byte offset
  65898. */
  65899. getArrayBuffer(): ArrayBuffer;
  65900. /**
  65901. * Get the byte offset of the array buffer
  65902. * @returns byte offset
  65903. */
  65904. getByteOffset(): number;
  65905. /**
  65906. * Stores an UInt8 in the array buffer
  65907. * @param entry
  65908. * @param byteOffset If defined, specifies where to set the value as an offset.
  65909. */
  65910. setUInt8(entry: number, byteOffset?: number): void;
  65911. /**
  65912. * Gets an UInt32 in the array buffer
  65913. * @param entry
  65914. * @param byteOffset If defined, specifies where to set the value as an offset.
  65915. */
  65916. getUInt32(byteOffset: number): number;
  65917. getVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  65918. setVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  65919. getVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  65920. setVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  65921. /**
  65922. * Stores a Float32 in the array buffer
  65923. * @param entry
  65924. */
  65925. setFloat32(entry: number, byteOffset?: number): void;
  65926. /**
  65927. * Stores an UInt32 in the array buffer
  65928. * @param entry
  65929. * @param byteOffset If defined, specifies where to set the value as an offset.
  65930. */
  65931. setUInt32(entry: number, byteOffset?: number): void;
  65932. }
  65933. }
  65934. declare module BABYLON.GLTF2.Exporter {
  65935. /**
  65936. * @hidden
  65937. * Interface to store animation data.
  65938. */
  65939. export interface _IAnimationData {
  65940. /**
  65941. * Keyframe data.
  65942. */
  65943. inputs: number[];
  65944. /**
  65945. * Value data.
  65946. */
  65947. outputs: number[][];
  65948. /**
  65949. * Animation interpolation data.
  65950. */
  65951. samplerInterpolation: AnimationSamplerInterpolation;
  65952. /**
  65953. * Minimum keyframe value.
  65954. */
  65955. inputsMin: number;
  65956. /**
  65957. * Maximum keyframe value.
  65958. */
  65959. inputsMax: number;
  65960. }
  65961. /**
  65962. * @hidden
  65963. */
  65964. export interface _IAnimationInfo {
  65965. /**
  65966. * The target channel for the animation
  65967. */
  65968. animationChannelTargetPath: AnimationChannelTargetPath;
  65969. /**
  65970. * The glTF accessor type for the data.
  65971. */
  65972. dataAccessorType: AccessorType.VEC3 | AccessorType.VEC4;
  65973. /**
  65974. * Specifies if quaternions should be used.
  65975. */
  65976. useQuaternion: boolean;
  65977. }
  65978. /**
  65979. * @hidden
  65980. * Utility class for generating glTF animation data from BabylonJS.
  65981. */
  65982. export class _GLTFAnimation {
  65983. /**
  65984. * @ignore
  65985. *
  65986. * Creates glTF channel animation from BabylonJS animation.
  65987. * @param babylonTransformNode - BabylonJS mesh.
  65988. * @param animation - animation.
  65989. * @param animationChannelTargetPath - The target animation channel.
  65990. * @param convertToRightHandedSystem - Specifies if the values should be converted to right-handed.
  65991. * @param useQuaternion - Specifies if quaternions are used.
  65992. * @returns nullable IAnimationData
  65993. */
  65994. static _CreateNodeAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData>;
  65995. private static _DeduceAnimationInfo;
  65996. /**
  65997. * @ignore
  65998. * Create node animations from the transform node animations
  65999. * @param babylonNode
  66000. * @param runtimeGLTFAnimation
  66001. * @param idleGLTFAnimations
  66002. * @param nodeMap
  66003. * @param nodes
  66004. * @param binaryWriter
  66005. * @param bufferViews
  66006. * @param accessors
  66007. * @param convertToRightHandedSystem
  66008. */
  66009. static _CreateNodeAnimationFromNodeAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  66010. [key: number]: number;
  66011. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  66012. /**
  66013. * @ignore
  66014. * Create node animations from the animation groups
  66015. * @param babylonScene
  66016. * @param glTFAnimations
  66017. * @param nodeMap
  66018. * @param nodes
  66019. * @param binaryWriter
  66020. * @param bufferViews
  66021. * @param accessors
  66022. * @param convertToRightHandedSystem
  66023. */
  66024. static _CreateNodeAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: {
  66025. [key: number]: number;
  66026. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  66027. private static AddAnimation;
  66028. /**
  66029. * Create a baked animation
  66030. * @param babylonTransformNode BabylonJS mesh
  66031. * @param animation BabylonJS animation corresponding to the BabylonJS mesh
  66032. * @param animationChannelTargetPath animation target channel
  66033. * @param minFrame minimum animation frame
  66034. * @param maxFrame maximum animation frame
  66035. * @param fps frames per second of the animation
  66036. * @param inputs input key frames of the animation
  66037. * @param outputs output key frame data of the animation
  66038. * @param convertToRightHandedSystem converts the values to right-handed
  66039. * @param useQuaternion specifies if quaternions should be used
  66040. */
  66041. private static _CreateBakedAnimation;
  66042. private static _ConvertFactorToVector3OrQuaternion;
  66043. private static _SetInterpolatedValue;
  66044. /**
  66045. * Creates linear animation from the animation key frames
  66046. * @param babylonTransformNode BabylonJS mesh
  66047. * @param animation BabylonJS animation
  66048. * @param animationChannelTargetPath The target animation channel
  66049. * @param frameDelta The difference between the last and first frame of the animation
  66050. * @param inputs Array to store the key frame times
  66051. * @param outputs Array to store the key frame data
  66052. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  66053. * @param useQuaternion Specifies if quaternions are used in the animation
  66054. */
  66055. private static _CreateLinearOrStepAnimation;
  66056. /**
  66057. * Creates cubic spline animation from the animation key frames
  66058. * @param babylonTransformNode BabylonJS mesh
  66059. * @param animation BabylonJS animation
  66060. * @param animationChannelTargetPath The target animation channel
  66061. * @param frameDelta The difference between the last and first frame of the animation
  66062. * @param inputs Array to store the key frame times
  66063. * @param outputs Array to store the key frame data
  66064. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  66065. * @param useQuaternion Specifies if quaternions are used in the animation
  66066. */
  66067. private static _CreateCubicSplineAnimation;
  66068. private static _GetBasePositionRotationOrScale;
  66069. /**
  66070. * Adds a key frame value
  66071. * @param keyFrame
  66072. * @param animation
  66073. * @param outputs
  66074. * @param animationChannelTargetPath
  66075. * @param basePositionRotationOrScale
  66076. * @param convertToRightHandedSystem
  66077. * @param useQuaternion
  66078. */
  66079. private static _AddKeyframeValue;
  66080. /**
  66081. * Determine the interpolation based on the key frames
  66082. * @param keyFrames
  66083. * @param animationChannelTargetPath
  66084. * @param useQuaternion
  66085. */
  66086. private static _DeduceInterpolation;
  66087. /**
  66088. * Adds an input tangent or output tangent to the output data
  66089. * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion
  66090. * @param tangentType Specifies which type of tangent to handle (inTangent or outTangent)
  66091. * @param outputs The animation data by keyframe
  66092. * @param animationChannelTargetPath The target animation channel
  66093. * @param interpolation The interpolation type
  66094. * @param keyFrame The key frame with the animation data
  66095. * @param frameDelta Time difference between two frames used to scale the tangent by the frame delta
  66096. * @param useQuaternion Specifies if quaternions are used
  66097. * @param convertToRightHandedSystem Specifies if the values should be converted to right-handed
  66098. */
  66099. private static AddSplineTangent;
  66100. /**
  66101. * Get the minimum and maximum key frames' frame values
  66102. * @param keyFrames animation key frames
  66103. * @returns the minimum and maximum key frame value
  66104. */
  66105. private static calculateMinMaxKeyFrames;
  66106. }
  66107. }
  66108. declare module BABYLON.GLTF2.Exporter {
  66109. /** @hidden */
  66110. export var textureTransformPixelShader: {
  66111. name: string;
  66112. shader: string;
  66113. };
  66114. }
  66115. declare module BABYLON.GLTF2.Exporter.Extensions {
  66116. /**
  66117. * @hidden
  66118. */
  66119. export class KHR_texture_transform implements IGLTFExporterExtensionV2 {
  66120. /** Name of this extension */
  66121. readonly name: string;
  66122. /** Defines whether this extension is enabled */
  66123. enabled: boolean;
  66124. /** Defines whether this extension is required */
  66125. required: boolean;
  66126. /** Reference to the glTF exporter */
  66127. private _exporter;
  66128. constructor(exporter: _Exporter);
  66129. dispose(): void;
  66130. preExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Nullable<Promise<Texture>>;
  66131. /**
  66132. * Transform the babylon texture by the offset, rotation and scale parameters using a procedural texture
  66133. * @param babylonTexture
  66134. * @param offset
  66135. * @param rotation
  66136. * @param scale
  66137. * @param scene
  66138. */
  66139. private _textureTransformTextureAsync;
  66140. }
  66141. }
  66142. declare module BABYLON.GLTF2.Exporter.Extensions {
  66143. /**
  66144. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  66145. */
  66146. export class KHR_lights_punctual implements IGLTFExporterExtensionV2 {
  66147. /** The name of this extension. */
  66148. readonly name: string;
  66149. /** Defines whether this extension is enabled. */
  66150. enabled: boolean;
  66151. /** Defines whether this extension is required */
  66152. required: boolean;
  66153. /** Reference to the glTF exporter */
  66154. private _exporter;
  66155. private _lights;
  66156. /** @hidden */
  66157. constructor(exporter: _Exporter);
  66158. /** @hidden */
  66159. dispose(): void;
  66160. /** @hidden */
  66161. onExporting(): void;
  66162. /**
  66163. * Define this method to modify the default behavior when exporting a node
  66164. * @param context The context when exporting the node
  66165. * @param node glTF node
  66166. * @param babylonNode BabylonJS node
  66167. * @returns nullable INode promise
  66168. */
  66169. postExportNodeAsync(context: string, node: INode, babylonNode: Node): Nullable<Promise<INode>>;
  66170. }
  66171. }
  66172. declare module BABYLON {
  66173. /**
  66174. * Class for generating STL data from a Babylon scene.
  66175. */
  66176. export class STLExport {
  66177. /**
  66178. * Exports the geometry of a Mesh array in .STL file format (ASCII)
  66179. * @param meshes list defines the mesh to serialize
  66180. * @param download triggers the automatic download of the file.
  66181. * @param fileName changes the downloads fileName.
  66182. * @param binary changes the STL to a binary type.
  66183. * @param isLittleEndian toggle for binary type exporter.
  66184. * @returns the STL as UTF8 string
  66185. */
  66186. static CreateSTL(meshes: Mesh[], download?: boolean, fileName?: string, binary?: boolean, isLittleEndian?: boolean): any;
  66187. }
  66188. }
  66189. /**
  66190. * @ignoreChildren
  66191. * @ignore
  66192. */
  66193. declare module "babylonjs-gltf2interface" {
  66194. export = BABYLON.GLTF2;
  66195. }
  66196. /**
  66197. * Module for glTF 2.0 Interface
  66198. * @ignoreChildren
  66199. * @ignore
  66200. */
  66201. declare module BABYLON.GLTF2 {
  66202. /**
  66203. * The datatype of the components in the attribute
  66204. */
  66205. const enum AccessorComponentType {
  66206. /**
  66207. * Byte
  66208. */
  66209. BYTE = 5120,
  66210. /**
  66211. * Unsigned Byte
  66212. */
  66213. UNSIGNED_BYTE = 5121,
  66214. /**
  66215. * Short
  66216. */
  66217. SHORT = 5122,
  66218. /**
  66219. * Unsigned Short
  66220. */
  66221. UNSIGNED_SHORT = 5123,
  66222. /**
  66223. * Unsigned Int
  66224. */
  66225. UNSIGNED_INT = 5125,
  66226. /**
  66227. * Float
  66228. */
  66229. FLOAT = 5126,
  66230. }
  66231. /**
  66232. * Specifies if the attirbute is a scalar, vector, or matrix
  66233. */
  66234. const enum AccessorType {
  66235. /**
  66236. * Scalar
  66237. */
  66238. SCALAR = "SCALAR",
  66239. /**
  66240. * Vector2
  66241. */
  66242. VEC2 = "VEC2",
  66243. /**
  66244. * Vector3
  66245. */
  66246. VEC3 = "VEC3",
  66247. /**
  66248. * Vector4
  66249. */
  66250. VEC4 = "VEC4",
  66251. /**
  66252. * Matrix2x2
  66253. */
  66254. MAT2 = "MAT2",
  66255. /**
  66256. * Matrix3x3
  66257. */
  66258. MAT3 = "MAT3",
  66259. /**
  66260. * Matrix4x4
  66261. */
  66262. MAT4 = "MAT4",
  66263. }
  66264. /**
  66265. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  66266. */
  66267. const enum AnimationChannelTargetPath {
  66268. /**
  66269. * Translation
  66270. */
  66271. TRANSLATION = "translation",
  66272. /**
  66273. * Rotation
  66274. */
  66275. ROTATION = "rotation",
  66276. /**
  66277. * Scale
  66278. */
  66279. SCALE = "scale",
  66280. /**
  66281. * Weights
  66282. */
  66283. WEIGHTS = "weights",
  66284. }
  66285. /**
  66286. * Interpolation algorithm
  66287. */
  66288. const enum AnimationSamplerInterpolation {
  66289. /**
  66290. * The animated values are linearly interpolated between keyframes
  66291. */
  66292. LINEAR = "LINEAR",
  66293. /**
  66294. * The animated values remain constant to the output of the first keyframe, until the next keyframe
  66295. */
  66296. STEP = "STEP",
  66297. /**
  66298. * The animation's interpolation is computed using a cubic spline with specified tangents
  66299. */
  66300. CUBICSPLINE = "CUBICSPLINE",
  66301. }
  66302. /**
  66303. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  66304. */
  66305. const enum CameraType {
  66306. /**
  66307. * A perspective camera containing properties to create a perspective projection matrix
  66308. */
  66309. PERSPECTIVE = "perspective",
  66310. /**
  66311. * An orthographic camera containing properties to create an orthographic projection matrix
  66312. */
  66313. ORTHOGRAPHIC = "orthographic",
  66314. }
  66315. /**
  66316. * The mime-type of the image
  66317. */
  66318. const enum ImageMimeType {
  66319. /**
  66320. * JPEG Mime-type
  66321. */
  66322. JPEG = "image/jpeg",
  66323. /**
  66324. * PNG Mime-type
  66325. */
  66326. PNG = "image/png",
  66327. }
  66328. /**
  66329. * The alpha rendering mode of the material
  66330. */
  66331. const enum MaterialAlphaMode {
  66332. /**
  66333. * The alpha value is ignored and the rendered output is fully opaque
  66334. */
  66335. OPAQUE = "OPAQUE",
  66336. /**
  66337. * The rendered output is either fully opaque or fully transparent depending on the alpha value and the specified alpha cutoff value
  66338. */
  66339. MASK = "MASK",
  66340. /**
  66341. * 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)
  66342. */
  66343. BLEND = "BLEND",
  66344. }
  66345. /**
  66346. * The type of the primitives to render
  66347. */
  66348. const enum MeshPrimitiveMode {
  66349. /**
  66350. * Points
  66351. */
  66352. POINTS = 0,
  66353. /**
  66354. * Lines
  66355. */
  66356. LINES = 1,
  66357. /**
  66358. * Line Loop
  66359. */
  66360. LINE_LOOP = 2,
  66361. /**
  66362. * Line Strip
  66363. */
  66364. LINE_STRIP = 3,
  66365. /**
  66366. * Triangles
  66367. */
  66368. TRIANGLES = 4,
  66369. /**
  66370. * Triangle Strip
  66371. */
  66372. TRIANGLE_STRIP = 5,
  66373. /**
  66374. * Triangle Fan
  66375. */
  66376. TRIANGLE_FAN = 6,
  66377. }
  66378. /**
  66379. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  66380. */
  66381. const enum TextureMagFilter {
  66382. /**
  66383. * Nearest
  66384. */
  66385. NEAREST = 9728,
  66386. /**
  66387. * Linear
  66388. */
  66389. LINEAR = 9729,
  66390. }
  66391. /**
  66392. * Minification filter. All valid values correspond to WebGL enums
  66393. */
  66394. const enum TextureMinFilter {
  66395. /**
  66396. * Nearest
  66397. */
  66398. NEAREST = 9728,
  66399. /**
  66400. * Linear
  66401. */
  66402. LINEAR = 9729,
  66403. /**
  66404. * Nearest Mip-Map Nearest
  66405. */
  66406. NEAREST_MIPMAP_NEAREST = 9984,
  66407. /**
  66408. * Linear Mipmap Nearest
  66409. */
  66410. LINEAR_MIPMAP_NEAREST = 9985,
  66411. /**
  66412. * Nearest Mipmap Linear
  66413. */
  66414. NEAREST_MIPMAP_LINEAR = 9986,
  66415. /**
  66416. * Linear Mipmap Linear
  66417. */
  66418. LINEAR_MIPMAP_LINEAR = 9987,
  66419. }
  66420. /**
  66421. * S (U) wrapping mode. All valid values correspond to WebGL enums
  66422. */
  66423. const enum TextureWrapMode {
  66424. /**
  66425. * Clamp to Edge
  66426. */
  66427. CLAMP_TO_EDGE = 33071,
  66428. /**
  66429. * Mirrored Repeat
  66430. */
  66431. MIRRORED_REPEAT = 33648,
  66432. /**
  66433. * Repeat
  66434. */
  66435. REPEAT = 10497,
  66436. }
  66437. /**
  66438. * glTF Property
  66439. */
  66440. interface IProperty {
  66441. /**
  66442. * Dictionary object with extension-specific objects
  66443. */
  66444. extensions?: {
  66445. [key: string]: any;
  66446. };
  66447. /**
  66448. * Application-Specific data
  66449. */
  66450. extras?: any;
  66451. }
  66452. /**
  66453. * glTF Child of Root Property
  66454. */
  66455. interface IChildRootProperty extends IProperty {
  66456. /**
  66457. * The user-defined name of this object
  66458. */
  66459. name?: string;
  66460. }
  66461. /**
  66462. * Indices of those attributes that deviate from their initialization value
  66463. */
  66464. interface IAccessorSparseIndices extends IProperty {
  66465. /**
  66466. * The index of the bufferView with sparse indices. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  66467. */
  66468. bufferView: number;
  66469. /**
  66470. * The offset relative to the start of the bufferView in bytes. Must be aligned
  66471. */
  66472. byteOffset?: number;
  66473. /**
  66474. * The indices data type. Valid values correspond to WebGL enums: 5121 (UNSIGNED_BYTE), 5123 (UNSIGNED_SHORT), 5125 (UNSIGNED_INT)
  66475. */
  66476. componentType: AccessorComponentType;
  66477. }
  66478. /**
  66479. * Array of size accessor.sparse.count times number of components storing the displaced accessor attributes pointed by accessor.sparse.indices
  66480. */
  66481. interface IAccessorSparseValues extends IProperty {
  66482. /**
  66483. * The index of the bufferView with sparse values. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  66484. */
  66485. bufferView: number;
  66486. /**
  66487. * The offset relative to the start of the bufferView in bytes. Must be aligned
  66488. */
  66489. byteOffset?: number;
  66490. }
  66491. /**
  66492. * Sparse storage of attributes that deviate from their initialization value
  66493. */
  66494. interface IAccessorSparse extends IProperty {
  66495. /**
  66496. * The number of attributes encoded in this sparse accessor
  66497. */
  66498. count: number;
  66499. /**
  66500. * Index array of size count that points to those accessor attributes that deviate from their initialization value. Indices must strictly increase
  66501. */
  66502. indices: IAccessorSparseIndices;
  66503. /**
  66504. * 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
  66505. */
  66506. values: IAccessorSparseValues;
  66507. }
  66508. /**
  66509. * 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
  66510. */
  66511. interface IAccessor extends IChildRootProperty {
  66512. /**
  66513. * The index of the bufferview
  66514. */
  66515. bufferView?: number;
  66516. /**
  66517. * The offset relative to the start of the bufferView in bytes
  66518. */
  66519. byteOffset?: number;
  66520. /**
  66521. * The datatype of components in the attribute
  66522. */
  66523. componentType: AccessorComponentType;
  66524. /**
  66525. * Specifies whether integer data values should be normalized
  66526. */
  66527. normalized?: boolean;
  66528. /**
  66529. * The number of attributes referenced by this accessor
  66530. */
  66531. count: number;
  66532. /**
  66533. * Specifies if the attribute is a scalar, vector, or matrix
  66534. */
  66535. type: AccessorType;
  66536. /**
  66537. * Maximum value of each component in this attribute
  66538. */
  66539. max?: number[];
  66540. /**
  66541. * Minimum value of each component in this attribute
  66542. */
  66543. min?: number[];
  66544. /**
  66545. * Sparse storage of attributes that deviate from their initialization value
  66546. */
  66547. sparse?: IAccessorSparse;
  66548. }
  66549. /**
  66550. * Targets an animation's sampler at a node's property
  66551. */
  66552. interface IAnimationChannel extends IProperty {
  66553. /**
  66554. * The index of a sampler in this animation used to compute the value for the target
  66555. */
  66556. sampler: number;
  66557. /**
  66558. * The index of the node and TRS property to target
  66559. */
  66560. target: IAnimationChannelTarget;
  66561. }
  66562. /**
  66563. * The index of the node and TRS property that an animation channel targets
  66564. */
  66565. interface IAnimationChannelTarget extends IProperty {
  66566. /**
  66567. * The index of the node to target
  66568. */
  66569. node: number;
  66570. /**
  66571. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  66572. */
  66573. path: AnimationChannelTargetPath;
  66574. }
  66575. /**
  66576. * Combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  66577. */
  66578. interface IAnimationSampler extends IProperty {
  66579. /**
  66580. * The index of an accessor containing keyframe input values, e.g., time
  66581. */
  66582. input: number;
  66583. /**
  66584. * Interpolation algorithm
  66585. */
  66586. interpolation?: AnimationSamplerInterpolation;
  66587. /**
  66588. * The index of an accessor, containing keyframe output values
  66589. */
  66590. output: number;
  66591. }
  66592. /**
  66593. * A keyframe animation
  66594. */
  66595. interface IAnimation extends IChildRootProperty {
  66596. /**
  66597. * An array of channels, each of which targets an animation's sampler at a node's property
  66598. */
  66599. channels: IAnimationChannel[];
  66600. /**
  66601. * An array of samplers that combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  66602. */
  66603. samplers: IAnimationSampler[];
  66604. }
  66605. /**
  66606. * Metadata about the glTF asset
  66607. */
  66608. interface IAsset extends IChildRootProperty {
  66609. /**
  66610. * A copyright message suitable for display to credit the content creator
  66611. */
  66612. copyright?: string;
  66613. /**
  66614. * Tool that generated this glTF model. Useful for debugging
  66615. */
  66616. generator?: string;
  66617. /**
  66618. * The glTF version that this asset targets
  66619. */
  66620. version: string;
  66621. /**
  66622. * The minimum glTF version that this asset targets
  66623. */
  66624. minVersion?: string;
  66625. }
  66626. /**
  66627. * A buffer points to binary geometry, animation, or skins
  66628. */
  66629. interface IBuffer extends IChildRootProperty {
  66630. /**
  66631. * 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
  66632. */
  66633. uri?: string;
  66634. /**
  66635. * The length of the buffer in bytes
  66636. */
  66637. byteLength: number;
  66638. }
  66639. /**
  66640. * A view into a buffer generally representing a subset of the buffer
  66641. */
  66642. interface IBufferView extends IChildRootProperty {
  66643. /**
  66644. * The index of the buffer
  66645. */
  66646. buffer: number;
  66647. /**
  66648. * The offset into the buffer in bytes
  66649. */
  66650. byteOffset?: number;
  66651. /**
  66652. * The lenth of the bufferView in bytes
  66653. */
  66654. byteLength: number;
  66655. /**
  66656. * The stride, in bytes
  66657. */
  66658. byteStride?: number;
  66659. }
  66660. /**
  66661. * An orthographic camera containing properties to create an orthographic projection matrix
  66662. */
  66663. interface ICameraOrthographic extends IProperty {
  66664. /**
  66665. * The floating-point horizontal magnification of the view. Must not be zero
  66666. */
  66667. xmag: number;
  66668. /**
  66669. * The floating-point vertical magnification of the view. Must not be zero
  66670. */
  66671. ymag: number;
  66672. /**
  66673. * The floating-point distance to the far clipping plane. zfar must be greater than znear
  66674. */
  66675. zfar: number;
  66676. /**
  66677. * The floating-point distance to the near clipping plane
  66678. */
  66679. znear: number;
  66680. }
  66681. /**
  66682. * A perspective camera containing properties to create a perspective projection matrix
  66683. */
  66684. interface ICameraPerspective extends IProperty {
  66685. /**
  66686. * The floating-point aspect ratio of the field of view
  66687. */
  66688. aspectRatio?: number;
  66689. /**
  66690. * The floating-point vertical field of view in radians
  66691. */
  66692. yfov: number;
  66693. /**
  66694. * The floating-point distance to the far clipping plane
  66695. */
  66696. zfar?: number;
  66697. /**
  66698. * The floating-point distance to the near clipping plane
  66699. */
  66700. znear: number;
  66701. }
  66702. /**
  66703. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  66704. */
  66705. interface ICamera extends IChildRootProperty {
  66706. /**
  66707. * An orthographic camera containing properties to create an orthographic projection matrix
  66708. */
  66709. orthographic?: ICameraOrthographic;
  66710. /**
  66711. * A perspective camera containing properties to create a perspective projection matrix
  66712. */
  66713. perspective?: ICameraPerspective;
  66714. /**
  66715. * Specifies if the camera uses a perspective or orthographic projection
  66716. */
  66717. type: CameraType;
  66718. }
  66719. /**
  66720. * Image data used to create a texture. Image can be referenced by URI or bufferView index. mimeType is required in the latter case
  66721. */
  66722. interface IImage extends IChildRootProperty {
  66723. /**
  66724. * 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
  66725. */
  66726. uri?: string;
  66727. /**
  66728. * The image's MIME type
  66729. */
  66730. mimeType?: ImageMimeType;
  66731. /**
  66732. * The index of the bufferView that contains the image. Use this instead of the image's uri property
  66733. */
  66734. bufferView?: number;
  66735. }
  66736. /**
  66737. * Material Normal Texture Info
  66738. */
  66739. interface IMaterialNormalTextureInfo extends ITextureInfo {
  66740. /**
  66741. * The scalar multiplier applied to each normal vector of the normal texture
  66742. */
  66743. scale?: number;
  66744. }
  66745. /**
  66746. * Material Occlusion Texture Info
  66747. */
  66748. interface IMaterialOcclusionTextureInfo extends ITextureInfo {
  66749. /**
  66750. * A scalar multiplier controlling the amount of occlusion applied
  66751. */
  66752. strength?: number;
  66753. }
  66754. /**
  66755. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology
  66756. */
  66757. interface IMaterialPbrMetallicRoughness {
  66758. /**
  66759. * The material's base color factor
  66760. */
  66761. baseColorFactor?: number[];
  66762. /**
  66763. * The base color texture
  66764. */
  66765. baseColorTexture?: ITextureInfo;
  66766. /**
  66767. * The metalness of the material
  66768. */
  66769. metallicFactor?: number;
  66770. /**
  66771. * The roughness of the material
  66772. */
  66773. roughnessFactor?: number;
  66774. /**
  66775. * The metallic-roughness texture
  66776. */
  66777. metallicRoughnessTexture?: ITextureInfo;
  66778. }
  66779. /**
  66780. * The material appearance of a primitive
  66781. */
  66782. interface IMaterial extends IChildRootProperty {
  66783. /**
  66784. * 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
  66785. */
  66786. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  66787. /**
  66788. * The normal map texture
  66789. */
  66790. normalTexture?: IMaterialNormalTextureInfo;
  66791. /**
  66792. * The occlusion map texture
  66793. */
  66794. occlusionTexture?: IMaterialOcclusionTextureInfo;
  66795. /**
  66796. * The emissive map texture
  66797. */
  66798. emissiveTexture?: ITextureInfo;
  66799. /**
  66800. * 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
  66801. */
  66802. emissiveFactor?: number[];
  66803. /**
  66804. * The alpha rendering mode of the material
  66805. */
  66806. alphaMode?: MaterialAlphaMode;
  66807. /**
  66808. * The alpha cutoff value of the material
  66809. */
  66810. alphaCutoff?: number;
  66811. /**
  66812. * Specifies whether the material is double sided
  66813. */
  66814. doubleSided?: boolean;
  66815. }
  66816. /**
  66817. * Geometry to be rendered with the given material
  66818. */
  66819. interface IMeshPrimitive extends IProperty {
  66820. /**
  66821. * A dictionary object, where each key corresponds to mesh attribute semantic and each value is the index of the accessor containing attribute's data
  66822. */
  66823. attributes: {
  66824. [name: string]: number;
  66825. };
  66826. /**
  66827. * The index of the accessor that contains the indices
  66828. */
  66829. indices?: number;
  66830. /**
  66831. * The index of the material to apply to this primitive when rendering
  66832. */
  66833. material?: number;
  66834. /**
  66835. * The type of primitives to render. All valid values correspond to WebGL enums
  66836. */
  66837. mode?: MeshPrimitiveMode;
  66838. /**
  66839. * 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
  66840. */
  66841. targets?: {
  66842. [name: string]: number;
  66843. }[];
  66844. }
  66845. /**
  66846. * A set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene
  66847. */
  66848. interface IMesh extends IChildRootProperty {
  66849. /**
  66850. * An array of primitives, each defining geometry to be rendered with a material
  66851. */
  66852. primitives: IMeshPrimitive[];
  66853. /**
  66854. * Array of weights to be applied to the Morph Targets
  66855. */
  66856. weights?: number[];
  66857. }
  66858. /**
  66859. * A node in the node hierarchy
  66860. */
  66861. interface INode extends IChildRootProperty {
  66862. /**
  66863. * The index of the camera referenced by this node
  66864. */
  66865. camera?: number;
  66866. /**
  66867. * The indices of this node's children
  66868. */
  66869. children?: number[];
  66870. /**
  66871. * The index of the skin referenced by this node
  66872. */
  66873. skin?: number;
  66874. /**
  66875. * A floating-point 4x4 transformation matrix stored in column-major order
  66876. */
  66877. matrix?: number[];
  66878. /**
  66879. * The index of the mesh in this node
  66880. */
  66881. mesh?: number;
  66882. /**
  66883. * The node's unit quaternion rotation in the order (x, y, z, w), where w is the scalar
  66884. */
  66885. rotation?: number[];
  66886. /**
  66887. * The node's non-uniform scale, given as the scaling factors along the x, y, and z axes
  66888. */
  66889. scale?: number[];
  66890. /**
  66891. * The node's translation along the x, y, and z axes
  66892. */
  66893. translation?: number[];
  66894. /**
  66895. * The weights of the instantiated Morph Target. Number of elements must match number of Morph Targets of used mesh
  66896. */
  66897. weights?: number[];
  66898. }
  66899. /**
  66900. * Texture sampler properties for filtering and wrapping modes
  66901. */
  66902. interface ISampler extends IChildRootProperty {
  66903. /**
  66904. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  66905. */
  66906. magFilter?: TextureMagFilter;
  66907. /**
  66908. * Minification filter. All valid values correspond to WebGL enums
  66909. */
  66910. minFilter?: TextureMinFilter;
  66911. /**
  66912. * S (U) wrapping mode. All valid values correspond to WebGL enums
  66913. */
  66914. wrapS?: TextureWrapMode;
  66915. /**
  66916. * T (V) wrapping mode. All valid values correspond to WebGL enums
  66917. */
  66918. wrapT?: TextureWrapMode;
  66919. }
  66920. /**
  66921. * The root nodes of a scene
  66922. */
  66923. interface IScene extends IChildRootProperty {
  66924. /**
  66925. * The indices of each root node
  66926. */
  66927. nodes: number[];
  66928. }
  66929. /**
  66930. * Joints and matrices defining a skin
  66931. */
  66932. interface ISkin extends IChildRootProperty {
  66933. /**
  66934. * 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
  66935. */
  66936. inverseBindMatrices?: number;
  66937. /**
  66938. * The index of the node used as a skeleton root. When undefined, joints transforms resolve to scene root
  66939. */
  66940. skeleton?: number;
  66941. /**
  66942. * 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)
  66943. */
  66944. joints: number[];
  66945. }
  66946. /**
  66947. * A texture and its sampler
  66948. */
  66949. interface ITexture extends IChildRootProperty {
  66950. /**
  66951. * The index of the sampler used by this texture. When undefined, a sampler with repeat wrapping and auto filtering should be used
  66952. */
  66953. sampler?: number;
  66954. /**
  66955. * The index of the image used by this texture
  66956. */
  66957. source: number;
  66958. }
  66959. /**
  66960. * Reference to a texture
  66961. */
  66962. interface ITextureInfo extends IProperty {
  66963. /**
  66964. * The index of the texture
  66965. */
  66966. index: number;
  66967. /**
  66968. * The set index of texture's TEXCOORD attribute used for texture coordinate mapping
  66969. */
  66970. texCoord?: number;
  66971. }
  66972. /**
  66973. * The root object for a glTF asset
  66974. */
  66975. interface IGLTF extends IProperty {
  66976. /**
  66977. * An array of accessors. An accessor is a typed view into a bufferView
  66978. */
  66979. accessors?: IAccessor[];
  66980. /**
  66981. * An array of keyframe animations
  66982. */
  66983. animations?: IAnimation[];
  66984. /**
  66985. * Metadata about the glTF asset
  66986. */
  66987. asset: IAsset;
  66988. /**
  66989. * An array of buffers. A buffer points to binary geometry, animation, or skins
  66990. */
  66991. buffers?: IBuffer[];
  66992. /**
  66993. * An array of bufferViews. A bufferView is a view into a buffer generally representing a subset of the buffer
  66994. */
  66995. bufferViews?: IBufferView[];
  66996. /**
  66997. * An array of cameras
  66998. */
  66999. cameras?: ICamera[];
  67000. /**
  67001. * Names of glTF extensions used somewhere in this asset
  67002. */
  67003. extensionsUsed?: string[];
  67004. /**
  67005. * Names of glTF extensions required to properly load this asset
  67006. */
  67007. extensionsRequired?: string[];
  67008. /**
  67009. * An array of images. An image defines data used to create a texture
  67010. */
  67011. images?: IImage[];
  67012. /**
  67013. * An array of materials. A material defines the appearance of a primitive
  67014. */
  67015. materials?: IMaterial[];
  67016. /**
  67017. * An array of meshes. A mesh is a set of primitives to be rendered
  67018. */
  67019. meshes?: IMesh[];
  67020. /**
  67021. * An array of nodes
  67022. */
  67023. nodes?: INode[];
  67024. /**
  67025. * An array of samplers. A sampler contains properties for texture filtering and wrapping modes
  67026. */
  67027. samplers?: ISampler[];
  67028. /**
  67029. * The index of the default scene
  67030. */
  67031. scene?: number;
  67032. /**
  67033. * An array of scenes
  67034. */
  67035. scenes?: IScene[];
  67036. /**
  67037. * An array of skins. A skin is defined by joints and matrices
  67038. */
  67039. skins?: ISkin[];
  67040. /**
  67041. * An array of textures
  67042. */
  67043. textures?: ITexture[];
  67044. }
  67045. /**
  67046. * The glTF validation results
  67047. */
  67048. interface IGLTFValidationResults {
  67049. info: {
  67050. generator: string;
  67051. hasAnimations: boolean;
  67052. hasDefaultScene: boolean;
  67053. hasMaterials: boolean;
  67054. hasMorphTargets: boolean;
  67055. hasSkins: boolean;
  67056. hasTextures: boolean;
  67057. maxAttributesUsed: number;
  67058. primitivesCount: number
  67059. };
  67060. issues: {
  67061. messages: Array<string>;
  67062. numErrors: number;
  67063. numHints: number;
  67064. numInfos: number;
  67065. numWarnings: number;
  67066. truncated: boolean
  67067. };
  67068. mimeType: string;
  67069. uri: string;
  67070. validatedAt: string;
  67071. validatorVersion: string;
  67072. }
  67073. /**
  67074. * The glTF validation options
  67075. */
  67076. interface IGLTFValidationOptions {
  67077. uri?: string;
  67078. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  67079. validateAccessorData?: boolean;
  67080. maxIssues?: number;
  67081. ignoredIssues?: Array<string>;
  67082. severityOverrides?: Object;
  67083. }
  67084. /**
  67085. * The glTF validator object
  67086. */
  67087. interface IGLTFValidator {
  67088. validateBytes: (data: Uint8Array, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  67089. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  67090. }
  67091. }
  67092. declare module BABYLON {
  67093. /** @hidden */
  67094. export var cellPixelShader: {
  67095. name: string;
  67096. shader: string;
  67097. };
  67098. }
  67099. declare module BABYLON {
  67100. /** @hidden */
  67101. export var cellVertexShader: {
  67102. name: string;
  67103. shader: string;
  67104. };
  67105. }
  67106. declare module BABYLON {
  67107. export class CellMaterial extends BABYLON.PushMaterial {
  67108. private _diffuseTexture;
  67109. diffuseTexture: BABYLON.BaseTexture;
  67110. diffuseColor: BABYLON.Color3;
  67111. _computeHighLevel: boolean;
  67112. computeHighLevel: boolean;
  67113. private _disableLighting;
  67114. disableLighting: boolean;
  67115. private _maxSimultaneousLights;
  67116. maxSimultaneousLights: number;
  67117. private _renderId;
  67118. constructor(name: string, scene: BABYLON.Scene);
  67119. needAlphaBlending(): boolean;
  67120. needAlphaTesting(): boolean;
  67121. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  67122. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  67123. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  67124. getAnimatables(): BABYLON.IAnimatable[];
  67125. getActiveTextures(): BABYLON.BaseTexture[];
  67126. hasTexture(texture: BABYLON.BaseTexture): boolean;
  67127. dispose(forceDisposeEffect?: boolean): void;
  67128. getClassName(): string;
  67129. clone(name: string): CellMaterial;
  67130. serialize(): any;
  67131. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): CellMaterial;
  67132. }
  67133. }
  67134. declare module BABYLON {
  67135. export class CustomShaderStructure {
  67136. FragmentStore: string;
  67137. VertexStore: string;
  67138. constructor();
  67139. }
  67140. export class ShaderSpecialParts {
  67141. constructor();
  67142. Fragment_Begin: string;
  67143. Fragment_Definitions: string;
  67144. Fragment_MainBegin: string;
  67145. Fragment_Custom_Diffuse: string;
  67146. Fragment_Before_Lights: string;
  67147. Fragment_Before_Fog: string;
  67148. Fragment_Custom_Alpha: string;
  67149. Fragment_Before_FragColor: string;
  67150. Vertex_Begin: string;
  67151. Vertex_Definitions: string;
  67152. Vertex_MainBegin: string;
  67153. Vertex_Before_PositionUpdated: string;
  67154. Vertex_Before_NormalUpdated: string;
  67155. Vertex_MainEnd: string;
  67156. }
  67157. export class CustomMaterial extends BABYLON.StandardMaterial {
  67158. static ShaderIndexer: number;
  67159. CustomParts: ShaderSpecialParts;
  67160. _isCreatedShader: boolean;
  67161. _createdShaderName: string;
  67162. _customUniform: string[];
  67163. _newUniforms: string[];
  67164. _newUniformInstances: any[];
  67165. _newSamplerInstances: BABYLON.Texture[];
  67166. FragmentShader: string;
  67167. VertexShader: string;
  67168. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  67169. ReviewUniform(name: string, arr: string[]): string[];
  67170. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.StandardMaterialDefines): string;
  67171. constructor(name: string, scene: BABYLON.Scene);
  67172. AddUniform(name: string, kind: string, param: any): CustomMaterial;
  67173. Fragment_Begin(shaderPart: string): CustomMaterial;
  67174. Fragment_Definitions(shaderPart: string): CustomMaterial;
  67175. Fragment_MainBegin(shaderPart: string): CustomMaterial;
  67176. Fragment_Custom_Diffuse(shaderPart: string): CustomMaterial;
  67177. Fragment_Custom_Alpha(shaderPart: string): CustomMaterial;
  67178. Fragment_Before_Lights(shaderPart: string): CustomMaterial;
  67179. Fragment_Before_Fog(shaderPart: string): CustomMaterial;
  67180. Fragment_Before_FragColor(shaderPart: string): CustomMaterial;
  67181. Vertex_Begin(shaderPart: string): CustomMaterial;
  67182. Vertex_Definitions(shaderPart: string): CustomMaterial;
  67183. Vertex_MainBegin(shaderPart: string): CustomMaterial;
  67184. Vertex_Before_PositionUpdated(shaderPart: string): CustomMaterial;
  67185. Vertex_Before_NormalUpdated(shaderPart: string): CustomMaterial;
  67186. Vertex_MainEnd(shaderPart: string): CustomMaterial;
  67187. }
  67188. }
  67189. declare module BABYLON {
  67190. export class ShaderAlebdoParts {
  67191. constructor();
  67192. Fragment_Begin: string;
  67193. Fragment_Definitions: string;
  67194. Fragment_MainBegin: string;
  67195. Fragment_Custom_Albedo: string;
  67196. Fragment_Before_Lights: string;
  67197. Fragment_Custom_MetallicRoughness: string;
  67198. Fragment_Custom_MicroSurface: string;
  67199. Fragment_Before_Fog: string;
  67200. Fragment_Custom_Alpha: string;
  67201. Fragment_Before_FragColor: string;
  67202. Vertex_Begin: string;
  67203. Vertex_Definitions: string;
  67204. Vertex_MainBegin: string;
  67205. Vertex_Before_PositionUpdated: string;
  67206. Vertex_Before_NormalUpdated: string;
  67207. Vertex_MainEnd: string;
  67208. }
  67209. export class PBRCustomMaterial extends BABYLON.PBRMaterial {
  67210. static ShaderIndexer: number;
  67211. CustomParts: ShaderAlebdoParts;
  67212. _isCreatedShader: boolean;
  67213. _createdShaderName: string;
  67214. _customUniform: string[];
  67215. _newUniforms: string[];
  67216. _newUniformInstances: any[];
  67217. _newSamplerInstances: BABYLON.Texture[];
  67218. FragmentShader: string;
  67219. VertexShader: string;
  67220. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  67221. ReviewUniform(name: string, arr: string[]): string[];
  67222. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.PBRMaterialDefines): string;
  67223. constructor(name: string, scene: BABYLON.Scene);
  67224. AddUniform(name: string, kind: string, param: any): PBRCustomMaterial;
  67225. Fragment_Begin(shaderPart: string): PBRCustomMaterial;
  67226. Fragment_Definitions(shaderPart: string): PBRCustomMaterial;
  67227. Fragment_MainBegin(shaderPart: string): PBRCustomMaterial;
  67228. Fragment_Custom_Albedo(shaderPart: string): PBRCustomMaterial;
  67229. Fragment_Custom_Alpha(shaderPart: string): PBRCustomMaterial;
  67230. Fragment_Before_Lights(shaderPart: string): PBRCustomMaterial;
  67231. Fragment_Custom_MetallicRoughness(shaderPart: string): PBRCustomMaterial;
  67232. Fragment_Custom_MicroSurface(shaderPart: string): PBRCustomMaterial;
  67233. Fragment_Before_Fog(shaderPart: string): PBRCustomMaterial;
  67234. Fragment_Before_FragColor(shaderPart: string): PBRCustomMaterial;
  67235. Vertex_Begin(shaderPart: string): PBRCustomMaterial;
  67236. Vertex_Definitions(shaderPart: string): PBRCustomMaterial;
  67237. Vertex_MainBegin(shaderPart: string): PBRCustomMaterial;
  67238. Vertex_Before_PositionUpdated(shaderPart: string): PBRCustomMaterial;
  67239. Vertex_Before_NormalUpdated(shaderPart: string): PBRCustomMaterial;
  67240. Vertex_MainEnd(shaderPart: string): PBRCustomMaterial;
  67241. }
  67242. }
  67243. declare module BABYLON {
  67244. /** @hidden */
  67245. export var firePixelShader: {
  67246. name: string;
  67247. shader: string;
  67248. };
  67249. }
  67250. declare module BABYLON {
  67251. /** @hidden */
  67252. export var fireVertexShader: {
  67253. name: string;
  67254. shader: string;
  67255. };
  67256. }
  67257. declare module BABYLON {
  67258. export class FireMaterial extends BABYLON.PushMaterial {
  67259. private _diffuseTexture;
  67260. diffuseTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  67261. private _distortionTexture;
  67262. distortionTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  67263. private _opacityTexture;
  67264. opacityTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  67265. diffuseColor: BABYLON.Color3;
  67266. speed: number;
  67267. private _scaledDiffuse;
  67268. private _renderId;
  67269. private _lastTime;
  67270. constructor(name: string, scene: BABYLON.Scene);
  67271. needAlphaBlending(): boolean;
  67272. needAlphaTesting(): boolean;
  67273. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  67274. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  67275. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  67276. getAnimatables(): BABYLON.IAnimatable[];
  67277. getActiveTextures(): BABYLON.BaseTexture[];
  67278. hasTexture(texture: BABYLON.BaseTexture): boolean;
  67279. getClassName(): string;
  67280. dispose(forceDisposeEffect?: boolean): void;
  67281. clone(name: string): FireMaterial;
  67282. serialize(): any;
  67283. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FireMaterial;
  67284. }
  67285. }
  67286. declare module BABYLON {
  67287. /** @hidden */
  67288. export var furPixelShader: {
  67289. name: string;
  67290. shader: string;
  67291. };
  67292. }
  67293. declare module BABYLON {
  67294. /** @hidden */
  67295. export var furVertexShader: {
  67296. name: string;
  67297. shader: string;
  67298. };
  67299. }
  67300. declare module BABYLON {
  67301. export class FurMaterial extends BABYLON.PushMaterial {
  67302. private _diffuseTexture;
  67303. diffuseTexture: BABYLON.BaseTexture;
  67304. private _heightTexture;
  67305. heightTexture: BABYLON.BaseTexture;
  67306. diffuseColor: BABYLON.Color3;
  67307. furLength: number;
  67308. furAngle: number;
  67309. furColor: BABYLON.Color3;
  67310. furOffset: number;
  67311. furSpacing: number;
  67312. furGravity: BABYLON.Vector3;
  67313. furSpeed: number;
  67314. furDensity: number;
  67315. furOcclusion: number;
  67316. furTexture: BABYLON.DynamicTexture;
  67317. private _disableLighting;
  67318. disableLighting: boolean;
  67319. private _maxSimultaneousLights;
  67320. maxSimultaneousLights: number;
  67321. highLevelFur: boolean;
  67322. _meshes: BABYLON.AbstractMesh[];
  67323. private _renderId;
  67324. private _furTime;
  67325. constructor(name: string, scene: BABYLON.Scene);
  67326. furTime: number;
  67327. needAlphaBlending(): boolean;
  67328. needAlphaTesting(): boolean;
  67329. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  67330. updateFur(): void;
  67331. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  67332. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  67333. getAnimatables(): BABYLON.IAnimatable[];
  67334. getActiveTextures(): BABYLON.BaseTexture[];
  67335. hasTexture(texture: BABYLON.BaseTexture): boolean;
  67336. dispose(forceDisposeEffect?: boolean): void;
  67337. clone(name: string): FurMaterial;
  67338. serialize(): any;
  67339. getClassName(): string;
  67340. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FurMaterial;
  67341. static GenerateTexture(name: string, scene: BABYLON.Scene): BABYLON.DynamicTexture;
  67342. static FurifyMesh(sourceMesh: BABYLON.Mesh, quality: number): BABYLON.Mesh[];
  67343. }
  67344. }
  67345. declare module BABYLON {
  67346. /** @hidden */
  67347. export var gradientPixelShader: {
  67348. name: string;
  67349. shader: string;
  67350. };
  67351. }
  67352. declare module BABYLON {
  67353. /** @hidden */
  67354. export var gradientVertexShader: {
  67355. name: string;
  67356. shader: string;
  67357. };
  67358. }
  67359. declare module BABYLON {
  67360. export class GradientMaterial extends BABYLON.PushMaterial {
  67361. private _maxSimultaneousLights;
  67362. maxSimultaneousLights: number;
  67363. topColor: BABYLON.Color3;
  67364. topColorAlpha: number;
  67365. bottomColor: BABYLON.Color3;
  67366. bottomColorAlpha: number;
  67367. offset: number;
  67368. scale: number;
  67369. smoothness: number;
  67370. private _disableLighting;
  67371. disableLighting: boolean;
  67372. private _renderId;
  67373. constructor(name: string, scene: BABYLON.Scene);
  67374. needAlphaBlending(): boolean;
  67375. needAlphaTesting(): boolean;
  67376. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  67377. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  67378. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  67379. getAnimatables(): BABYLON.IAnimatable[];
  67380. dispose(forceDisposeEffect?: boolean): void;
  67381. clone(name: string): GradientMaterial;
  67382. serialize(): any;
  67383. getClassName(): string;
  67384. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GradientMaterial;
  67385. }
  67386. }
  67387. declare module BABYLON {
  67388. /** @hidden */
  67389. export var gridPixelShader: {
  67390. name: string;
  67391. shader: string;
  67392. };
  67393. }
  67394. declare module BABYLON {
  67395. /** @hidden */
  67396. export var gridVertexShader: {
  67397. name: string;
  67398. shader: string;
  67399. };
  67400. }
  67401. declare module BABYLON {
  67402. /**
  67403. * The grid materials allows you to wrap any shape with a grid.
  67404. * Colors are customizable.
  67405. */
  67406. export class GridMaterial extends BABYLON.PushMaterial {
  67407. /**
  67408. * Main color of the grid (e.g. between lines)
  67409. */
  67410. mainColor: BABYLON.Color3;
  67411. /**
  67412. * Color of the grid lines.
  67413. */
  67414. lineColor: BABYLON.Color3;
  67415. /**
  67416. * The scale of the grid compared to unit.
  67417. */
  67418. gridRatio: number;
  67419. /**
  67420. * Allows setting an offset for the grid lines.
  67421. */
  67422. gridOffset: BABYLON.Vector3;
  67423. /**
  67424. * The frequency of thicker lines.
  67425. */
  67426. majorUnitFrequency: number;
  67427. /**
  67428. * The visibility of minor units in the grid.
  67429. */
  67430. minorUnitVisibility: number;
  67431. /**
  67432. * The grid opacity outside of the lines.
  67433. */
  67434. opacity: number;
  67435. /**
  67436. * Determine RBG output is premultiplied by alpha value.
  67437. */
  67438. preMultiplyAlpha: boolean;
  67439. private _opacityTexture;
  67440. opacityTexture: BABYLON.BaseTexture;
  67441. private _gridControl;
  67442. private _renderId;
  67443. /**
  67444. * constructor
  67445. * @param name The name given to the material in order to identify it afterwards.
  67446. * @param scene The scene the material is used in.
  67447. */
  67448. constructor(name: string, scene: BABYLON.Scene);
  67449. /**
  67450. * Returns wehter or not the grid requires alpha blending.
  67451. */
  67452. needAlphaBlending(): boolean;
  67453. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  67454. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  67455. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  67456. /**
  67457. * Dispose the material and its associated resources.
  67458. * @param forceDisposeEffect will also dispose the used effect when true
  67459. */
  67460. dispose(forceDisposeEffect?: boolean): void;
  67461. clone(name: string): GridMaterial;
  67462. serialize(): any;
  67463. getClassName(): string;
  67464. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GridMaterial;
  67465. }
  67466. }
  67467. declare module BABYLON {
  67468. /** @hidden */
  67469. export var lavaPixelShader: {
  67470. name: string;
  67471. shader: string;
  67472. };
  67473. }
  67474. declare module BABYLON {
  67475. /** @hidden */
  67476. export var lavaVertexShader: {
  67477. name: string;
  67478. shader: string;
  67479. };
  67480. }
  67481. declare module BABYLON {
  67482. export class LavaMaterial extends BABYLON.PushMaterial {
  67483. private _diffuseTexture;
  67484. diffuseTexture: BABYLON.BaseTexture;
  67485. noiseTexture: BABYLON.BaseTexture;
  67486. fogColor: BABYLON.Color3;
  67487. speed: number;
  67488. movingSpeed: number;
  67489. lowFrequencySpeed: number;
  67490. fogDensity: number;
  67491. private _lastTime;
  67492. diffuseColor: BABYLON.Color3;
  67493. private _disableLighting;
  67494. disableLighting: boolean;
  67495. private _unlit;
  67496. unlit: boolean;
  67497. private _maxSimultaneousLights;
  67498. maxSimultaneousLights: number;
  67499. private _scaledDiffuse;
  67500. private _renderId;
  67501. constructor(name: string, scene: BABYLON.Scene);
  67502. needAlphaBlending(): boolean;
  67503. needAlphaTesting(): boolean;
  67504. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  67505. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  67506. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  67507. getAnimatables(): BABYLON.IAnimatable[];
  67508. getActiveTextures(): BABYLON.BaseTexture[];
  67509. hasTexture(texture: BABYLON.BaseTexture): boolean;
  67510. dispose(forceDisposeEffect?: boolean): void;
  67511. clone(name: string): LavaMaterial;
  67512. serialize(): any;
  67513. getClassName(): string;
  67514. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): LavaMaterial;
  67515. }
  67516. }
  67517. declare module BABYLON {
  67518. /** @hidden */
  67519. export var mixPixelShader: {
  67520. name: string;
  67521. shader: string;
  67522. };
  67523. }
  67524. declare module BABYLON {
  67525. /** @hidden */
  67526. export var mixVertexShader: {
  67527. name: string;
  67528. shader: string;
  67529. };
  67530. }
  67531. declare module BABYLON {
  67532. export class MixMaterial extends BABYLON.PushMaterial {
  67533. /**
  67534. * Mix textures
  67535. */
  67536. private _mixTexture1;
  67537. mixTexture1: BABYLON.BaseTexture;
  67538. private _mixTexture2;
  67539. mixTexture2: BABYLON.BaseTexture;
  67540. /**
  67541. * Diffuse textures
  67542. */
  67543. private _diffuseTexture1;
  67544. diffuseTexture1: BABYLON.Texture;
  67545. private _diffuseTexture2;
  67546. diffuseTexture2: BABYLON.Texture;
  67547. private _diffuseTexture3;
  67548. diffuseTexture3: BABYLON.Texture;
  67549. private _diffuseTexture4;
  67550. diffuseTexture4: BABYLON.Texture;
  67551. private _diffuseTexture5;
  67552. diffuseTexture5: BABYLON.Texture;
  67553. private _diffuseTexture6;
  67554. diffuseTexture6: BABYLON.Texture;
  67555. private _diffuseTexture7;
  67556. diffuseTexture7: BABYLON.Texture;
  67557. private _diffuseTexture8;
  67558. diffuseTexture8: BABYLON.Texture;
  67559. /**
  67560. * Uniforms
  67561. */
  67562. diffuseColor: BABYLON.Color3;
  67563. specularColor: BABYLON.Color3;
  67564. specularPower: number;
  67565. private _disableLighting;
  67566. disableLighting: boolean;
  67567. private _maxSimultaneousLights;
  67568. maxSimultaneousLights: number;
  67569. private _renderId;
  67570. constructor(name: string, scene: BABYLON.Scene);
  67571. needAlphaBlending(): boolean;
  67572. needAlphaTesting(): boolean;
  67573. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  67574. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  67575. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  67576. getAnimatables(): BABYLON.IAnimatable[];
  67577. getActiveTextures(): BABYLON.BaseTexture[];
  67578. hasTexture(texture: BABYLON.BaseTexture): boolean;
  67579. dispose(forceDisposeEffect?: boolean): void;
  67580. clone(name: string): MixMaterial;
  67581. serialize(): any;
  67582. getClassName(): string;
  67583. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): MixMaterial;
  67584. }
  67585. }
  67586. declare module BABYLON {
  67587. /** @hidden */
  67588. export var normalPixelShader: {
  67589. name: string;
  67590. shader: string;
  67591. };
  67592. }
  67593. declare module BABYLON {
  67594. /** @hidden */
  67595. export var normalVertexShader: {
  67596. name: string;
  67597. shader: string;
  67598. };
  67599. }
  67600. declare module BABYLON {
  67601. export class NormalMaterial extends BABYLON.PushMaterial {
  67602. private _diffuseTexture;
  67603. diffuseTexture: BABYLON.BaseTexture;
  67604. diffuseColor: BABYLON.Color3;
  67605. private _disableLighting;
  67606. disableLighting: boolean;
  67607. private _maxSimultaneousLights;
  67608. maxSimultaneousLights: number;
  67609. private _renderId;
  67610. constructor(name: string, scene: BABYLON.Scene);
  67611. needAlphaBlending(): boolean;
  67612. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  67613. needAlphaTesting(): boolean;
  67614. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  67615. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  67616. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  67617. getAnimatables(): BABYLON.IAnimatable[];
  67618. getActiveTextures(): BABYLON.BaseTexture[];
  67619. hasTexture(texture: BABYLON.BaseTexture): boolean;
  67620. dispose(forceDisposeEffect?: boolean): void;
  67621. clone(name: string): NormalMaterial;
  67622. serialize(): any;
  67623. getClassName(): string;
  67624. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): NormalMaterial;
  67625. }
  67626. }
  67627. declare module BABYLON {
  67628. /** @hidden */
  67629. export var shadowOnlyPixelShader: {
  67630. name: string;
  67631. shader: string;
  67632. };
  67633. }
  67634. declare module BABYLON {
  67635. /** @hidden */
  67636. export var shadowOnlyVertexShader: {
  67637. name: string;
  67638. shader: string;
  67639. };
  67640. }
  67641. declare module BABYLON {
  67642. export class ShadowOnlyMaterial extends BABYLON.PushMaterial {
  67643. private _renderId;
  67644. private _activeLight;
  67645. constructor(name: string, scene: BABYLON.Scene);
  67646. shadowColor: BABYLON.Color3;
  67647. needAlphaBlending(): boolean;
  67648. needAlphaTesting(): boolean;
  67649. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  67650. activeLight: BABYLON.IShadowLight;
  67651. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  67652. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  67653. clone(name: string): ShadowOnlyMaterial;
  67654. serialize(): any;
  67655. getClassName(): string;
  67656. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): ShadowOnlyMaterial;
  67657. }
  67658. }
  67659. declare module BABYLON {
  67660. /** @hidden */
  67661. export var simplePixelShader: {
  67662. name: string;
  67663. shader: string;
  67664. };
  67665. }
  67666. declare module BABYLON {
  67667. /** @hidden */
  67668. export var simpleVertexShader: {
  67669. name: string;
  67670. shader: string;
  67671. };
  67672. }
  67673. declare module BABYLON {
  67674. export class SimpleMaterial extends BABYLON.PushMaterial {
  67675. private _diffuseTexture;
  67676. diffuseTexture: BABYLON.BaseTexture;
  67677. diffuseColor: BABYLON.Color3;
  67678. private _disableLighting;
  67679. disableLighting: boolean;
  67680. private _maxSimultaneousLights;
  67681. maxSimultaneousLights: number;
  67682. private _renderId;
  67683. constructor(name: string, scene: BABYLON.Scene);
  67684. needAlphaBlending(): boolean;
  67685. needAlphaTesting(): boolean;
  67686. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  67687. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  67688. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  67689. getAnimatables(): BABYLON.IAnimatable[];
  67690. getActiveTextures(): BABYLON.BaseTexture[];
  67691. hasTexture(texture: BABYLON.BaseTexture): boolean;
  67692. dispose(forceDisposeEffect?: boolean): void;
  67693. clone(name: string): SimpleMaterial;
  67694. serialize(): any;
  67695. getClassName(): string;
  67696. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SimpleMaterial;
  67697. }
  67698. }
  67699. declare module BABYLON {
  67700. /** @hidden */
  67701. export var skyPixelShader: {
  67702. name: string;
  67703. shader: string;
  67704. };
  67705. }
  67706. declare module BABYLON {
  67707. /** @hidden */
  67708. export var skyVertexShader: {
  67709. name: string;
  67710. shader: string;
  67711. };
  67712. }
  67713. declare module BABYLON {
  67714. /**
  67715. * This is the sky material which allows to create dynamic and texture free effects for skyboxes.
  67716. * @see https://doc.babylonjs.com/extensions/sky
  67717. */
  67718. export class SkyMaterial extends BABYLON.PushMaterial {
  67719. /**
  67720. * Defines the overall luminance of sky in interval ]0, 1[.
  67721. */
  67722. luminance: number;
  67723. /**
  67724. * Defines the amount (scattering) of haze as opposed to molecules in atmosphere.
  67725. */
  67726. turbidity: number;
  67727. /**
  67728. * Defines the sky appearance (light intensity).
  67729. */
  67730. rayleigh: number;
  67731. /**
  67732. * Defines the mieCoefficient in interval [0, 0.1] which affects the property .mieDirectionalG.
  67733. */
  67734. mieCoefficient: number;
  67735. /**
  67736. * Defines the amount of haze particles following the Mie scattering theory.
  67737. */
  67738. mieDirectionalG: number;
  67739. /**
  67740. * Defines the distance of the sun according to the active scene camera.
  67741. */
  67742. distance: number;
  67743. /**
  67744. * Defines the sun inclination, in interval [-0.5, 0.5]. When the inclination is not 0, the sun is said
  67745. * "inclined".
  67746. */
  67747. inclination: number;
  67748. /**
  67749. * Defines the solar azimuth in interval [0, 1]. The azimuth is the angle in the horizontal plan between
  67750. * an object direction and a reference direction.
  67751. */
  67752. azimuth: number;
  67753. /**
  67754. * Defines the sun position in the sky on (x,y,z). If the property .useSunPosition is set to false, then
  67755. * the property is overriden by the inclination and the azimuth and can be read at any moment.
  67756. */
  67757. sunPosition: BABYLON.Vector3;
  67758. /**
  67759. * Defines if the sun position should be computed (inclination and azimuth) according to the given
  67760. * .sunPosition property.
  67761. */
  67762. useSunPosition: boolean;
  67763. /**
  67764. * Defines an offset vector used to get a horizon offset.
  67765. * @example skyMaterial.cameraOffset.y = camera.globalPosition.y // Set horizon relative to 0 on the Y axis
  67766. */
  67767. cameraOffset: BABYLON.Vector3;
  67768. private _cameraPosition;
  67769. private _renderId;
  67770. /**
  67771. * Instantiates a new sky material.
  67772. * This material allows to create dynamic and texture free
  67773. * effects for skyboxes by taking care of the atmosphere state.
  67774. * @see https://doc.babylonjs.com/extensions/sky
  67775. * @param name Define the name of the material in the scene
  67776. * @param scene Define the scene the material belong to
  67777. */
  67778. constructor(name: string, scene: BABYLON.Scene);
  67779. /**
  67780. * Specifies if the material will require alpha blending
  67781. * @returns a boolean specifying if alpha blending is needed
  67782. */
  67783. needAlphaBlending(): boolean;
  67784. /**
  67785. * Specifies if this material should be rendered in alpha test mode
  67786. * @returns false as the sky material doesn't need alpha testing.
  67787. */
  67788. needAlphaTesting(): boolean;
  67789. /**
  67790. * Get the texture used for alpha test purpose.
  67791. * @returns null as the sky material has no texture.
  67792. */
  67793. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  67794. /**
  67795. * Get if the submesh is ready to be used and all its information available.
  67796. * Child classes can use it to update shaders
  67797. * @param mesh defines the mesh to check
  67798. * @param subMesh defines which submesh to check
  67799. * @param useInstances specifies that instances should be used
  67800. * @returns a boolean indicating that the submesh is ready or not
  67801. */
  67802. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  67803. /**
  67804. * Binds the submesh to this material by preparing the effect and shader to draw
  67805. * @param world defines the world transformation matrix
  67806. * @param mesh defines the mesh containing the submesh
  67807. * @param subMesh defines the submesh to bind the material to
  67808. */
  67809. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  67810. /**
  67811. * Get the list of animatables in the material.
  67812. * @returns the list of animatables object used in the material
  67813. */
  67814. getAnimatables(): BABYLON.IAnimatable[];
  67815. /**
  67816. * Disposes the material
  67817. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  67818. */
  67819. dispose(forceDisposeEffect?: boolean): void;
  67820. /**
  67821. * Makes a duplicate of the material, and gives it a new name
  67822. * @param name defines the new name for the duplicated material
  67823. * @returns the cloned material
  67824. */
  67825. clone(name: string): SkyMaterial;
  67826. /**
  67827. * Serializes this material in a JSON representation
  67828. * @returns the serialized material object
  67829. */
  67830. serialize(): any;
  67831. /**
  67832. * Gets the current class name of the material e.g. "SkyMaterial"
  67833. * Mainly use in serialization.
  67834. * @returns the class name
  67835. */
  67836. getClassName(): string;
  67837. /**
  67838. * Creates a sky material from parsed material data
  67839. * @param source defines the JSON representation of the material
  67840. * @param scene defines the hosting scene
  67841. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  67842. * @returns a new sky material
  67843. */
  67844. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SkyMaterial;
  67845. }
  67846. }
  67847. declare module BABYLON {
  67848. /** @hidden */
  67849. export var terrainPixelShader: {
  67850. name: string;
  67851. shader: string;
  67852. };
  67853. }
  67854. declare module BABYLON {
  67855. /** @hidden */
  67856. export var terrainVertexShader: {
  67857. name: string;
  67858. shader: string;
  67859. };
  67860. }
  67861. declare module BABYLON {
  67862. export class TerrainMaterial extends BABYLON.PushMaterial {
  67863. private _mixTexture;
  67864. mixTexture: BABYLON.BaseTexture;
  67865. private _diffuseTexture1;
  67866. diffuseTexture1: BABYLON.Texture;
  67867. private _diffuseTexture2;
  67868. diffuseTexture2: BABYLON.Texture;
  67869. private _diffuseTexture3;
  67870. diffuseTexture3: BABYLON.Texture;
  67871. private _bumpTexture1;
  67872. bumpTexture1: BABYLON.Texture;
  67873. private _bumpTexture2;
  67874. bumpTexture2: BABYLON.Texture;
  67875. private _bumpTexture3;
  67876. bumpTexture3: BABYLON.Texture;
  67877. diffuseColor: BABYLON.Color3;
  67878. specularColor: BABYLON.Color3;
  67879. specularPower: number;
  67880. private _disableLighting;
  67881. disableLighting: boolean;
  67882. private _maxSimultaneousLights;
  67883. maxSimultaneousLights: number;
  67884. private _renderId;
  67885. constructor(name: string, scene: BABYLON.Scene);
  67886. needAlphaBlending(): boolean;
  67887. needAlphaTesting(): boolean;
  67888. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  67889. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  67890. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  67891. getAnimatables(): BABYLON.IAnimatable[];
  67892. getActiveTextures(): BABYLON.BaseTexture[];
  67893. hasTexture(texture: BABYLON.BaseTexture): boolean;
  67894. dispose(forceDisposeEffect?: boolean): void;
  67895. clone(name: string): TerrainMaterial;
  67896. serialize(): any;
  67897. getClassName(): string;
  67898. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TerrainMaterial;
  67899. }
  67900. }
  67901. declare module BABYLON {
  67902. /** @hidden */
  67903. export var triplanarPixelShader: {
  67904. name: string;
  67905. shader: string;
  67906. };
  67907. }
  67908. declare module BABYLON {
  67909. /** @hidden */
  67910. export var triplanarVertexShader: {
  67911. name: string;
  67912. shader: string;
  67913. };
  67914. }
  67915. declare module BABYLON {
  67916. export class TriPlanarMaterial extends BABYLON.PushMaterial {
  67917. mixTexture: BABYLON.BaseTexture;
  67918. private _diffuseTextureX;
  67919. diffuseTextureX: BABYLON.BaseTexture;
  67920. private _diffuseTextureY;
  67921. diffuseTextureY: BABYLON.BaseTexture;
  67922. private _diffuseTextureZ;
  67923. diffuseTextureZ: BABYLON.BaseTexture;
  67924. private _normalTextureX;
  67925. normalTextureX: BABYLON.BaseTexture;
  67926. private _normalTextureY;
  67927. normalTextureY: BABYLON.BaseTexture;
  67928. private _normalTextureZ;
  67929. normalTextureZ: BABYLON.BaseTexture;
  67930. tileSize: number;
  67931. diffuseColor: BABYLON.Color3;
  67932. specularColor: BABYLON.Color3;
  67933. specularPower: number;
  67934. private _disableLighting;
  67935. disableLighting: boolean;
  67936. private _maxSimultaneousLights;
  67937. maxSimultaneousLights: number;
  67938. private _renderId;
  67939. constructor(name: string, scene: BABYLON.Scene);
  67940. needAlphaBlending(): boolean;
  67941. needAlphaTesting(): boolean;
  67942. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  67943. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  67944. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  67945. getAnimatables(): BABYLON.IAnimatable[];
  67946. getActiveTextures(): BABYLON.BaseTexture[];
  67947. hasTexture(texture: BABYLON.BaseTexture): boolean;
  67948. dispose(forceDisposeEffect?: boolean): void;
  67949. clone(name: string): TriPlanarMaterial;
  67950. serialize(): any;
  67951. getClassName(): string;
  67952. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TriPlanarMaterial;
  67953. }
  67954. }
  67955. declare module BABYLON {
  67956. /** @hidden */
  67957. export var waterPixelShader: {
  67958. name: string;
  67959. shader: string;
  67960. };
  67961. }
  67962. declare module BABYLON {
  67963. /** @hidden */
  67964. export var waterVertexShader: {
  67965. name: string;
  67966. shader: string;
  67967. };
  67968. }
  67969. declare module BABYLON {
  67970. export class WaterMaterial extends BABYLON.PushMaterial {
  67971. renderTargetSize: BABYLON.Vector2;
  67972. private _bumpTexture;
  67973. bumpTexture: BABYLON.BaseTexture;
  67974. diffuseColor: BABYLON.Color3;
  67975. specularColor: BABYLON.Color3;
  67976. specularPower: number;
  67977. private _disableLighting;
  67978. disableLighting: boolean;
  67979. private _maxSimultaneousLights;
  67980. maxSimultaneousLights: number;
  67981. /**
  67982. * @param {number}: Represents the wind force
  67983. */
  67984. windForce: number;
  67985. /**
  67986. * @param {Vector2}: The direction of the wind in the plane (X, Z)
  67987. */
  67988. windDirection: BABYLON.Vector2;
  67989. /**
  67990. * @param {number}: Wave height, represents the height of the waves
  67991. */
  67992. waveHeight: number;
  67993. /**
  67994. * @param {number}: Bump height, represents the bump height related to the bump map
  67995. */
  67996. bumpHeight: number;
  67997. /**
  67998. * @param {boolean}: Add a smaller moving bump to less steady waves.
  67999. */
  68000. private _bumpSuperimpose;
  68001. bumpSuperimpose: boolean;
  68002. /**
  68003. * @param {boolean}: Color refraction and reflection differently with .waterColor2 and .colorBlendFactor2. Non-linear (physically correct) fresnel.
  68004. */
  68005. private _fresnelSeparate;
  68006. fresnelSeparate: boolean;
  68007. /**
  68008. * @param {boolean}: bump Waves modify the reflection.
  68009. */
  68010. private _bumpAffectsReflection;
  68011. bumpAffectsReflection: boolean;
  68012. /**
  68013. * @param {number}: The water color blended with the refraction (near)
  68014. */
  68015. waterColor: BABYLON.Color3;
  68016. /**
  68017. * @param {number}: The blend factor related to the water color
  68018. */
  68019. colorBlendFactor: number;
  68020. /**
  68021. * @param {number}: The water color blended with the reflection (far)
  68022. */
  68023. waterColor2: BABYLON.Color3;
  68024. /**
  68025. * @param {number}: The blend factor related to the water color (reflection, far)
  68026. */
  68027. colorBlendFactor2: number;
  68028. /**
  68029. * @param {number}: Represents the maximum length of a wave
  68030. */
  68031. waveLength: number;
  68032. /**
  68033. * @param {number}: Defines the waves speed
  68034. */
  68035. waveSpeed: number;
  68036. protected _renderTargets: BABYLON.SmartArray<BABYLON.RenderTargetTexture>;
  68037. private _mesh;
  68038. private _refractionRTT;
  68039. private _reflectionRTT;
  68040. private _reflectionTransform;
  68041. private _lastTime;
  68042. private _lastDeltaTime;
  68043. private _renderId;
  68044. private _useLogarithmicDepth;
  68045. private _waitingRenderList;
  68046. /**
  68047. * Gets a boolean indicating that current material needs to register RTT
  68048. */
  68049. readonly hasRenderTargetTextures: boolean;
  68050. /**
  68051. * Constructor
  68052. */
  68053. constructor(name: string, scene: BABYLON.Scene, renderTargetSize?: BABYLON.Vector2);
  68054. useLogarithmicDepth: boolean;
  68055. readonly refractionTexture: BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  68056. readonly reflectionTexture: BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  68057. addToRenderList(node: any): void;
  68058. enableRenderTargets(enable: boolean): void;
  68059. getRenderList(): BABYLON.Nullable<BABYLON.AbstractMesh[]>;
  68060. readonly renderTargetsEnabled: boolean;
  68061. needAlphaBlending(): boolean;
  68062. needAlphaTesting(): boolean;
  68063. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  68064. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  68065. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  68066. private _createRenderTargets;
  68067. getAnimatables(): BABYLON.IAnimatable[];
  68068. getActiveTextures(): BABYLON.BaseTexture[];
  68069. hasTexture(texture: BABYLON.BaseTexture): boolean;
  68070. dispose(forceDisposeEffect?: boolean): void;
  68071. clone(name: string): WaterMaterial;
  68072. serialize(): any;
  68073. getClassName(): string;
  68074. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): WaterMaterial;
  68075. static CreateDefaultMesh(name: string, scene: BABYLON.Scene): BABYLON.Mesh;
  68076. }
  68077. }
  68078. declare module BABYLON {
  68079. /** @hidden */
  68080. export var asciiartPixelShader: {
  68081. name: string;
  68082. shader: string;
  68083. };
  68084. }
  68085. declare module BABYLON {
  68086. /**
  68087. * AsciiArtFontTexture is the helper class used to easily create your ascii art font texture.
  68088. *
  68089. * It basically takes care rendering the font front the given font size to a texture.
  68090. * This is used later on in the postprocess.
  68091. */
  68092. export class AsciiArtFontTexture extends BABYLON.BaseTexture {
  68093. private _font;
  68094. private _text;
  68095. private _charSize;
  68096. /**
  68097. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  68098. */
  68099. readonly charSize: number;
  68100. /**
  68101. * Create a new instance of the Ascii Art FontTexture class
  68102. * @param name the name of the texture
  68103. * @param font the font to use, use the W3C CSS notation
  68104. * @param text the caracter set to use in the rendering.
  68105. * @param scene the scene that owns the texture
  68106. */
  68107. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  68108. /**
  68109. * Gets the max char width of a font.
  68110. * @param font the font to use, use the W3C CSS notation
  68111. * @return the max char width
  68112. */
  68113. private getFontWidth;
  68114. /**
  68115. * Gets the max char height of a font.
  68116. * @param font the font to use, use the W3C CSS notation
  68117. * @return the max char height
  68118. */
  68119. private getFontHeight;
  68120. /**
  68121. * Clones the current AsciiArtTexture.
  68122. * @return the clone of the texture.
  68123. */
  68124. clone(): AsciiArtFontTexture;
  68125. /**
  68126. * Parses a json object representing the texture and returns an instance of it.
  68127. * @param source the source JSON representation
  68128. * @param scene the scene to create the texture for
  68129. * @return the parsed texture
  68130. */
  68131. static Parse(source: any, scene: BABYLON.Scene): AsciiArtFontTexture;
  68132. }
  68133. /**
  68134. * Option available in the Ascii Art Post Process.
  68135. */
  68136. export interface IAsciiArtPostProcessOptions {
  68137. /**
  68138. * The font to use following the w3c font definition.
  68139. */
  68140. font?: string;
  68141. /**
  68142. * The character set to use in the postprocess.
  68143. */
  68144. characterSet?: string;
  68145. /**
  68146. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  68147. * This number is defined between 0 and 1;
  68148. */
  68149. mixToTile?: number;
  68150. /**
  68151. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  68152. * This number is defined between 0 and 1;
  68153. */
  68154. mixToNormal?: number;
  68155. }
  68156. /**
  68157. * AsciiArtPostProcess helps rendering everithing in Ascii Art.
  68158. *
  68159. * Simmply add it to your scene and let the nerd that lives in you have fun.
  68160. * Example usage: var pp = new AsciiArtPostProcess("myAscii", "20px Monospace", camera);
  68161. */
  68162. export class AsciiArtPostProcess extends BABYLON.PostProcess {
  68163. /**
  68164. * The font texture used to render the char in the post process.
  68165. */
  68166. private _asciiArtFontTexture;
  68167. /**
  68168. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  68169. * This number is defined between 0 and 1;
  68170. */
  68171. mixToTile: number;
  68172. /**
  68173. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  68174. * This number is defined between 0 and 1;
  68175. */
  68176. mixToNormal: number;
  68177. /**
  68178. * Instantiates a new Ascii Art Post Process.
  68179. * @param name the name to give to the postprocess
  68180. * @camera the camera to apply the post process to.
  68181. * @param options can either be the font name or an option object following the IAsciiArtPostProcessOptions format
  68182. */
  68183. constructor(name: string, camera: BABYLON.Camera, options?: string | IAsciiArtPostProcessOptions);
  68184. }
  68185. }
  68186. declare module BABYLON {
  68187. /** @hidden */
  68188. export var digitalrainPixelShader: {
  68189. name: string;
  68190. shader: string;
  68191. };
  68192. }
  68193. declare module BABYLON {
  68194. /**
  68195. * DigitalRainFontTexture is the helper class used to easily create your digital rain font texture.
  68196. *
  68197. * It basically takes care rendering the font front the given font size to a texture.
  68198. * This is used later on in the postprocess.
  68199. */
  68200. export class DigitalRainFontTexture extends BABYLON.BaseTexture {
  68201. private _font;
  68202. private _text;
  68203. private _charSize;
  68204. /**
  68205. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  68206. */
  68207. readonly charSize: number;
  68208. /**
  68209. * Create a new instance of the Digital Rain FontTexture class
  68210. * @param name the name of the texture
  68211. * @param font the font to use, use the W3C CSS notation
  68212. * @param text the caracter set to use in the rendering.
  68213. * @param scene the scene that owns the texture
  68214. */
  68215. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  68216. /**
  68217. * Gets the max char width of a font.
  68218. * @param font the font to use, use the W3C CSS notation
  68219. * @return the max char width
  68220. */
  68221. private getFontWidth;
  68222. /**
  68223. * Gets the max char height of a font.
  68224. * @param font the font to use, use the W3C CSS notation
  68225. * @return the max char height
  68226. */
  68227. private getFontHeight;
  68228. /**
  68229. * Clones the current DigitalRainFontTexture.
  68230. * @return the clone of the texture.
  68231. */
  68232. clone(): DigitalRainFontTexture;
  68233. /**
  68234. * Parses a json object representing the texture and returns an instance of it.
  68235. * @param source the source JSON representation
  68236. * @param scene the scene to create the texture for
  68237. * @return the parsed texture
  68238. */
  68239. static Parse(source: any, scene: BABYLON.Scene): DigitalRainFontTexture;
  68240. }
  68241. /**
  68242. * Option available in the Digital Rain Post Process.
  68243. */
  68244. export interface IDigitalRainPostProcessOptions {
  68245. /**
  68246. * The font to use following the w3c font definition.
  68247. */
  68248. font?: string;
  68249. /**
  68250. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  68251. * This number is defined between 0 and 1;
  68252. */
  68253. mixToTile?: number;
  68254. /**
  68255. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  68256. * This number is defined between 0 and 1;
  68257. */
  68258. mixToNormal?: number;
  68259. }
  68260. /**
  68261. * DigitalRainPostProcess helps rendering everithing in digital rain.
  68262. *
  68263. * Simmply add it to your scene and let the nerd that lives in you have fun.
  68264. * Example usage: var pp = new DigitalRainPostProcess("digitalRain", "20px Monospace", camera);
  68265. */
  68266. export class DigitalRainPostProcess extends BABYLON.PostProcess {
  68267. /**
  68268. * The font texture used to render the char in the post process.
  68269. */
  68270. private _digitalRainFontTexture;
  68271. /**
  68272. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  68273. * This number is defined between 0 and 1;
  68274. */
  68275. mixToTile: number;
  68276. /**
  68277. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  68278. * This number is defined between 0 and 1;
  68279. */
  68280. mixToNormal: number;
  68281. /**
  68282. * Instantiates a new Digital Rain Post Process.
  68283. * @param name the name to give to the postprocess
  68284. * @camera the camera to apply the post process to.
  68285. * @param options can either be the font name or an option object following the IDigitalRainPostProcessOptions format
  68286. */
  68287. constructor(name: string, camera: BABYLON.Camera, options?: string | IDigitalRainPostProcessOptions);
  68288. }
  68289. }
  68290. declare module BABYLON {
  68291. /** @hidden */
  68292. export var oceanPostProcessPixelShader: {
  68293. name: string;
  68294. shader: string;
  68295. };
  68296. }
  68297. declare module BABYLON {
  68298. /**
  68299. * Option available in the Ocean Post Process.
  68300. */
  68301. export interface IOceanPostProcessOptions {
  68302. /**
  68303. * The size of the reflection RTT (number if square, or {width: number, height:number} or {ratio:} to define a ratio from the main scene)
  68304. */
  68305. reflectionSize?: number | {
  68306. width: number;
  68307. height: number;
  68308. } | {
  68309. ratio: number;
  68310. };
  68311. /**
  68312. * The size of the refraction RTT (number if square, or {width: number, height:number} or {ratio:} to define a ratio from the main scene)
  68313. */
  68314. refractionSize?: number | {
  68315. width: number;
  68316. height: number;
  68317. } | {
  68318. ratio: number;
  68319. };
  68320. }
  68321. /**
  68322. * OceanPostProcess helps rendering an infinite ocean surface that can reflect and refract environment.
  68323. *
  68324. * Simmply add it to your scene and let the nerd that lives in you have fun.
  68325. * Example usage:
  68326. * var pp = new OceanPostProcess("myOcean", camera);
  68327. * pp.reflectionEnabled = true;
  68328. * pp.refractionEnabled = true;
  68329. */
  68330. export class OceanPostProcess extends BABYLON.PostProcess {
  68331. /**
  68332. * Gets a boolean indicating if the real-time reflection is enabled on the ocean.
  68333. */
  68334. /**
  68335. * Sets weither or not the real-time reflection is enabled on the ocean.
  68336. * Is set to true, the reflection mirror texture will be used as reflection texture.
  68337. */
  68338. reflectionEnabled: boolean;
  68339. /**
  68340. * Gets a boolean indicating if the real-time refraction is enabled on the ocean.
  68341. */
  68342. /**
  68343. * Sets weither or not the real-time refraction is enabled on the ocean.
  68344. * Is set to true, the refraction render target texture will be used as refraction texture.
  68345. */
  68346. refractionEnabled: boolean;
  68347. /**
  68348. * Gets wether or not the post-processes is supported by the running hardware.
  68349. * This requires draw buffer supports.
  68350. */
  68351. readonly isSupported: boolean;
  68352. /**
  68353. * This is the reflection mirror texture used to display reflections on the ocean.
  68354. * By default, render list is empty.
  68355. */
  68356. reflectionTexture: BABYLON.MirrorTexture;
  68357. /**
  68358. * This is the refraction render target texture used to display refraction on the ocean.
  68359. * By default, render list is empty.
  68360. */
  68361. refractionTexture: BABYLON.RenderTargetTexture;
  68362. private _time;
  68363. private _cameraRotation;
  68364. private _cameraViewMatrix;
  68365. private _reflectionEnabled;
  68366. private _refractionEnabled;
  68367. private _geometryRenderer;
  68368. /**
  68369. * Instantiates a new Ocean Post Process.
  68370. * @param name the name to give to the postprocess.
  68371. * @camera the camera to apply the post process to.
  68372. * @param options optional object following the IOceanPostProcessOptions format used to customize reflection and refraction render targets sizes.
  68373. */
  68374. constructor(name: string, camera: BABYLON.TargetCamera, options?: IOceanPostProcessOptions);
  68375. /**
  68376. * Returns the appropriate defines according to the current configuration.
  68377. */
  68378. private _getDefines;
  68379. /**
  68380. * Computes the current camera rotation as the shader requires a camera rotation.
  68381. */
  68382. private _computeCameraRotation;
  68383. }
  68384. }
  68385. declare module BABYLON {
  68386. /** @hidden */
  68387. export var brickProceduralTexturePixelShader: {
  68388. name: string;
  68389. shader: string;
  68390. };
  68391. }
  68392. declare module BABYLON {
  68393. export class BrickProceduralTexture extends BABYLON.ProceduralTexture {
  68394. private _numberOfBricksHeight;
  68395. private _numberOfBricksWidth;
  68396. private _jointColor;
  68397. private _brickColor;
  68398. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  68399. updateShaderUniforms(): void;
  68400. numberOfBricksHeight: number;
  68401. numberOfBricksWidth: number;
  68402. jointColor: BABYLON.Color3;
  68403. brickColor: BABYLON.Color3;
  68404. /**
  68405. * Serializes this brick procedural texture
  68406. * @returns a serialized brick procedural texture object
  68407. */
  68408. serialize(): any;
  68409. /**
  68410. * Creates a Brick Procedural BABYLON.Texture from parsed brick procedural texture data
  68411. * @param parsedTexture defines parsed texture data
  68412. * @param scene defines the current scene
  68413. * @param rootUrl defines the root URL containing brick procedural texture information
  68414. * @returns a parsed Brick Procedural BABYLON.Texture
  68415. */
  68416. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): BrickProceduralTexture;
  68417. }
  68418. }
  68419. declare module BABYLON {
  68420. /** @hidden */
  68421. export var cloudProceduralTexturePixelShader: {
  68422. name: string;
  68423. shader: string;
  68424. };
  68425. }
  68426. declare module BABYLON {
  68427. export class CloudProceduralTexture extends BABYLON.ProceduralTexture {
  68428. private _skyColor;
  68429. private _cloudColor;
  68430. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  68431. updateShaderUniforms(): void;
  68432. skyColor: BABYLON.Color4;
  68433. cloudColor: BABYLON.Color4;
  68434. /**
  68435. * Serializes this cloud procedural texture
  68436. * @returns a serialized cloud procedural texture object
  68437. */
  68438. serialize(): any;
  68439. /**
  68440. * Creates a Cloud Procedural BABYLON.Texture from parsed cloud procedural texture data
  68441. * @param parsedTexture defines parsed texture data
  68442. * @param scene defines the current scene
  68443. * @param rootUrl defines the root URL containing cloud procedural texture information
  68444. * @returns a parsed Cloud Procedural BABYLON.Texture
  68445. */
  68446. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): CloudProceduralTexture;
  68447. }
  68448. }
  68449. declare module BABYLON {
  68450. /** @hidden */
  68451. export var fireProceduralTexturePixelShader: {
  68452. name: string;
  68453. shader: string;
  68454. };
  68455. }
  68456. declare module BABYLON {
  68457. export class FireProceduralTexture extends BABYLON.ProceduralTexture {
  68458. private _time;
  68459. private _speed;
  68460. private _autoGenerateTime;
  68461. private _fireColors;
  68462. private _alphaThreshold;
  68463. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  68464. updateShaderUniforms(): void;
  68465. render(useCameraPostProcess?: boolean): void;
  68466. static readonly PurpleFireColors: BABYLON.Color3[];
  68467. static readonly GreenFireColors: BABYLON.Color3[];
  68468. static readonly RedFireColors: BABYLON.Color3[];
  68469. static readonly BlueFireColors: BABYLON.Color3[];
  68470. autoGenerateTime: boolean;
  68471. fireColors: BABYLON.Color3[];
  68472. time: number;
  68473. speed: BABYLON.Vector2;
  68474. alphaThreshold: number;
  68475. /**
  68476. * Serializes this fire procedural texture
  68477. * @returns a serialized fire procedural texture object
  68478. */
  68479. serialize(): any;
  68480. /**
  68481. * Creates a Fire Procedural BABYLON.Texture from parsed fire procedural texture data
  68482. * @param parsedTexture defines parsed texture data
  68483. * @param scene defines the current scene
  68484. * @param rootUrl defines the root URL containing fire procedural texture information
  68485. * @returns a parsed Fire Procedural BABYLON.Texture
  68486. */
  68487. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): FireProceduralTexture;
  68488. }
  68489. }
  68490. declare module BABYLON {
  68491. /** @hidden */
  68492. export var grassProceduralTexturePixelShader: {
  68493. name: string;
  68494. shader: string;
  68495. };
  68496. }
  68497. declare module BABYLON {
  68498. export class GrassProceduralTexture extends BABYLON.ProceduralTexture {
  68499. private _grassColors;
  68500. private _groundColor;
  68501. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  68502. updateShaderUniforms(): void;
  68503. grassColors: BABYLON.Color3[];
  68504. groundColor: BABYLON.Color3;
  68505. /**
  68506. * Serializes this grass procedural texture
  68507. * @returns a serialized grass procedural texture object
  68508. */
  68509. serialize(): any;
  68510. /**
  68511. * Creates a Grass Procedural BABYLON.Texture from parsed grass procedural texture data
  68512. * @param parsedTexture defines parsed texture data
  68513. * @param scene defines the current scene
  68514. * @param rootUrl defines the root URL containing grass procedural texture information
  68515. * @returns a parsed Grass Procedural BABYLON.Texture
  68516. */
  68517. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): GrassProceduralTexture;
  68518. }
  68519. }
  68520. declare module BABYLON {
  68521. /** @hidden */
  68522. export var marbleProceduralTexturePixelShader: {
  68523. name: string;
  68524. shader: string;
  68525. };
  68526. }
  68527. declare module BABYLON {
  68528. export class MarbleProceduralTexture extends BABYLON.ProceduralTexture {
  68529. private _numberOfTilesHeight;
  68530. private _numberOfTilesWidth;
  68531. private _amplitude;
  68532. private _jointColor;
  68533. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  68534. updateShaderUniforms(): void;
  68535. numberOfTilesHeight: number;
  68536. amplitude: number;
  68537. numberOfTilesWidth: number;
  68538. jointColor: BABYLON.Color3;
  68539. /**
  68540. * Serializes this marble procedural texture
  68541. * @returns a serialized marble procedural texture object
  68542. */
  68543. serialize(): any;
  68544. /**
  68545. * Creates a Marble Procedural BABYLON.Texture from parsed marble procedural texture data
  68546. * @param parsedTexture defines parsed texture data
  68547. * @param scene defines the current scene
  68548. * @param rootUrl defines the root URL containing marble procedural texture information
  68549. * @returns a parsed Marble Procedural BABYLON.Texture
  68550. */
  68551. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): MarbleProceduralTexture;
  68552. }
  68553. }
  68554. declare module BABYLON {
  68555. /** @hidden */
  68556. export var normalMapProceduralTexturePixelShader: {
  68557. name: string;
  68558. shader: string;
  68559. };
  68560. }
  68561. declare module BABYLON {
  68562. export class NormalMapProceduralTexture extends BABYLON.ProceduralTexture {
  68563. private _baseTexture;
  68564. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  68565. updateShaderUniforms(): void;
  68566. render(useCameraPostProcess?: boolean): void;
  68567. resize(size: any, generateMipMaps: any): void;
  68568. baseTexture: BABYLON.Texture;
  68569. /**
  68570. * Serializes this normal map procedural texture
  68571. * @returns a serialized normal map procedural texture object
  68572. */
  68573. serialize(): any;
  68574. /**
  68575. * Creates a Normal Map Procedural BABYLON.Texture from parsed normal map procedural texture data
  68576. * @param parsedTexture defines parsed texture data
  68577. * @param scene defines the current scene
  68578. * @param rootUrl defines the root URL containing normal map procedural texture information
  68579. * @returns a parsed Normal Map Procedural BABYLON.Texture
  68580. */
  68581. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): NormalMapProceduralTexture;
  68582. }
  68583. }
  68584. declare module BABYLON {
  68585. /** @hidden */
  68586. export var perlinNoiseProceduralTexturePixelShader: {
  68587. name: string;
  68588. shader: string;
  68589. };
  68590. }
  68591. declare module BABYLON {
  68592. export class PerlinNoiseProceduralTexture extends BABYLON.ProceduralTexture {
  68593. time: number;
  68594. timeScale: number;
  68595. translationSpeed: number;
  68596. private _currentTranslation;
  68597. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  68598. updateShaderUniforms(): void;
  68599. render(useCameraPostProcess?: boolean): void;
  68600. resize(size: any, generateMipMaps: any): void;
  68601. /**
  68602. * Serializes this perlin noise procedural texture
  68603. * @returns a serialized perlin noise procedural texture object
  68604. */
  68605. serialize(): any;
  68606. /**
  68607. * Creates a Perlin Noise Procedural BABYLON.Texture from parsed perlin noise procedural texture data
  68608. * @param parsedTexture defines parsed texture data
  68609. * @param scene defines the current scene
  68610. * @param rootUrl defines the root URL containing perlin noise procedural texture information
  68611. * @returns a parsed Perlin Noise Procedural BABYLON.Texture
  68612. */
  68613. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): PerlinNoiseProceduralTexture;
  68614. }
  68615. }
  68616. declare module BABYLON {
  68617. /** @hidden */
  68618. export var roadProceduralTexturePixelShader: {
  68619. name: string;
  68620. shader: string;
  68621. };
  68622. }
  68623. declare module BABYLON {
  68624. export class RoadProceduralTexture extends BABYLON.ProceduralTexture {
  68625. private _roadColor;
  68626. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  68627. updateShaderUniforms(): void;
  68628. roadColor: BABYLON.Color3;
  68629. /**
  68630. * Serializes this road procedural texture
  68631. * @returns a serialized road procedural texture object
  68632. */
  68633. serialize(): any;
  68634. /**
  68635. * Creates a Road Procedural BABYLON.Texture from parsed road procedural texture data
  68636. * @param parsedTexture defines parsed texture data
  68637. * @param scene defines the current scene
  68638. * @param rootUrl defines the root URL containing road procedural texture information
  68639. * @returns a parsed Road Procedural BABYLON.Texture
  68640. */
  68641. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): RoadProceduralTexture;
  68642. }
  68643. }
  68644. declare module BABYLON {
  68645. /** @hidden */
  68646. export var starfieldProceduralTexturePixelShader: {
  68647. name: string;
  68648. shader: string;
  68649. };
  68650. }
  68651. declare module BABYLON {
  68652. export class StarfieldProceduralTexture extends BABYLON.ProceduralTexture {
  68653. private _time;
  68654. private _alpha;
  68655. private _beta;
  68656. private _zoom;
  68657. private _formuparam;
  68658. private _stepsize;
  68659. private _tile;
  68660. private _brightness;
  68661. private _darkmatter;
  68662. private _distfading;
  68663. private _saturation;
  68664. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  68665. updateShaderUniforms(): void;
  68666. time: number;
  68667. alpha: number;
  68668. beta: number;
  68669. formuparam: number;
  68670. stepsize: number;
  68671. zoom: number;
  68672. tile: number;
  68673. brightness: number;
  68674. darkmatter: number;
  68675. distfading: number;
  68676. saturation: number;
  68677. /**
  68678. * Serializes this starfield procedural texture
  68679. * @returns a serialized starfield procedural texture object
  68680. */
  68681. serialize(): any;
  68682. /**
  68683. * Creates a Starfield Procedural BABYLON.Texture from parsed startfield procedural texture data
  68684. * @param parsedTexture defines parsed texture data
  68685. * @param scene defines the current scene
  68686. * @param rootUrl defines the root URL containing startfield procedural texture information
  68687. * @returns a parsed Starfield Procedural BABYLON.Texture
  68688. */
  68689. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): StarfieldProceduralTexture;
  68690. }
  68691. }
  68692. declare module BABYLON {
  68693. /** @hidden */
  68694. export var woodProceduralTexturePixelShader: {
  68695. name: string;
  68696. shader: string;
  68697. };
  68698. }
  68699. declare module BABYLON {
  68700. export class WoodProceduralTexture extends BABYLON.ProceduralTexture {
  68701. private _ampScale;
  68702. private _woodColor;
  68703. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  68704. updateShaderUniforms(): void;
  68705. ampScale: number;
  68706. woodColor: BABYLON.Color3;
  68707. /**
  68708. * Serializes this wood procedural texture
  68709. * @returns a serialized wood procedural texture object
  68710. */
  68711. serialize(): any;
  68712. /**
  68713. * Creates a Wood Procedural BABYLON.Texture from parsed wood procedural texture data
  68714. * @param parsedTexture defines parsed texture data
  68715. * @param scene defines the current scene
  68716. * @param rootUrl defines the root URL containing wood procedural texture information
  68717. * @returns a parsed Wood Procedural BABYLON.Texture
  68718. */
  68719. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): WoodProceduralTexture;
  68720. }
  68721. }