documentation.d.ts 3.0 MB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010270112701227013270142701527016270172701827019270202702127022270232702427025270262702727028270292703027031270322703327034270352703627037270382703927040270412704227043270442704527046270472704827049270502705127052270532705427055270562705727058270592706027061270622706327064270652706627067270682706927070270712707227073270742707527076270772707827079270802708127082270832708427085270862708727088270892709027091270922709327094270952709627097270982709927100271012710227103271042710527106271072710827109271102711127112271132711427115271162711727118271192712027121271222712327124271252712627127271282712927130271312713227133271342713527136271372713827139271402714127142271432714427145271462714727148271492715027151271522715327154271552715627157271582715927160271612716227163271642716527166271672716827169271702717127172271732717427175271762717727178271792718027181271822718327184271852718627187271882718927190271912719227193271942719527196271972719827199272002720127202272032720427205272062720727208272092721027211272122721327214272152721627217272182721927220272212722227223272242722527226272272722827229272302723127232272332723427235272362723727238272392724027241272422724327244272452724627247272482724927250272512725227253272542725527256272572725827259272602726127262272632726427265272662726727268272692727027271272722727327274272752727627277272782727927280272812728227283272842728527286272872728827289272902729127292272932729427295272962729727298272992730027301273022730327304273052730627307273082730927310273112731227313273142731527316273172731827319273202732127322273232732427325273262732727328273292733027331273322733327334273352733627337273382733927340273412734227343273442734527346273472734827349273502735127352273532735427355273562735727358273592736027361273622736327364273652736627367273682736927370273712737227373273742737527376273772737827379273802738127382273832738427385273862738727388273892739027391273922739327394273952739627397273982739927400274012740227403274042740527406274072740827409274102741127412274132741427415274162741727418274192742027421274222742327424274252742627427274282742927430274312743227433274342743527436274372743827439274402744127442274432744427445274462744727448274492745027451274522745327454274552745627457274582745927460274612746227463274642746527466274672746827469274702747127472274732747427475274762747727478274792748027481274822748327484274852748627487274882748927490274912749227493274942749527496274972749827499275002750127502275032750427505275062750727508275092751027511275122751327514275152751627517275182751927520275212752227523275242752527526275272752827529275302753127532275332753427535275362753727538275392754027541275422754327544275452754627547275482754927550275512755227553275542755527556275572755827559275602756127562275632756427565275662756727568275692757027571275722757327574275752757627577275782757927580275812758227583275842758527586275872758827589275902759127592275932759427595275962759727598275992760027601276022760327604276052760627607276082760927610276112761227613276142761527616276172761827619276202762127622276232762427625276262762727628276292763027631276322763327634276352763627637276382763927640276412764227643276442764527646276472764827649276502765127652276532765427655276562765727658276592766027661276622766327664276652766627667276682766927670276712767227673276742767527676276772767827679276802768127682276832768427685276862768727688276892769027691276922769327694276952769627697276982769927700277012770227703277042770527706277072770827709277102771127712277132771427715277162771727718277192772027721277222772327724277252772627727277282772927730277312773227733277342773527736277372773827739277402774127742277432774427745277462774727748277492775027751277522775327754277552775627757277582775927760277612776227763277642776527766277672776827769277702777127772277732777427775277762777727778277792778027781277822778327784277852778627787277882778927790277912779227793277942779527796277972779827799278002780127802278032780427805278062780727808278092781027811278122781327814278152781627817278182781927820278212782227823278242782527826278272782827829278302783127832278332783427835278362783727838278392784027841278422784327844278452784627847278482784927850278512785227853278542785527856278572785827859278602786127862278632786427865278662786727868278692787027871278722787327874278752787627877278782787927880278812788227883278842788527886278872788827889278902789127892278932789427895278962789727898278992790027901279022790327904279052790627907279082790927910279112791227913279142791527916279172791827919279202792127922279232792427925279262792727928279292793027931279322793327934279352793627937279382793927940279412794227943279442794527946279472794827949279502795127952279532795427955279562795727958279592796027961279622796327964279652796627967279682796927970279712797227973279742797527976279772797827979279802798127982279832798427985279862798727988279892799027991279922799327994279952799627997279982799928000280012800228003280042800528006280072800828009280102801128012280132801428015280162801728018280192802028021280222802328024280252802628027280282802928030280312803228033280342803528036280372803828039280402804128042280432804428045280462804728048280492805028051280522805328054280552805628057280582805928060280612806228063280642806528066280672806828069280702807128072280732807428075280762807728078280792808028081280822808328084280852808628087280882808928090280912809228093280942809528096280972809828099281002810128102281032810428105281062810728108281092811028111281122811328114281152811628117281182811928120281212812228123281242812528126281272812828129281302813128132281332813428135281362813728138281392814028141281422814328144281452814628147281482814928150281512815228153281542815528156281572815828159281602816128162281632816428165281662816728168281692817028171281722817328174281752817628177281782817928180281812818228183281842818528186281872818828189281902819128192281932819428195281962819728198281992820028201282022820328204282052820628207282082820928210282112821228213282142821528216282172821828219282202822128222282232822428225282262822728228282292823028231282322823328234282352823628237282382823928240282412824228243282442824528246282472824828249282502825128252282532825428255282562825728258282592826028261282622826328264282652826628267282682826928270282712827228273282742827528276282772827828279282802828128282282832828428285282862828728288282892829028291282922829328294282952829628297282982829928300283012830228303283042830528306283072830828309283102831128312283132831428315283162831728318283192832028321283222832328324283252832628327283282832928330283312833228333283342833528336283372833828339283402834128342283432834428345283462834728348283492835028351283522835328354283552835628357283582835928360283612836228363283642836528366283672836828369283702837128372283732837428375283762837728378283792838028381283822838328384283852838628387283882838928390283912839228393283942839528396283972839828399284002840128402284032840428405284062840728408284092841028411284122841328414284152841628417284182841928420284212842228423284242842528426284272842828429284302843128432284332843428435284362843728438284392844028441284422844328444284452844628447284482844928450284512845228453284542845528456284572845828459284602846128462284632846428465284662846728468284692847028471284722847328474284752847628477284782847928480284812848228483284842848528486284872848828489284902849128492284932849428495284962849728498284992850028501285022850328504285052850628507285082850928510285112851228513285142851528516285172851828519285202852128522285232852428525285262852728528285292853028531285322853328534285352853628537285382853928540285412854228543285442854528546285472854828549285502855128552285532855428555285562855728558285592856028561285622856328564285652856628567285682856928570285712857228573285742857528576285772857828579285802858128582285832858428585285862858728588285892859028591285922859328594285952859628597285982859928600286012860228603286042860528606286072860828609286102861128612286132861428615286162861728618286192862028621286222862328624286252862628627286282862928630286312863228633286342863528636286372863828639286402864128642286432864428645286462864728648286492865028651286522865328654286552865628657286582865928660286612866228663286642866528666286672866828669286702867128672286732867428675286762867728678286792868028681286822868328684286852868628687286882868928690286912869228693286942869528696286972869828699287002870128702287032870428705287062870728708287092871028711287122871328714287152871628717287182871928720287212872228723287242872528726287272872828729287302873128732287332873428735287362873728738287392874028741287422874328744287452874628747287482874928750287512875228753287542875528756287572875828759287602876128762287632876428765287662876728768287692877028771287722877328774287752877628777287782877928780287812878228783287842878528786287872878828789287902879128792287932879428795287962879728798287992880028801288022880328804288052880628807288082880928810288112881228813288142881528816288172881828819288202882128822288232882428825288262882728828288292883028831288322883328834288352883628837288382883928840288412884228843288442884528846288472884828849288502885128852288532885428855288562885728858288592886028861288622886328864288652886628867288682886928870288712887228873288742887528876288772887828879288802888128882288832888428885288862888728888288892889028891288922889328894288952889628897288982889928900289012890228903289042890528906289072890828909289102891128912289132891428915289162891728918289192892028921289222892328924289252892628927289282892928930289312893228933289342893528936289372893828939289402894128942289432894428945289462894728948289492895028951289522895328954289552895628957289582895928960289612896228963289642896528966289672896828969289702897128972289732897428975289762897728978289792898028981289822898328984289852898628987289882898928990289912899228993289942899528996289972899828999290002900129002290032900429005290062900729008290092901029011290122901329014290152901629017290182901929020290212902229023290242902529026290272902829029290302903129032290332903429035290362903729038290392904029041290422904329044290452904629047290482904929050290512905229053290542905529056290572905829059290602906129062290632906429065290662906729068290692907029071290722907329074290752907629077290782907929080290812908229083290842908529086290872908829089290902909129092290932909429095290962909729098290992910029101291022910329104291052910629107291082910929110291112911229113291142911529116291172911829119291202912129122291232912429125291262912729128291292913029131291322913329134291352913629137291382913929140291412914229143291442914529146291472914829149291502915129152291532915429155291562915729158291592916029161291622916329164291652916629167291682916929170291712917229173291742917529176291772917829179291802918129182291832918429185291862918729188291892919029191291922919329194291952919629197291982919929200292012920229203292042920529206292072920829209292102921129212292132921429215292162921729218292192922029221292222922329224292252922629227292282922929230292312923229233292342923529236292372923829239292402924129242292432924429245292462924729248292492925029251292522925329254292552925629257292582925929260292612926229263292642926529266292672926829269292702927129272292732927429275292762927729278292792928029281292822928329284292852928629287292882928929290292912929229293292942929529296292972929829299293002930129302293032930429305293062930729308293092931029311293122931329314293152931629317293182931929320293212932229323293242932529326293272932829329293302933129332293332933429335293362933729338293392934029341293422934329344293452934629347293482934929350293512935229353293542935529356293572935829359293602936129362293632936429365293662936729368293692937029371293722937329374293752937629377293782937929380293812938229383293842938529386293872938829389293902939129392293932939429395293962939729398293992940029401294022940329404294052940629407294082940929410294112941229413294142941529416294172941829419294202942129422294232942429425294262942729428294292943029431294322943329434294352943629437294382943929440294412944229443294442944529446294472944829449294502945129452294532945429455294562945729458294592946029461294622946329464294652946629467294682946929470294712947229473294742947529476294772947829479294802948129482294832948429485294862948729488294892949029491294922949329494294952949629497294982949929500295012950229503295042950529506295072950829509295102951129512295132951429515295162951729518295192952029521295222952329524295252952629527295282952929530295312953229533295342953529536295372953829539295402954129542295432954429545295462954729548295492955029551295522955329554295552955629557295582955929560295612956229563295642956529566295672956829569295702957129572295732957429575295762957729578295792958029581295822958329584295852958629587295882958929590295912959229593295942959529596295972959829599296002960129602296032960429605296062960729608296092961029611296122961329614296152961629617296182961929620296212962229623296242962529626296272962829629296302963129632296332963429635296362963729638296392964029641296422964329644296452964629647296482964929650296512965229653296542965529656296572965829659296602966129662296632966429665296662966729668296692967029671296722967329674296752967629677296782967929680296812968229683296842968529686296872968829689296902969129692296932969429695296962969729698296992970029701297022970329704297052970629707297082970929710297112971229713297142971529716297172971829719297202972129722297232972429725297262972729728297292973029731297322973329734297352973629737297382973929740297412974229743297442974529746297472974829749297502975129752297532975429755297562975729758297592976029761297622976329764297652976629767297682976929770297712977229773297742977529776297772977829779297802978129782297832978429785297862978729788297892979029791297922979329794297952979629797297982979929800298012980229803298042980529806298072980829809298102981129812298132981429815298162981729818298192982029821298222982329824298252982629827298282982929830298312983229833298342983529836298372983829839298402984129842298432984429845298462984729848298492985029851298522985329854298552985629857298582985929860298612986229863298642986529866298672986829869298702987129872298732987429875298762987729878298792988029881298822988329884298852988629887298882988929890298912989229893298942989529896298972989829899299002990129902299032990429905299062990729908299092991029911299122991329914299152991629917299182991929920299212992229923299242992529926299272992829929299302993129932299332993429935299362993729938299392994029941299422994329944299452994629947299482994929950299512995229953299542995529956299572995829959299602996129962299632996429965299662996729968299692997029971299722997329974299752997629977299782997929980299812998229983299842998529986299872998829989299902999129992299932999429995299962999729998299993000030001300023000330004300053000630007300083000930010300113001230013300143001530016300173001830019300203002130022300233002430025300263002730028300293003030031300323003330034300353003630037300383003930040300413004230043300443004530046300473004830049300503005130052300533005430055300563005730058300593006030061300623006330064300653006630067300683006930070300713007230073300743007530076300773007830079300803008130082300833008430085300863008730088300893009030091300923009330094300953009630097300983009930100301013010230103301043010530106301073010830109301103011130112301133011430115301163011730118301193012030121301223012330124301253012630127301283012930130301313013230133301343013530136301373013830139301403014130142301433014430145301463014730148301493015030151301523015330154301553015630157301583015930160301613016230163301643016530166301673016830169301703017130172301733017430175301763017730178301793018030181301823018330184301853018630187301883018930190301913019230193301943019530196301973019830199302003020130202302033020430205302063020730208302093021030211302123021330214302153021630217302183021930220302213022230223302243022530226302273022830229302303023130232302333023430235302363023730238302393024030241302423024330244302453024630247302483024930250302513025230253302543025530256302573025830259302603026130262302633026430265302663026730268302693027030271302723027330274302753027630277302783027930280302813028230283302843028530286302873028830289302903029130292302933029430295302963029730298302993030030301303023030330304303053030630307303083030930310303113031230313303143031530316303173031830319303203032130322303233032430325303263032730328303293033030331303323033330334303353033630337303383033930340303413034230343303443034530346303473034830349303503035130352303533035430355303563035730358303593036030361303623036330364303653036630367303683036930370303713037230373303743037530376303773037830379303803038130382303833038430385303863038730388303893039030391303923039330394303953039630397303983039930400304013040230403304043040530406304073040830409304103041130412304133041430415304163041730418304193042030421304223042330424304253042630427304283042930430304313043230433304343043530436304373043830439304403044130442304433044430445304463044730448304493045030451304523045330454304553045630457304583045930460304613046230463304643046530466304673046830469304703047130472304733047430475304763047730478304793048030481304823048330484304853048630487304883048930490304913049230493304943049530496304973049830499305003050130502305033050430505305063050730508305093051030511305123051330514305153051630517305183051930520305213052230523305243052530526305273052830529305303053130532305333053430535305363053730538305393054030541305423054330544305453054630547305483054930550305513055230553305543055530556305573055830559305603056130562305633056430565305663056730568305693057030571305723057330574305753057630577305783057930580305813058230583305843058530586305873058830589305903059130592305933059430595305963059730598305993060030601306023060330604306053060630607306083060930610306113061230613306143061530616306173061830619306203062130622306233062430625306263062730628306293063030631306323063330634306353063630637306383063930640306413064230643306443064530646306473064830649306503065130652306533065430655306563065730658306593066030661306623066330664306653066630667306683066930670306713067230673306743067530676306773067830679306803068130682306833068430685306863068730688306893069030691306923069330694306953069630697306983069930700307013070230703307043070530706307073070830709307103071130712307133071430715307163071730718307193072030721307223072330724307253072630727307283072930730307313073230733307343073530736307373073830739307403074130742307433074430745307463074730748307493075030751307523075330754307553075630757307583075930760307613076230763307643076530766307673076830769307703077130772307733077430775307763077730778307793078030781307823078330784307853078630787307883078930790307913079230793307943079530796307973079830799308003080130802308033080430805308063080730808308093081030811308123081330814308153081630817308183081930820308213082230823308243082530826308273082830829308303083130832308333083430835308363083730838308393084030841308423084330844308453084630847308483084930850308513085230853308543085530856308573085830859308603086130862308633086430865308663086730868308693087030871308723087330874308753087630877308783087930880308813088230883308843088530886308873088830889308903089130892308933089430895308963089730898308993090030901309023090330904309053090630907309083090930910309113091230913309143091530916309173091830919309203092130922309233092430925309263092730928309293093030931309323093330934309353093630937309383093930940309413094230943309443094530946309473094830949309503095130952309533095430955309563095730958309593096030961309623096330964309653096630967309683096930970309713097230973309743097530976309773097830979309803098130982309833098430985309863098730988309893099030991309923099330994309953099630997309983099931000310013100231003310043100531006310073100831009310103101131012310133101431015310163101731018310193102031021310223102331024310253102631027310283102931030310313103231033310343103531036310373103831039310403104131042310433104431045310463104731048310493105031051310523105331054310553105631057310583105931060310613106231063310643106531066310673106831069310703107131072310733107431075310763107731078310793108031081310823108331084310853108631087310883108931090310913109231093310943109531096310973109831099311003110131102311033110431105311063110731108311093111031111311123111331114311153111631117311183111931120311213112231123311243112531126311273112831129311303113131132311333113431135311363113731138311393114031141311423114331144311453114631147311483114931150311513115231153311543115531156311573115831159311603116131162311633116431165311663116731168311693117031171311723117331174311753117631177311783117931180311813118231183311843118531186311873118831189311903119131192311933119431195311963119731198311993120031201312023120331204312053120631207312083120931210312113121231213312143121531216312173121831219312203122131222312233122431225312263122731228312293123031231312323123331234312353123631237312383123931240312413124231243312443124531246312473124831249312503125131252312533125431255312563125731258312593126031261312623126331264312653126631267312683126931270312713127231273312743127531276312773127831279312803128131282312833128431285312863128731288312893129031291312923129331294312953129631297312983129931300313013130231303313043130531306313073130831309313103131131312313133131431315313163131731318313193132031321313223132331324313253132631327313283132931330313313133231333313343133531336313373133831339313403134131342313433134431345313463134731348313493135031351313523135331354313553135631357313583135931360313613136231363313643136531366313673136831369313703137131372313733137431375313763137731378313793138031381313823138331384313853138631387313883138931390313913139231393313943139531396313973139831399314003140131402314033140431405314063140731408314093141031411314123141331414314153141631417314183141931420314213142231423314243142531426314273142831429314303143131432314333143431435314363143731438314393144031441314423144331444314453144631447314483144931450314513145231453314543145531456314573145831459314603146131462314633146431465314663146731468314693147031471314723147331474314753147631477314783147931480314813148231483314843148531486314873148831489314903149131492314933149431495314963149731498314993150031501315023150331504315053150631507315083150931510315113151231513315143151531516315173151831519315203152131522315233152431525315263152731528315293153031531315323153331534315353153631537315383153931540315413154231543315443154531546315473154831549315503155131552315533155431555315563155731558315593156031561315623156331564315653156631567315683156931570315713157231573315743157531576315773157831579315803158131582315833158431585315863158731588315893159031591315923159331594315953159631597315983159931600316013160231603316043160531606316073160831609316103161131612316133161431615316163161731618316193162031621316223162331624316253162631627316283162931630316313163231633316343163531636316373163831639316403164131642316433164431645316463164731648316493165031651316523165331654316553165631657316583165931660316613166231663316643166531666316673166831669316703167131672316733167431675316763167731678316793168031681316823168331684316853168631687316883168931690316913169231693316943169531696316973169831699317003170131702317033170431705317063170731708317093171031711317123171331714317153171631717317183171931720317213172231723317243172531726317273172831729317303173131732317333173431735317363173731738317393174031741317423174331744317453174631747317483174931750317513175231753317543175531756317573175831759317603176131762317633176431765317663176731768317693177031771317723177331774317753177631777317783177931780317813178231783317843178531786317873178831789317903179131792317933179431795317963179731798317993180031801318023180331804318053180631807318083180931810318113181231813318143181531816318173181831819318203182131822318233182431825318263182731828318293183031831318323183331834318353183631837318383183931840318413184231843318443184531846318473184831849318503185131852318533185431855318563185731858318593186031861318623186331864318653186631867318683186931870318713187231873318743187531876318773187831879318803188131882318833188431885318863188731888318893189031891318923189331894318953189631897318983189931900319013190231903319043190531906319073190831909319103191131912319133191431915319163191731918319193192031921319223192331924319253192631927319283192931930319313193231933319343193531936319373193831939319403194131942319433194431945319463194731948319493195031951319523195331954319553195631957319583195931960319613196231963319643196531966319673196831969319703197131972319733197431975319763197731978319793198031981319823198331984319853198631987319883198931990319913199231993319943199531996319973199831999320003200132002320033200432005320063200732008320093201032011320123201332014320153201632017320183201932020320213202232023320243202532026320273202832029320303203132032320333203432035320363203732038320393204032041320423204332044320453204632047320483204932050320513205232053320543205532056320573205832059320603206132062320633206432065320663206732068320693207032071320723207332074320753207632077320783207932080320813208232083320843208532086320873208832089320903209132092320933209432095320963209732098320993210032101321023210332104321053210632107321083210932110321113211232113321143211532116321173211832119321203212132122321233212432125321263212732128321293213032131321323213332134321353213632137321383213932140321413214232143321443214532146321473214832149321503215132152321533215432155321563215732158321593216032161321623216332164321653216632167321683216932170321713217232173321743217532176321773217832179321803218132182321833218432185321863218732188321893219032191321923219332194321953219632197321983219932200322013220232203322043220532206322073220832209322103221132212322133221432215322163221732218322193222032221322223222332224322253222632227322283222932230322313223232233322343223532236322373223832239322403224132242322433224432245322463224732248322493225032251322523225332254322553225632257322583225932260322613226232263322643226532266322673226832269322703227132272322733227432275322763227732278322793228032281322823228332284322853228632287322883228932290322913229232293322943229532296322973229832299323003230132302323033230432305323063230732308323093231032311323123231332314323153231632317323183231932320323213232232323323243232532326323273232832329323303233132332323333233432335323363233732338323393234032341323423234332344323453234632347323483234932350323513235232353323543235532356323573235832359323603236132362323633236432365323663236732368323693237032371323723237332374323753237632377323783237932380323813238232383323843238532386323873238832389323903239132392323933239432395323963239732398323993240032401324023240332404324053240632407324083240932410324113241232413324143241532416324173241832419324203242132422324233242432425324263242732428324293243032431324323243332434324353243632437324383243932440324413244232443324443244532446324473244832449324503245132452324533245432455324563245732458324593246032461324623246332464324653246632467324683246932470324713247232473324743247532476324773247832479324803248132482324833248432485324863248732488324893249032491324923249332494324953249632497324983249932500325013250232503325043250532506325073250832509325103251132512325133251432515325163251732518325193252032521325223252332524325253252632527325283252932530325313253232533325343253532536325373253832539325403254132542325433254432545325463254732548325493255032551325523255332554325553255632557325583255932560325613256232563325643256532566325673256832569325703257132572325733257432575325763257732578325793258032581325823258332584325853258632587325883258932590325913259232593325943259532596325973259832599326003260132602326033260432605326063260732608326093261032611326123261332614326153261632617326183261932620326213262232623326243262532626326273262832629326303263132632326333263432635326363263732638326393264032641326423264332644326453264632647326483264932650326513265232653326543265532656326573265832659326603266132662326633266432665326663266732668326693267032671326723267332674326753267632677326783267932680326813268232683326843268532686326873268832689326903269132692326933269432695326963269732698326993270032701327023270332704327053270632707327083270932710327113271232713327143271532716327173271832719327203272132722327233272432725327263272732728327293273032731327323273332734327353273632737327383273932740327413274232743327443274532746327473274832749327503275132752327533275432755327563275732758327593276032761327623276332764327653276632767327683276932770327713277232773327743277532776327773277832779327803278132782327833278432785327863278732788327893279032791327923279332794327953279632797327983279932800328013280232803328043280532806328073280832809328103281132812328133281432815328163281732818328193282032821328223282332824328253282632827328283282932830328313283232833328343283532836328373283832839328403284132842328433284432845328463284732848328493285032851328523285332854328553285632857328583285932860328613286232863328643286532866328673286832869328703287132872328733287432875328763287732878328793288032881328823288332884328853288632887328883288932890328913289232893328943289532896328973289832899329003290132902329033290432905329063290732908329093291032911329123291332914329153291632917329183291932920329213292232923329243292532926329273292832929329303293132932329333293432935329363293732938329393294032941329423294332944329453294632947329483294932950329513295232953329543295532956329573295832959329603296132962329633296432965329663296732968329693297032971329723297332974329753297632977329783297932980329813298232983329843298532986329873298832989329903299132992329933299432995329963299732998329993300033001330023300333004330053300633007330083300933010330113301233013330143301533016330173301833019330203302133022330233302433025330263302733028330293303033031330323303333034330353303633037330383303933040330413304233043330443304533046330473304833049330503305133052330533305433055330563305733058330593306033061330623306333064330653306633067330683306933070330713307233073330743307533076330773307833079330803308133082330833308433085330863308733088330893309033091330923309333094330953309633097330983309933100331013310233103331043310533106331073310833109331103311133112331133311433115331163311733118331193312033121331223312333124331253312633127331283312933130331313313233133331343313533136331373313833139331403314133142331433314433145331463314733148331493315033151331523315333154331553315633157331583315933160331613316233163331643316533166331673316833169331703317133172331733317433175331763317733178331793318033181331823318333184331853318633187331883318933190331913319233193331943319533196331973319833199332003320133202332033320433205332063320733208332093321033211332123321333214332153321633217332183321933220332213322233223332243322533226332273322833229332303323133232332333323433235332363323733238332393324033241332423324333244332453324633247332483324933250332513325233253332543325533256332573325833259332603326133262332633326433265332663326733268332693327033271332723327333274332753327633277332783327933280332813328233283332843328533286332873328833289332903329133292332933329433295332963329733298332993330033301333023330333304333053330633307333083330933310333113331233313333143331533316333173331833319333203332133322333233332433325333263332733328333293333033331333323333333334333353333633337333383333933340333413334233343333443334533346333473334833349333503335133352333533335433355333563335733358333593336033361333623336333364333653336633367333683336933370333713337233373333743337533376333773337833379333803338133382333833338433385333863338733388333893339033391333923339333394333953339633397333983339933400334013340233403334043340533406334073340833409334103341133412334133341433415334163341733418334193342033421334223342333424334253342633427334283342933430334313343233433334343343533436334373343833439334403344133442334433344433445334463344733448334493345033451334523345333454334553345633457334583345933460334613346233463334643346533466334673346833469334703347133472334733347433475334763347733478334793348033481334823348333484334853348633487334883348933490334913349233493334943349533496334973349833499335003350133502335033350433505335063350733508335093351033511335123351333514335153351633517335183351933520335213352233523335243352533526335273352833529335303353133532335333353433535335363353733538335393354033541335423354333544335453354633547335483354933550335513355233553335543355533556335573355833559335603356133562335633356433565335663356733568335693357033571335723357333574335753357633577335783357933580335813358233583335843358533586335873358833589335903359133592335933359433595335963359733598335993360033601336023360333604336053360633607336083360933610336113361233613336143361533616336173361833619336203362133622336233362433625336263362733628336293363033631336323363333634336353363633637336383363933640336413364233643336443364533646336473364833649336503365133652336533365433655336563365733658336593366033661336623366333664336653366633667336683366933670336713367233673336743367533676336773367833679336803368133682336833368433685336863368733688336893369033691336923369333694336953369633697336983369933700337013370233703337043370533706337073370833709337103371133712337133371433715337163371733718337193372033721337223372333724337253372633727337283372933730337313373233733337343373533736337373373833739337403374133742337433374433745337463374733748337493375033751337523375333754337553375633757337583375933760337613376233763337643376533766337673376833769337703377133772337733377433775337763377733778337793378033781337823378333784337853378633787337883378933790337913379233793337943379533796337973379833799338003380133802338033380433805338063380733808338093381033811338123381333814338153381633817338183381933820338213382233823338243382533826338273382833829338303383133832338333383433835338363383733838338393384033841338423384333844338453384633847338483384933850338513385233853338543385533856338573385833859338603386133862338633386433865338663386733868338693387033871338723387333874338753387633877338783387933880338813388233883338843388533886338873388833889338903389133892338933389433895338963389733898338993390033901339023390333904339053390633907339083390933910339113391233913339143391533916339173391833919339203392133922339233392433925339263392733928339293393033931339323393333934339353393633937339383393933940339413394233943339443394533946339473394833949339503395133952339533395433955339563395733958339593396033961339623396333964339653396633967339683396933970339713397233973339743397533976339773397833979339803398133982339833398433985339863398733988339893399033991339923399333994339953399633997339983399934000340013400234003340043400534006340073400834009340103401134012340133401434015340163401734018340193402034021340223402334024340253402634027340283402934030340313403234033340343403534036340373403834039340403404134042340433404434045340463404734048340493405034051340523405334054340553405634057340583405934060340613406234063340643406534066340673406834069340703407134072340733407434075340763407734078340793408034081340823408334084340853408634087340883408934090340913409234093340943409534096340973409834099341003410134102341033410434105341063410734108341093411034111341123411334114341153411634117341183411934120341213412234123341243412534126341273412834129341303413134132341333413434135341363413734138341393414034141341423414334144341453414634147341483414934150341513415234153341543415534156341573415834159341603416134162341633416434165341663416734168341693417034171341723417334174341753417634177341783417934180341813418234183341843418534186341873418834189341903419134192341933419434195341963419734198341993420034201342023420334204342053420634207342083420934210342113421234213342143421534216342173421834219342203422134222342233422434225342263422734228342293423034231342323423334234342353423634237342383423934240342413424234243342443424534246342473424834249342503425134252342533425434255342563425734258342593426034261342623426334264342653426634267342683426934270342713427234273342743427534276342773427834279342803428134282342833428434285342863428734288342893429034291342923429334294342953429634297342983429934300343013430234303343043430534306343073430834309343103431134312343133431434315343163431734318343193432034321343223432334324343253432634327343283432934330343313433234333343343433534336343373433834339343403434134342343433434434345343463434734348343493435034351343523435334354343553435634357343583435934360343613436234363343643436534366343673436834369343703437134372343733437434375343763437734378343793438034381343823438334384343853438634387343883438934390343913439234393343943439534396343973439834399344003440134402344033440434405344063440734408344093441034411344123441334414344153441634417344183441934420344213442234423344243442534426344273442834429344303443134432344333443434435344363443734438344393444034441344423444334444344453444634447344483444934450344513445234453344543445534456344573445834459344603446134462344633446434465344663446734468344693447034471344723447334474344753447634477344783447934480344813448234483344843448534486344873448834489344903449134492344933449434495344963449734498344993450034501345023450334504345053450634507345083450934510345113451234513345143451534516345173451834519345203452134522345233452434525345263452734528345293453034531345323453334534345353453634537345383453934540345413454234543345443454534546345473454834549345503455134552345533455434555345563455734558345593456034561345623456334564345653456634567345683456934570345713457234573345743457534576345773457834579345803458134582345833458434585345863458734588345893459034591345923459334594345953459634597345983459934600346013460234603346043460534606346073460834609346103461134612346133461434615346163461734618346193462034621346223462334624346253462634627346283462934630346313463234633346343463534636346373463834639346403464134642346433464434645346463464734648346493465034651346523465334654346553465634657346583465934660346613466234663346643466534666346673466834669346703467134672346733467434675346763467734678346793468034681346823468334684346853468634687346883468934690346913469234693346943469534696346973469834699347003470134702347033470434705347063470734708347093471034711347123471334714347153471634717347183471934720347213472234723347243472534726347273472834729347303473134732347333473434735347363473734738347393474034741347423474334744347453474634747347483474934750347513475234753347543475534756347573475834759347603476134762347633476434765347663476734768347693477034771347723477334774347753477634777347783477934780347813478234783347843478534786347873478834789347903479134792347933479434795347963479734798347993480034801348023480334804348053480634807348083480934810348113481234813348143481534816348173481834819348203482134822348233482434825348263482734828348293483034831348323483334834348353483634837348383483934840348413484234843348443484534846348473484834849348503485134852348533485434855348563485734858348593486034861348623486334864348653486634867348683486934870348713487234873348743487534876348773487834879348803488134882348833488434885348863488734888348893489034891348923489334894348953489634897348983489934900349013490234903349043490534906349073490834909349103491134912349133491434915349163491734918349193492034921349223492334924349253492634927349283492934930349313493234933349343493534936349373493834939349403494134942349433494434945349463494734948349493495034951349523495334954349553495634957349583495934960349613496234963349643496534966349673496834969349703497134972349733497434975349763497734978349793498034981349823498334984349853498634987349883498934990349913499234993349943499534996349973499834999350003500135002350033500435005350063500735008350093501035011350123501335014350153501635017350183501935020350213502235023350243502535026350273502835029350303503135032350333503435035350363503735038350393504035041350423504335044350453504635047350483504935050350513505235053350543505535056350573505835059350603506135062350633506435065350663506735068350693507035071350723507335074350753507635077350783507935080350813508235083350843508535086350873508835089350903509135092350933509435095350963509735098350993510035101351023510335104351053510635107351083510935110351113511235113351143511535116351173511835119351203512135122351233512435125351263512735128351293513035131351323513335134351353513635137351383513935140351413514235143351443514535146351473514835149351503515135152351533515435155351563515735158351593516035161351623516335164351653516635167351683516935170351713517235173351743517535176351773517835179351803518135182351833518435185351863518735188351893519035191351923519335194351953519635197351983519935200352013520235203352043520535206352073520835209352103521135212352133521435215352163521735218352193522035221352223522335224352253522635227352283522935230352313523235233352343523535236352373523835239352403524135242352433524435245352463524735248352493525035251352523525335254352553525635257352583525935260352613526235263352643526535266352673526835269352703527135272352733527435275352763527735278352793528035281352823528335284352853528635287352883528935290352913529235293352943529535296352973529835299353003530135302353033530435305353063530735308353093531035311353123531335314353153531635317353183531935320353213532235323353243532535326353273532835329353303533135332353333533435335353363533735338353393534035341353423534335344353453534635347353483534935350353513535235353353543535535356353573535835359353603536135362353633536435365353663536735368353693537035371353723537335374353753537635377353783537935380353813538235383353843538535386353873538835389353903539135392353933539435395353963539735398353993540035401354023540335404354053540635407354083540935410354113541235413354143541535416354173541835419354203542135422354233542435425354263542735428354293543035431354323543335434354353543635437354383543935440354413544235443354443544535446354473544835449354503545135452354533545435455354563545735458354593546035461354623546335464354653546635467354683546935470354713547235473354743547535476354773547835479354803548135482354833548435485354863548735488354893549035491354923549335494354953549635497354983549935500355013550235503355043550535506355073550835509355103551135512355133551435515355163551735518355193552035521355223552335524355253552635527355283552935530355313553235533355343553535536355373553835539355403554135542355433554435545355463554735548355493555035551355523555335554355553555635557355583555935560355613556235563355643556535566355673556835569355703557135572355733557435575355763557735578355793558035581355823558335584355853558635587355883558935590355913559235593355943559535596355973559835599356003560135602356033560435605356063560735608356093561035611356123561335614356153561635617356183561935620356213562235623356243562535626356273562835629356303563135632356333563435635356363563735638356393564035641356423564335644356453564635647356483564935650356513565235653356543565535656356573565835659356603566135662356633566435665356663566735668356693567035671356723567335674356753567635677356783567935680356813568235683356843568535686356873568835689356903569135692356933569435695356963569735698356993570035701357023570335704357053570635707357083570935710357113571235713357143571535716357173571835719357203572135722357233572435725357263572735728357293573035731357323573335734357353573635737357383573935740357413574235743357443574535746357473574835749357503575135752357533575435755357563575735758357593576035761357623576335764357653576635767357683576935770357713577235773357743577535776357773577835779357803578135782357833578435785357863578735788357893579035791357923579335794357953579635797357983579935800358013580235803358043580535806358073580835809358103581135812358133581435815358163581735818358193582035821358223582335824358253582635827358283582935830358313583235833358343583535836358373583835839358403584135842358433584435845358463584735848358493585035851358523585335854358553585635857358583585935860358613586235863358643586535866358673586835869358703587135872358733587435875358763587735878358793588035881358823588335884358853588635887358883588935890358913589235893358943589535896358973589835899359003590135902359033590435905359063590735908359093591035911359123591335914359153591635917359183591935920359213592235923359243592535926359273592835929359303593135932359333593435935359363593735938359393594035941359423594335944359453594635947359483594935950359513595235953359543595535956359573595835959359603596135962359633596435965359663596735968359693597035971359723597335974359753597635977359783597935980359813598235983359843598535986359873598835989359903599135992359933599435995359963599735998359993600036001360023600336004360053600636007360083600936010360113601236013360143601536016360173601836019360203602136022360233602436025360263602736028360293603036031360323603336034360353603636037360383603936040360413604236043360443604536046360473604836049360503605136052360533605436055360563605736058360593606036061360623606336064360653606636067360683606936070360713607236073360743607536076360773607836079360803608136082360833608436085360863608736088360893609036091360923609336094360953609636097360983609936100361013610236103361043610536106361073610836109361103611136112361133611436115361163611736118361193612036121361223612336124361253612636127361283612936130361313613236133361343613536136361373613836139361403614136142361433614436145361463614736148361493615036151361523615336154361553615636157361583615936160361613616236163361643616536166361673616836169361703617136172361733617436175361763617736178361793618036181361823618336184361853618636187361883618936190361913619236193361943619536196361973619836199362003620136202362033620436205362063620736208362093621036211362123621336214362153621636217362183621936220362213622236223362243622536226362273622836229362303623136232362333623436235362363623736238362393624036241362423624336244362453624636247362483624936250362513625236253362543625536256362573625836259362603626136262362633626436265362663626736268362693627036271362723627336274362753627636277362783627936280362813628236283362843628536286362873628836289362903629136292362933629436295362963629736298362993630036301363023630336304363053630636307363083630936310363113631236313363143631536316363173631836319363203632136322363233632436325363263632736328363293633036331363323633336334363353633636337363383633936340363413634236343363443634536346363473634836349363503635136352363533635436355363563635736358363593636036361363623636336364363653636636367363683636936370363713637236373363743637536376363773637836379363803638136382363833638436385363863638736388363893639036391363923639336394363953639636397363983639936400364013640236403364043640536406364073640836409364103641136412364133641436415364163641736418364193642036421364223642336424364253642636427364283642936430364313643236433364343643536436364373643836439364403644136442364433644436445364463644736448364493645036451364523645336454364553645636457364583645936460364613646236463364643646536466364673646836469364703647136472364733647436475364763647736478364793648036481364823648336484364853648636487364883648936490364913649236493364943649536496364973649836499365003650136502365033650436505365063650736508365093651036511365123651336514365153651636517365183651936520365213652236523365243652536526365273652836529365303653136532365333653436535365363653736538365393654036541365423654336544365453654636547365483654936550365513655236553365543655536556365573655836559365603656136562365633656436565365663656736568365693657036571365723657336574365753657636577365783657936580365813658236583365843658536586365873658836589365903659136592365933659436595365963659736598365993660036601366023660336604366053660636607366083660936610366113661236613366143661536616366173661836619366203662136622366233662436625366263662736628366293663036631366323663336634366353663636637366383663936640366413664236643366443664536646366473664836649366503665136652366533665436655366563665736658366593666036661366623666336664366653666636667366683666936670366713667236673366743667536676366773667836679366803668136682366833668436685366863668736688366893669036691366923669336694366953669636697366983669936700367013670236703367043670536706367073670836709367103671136712367133671436715367163671736718367193672036721367223672336724367253672636727367283672936730367313673236733367343673536736367373673836739367403674136742367433674436745367463674736748367493675036751367523675336754367553675636757367583675936760367613676236763367643676536766367673676836769367703677136772367733677436775367763677736778367793678036781367823678336784367853678636787367883678936790367913679236793367943679536796367973679836799368003680136802368033680436805368063680736808368093681036811368123681336814368153681636817368183681936820368213682236823368243682536826368273682836829368303683136832368333683436835368363683736838368393684036841368423684336844368453684636847368483684936850368513685236853368543685536856368573685836859368603686136862368633686436865368663686736868368693687036871368723687336874368753687636877368783687936880368813688236883368843688536886368873688836889368903689136892368933689436895368963689736898368993690036901369023690336904369053690636907369083690936910369113691236913369143691536916369173691836919369203692136922369233692436925369263692736928369293693036931369323693336934369353693636937369383693936940369413694236943369443694536946369473694836949369503695136952369533695436955369563695736958369593696036961369623696336964369653696636967369683696936970369713697236973369743697536976369773697836979369803698136982369833698436985369863698736988369893699036991369923699336994369953699636997369983699937000370013700237003370043700537006370073700837009370103701137012370133701437015370163701737018370193702037021370223702337024370253702637027370283702937030370313703237033370343703537036370373703837039370403704137042370433704437045370463704737048370493705037051370523705337054370553705637057370583705937060370613706237063370643706537066370673706837069370703707137072370733707437075370763707737078370793708037081370823708337084370853708637087370883708937090370913709237093370943709537096370973709837099371003710137102371033710437105371063710737108371093711037111371123711337114371153711637117371183711937120371213712237123371243712537126371273712837129371303713137132371333713437135371363713737138371393714037141371423714337144371453714637147371483714937150371513715237153371543715537156371573715837159371603716137162371633716437165371663716737168371693717037171371723717337174371753717637177371783717937180371813718237183371843718537186371873718837189371903719137192371933719437195371963719737198371993720037201372023720337204372053720637207372083720937210372113721237213372143721537216372173721837219372203722137222372233722437225372263722737228372293723037231372323723337234372353723637237372383723937240372413724237243372443724537246372473724837249372503725137252372533725437255372563725737258372593726037261372623726337264372653726637267372683726937270372713727237273372743727537276372773727837279372803728137282372833728437285372863728737288372893729037291372923729337294372953729637297372983729937300373013730237303373043730537306373073730837309373103731137312373133731437315373163731737318373193732037321373223732337324373253732637327373283732937330373313733237333373343733537336373373733837339373403734137342373433734437345373463734737348373493735037351373523735337354373553735637357373583735937360373613736237363373643736537366373673736837369373703737137372373733737437375373763737737378373793738037381373823738337384373853738637387373883738937390373913739237393373943739537396373973739837399374003740137402374033740437405374063740737408374093741037411374123741337414374153741637417374183741937420374213742237423374243742537426374273742837429374303743137432374333743437435374363743737438374393744037441374423744337444374453744637447374483744937450374513745237453374543745537456374573745837459374603746137462374633746437465374663746737468374693747037471374723747337474374753747637477374783747937480374813748237483374843748537486374873748837489374903749137492374933749437495374963749737498374993750037501375023750337504375053750637507375083750937510375113751237513375143751537516375173751837519375203752137522375233752437525375263752737528375293753037531375323753337534375353753637537375383753937540375413754237543375443754537546375473754837549375503755137552375533755437555375563755737558375593756037561375623756337564375653756637567375683756937570375713757237573375743757537576375773757837579375803758137582375833758437585375863758737588375893759037591375923759337594375953759637597375983759937600376013760237603376043760537606376073760837609376103761137612376133761437615376163761737618376193762037621376223762337624376253762637627376283762937630376313763237633376343763537636376373763837639376403764137642376433764437645376463764737648376493765037651376523765337654376553765637657376583765937660376613766237663376643766537666376673766837669376703767137672376733767437675376763767737678376793768037681376823768337684376853768637687376883768937690376913769237693376943769537696376973769837699377003770137702377033770437705377063770737708377093771037711377123771337714377153771637717377183771937720377213772237723377243772537726377273772837729377303773137732377333773437735377363773737738377393774037741377423774337744377453774637747377483774937750377513775237753377543775537756377573775837759377603776137762377633776437765377663776737768377693777037771377723777337774377753777637777377783777937780377813778237783377843778537786377873778837789377903779137792377933779437795377963779737798377993780037801378023780337804378053780637807378083780937810378113781237813378143781537816378173781837819378203782137822378233782437825378263782737828378293783037831378323783337834378353783637837378383783937840378413784237843378443784537846378473784837849378503785137852378533785437855378563785737858378593786037861378623786337864378653786637867378683786937870378713787237873378743787537876378773787837879378803788137882378833788437885378863788737888378893789037891378923789337894378953789637897378983789937900379013790237903379043790537906379073790837909379103791137912379133791437915379163791737918379193792037921379223792337924379253792637927379283792937930379313793237933379343793537936379373793837939379403794137942379433794437945379463794737948379493795037951379523795337954379553795637957379583795937960379613796237963379643796537966379673796837969379703797137972379733797437975379763797737978379793798037981379823798337984379853798637987379883798937990379913799237993379943799537996379973799837999380003800138002380033800438005380063800738008380093801038011380123801338014380153801638017380183801938020380213802238023380243802538026380273802838029380303803138032380333803438035380363803738038380393804038041380423804338044380453804638047380483804938050380513805238053380543805538056380573805838059380603806138062380633806438065380663806738068380693807038071380723807338074380753807638077380783807938080380813808238083380843808538086380873808838089380903809138092380933809438095380963809738098380993810038101381023810338104381053810638107381083810938110381113811238113381143811538116381173811838119381203812138122381233812438125381263812738128381293813038131381323813338134381353813638137381383813938140381413814238143381443814538146381473814838149381503815138152381533815438155381563815738158381593816038161381623816338164381653816638167381683816938170381713817238173381743817538176381773817838179381803818138182381833818438185381863818738188381893819038191381923819338194381953819638197381983819938200382013820238203382043820538206382073820838209382103821138212382133821438215382163821738218382193822038221382223822338224382253822638227382283822938230382313823238233382343823538236382373823838239382403824138242382433824438245382463824738248382493825038251382523825338254382553825638257382583825938260382613826238263382643826538266382673826838269382703827138272382733827438275382763827738278382793828038281382823828338284382853828638287382883828938290382913829238293382943829538296382973829838299383003830138302383033830438305383063830738308383093831038311383123831338314383153831638317383183831938320383213832238323383243832538326383273832838329383303833138332383333833438335383363833738338383393834038341383423834338344383453834638347383483834938350383513835238353383543835538356383573835838359383603836138362383633836438365383663836738368383693837038371383723837338374383753837638377383783837938380383813838238383383843838538386383873838838389383903839138392383933839438395383963839738398383993840038401384023840338404384053840638407384083840938410384113841238413384143841538416384173841838419384203842138422384233842438425384263842738428384293843038431384323843338434384353843638437384383843938440384413844238443384443844538446384473844838449384503845138452384533845438455384563845738458384593846038461384623846338464384653846638467384683846938470384713847238473384743847538476384773847838479384803848138482384833848438485384863848738488384893849038491384923849338494384953849638497384983849938500385013850238503385043850538506385073850838509385103851138512385133851438515385163851738518385193852038521385223852338524385253852638527385283852938530385313853238533385343853538536385373853838539385403854138542385433854438545385463854738548385493855038551385523855338554385553855638557385583855938560385613856238563385643856538566385673856838569385703857138572385733857438575385763857738578385793858038581385823858338584385853858638587385883858938590385913859238593385943859538596385973859838599386003860138602386033860438605386063860738608386093861038611386123861338614386153861638617386183861938620386213862238623386243862538626386273862838629386303863138632386333863438635386363863738638386393864038641386423864338644386453864638647386483864938650386513865238653386543865538656386573865838659386603866138662386633866438665386663866738668386693867038671386723867338674386753867638677386783867938680386813868238683386843868538686386873868838689386903869138692386933869438695386963869738698386993870038701387023870338704387053870638707387083870938710387113871238713387143871538716387173871838719387203872138722387233872438725387263872738728387293873038731387323873338734387353873638737387383873938740387413874238743387443874538746387473874838749387503875138752387533875438755387563875738758387593876038761387623876338764387653876638767387683876938770387713877238773387743877538776387773877838779387803878138782387833878438785387863878738788387893879038791387923879338794387953879638797387983879938800388013880238803388043880538806388073880838809388103881138812388133881438815388163881738818388193882038821388223882338824388253882638827388283882938830388313883238833388343883538836388373883838839388403884138842388433884438845388463884738848388493885038851388523885338854388553885638857388583885938860388613886238863388643886538866388673886838869388703887138872388733887438875388763887738878388793888038881388823888338884388853888638887388883888938890388913889238893388943889538896388973889838899389003890138902389033890438905389063890738908389093891038911389123891338914389153891638917389183891938920389213892238923389243892538926389273892838929389303893138932389333893438935389363893738938389393894038941389423894338944389453894638947389483894938950389513895238953389543895538956389573895838959389603896138962389633896438965389663896738968389693897038971389723897338974389753897638977389783897938980389813898238983389843898538986389873898838989389903899138992389933899438995389963899738998389993900039001390023900339004390053900639007390083900939010390113901239013390143901539016390173901839019390203902139022390233902439025390263902739028390293903039031390323903339034390353903639037390383903939040390413904239043390443904539046390473904839049390503905139052390533905439055390563905739058390593906039061390623906339064390653906639067390683906939070390713907239073390743907539076390773907839079390803908139082390833908439085390863908739088390893909039091390923909339094390953909639097390983909939100391013910239103391043910539106391073910839109391103911139112391133911439115391163911739118391193912039121391223912339124391253912639127391283912939130391313913239133391343913539136391373913839139391403914139142391433914439145391463914739148391493915039151391523915339154391553915639157391583915939160391613916239163391643916539166391673916839169391703917139172391733917439175391763917739178391793918039181391823918339184391853918639187391883918939190391913919239193391943919539196391973919839199392003920139202392033920439205392063920739208392093921039211392123921339214392153921639217392183921939220392213922239223392243922539226392273922839229392303923139232392333923439235392363923739238392393924039241392423924339244392453924639247392483924939250392513925239253392543925539256392573925839259392603926139262392633926439265392663926739268392693927039271392723927339274392753927639277392783927939280392813928239283392843928539286392873928839289392903929139292392933929439295392963929739298392993930039301393023930339304393053930639307393083930939310393113931239313393143931539316393173931839319393203932139322393233932439325393263932739328393293933039331393323933339334393353933639337393383933939340393413934239343393443934539346393473934839349393503935139352393533935439355393563935739358393593936039361393623936339364393653936639367393683936939370393713937239373393743937539376393773937839379393803938139382393833938439385393863938739388393893939039391393923939339394393953939639397393983939939400394013940239403394043940539406394073940839409394103941139412394133941439415394163941739418394193942039421394223942339424394253942639427394283942939430394313943239433394343943539436394373943839439394403944139442394433944439445394463944739448394493945039451394523945339454394553945639457394583945939460394613946239463394643946539466394673946839469394703947139472394733947439475394763947739478394793948039481394823948339484394853948639487394883948939490394913949239493394943949539496394973949839499395003950139502395033950439505395063950739508395093951039511395123951339514395153951639517395183951939520395213952239523395243952539526395273952839529395303953139532395333953439535395363953739538395393954039541395423954339544395453954639547395483954939550395513955239553395543955539556395573955839559395603956139562395633956439565395663956739568395693957039571395723957339574395753957639577395783957939580395813958239583395843958539586395873958839589395903959139592395933959439595395963959739598395993960039601396023960339604396053960639607396083960939610396113961239613396143961539616396173961839619396203962139622396233962439625396263962739628396293963039631396323963339634396353963639637396383963939640396413964239643396443964539646396473964839649396503965139652396533965439655396563965739658396593966039661396623966339664396653966639667396683966939670396713967239673396743967539676396773967839679396803968139682396833968439685396863968739688396893969039691396923969339694396953969639697396983969939700397013970239703397043970539706397073970839709397103971139712397133971439715397163971739718397193972039721397223972339724397253972639727397283972939730397313973239733397343973539736397373973839739397403974139742397433974439745397463974739748397493975039751397523975339754397553975639757397583975939760397613976239763397643976539766397673976839769397703977139772397733977439775397763977739778397793978039781397823978339784397853978639787397883978939790397913979239793397943979539796397973979839799398003980139802398033980439805398063980739808398093981039811398123981339814398153981639817398183981939820398213982239823398243982539826398273982839829398303983139832398333983439835398363983739838398393984039841398423984339844398453984639847398483984939850398513985239853398543985539856398573985839859398603986139862398633986439865398663986739868398693987039871398723987339874398753987639877398783987939880398813988239883398843988539886398873988839889398903989139892398933989439895398963989739898398993990039901399023990339904399053990639907399083990939910399113991239913399143991539916399173991839919399203992139922399233992439925399263992739928399293993039931399323993339934399353993639937399383993939940399413994239943399443994539946399473994839949399503995139952399533995439955399563995739958399593996039961399623996339964399653996639967399683996939970399713997239973399743997539976399773997839979399803998139982399833998439985399863998739988399893999039991399923999339994399953999639997399983999940000400014000240003400044000540006400074000840009400104001140012400134001440015400164001740018400194002040021400224002340024400254002640027400284002940030400314003240033400344003540036400374003840039400404004140042400434004440045400464004740048400494005040051400524005340054400554005640057400584005940060400614006240063400644006540066400674006840069400704007140072400734007440075400764007740078400794008040081400824008340084400854008640087400884008940090400914009240093400944009540096400974009840099401004010140102401034010440105401064010740108401094011040111401124011340114401154011640117401184011940120401214012240123401244012540126401274012840129401304013140132401334013440135401364013740138401394014040141401424014340144401454014640147401484014940150401514015240153401544015540156401574015840159401604016140162401634016440165401664016740168401694017040171401724017340174401754017640177401784017940180401814018240183401844018540186401874018840189401904019140192401934019440195401964019740198401994020040201402024020340204402054020640207402084020940210402114021240213402144021540216402174021840219402204022140222402234022440225402264022740228402294023040231402324023340234402354023640237402384023940240402414024240243402444024540246402474024840249402504025140252402534025440255402564025740258402594026040261402624026340264402654026640267402684026940270402714027240273402744027540276402774027840279402804028140282402834028440285402864028740288402894029040291402924029340294402954029640297402984029940300403014030240303403044030540306403074030840309403104031140312403134031440315403164031740318403194032040321403224032340324403254032640327403284032940330403314033240333403344033540336403374033840339403404034140342403434034440345403464034740348403494035040351403524035340354403554035640357403584035940360403614036240363403644036540366403674036840369403704037140372403734037440375403764037740378403794038040381403824038340384403854038640387403884038940390403914039240393403944039540396403974039840399404004040140402404034040440405404064040740408404094041040411404124041340414404154041640417404184041940420404214042240423404244042540426404274042840429404304043140432404334043440435404364043740438404394044040441404424044340444404454044640447404484044940450404514045240453404544045540456404574045840459404604046140462404634046440465404664046740468404694047040471404724047340474404754047640477404784047940480404814048240483404844048540486404874048840489404904049140492404934049440495404964049740498404994050040501405024050340504405054050640507405084050940510405114051240513405144051540516405174051840519405204052140522405234052440525405264052740528405294053040531405324053340534405354053640537405384053940540405414054240543405444054540546405474054840549405504055140552405534055440555405564055740558405594056040561405624056340564405654056640567405684056940570405714057240573405744057540576405774057840579405804058140582405834058440585405864058740588405894059040591405924059340594405954059640597405984059940600406014060240603406044060540606406074060840609406104061140612406134061440615406164061740618406194062040621406224062340624406254062640627406284062940630406314063240633406344063540636406374063840639406404064140642406434064440645406464064740648406494065040651406524065340654406554065640657406584065940660406614066240663406644066540666406674066840669406704067140672406734067440675406764067740678406794068040681406824068340684406854068640687406884068940690406914069240693406944069540696406974069840699407004070140702407034070440705407064070740708407094071040711407124071340714407154071640717407184071940720407214072240723407244072540726407274072840729407304073140732407334073440735407364073740738407394074040741407424074340744407454074640747407484074940750407514075240753407544075540756407574075840759407604076140762407634076440765407664076740768407694077040771407724077340774407754077640777407784077940780407814078240783407844078540786407874078840789407904079140792407934079440795407964079740798407994080040801408024080340804408054080640807408084080940810408114081240813408144081540816408174081840819408204082140822408234082440825408264082740828408294083040831408324083340834408354083640837408384083940840408414084240843408444084540846408474084840849408504085140852408534085440855408564085740858408594086040861408624086340864408654086640867408684086940870408714087240873408744087540876408774087840879408804088140882408834088440885408864088740888408894089040891408924089340894408954089640897408984089940900409014090240903409044090540906409074090840909409104091140912409134091440915409164091740918409194092040921409224092340924409254092640927409284092940930409314093240933409344093540936409374093840939409404094140942409434094440945409464094740948409494095040951409524095340954409554095640957409584095940960409614096240963409644096540966409674096840969409704097140972409734097440975409764097740978409794098040981409824098340984409854098640987409884098940990409914099240993409944099540996409974099840999410004100141002410034100441005410064100741008410094101041011410124101341014410154101641017410184101941020410214102241023410244102541026410274102841029410304103141032410334103441035410364103741038410394104041041410424104341044410454104641047410484104941050410514105241053410544105541056410574105841059410604106141062410634106441065410664106741068410694107041071410724107341074410754107641077410784107941080410814108241083410844108541086410874108841089410904109141092410934109441095410964109741098410994110041101411024110341104411054110641107411084110941110411114111241113411144111541116411174111841119411204112141122411234112441125411264112741128411294113041131411324113341134411354113641137411384113941140411414114241143411444114541146411474114841149411504115141152411534115441155411564115741158411594116041161411624116341164411654116641167411684116941170411714117241173411744117541176411774117841179411804118141182411834118441185411864118741188411894119041191411924119341194411954119641197411984119941200412014120241203412044120541206412074120841209412104121141212412134121441215412164121741218412194122041221412224122341224412254122641227412284122941230412314123241233412344123541236412374123841239412404124141242412434124441245412464124741248412494125041251412524125341254412554125641257412584125941260412614126241263412644126541266412674126841269412704127141272412734127441275412764127741278412794128041281412824128341284412854128641287412884128941290412914129241293412944129541296412974129841299413004130141302413034130441305413064130741308413094131041311413124131341314413154131641317413184131941320413214132241323413244132541326413274132841329413304133141332413334133441335413364133741338413394134041341413424134341344413454134641347413484134941350413514135241353413544135541356413574135841359413604136141362413634136441365413664136741368413694137041371413724137341374413754137641377413784137941380413814138241383413844138541386413874138841389413904139141392413934139441395413964139741398413994140041401414024140341404414054140641407414084140941410414114141241413414144141541416414174141841419414204142141422414234142441425414264142741428414294143041431414324143341434414354143641437414384143941440414414144241443414444144541446414474144841449414504145141452414534145441455414564145741458414594146041461414624146341464414654146641467414684146941470414714147241473414744147541476414774147841479414804148141482414834148441485414864148741488414894149041491414924149341494414954149641497414984149941500415014150241503415044150541506415074150841509415104151141512415134151441515415164151741518415194152041521415224152341524415254152641527415284152941530415314153241533415344153541536415374153841539415404154141542415434154441545415464154741548415494155041551415524155341554415554155641557415584155941560415614156241563415644156541566415674156841569415704157141572415734157441575415764157741578415794158041581415824158341584415854158641587415884158941590415914159241593415944159541596415974159841599416004160141602416034160441605416064160741608416094161041611416124161341614416154161641617416184161941620416214162241623416244162541626416274162841629416304163141632416334163441635416364163741638416394164041641416424164341644416454164641647416484164941650416514165241653416544165541656416574165841659416604166141662416634166441665416664166741668416694167041671416724167341674416754167641677416784167941680416814168241683416844168541686416874168841689416904169141692416934169441695416964169741698416994170041701417024170341704417054170641707417084170941710417114171241713417144171541716417174171841719417204172141722417234172441725417264172741728417294173041731417324173341734417354173641737417384173941740417414174241743417444174541746417474174841749417504175141752417534175441755417564175741758417594176041761417624176341764417654176641767417684176941770417714177241773417744177541776417774177841779417804178141782417834178441785417864178741788417894179041791417924179341794417954179641797417984179941800418014180241803418044180541806418074180841809418104181141812418134181441815418164181741818418194182041821418224182341824418254182641827418284182941830418314183241833418344183541836418374183841839418404184141842418434184441845418464184741848418494185041851418524185341854418554185641857418584185941860418614186241863418644186541866418674186841869418704187141872418734187441875418764187741878418794188041881418824188341884418854188641887418884188941890418914189241893418944189541896418974189841899419004190141902419034190441905419064190741908419094191041911419124191341914419154191641917419184191941920419214192241923419244192541926419274192841929419304193141932419334193441935419364193741938419394194041941419424194341944419454194641947419484194941950419514195241953419544195541956419574195841959419604196141962419634196441965419664196741968419694197041971419724197341974419754197641977419784197941980419814198241983419844198541986419874198841989419904199141992419934199441995419964199741998419994200042001420024200342004420054200642007420084200942010420114201242013420144201542016420174201842019420204202142022420234202442025420264202742028420294203042031420324203342034420354203642037420384203942040420414204242043420444204542046420474204842049420504205142052420534205442055420564205742058420594206042061420624206342064420654206642067420684206942070420714207242073420744207542076420774207842079420804208142082420834208442085420864208742088420894209042091420924209342094420954209642097420984209942100421014210242103421044210542106421074210842109421104211142112421134211442115421164211742118421194212042121421224212342124421254212642127421284212942130421314213242133421344213542136421374213842139421404214142142421434214442145421464214742148421494215042151421524215342154421554215642157421584215942160421614216242163421644216542166421674216842169421704217142172421734217442175421764217742178421794218042181421824218342184421854218642187421884218942190421914219242193421944219542196421974219842199422004220142202422034220442205422064220742208422094221042211422124221342214422154221642217422184221942220422214222242223422244222542226422274222842229422304223142232422334223442235422364223742238422394224042241422424224342244422454224642247422484224942250422514225242253422544225542256422574225842259422604226142262422634226442265422664226742268422694227042271422724227342274422754227642277422784227942280422814228242283422844228542286422874228842289422904229142292422934229442295422964229742298422994230042301423024230342304423054230642307423084230942310423114231242313423144231542316423174231842319423204232142322423234232442325423264232742328423294233042331423324233342334423354233642337423384233942340423414234242343423444234542346423474234842349423504235142352423534235442355423564235742358423594236042361423624236342364423654236642367423684236942370423714237242373423744237542376423774237842379423804238142382423834238442385423864238742388423894239042391423924239342394423954239642397423984239942400424014240242403424044240542406424074240842409424104241142412424134241442415424164241742418424194242042421424224242342424424254242642427424284242942430424314243242433424344243542436424374243842439424404244142442424434244442445424464244742448424494245042451424524245342454424554245642457424584245942460424614246242463424644246542466424674246842469424704247142472424734247442475424764247742478424794248042481424824248342484424854248642487424884248942490424914249242493424944249542496424974249842499425004250142502425034250442505425064250742508425094251042511425124251342514425154251642517425184251942520425214252242523425244252542526425274252842529425304253142532425334253442535425364253742538425394254042541425424254342544425454254642547425484254942550425514255242553425544255542556425574255842559425604256142562425634256442565425664256742568425694257042571425724257342574425754257642577425784257942580425814258242583425844258542586425874258842589425904259142592425934259442595425964259742598425994260042601426024260342604426054260642607426084260942610426114261242613426144261542616426174261842619426204262142622426234262442625426264262742628426294263042631426324263342634426354263642637426384263942640426414264242643426444264542646426474264842649426504265142652426534265442655426564265742658426594266042661426624266342664426654266642667426684266942670426714267242673426744267542676426774267842679426804268142682426834268442685426864268742688426894269042691426924269342694426954269642697426984269942700427014270242703427044270542706427074270842709427104271142712427134271442715427164271742718427194272042721427224272342724427254272642727427284272942730427314273242733427344273542736427374273842739427404274142742427434274442745427464274742748427494275042751427524275342754427554275642757427584275942760427614276242763427644276542766427674276842769427704277142772427734277442775427764277742778427794278042781427824278342784427854278642787427884278942790427914279242793427944279542796427974279842799428004280142802428034280442805428064280742808428094281042811428124281342814428154281642817428184281942820428214282242823428244282542826428274282842829428304283142832428334283442835428364283742838428394284042841428424284342844428454284642847428484284942850428514285242853428544285542856428574285842859428604286142862428634286442865428664286742868428694287042871428724287342874428754287642877428784287942880428814288242883428844288542886428874288842889428904289142892428934289442895428964289742898428994290042901429024290342904429054290642907429084290942910429114291242913429144291542916429174291842919429204292142922429234292442925429264292742928429294293042931429324293342934429354293642937429384293942940429414294242943429444294542946429474294842949429504295142952429534295442955429564295742958429594296042961429624296342964429654296642967429684296942970429714297242973429744297542976429774297842979429804298142982429834298442985429864298742988429894299042991429924299342994429954299642997429984299943000430014300243003430044300543006430074300843009430104301143012430134301443015430164301743018430194302043021430224302343024430254302643027430284302943030430314303243033430344303543036430374303843039430404304143042430434304443045430464304743048430494305043051430524305343054430554305643057430584305943060430614306243063430644306543066430674306843069430704307143072430734307443075430764307743078430794308043081430824308343084430854308643087430884308943090430914309243093430944309543096430974309843099431004310143102431034310443105431064310743108431094311043111431124311343114431154311643117431184311943120431214312243123431244312543126431274312843129431304313143132431334313443135431364313743138431394314043141431424314343144431454314643147431484314943150431514315243153431544315543156431574315843159431604316143162431634316443165431664316743168431694317043171431724317343174431754317643177431784317943180431814318243183431844318543186431874318843189431904319143192431934319443195431964319743198431994320043201432024320343204432054320643207432084320943210432114321243213432144321543216432174321843219432204322143222432234322443225432264322743228432294323043231432324323343234432354323643237432384323943240432414324243243432444324543246432474324843249432504325143252432534325443255432564325743258432594326043261432624326343264432654326643267432684326943270432714327243273432744327543276432774327843279432804328143282432834328443285432864328743288432894329043291432924329343294432954329643297432984329943300433014330243303433044330543306433074330843309433104331143312433134331443315433164331743318433194332043321433224332343324433254332643327433284332943330433314333243333433344333543336433374333843339433404334143342433434334443345433464334743348433494335043351433524335343354433554335643357433584335943360433614336243363433644336543366433674336843369433704337143372433734337443375433764337743378433794338043381433824338343384433854338643387433884338943390433914339243393433944339543396433974339843399434004340143402434034340443405434064340743408434094341043411434124341343414434154341643417434184341943420434214342243423434244342543426434274342843429434304343143432434334343443435434364343743438434394344043441434424344343444434454344643447434484344943450434514345243453434544345543456434574345843459434604346143462434634346443465434664346743468434694347043471434724347343474434754347643477434784347943480434814348243483434844348543486434874348843489434904349143492434934349443495434964349743498434994350043501435024350343504435054350643507435084350943510435114351243513435144351543516435174351843519435204352143522435234352443525435264352743528435294353043531435324353343534435354353643537435384353943540435414354243543435444354543546435474354843549435504355143552435534355443555435564355743558435594356043561435624356343564435654356643567435684356943570435714357243573435744357543576435774357843579435804358143582435834358443585435864358743588435894359043591435924359343594435954359643597435984359943600436014360243603436044360543606436074360843609436104361143612436134361443615436164361743618436194362043621436224362343624436254362643627436284362943630436314363243633436344363543636436374363843639436404364143642436434364443645436464364743648436494365043651436524365343654436554365643657436584365943660436614366243663436644366543666436674366843669436704367143672436734367443675436764367743678436794368043681436824368343684436854368643687436884368943690436914369243693436944369543696436974369843699437004370143702437034370443705437064370743708437094371043711437124371343714437154371643717437184371943720437214372243723437244372543726437274372843729437304373143732437334373443735437364373743738437394374043741437424374343744437454374643747437484374943750437514375243753437544375543756437574375843759437604376143762437634376443765437664376743768437694377043771437724377343774437754377643777437784377943780437814378243783437844378543786437874378843789437904379143792437934379443795437964379743798437994380043801438024380343804438054380643807438084380943810438114381243813438144381543816438174381843819438204382143822438234382443825438264382743828438294383043831438324383343834438354383643837438384383943840438414384243843438444384543846438474384843849438504385143852438534385443855438564385743858438594386043861438624386343864438654386643867438684386943870438714387243873438744387543876438774387843879438804388143882438834388443885438864388743888438894389043891438924389343894438954389643897438984389943900439014390243903439044390543906439074390843909439104391143912439134391443915439164391743918439194392043921439224392343924439254392643927439284392943930439314393243933439344393543936439374393843939439404394143942439434394443945439464394743948439494395043951439524395343954439554395643957439584395943960439614396243963439644396543966439674396843969439704397143972439734397443975439764397743978439794398043981439824398343984439854398643987439884398943990439914399243993439944399543996439974399843999440004400144002440034400444005440064400744008440094401044011440124401344014440154401644017440184401944020440214402244023440244402544026440274402844029440304403144032440334403444035440364403744038440394404044041440424404344044440454404644047440484404944050440514405244053440544405544056440574405844059440604406144062440634406444065440664406744068440694407044071440724407344074440754407644077440784407944080440814408244083440844408544086440874408844089440904409144092440934409444095440964409744098440994410044101441024410344104441054410644107441084410944110441114411244113441144411544116441174411844119441204412144122441234412444125441264412744128441294413044131441324413344134441354413644137441384413944140441414414244143441444414544146441474414844149441504415144152441534415444155441564415744158441594416044161441624416344164441654416644167441684416944170441714417244173441744417544176441774417844179441804418144182441834418444185441864418744188441894419044191441924419344194441954419644197441984419944200442014420244203442044420544206442074420844209442104421144212442134421444215442164421744218442194422044221442224422344224442254422644227442284422944230442314423244233442344423544236442374423844239442404424144242442434424444245442464424744248442494425044251442524425344254442554425644257442584425944260442614426244263442644426544266442674426844269442704427144272442734427444275442764427744278442794428044281442824428344284442854428644287442884428944290442914429244293442944429544296442974429844299443004430144302443034430444305443064430744308443094431044311443124431344314443154431644317443184431944320443214432244323443244432544326443274432844329443304433144332443334433444335443364433744338443394434044341443424434344344443454434644347443484434944350443514435244353443544435544356443574435844359443604436144362443634436444365443664436744368443694437044371443724437344374443754437644377443784437944380443814438244383443844438544386443874438844389443904439144392443934439444395443964439744398443994440044401444024440344404444054440644407444084440944410444114441244413444144441544416444174441844419444204442144422444234442444425444264442744428444294443044431444324443344434444354443644437444384443944440444414444244443444444444544446444474444844449444504445144452444534445444455444564445744458444594446044461444624446344464444654446644467444684446944470444714447244473444744447544476444774447844479444804448144482444834448444485444864448744488444894449044491444924449344494444954449644497444984449944500445014450244503445044450544506445074450844509445104451144512445134451444515445164451744518445194452044521445224452344524445254452644527445284452944530445314453244533445344453544536445374453844539445404454144542445434454444545445464454744548445494455044551445524455344554445554455644557445584455944560445614456244563445644456544566445674456844569445704457144572445734457444575445764457744578445794458044581445824458344584445854458644587445884458944590445914459244593445944459544596445974459844599446004460144602446034460444605446064460744608446094461044611446124461344614446154461644617446184461944620446214462244623446244462544626446274462844629446304463144632446334463444635446364463744638446394464044641446424464344644446454464644647446484464944650446514465244653446544465544656446574465844659446604466144662446634466444665446664466744668446694467044671446724467344674446754467644677446784467944680446814468244683446844468544686446874468844689446904469144692446934469444695446964469744698446994470044701447024470344704447054470644707447084470944710447114471244713447144471544716447174471844719447204472144722447234472444725447264472744728447294473044731447324473344734447354473644737447384473944740447414474244743447444474544746447474474844749447504475144752447534475444755447564475744758447594476044761447624476344764447654476644767447684476944770447714477244773447744477544776447774477844779447804478144782447834478444785447864478744788447894479044791447924479344794447954479644797447984479944800448014480244803448044480544806448074480844809448104481144812448134481444815448164481744818448194482044821448224482344824448254482644827448284482944830448314483244833448344483544836448374483844839448404484144842448434484444845448464484744848448494485044851448524485344854448554485644857448584485944860448614486244863448644486544866448674486844869448704487144872448734487444875448764487744878448794488044881448824488344884448854488644887448884488944890448914489244893448944489544896448974489844899449004490144902449034490444905449064490744908449094491044911449124491344914449154491644917449184491944920449214492244923449244492544926449274492844929449304493144932449334493444935449364493744938449394494044941449424494344944449454494644947449484494944950449514495244953449544495544956449574495844959449604496144962449634496444965449664496744968449694497044971449724497344974449754497644977449784497944980449814498244983449844498544986449874498844989449904499144992449934499444995449964499744998449994500045001450024500345004450054500645007450084500945010450114501245013450144501545016450174501845019450204502145022450234502445025450264502745028450294503045031450324503345034450354503645037450384503945040450414504245043450444504545046450474504845049450504505145052450534505445055450564505745058450594506045061450624506345064450654506645067450684506945070450714507245073450744507545076450774507845079450804508145082450834508445085450864508745088450894509045091450924509345094450954509645097450984509945100451014510245103451044510545106451074510845109451104511145112451134511445115451164511745118451194512045121451224512345124451254512645127451284512945130451314513245133451344513545136451374513845139451404514145142451434514445145451464514745148451494515045151451524515345154451554515645157451584515945160451614516245163451644516545166451674516845169451704517145172451734517445175451764517745178451794518045181451824518345184451854518645187451884518945190451914519245193451944519545196451974519845199452004520145202452034520445205452064520745208452094521045211452124521345214452154521645217452184521945220452214522245223452244522545226452274522845229452304523145232452334523445235452364523745238452394524045241452424524345244452454524645247452484524945250452514525245253452544525545256452574525845259452604526145262452634526445265452664526745268452694527045271452724527345274452754527645277452784527945280452814528245283452844528545286452874528845289452904529145292452934529445295452964529745298452994530045301453024530345304453054530645307453084530945310453114531245313453144531545316453174531845319453204532145322453234532445325453264532745328453294533045331453324533345334453354533645337453384533945340453414534245343453444534545346453474534845349453504535145352453534535445355453564535745358453594536045361453624536345364453654536645367453684536945370453714537245373453744537545376453774537845379453804538145382453834538445385453864538745388453894539045391453924539345394453954539645397453984539945400454014540245403454044540545406454074540845409454104541145412454134541445415454164541745418454194542045421454224542345424454254542645427454284542945430454314543245433454344543545436454374543845439454404544145442454434544445445454464544745448454494545045451454524545345454454554545645457454584545945460454614546245463454644546545466454674546845469454704547145472454734547445475454764547745478454794548045481454824548345484454854548645487454884548945490454914549245493454944549545496454974549845499455004550145502455034550445505455064550745508455094551045511455124551345514455154551645517455184551945520455214552245523455244552545526455274552845529455304553145532455334553445535455364553745538455394554045541455424554345544455454554645547455484554945550455514555245553455544555545556455574555845559455604556145562455634556445565455664556745568455694557045571455724557345574455754557645577455784557945580455814558245583455844558545586455874558845589455904559145592455934559445595455964559745598455994560045601456024560345604456054560645607456084560945610456114561245613456144561545616456174561845619456204562145622456234562445625456264562745628456294563045631456324563345634456354563645637456384563945640456414564245643456444564545646456474564845649456504565145652456534565445655456564565745658456594566045661456624566345664456654566645667456684566945670456714567245673456744567545676456774567845679456804568145682456834568445685456864568745688456894569045691456924569345694456954569645697456984569945700457014570245703457044570545706457074570845709457104571145712457134571445715457164571745718457194572045721457224572345724457254572645727457284572945730457314573245733457344573545736457374573845739457404574145742457434574445745457464574745748457494575045751457524575345754457554575645757457584575945760457614576245763457644576545766457674576845769457704577145772457734577445775457764577745778457794578045781457824578345784457854578645787457884578945790457914579245793457944579545796457974579845799458004580145802458034580445805458064580745808458094581045811458124581345814458154581645817458184581945820458214582245823458244582545826458274582845829458304583145832458334583445835458364583745838458394584045841458424584345844458454584645847458484584945850458514585245853458544585545856458574585845859458604586145862458634586445865458664586745868458694587045871458724587345874458754587645877458784587945880458814588245883458844588545886458874588845889458904589145892458934589445895458964589745898458994590045901459024590345904459054590645907459084590945910459114591245913459144591545916459174591845919459204592145922459234592445925459264592745928459294593045931459324593345934459354593645937459384593945940459414594245943459444594545946459474594845949459504595145952459534595445955459564595745958459594596045961459624596345964459654596645967459684596945970459714597245973459744597545976459774597845979459804598145982459834598445985459864598745988459894599045991459924599345994459954599645997459984599946000460014600246003460044600546006460074600846009460104601146012460134601446015460164601746018460194602046021460224602346024460254602646027460284602946030460314603246033460344603546036460374603846039460404604146042460434604446045460464604746048460494605046051460524605346054460554605646057460584605946060460614606246063460644606546066460674606846069460704607146072460734607446075460764607746078460794608046081460824608346084460854608646087460884608946090460914609246093460944609546096460974609846099461004610146102461034610446105461064610746108461094611046111461124611346114461154611646117461184611946120461214612246123461244612546126461274612846129461304613146132461334613446135461364613746138461394614046141461424614346144461454614646147461484614946150461514615246153461544615546156461574615846159461604616146162461634616446165461664616746168461694617046171461724617346174461754617646177461784617946180461814618246183461844618546186461874618846189461904619146192461934619446195461964619746198461994620046201462024620346204462054620646207462084620946210462114621246213462144621546216462174621846219462204622146222462234622446225462264622746228462294623046231462324623346234462354623646237462384623946240462414624246243462444624546246462474624846249462504625146252462534625446255462564625746258462594626046261462624626346264462654626646267462684626946270462714627246273462744627546276462774627846279462804628146282462834628446285462864628746288462894629046291462924629346294462954629646297462984629946300463014630246303463044630546306463074630846309463104631146312463134631446315463164631746318463194632046321463224632346324463254632646327463284632946330463314633246333463344633546336463374633846339463404634146342463434634446345463464634746348463494635046351463524635346354463554635646357463584635946360463614636246363463644636546366463674636846369463704637146372463734637446375463764637746378463794638046381463824638346384463854638646387463884638946390463914639246393463944639546396463974639846399464004640146402464034640446405464064640746408464094641046411464124641346414464154641646417464184641946420464214642246423464244642546426464274642846429464304643146432464334643446435464364643746438464394644046441464424644346444464454644646447464484644946450464514645246453464544645546456464574645846459464604646146462464634646446465464664646746468464694647046471464724647346474464754647646477464784647946480464814648246483464844648546486464874648846489464904649146492464934649446495464964649746498464994650046501465024650346504465054650646507465084650946510465114651246513465144651546516465174651846519465204652146522465234652446525465264652746528465294653046531465324653346534465354653646537465384653946540465414654246543465444654546546465474654846549465504655146552465534655446555465564655746558465594656046561465624656346564465654656646567465684656946570465714657246573465744657546576465774657846579465804658146582465834658446585465864658746588465894659046591465924659346594465954659646597465984659946600466014660246603466044660546606466074660846609466104661146612466134661446615466164661746618466194662046621466224662346624466254662646627466284662946630466314663246633466344663546636466374663846639466404664146642466434664446645466464664746648466494665046651466524665346654466554665646657466584665946660466614666246663466644666546666466674666846669466704667146672466734667446675466764667746678466794668046681466824668346684466854668646687466884668946690466914669246693466944669546696466974669846699467004670146702467034670446705467064670746708467094671046711467124671346714467154671646717467184671946720467214672246723467244672546726467274672846729467304673146732467334673446735467364673746738467394674046741467424674346744467454674646747467484674946750467514675246753467544675546756467574675846759467604676146762467634676446765467664676746768467694677046771467724677346774467754677646777467784677946780467814678246783467844678546786467874678846789467904679146792467934679446795467964679746798467994680046801468024680346804468054680646807468084680946810468114681246813468144681546816468174681846819468204682146822468234682446825468264682746828468294683046831468324683346834468354683646837468384683946840468414684246843468444684546846468474684846849468504685146852468534685446855468564685746858468594686046861468624686346864468654686646867468684686946870468714687246873468744687546876468774687846879468804688146882468834688446885468864688746888468894689046891468924689346894468954689646897468984689946900469014690246903469044690546906469074690846909469104691146912469134691446915469164691746918469194692046921469224692346924469254692646927469284692946930469314693246933469344693546936469374693846939469404694146942469434694446945469464694746948469494695046951469524695346954469554695646957469584695946960469614696246963469644696546966469674696846969469704697146972469734697446975469764697746978469794698046981469824698346984469854698646987469884698946990469914699246993469944699546996469974699846999470004700147002470034700447005470064700747008470094701047011470124701347014470154701647017470184701947020470214702247023470244702547026470274702847029470304703147032470334703447035470364703747038470394704047041470424704347044470454704647047470484704947050470514705247053470544705547056470574705847059470604706147062470634706447065470664706747068470694707047071470724707347074470754707647077470784707947080470814708247083470844708547086470874708847089470904709147092470934709447095470964709747098470994710047101471024710347104471054710647107471084710947110471114711247113471144711547116471174711847119471204712147122471234712447125471264712747128471294713047131471324713347134471354713647137471384713947140471414714247143471444714547146471474714847149471504715147152471534715447155471564715747158471594716047161471624716347164471654716647167471684716947170471714717247173471744717547176471774717847179471804718147182471834718447185471864718747188471894719047191471924719347194471954719647197471984719947200472014720247203472044720547206472074720847209472104721147212472134721447215472164721747218472194722047221472224722347224472254722647227472284722947230472314723247233472344723547236472374723847239472404724147242472434724447245472464724747248472494725047251472524725347254472554725647257472584725947260472614726247263472644726547266472674726847269472704727147272472734727447275472764727747278472794728047281472824728347284472854728647287472884728947290472914729247293472944729547296472974729847299473004730147302473034730447305473064730747308473094731047311473124731347314473154731647317473184731947320473214732247323473244732547326473274732847329473304733147332473334733447335473364733747338473394734047341473424734347344473454734647347473484734947350473514735247353473544735547356473574735847359473604736147362473634736447365473664736747368473694737047371473724737347374473754737647377473784737947380473814738247383473844738547386473874738847389473904739147392473934739447395473964739747398473994740047401474024740347404474054740647407474084740947410474114741247413474144741547416474174741847419474204742147422474234742447425474264742747428474294743047431474324743347434474354743647437474384743947440474414744247443474444744547446474474744847449474504745147452474534745447455474564745747458474594746047461474624746347464474654746647467474684746947470474714747247473474744747547476474774747847479474804748147482474834748447485474864748747488474894749047491474924749347494474954749647497474984749947500475014750247503475044750547506475074750847509475104751147512475134751447515475164751747518475194752047521475224752347524475254752647527475284752947530475314753247533475344753547536475374753847539475404754147542475434754447545475464754747548475494755047551475524755347554475554755647557475584755947560475614756247563475644756547566475674756847569475704757147572475734757447575475764757747578475794758047581475824758347584475854758647587475884758947590475914759247593475944759547596475974759847599476004760147602476034760447605476064760747608476094761047611476124761347614476154761647617476184761947620476214762247623476244762547626476274762847629476304763147632476334763447635476364763747638476394764047641476424764347644476454764647647476484764947650476514765247653476544765547656476574765847659476604766147662476634766447665476664766747668476694767047671476724767347674476754767647677476784767947680476814768247683476844768547686476874768847689476904769147692476934769447695476964769747698476994770047701477024770347704477054770647707477084770947710477114771247713477144771547716477174771847719477204772147722477234772447725477264772747728477294773047731477324773347734477354773647737477384773947740477414774247743477444774547746477474774847749477504775147752477534775447755477564775747758477594776047761477624776347764477654776647767477684776947770477714777247773477744777547776477774777847779477804778147782477834778447785477864778747788477894779047791477924779347794477954779647797477984779947800478014780247803478044780547806478074780847809478104781147812478134781447815478164781747818478194782047821478224782347824478254782647827478284782947830478314783247833478344783547836478374783847839478404784147842478434784447845478464784747848478494785047851478524785347854478554785647857478584785947860478614786247863478644786547866478674786847869478704787147872478734787447875478764787747878478794788047881478824788347884478854788647887478884788947890478914789247893478944789547896478974789847899479004790147902479034790447905479064790747908479094791047911479124791347914479154791647917479184791947920479214792247923479244792547926479274792847929479304793147932479334793447935479364793747938479394794047941479424794347944479454794647947479484794947950479514795247953479544795547956479574795847959479604796147962479634796447965479664796747968479694797047971479724797347974479754797647977479784797947980479814798247983479844798547986479874798847989479904799147992479934799447995479964799747998479994800048001480024800348004480054800648007480084800948010480114801248013480144801548016480174801848019480204802148022480234802448025480264802748028480294803048031480324803348034480354803648037480384803948040480414804248043480444804548046480474804848049480504805148052480534805448055480564805748058480594806048061480624806348064480654806648067480684806948070480714807248073480744807548076480774807848079480804808148082480834808448085480864808748088480894809048091480924809348094480954809648097480984809948100481014810248103481044810548106481074810848109481104811148112481134811448115481164811748118481194812048121481224812348124481254812648127481284812948130481314813248133481344813548136481374813848139481404814148142481434814448145481464814748148481494815048151481524815348154481554815648157481584815948160481614816248163481644816548166481674816848169481704817148172481734817448175481764817748178481794818048181481824818348184481854818648187481884818948190481914819248193481944819548196481974819848199482004820148202482034820448205482064820748208482094821048211482124821348214482154821648217482184821948220482214822248223482244822548226482274822848229482304823148232482334823448235482364823748238482394824048241482424824348244482454824648247482484824948250482514825248253482544825548256482574825848259482604826148262482634826448265482664826748268482694827048271482724827348274482754827648277482784827948280482814828248283482844828548286482874828848289482904829148292482934829448295482964829748298482994830048301483024830348304483054830648307483084830948310483114831248313483144831548316483174831848319483204832148322483234832448325483264832748328483294833048331483324833348334483354833648337483384833948340483414834248343483444834548346483474834848349483504835148352483534835448355483564835748358483594836048361483624836348364483654836648367483684836948370483714837248373483744837548376483774837848379483804838148382483834838448385483864838748388483894839048391483924839348394483954839648397483984839948400484014840248403484044840548406484074840848409484104841148412484134841448415484164841748418484194842048421484224842348424484254842648427484284842948430484314843248433484344843548436484374843848439484404844148442484434844448445484464844748448484494845048451484524845348454484554845648457484584845948460484614846248463484644846548466484674846848469484704847148472484734847448475484764847748478484794848048481484824848348484484854848648487484884848948490484914849248493484944849548496484974849848499485004850148502485034850448505485064850748508485094851048511485124851348514485154851648517485184851948520485214852248523485244852548526485274852848529485304853148532485334853448535485364853748538485394854048541485424854348544485454854648547485484854948550485514855248553485544855548556485574855848559485604856148562485634856448565485664856748568485694857048571485724857348574485754857648577485784857948580485814858248583485844858548586485874858848589485904859148592485934859448595485964859748598485994860048601486024860348604486054860648607486084860948610486114861248613486144861548616486174861848619486204862148622486234862448625486264862748628486294863048631486324863348634486354863648637486384863948640486414864248643486444864548646486474864848649486504865148652486534865448655486564865748658486594866048661486624866348664486654866648667486684866948670486714867248673486744867548676486774867848679486804868148682486834868448685486864868748688486894869048691486924869348694486954869648697486984869948700487014870248703487044870548706487074870848709487104871148712487134871448715487164871748718487194872048721487224872348724487254872648727487284872948730487314873248733487344873548736487374873848739487404874148742487434874448745487464874748748487494875048751487524875348754487554875648757487584875948760487614876248763487644876548766487674876848769487704877148772487734877448775487764877748778487794878048781487824878348784487854878648787487884878948790487914879248793487944879548796487974879848799488004880148802488034880448805488064880748808488094881048811488124881348814488154881648817488184881948820488214882248823488244882548826488274882848829488304883148832488334883448835488364883748838488394884048841488424884348844488454884648847488484884948850488514885248853488544885548856488574885848859488604886148862488634886448865488664886748868488694887048871488724887348874488754887648877488784887948880488814888248883488844888548886488874888848889488904889148892488934889448895488964889748898488994890048901489024890348904489054890648907489084890948910489114891248913489144891548916489174891848919489204892148922489234892448925489264892748928489294893048931489324893348934489354893648937489384893948940489414894248943489444894548946489474894848949489504895148952489534895448955489564895748958489594896048961489624896348964489654896648967489684896948970489714897248973489744897548976489774897848979489804898148982489834898448985489864898748988489894899048991489924899348994489954899648997489984899949000490014900249003490044900549006490074900849009490104901149012490134901449015490164901749018490194902049021490224902349024490254902649027490284902949030490314903249033490344903549036490374903849039490404904149042490434904449045490464904749048490494905049051490524905349054490554905649057490584905949060490614906249063490644906549066490674906849069490704907149072490734907449075490764907749078490794908049081490824908349084490854908649087490884908949090490914909249093490944909549096490974909849099491004910149102491034910449105491064910749108491094911049111491124911349114491154911649117491184911949120491214912249123491244912549126491274912849129491304913149132491334913449135491364913749138491394914049141491424914349144491454914649147491484914949150491514915249153491544915549156491574915849159491604916149162491634916449165491664916749168491694917049171491724917349174491754917649177491784917949180491814918249183491844918549186491874918849189491904919149192491934919449195491964919749198491994920049201492024920349204492054920649207492084920949210492114921249213492144921549216492174921849219492204922149222492234922449225492264922749228492294923049231492324923349234492354923649237492384923949240492414924249243492444924549246492474924849249492504925149252492534925449255492564925749258492594926049261492624926349264492654926649267492684926949270492714927249273492744927549276492774927849279492804928149282492834928449285492864928749288492894929049291492924929349294492954929649297492984929949300493014930249303493044930549306493074930849309493104931149312493134931449315493164931749318493194932049321493224932349324493254932649327493284932949330493314933249333493344933549336493374933849339493404934149342493434934449345493464934749348493494935049351493524935349354493554935649357493584935949360493614936249363493644936549366493674936849369493704937149372493734937449375493764937749378493794938049381493824938349384493854938649387493884938949390493914939249393493944939549396493974939849399494004940149402494034940449405494064940749408494094941049411494124941349414494154941649417494184941949420494214942249423494244942549426494274942849429494304943149432494334943449435494364943749438494394944049441494424944349444494454944649447494484944949450494514945249453494544945549456494574945849459494604946149462494634946449465494664946749468494694947049471494724947349474494754947649477494784947949480494814948249483494844948549486494874948849489494904949149492494934949449495494964949749498494994950049501495024950349504495054950649507495084950949510495114951249513495144951549516495174951849519495204952149522495234952449525495264952749528495294953049531495324953349534495354953649537495384953949540495414954249543495444954549546495474954849549495504955149552495534955449555495564955749558495594956049561495624956349564495654956649567495684956949570495714957249573495744957549576495774957849579495804958149582495834958449585495864958749588495894959049591495924959349594495954959649597495984959949600496014960249603496044960549606496074960849609496104961149612496134961449615496164961749618496194962049621496224962349624496254962649627496284962949630496314963249633496344963549636496374963849639496404964149642496434964449645496464964749648496494965049651496524965349654496554965649657496584965949660496614966249663496644966549666496674966849669496704967149672496734967449675496764967749678496794968049681496824968349684496854968649687496884968949690496914969249693496944969549696496974969849699497004970149702497034970449705497064970749708497094971049711497124971349714497154971649717497184971949720497214972249723497244972549726497274972849729497304973149732497334973449735497364973749738497394974049741497424974349744497454974649747497484974949750497514975249753497544975549756497574975849759497604976149762497634976449765497664976749768497694977049771497724977349774497754977649777497784977949780497814978249783497844978549786497874978849789497904979149792497934979449795497964979749798497994980049801498024980349804498054980649807498084980949810498114981249813498144981549816498174981849819498204982149822498234982449825498264982749828498294983049831498324983349834498354983649837498384983949840498414984249843498444984549846498474984849849498504985149852498534985449855498564985749858498594986049861498624986349864498654986649867498684986949870498714987249873498744987549876498774987849879498804988149882498834988449885498864988749888498894989049891498924989349894498954989649897498984989949900499014990249903499044990549906499074990849909499104991149912499134991449915499164991749918499194992049921499224992349924499254992649927499284992949930499314993249933499344993549936499374993849939499404994149942499434994449945499464994749948499494995049951499524995349954499554995649957499584995949960499614996249963499644996549966499674996849969499704997149972499734997449975499764997749978499794998049981499824998349984499854998649987499884998949990499914999249993499944999549996499974999849999500005000150002500035000450005500065000750008500095001050011500125001350014500155001650017500185001950020500215002250023500245002550026500275002850029500305003150032500335003450035500365003750038500395004050041500425004350044500455004650047500485004950050500515005250053500545005550056500575005850059500605006150062500635006450065500665006750068500695007050071500725007350074500755007650077500785007950080500815008250083500845008550086500875008850089500905009150092500935009450095500965009750098500995010050101501025010350104501055010650107501085010950110501115011250113501145011550116501175011850119501205012150122501235012450125501265012750128501295013050131501325013350134501355013650137501385013950140501415014250143501445014550146501475014850149501505015150152501535015450155501565015750158501595016050161501625016350164501655016650167501685016950170501715017250173501745017550176501775017850179501805018150182501835018450185501865018750188501895019050191501925019350194501955019650197501985019950200502015020250203502045020550206502075020850209502105021150212502135021450215502165021750218502195022050221502225022350224502255022650227502285022950230502315023250233502345023550236502375023850239502405024150242502435024450245502465024750248502495025050251502525025350254502555025650257502585025950260502615026250263502645026550266502675026850269502705027150272502735027450275502765027750278502795028050281502825028350284502855028650287502885028950290502915029250293502945029550296502975029850299503005030150302503035030450305503065030750308503095031050311503125031350314503155031650317503185031950320503215032250323503245032550326503275032850329503305033150332503335033450335503365033750338503395034050341503425034350344503455034650347503485034950350503515035250353503545035550356503575035850359503605036150362503635036450365503665036750368503695037050371503725037350374503755037650377503785037950380503815038250383503845038550386503875038850389503905039150392503935039450395503965039750398503995040050401504025040350404504055040650407504085040950410504115041250413504145041550416504175041850419504205042150422504235042450425504265042750428504295043050431504325043350434504355043650437504385043950440504415044250443504445044550446504475044850449504505045150452504535045450455504565045750458504595046050461504625046350464504655046650467504685046950470504715047250473504745047550476504775047850479504805048150482504835048450485504865048750488504895049050491504925049350494504955049650497504985049950500505015050250503505045050550506505075050850509505105051150512505135051450515505165051750518505195052050521505225052350524505255052650527505285052950530505315053250533505345053550536505375053850539505405054150542505435054450545505465054750548505495055050551505525055350554505555055650557505585055950560505615056250563505645056550566505675056850569505705057150572505735057450575505765057750578505795058050581505825058350584505855058650587505885058950590505915059250593505945059550596505975059850599506005060150602506035060450605506065060750608506095061050611506125061350614506155061650617506185061950620506215062250623506245062550626506275062850629506305063150632506335063450635506365063750638506395064050641506425064350644506455064650647506485064950650506515065250653506545065550656506575065850659506605066150662506635066450665506665066750668506695067050671506725067350674506755067650677506785067950680506815068250683506845068550686506875068850689506905069150692506935069450695506965069750698506995070050701507025070350704507055070650707507085070950710507115071250713507145071550716507175071850719507205072150722507235072450725507265072750728507295073050731507325073350734507355073650737507385073950740507415074250743507445074550746507475074850749507505075150752507535075450755507565075750758507595076050761507625076350764507655076650767507685076950770507715077250773507745077550776507775077850779507805078150782507835078450785507865078750788507895079050791507925079350794507955079650797507985079950800508015080250803508045080550806508075080850809508105081150812508135081450815508165081750818508195082050821508225082350824508255082650827508285082950830508315083250833508345083550836508375083850839508405084150842508435084450845508465084750848508495085050851508525085350854508555085650857508585085950860508615086250863508645086550866508675086850869508705087150872508735087450875508765087750878508795088050881508825088350884508855088650887508885088950890508915089250893508945089550896508975089850899509005090150902509035090450905509065090750908509095091050911509125091350914509155091650917509185091950920509215092250923509245092550926509275092850929509305093150932509335093450935509365093750938509395094050941509425094350944509455094650947509485094950950509515095250953509545095550956509575095850959509605096150962509635096450965509665096750968509695097050971509725097350974509755097650977509785097950980509815098250983509845098550986509875098850989509905099150992509935099450995509965099750998509995100051001510025100351004510055100651007510085100951010510115101251013510145101551016510175101851019510205102151022510235102451025510265102751028510295103051031510325103351034510355103651037510385103951040510415104251043510445104551046510475104851049510505105151052510535105451055510565105751058510595106051061510625106351064510655106651067510685106951070510715107251073510745107551076510775107851079510805108151082510835108451085510865108751088510895109051091510925109351094510955109651097510985109951100511015110251103511045110551106511075110851109511105111151112511135111451115511165111751118511195112051121511225112351124511255112651127511285112951130511315113251133511345113551136511375113851139511405114151142511435114451145511465114751148511495115051151511525115351154511555115651157511585115951160511615116251163511645116551166511675116851169511705117151172511735117451175511765117751178511795118051181511825118351184511855118651187511885118951190511915119251193511945119551196511975119851199512005120151202512035120451205512065120751208512095121051211512125121351214512155121651217512185121951220512215122251223512245122551226512275122851229512305123151232512335123451235512365123751238512395124051241512425124351244512455124651247512485124951250512515125251253512545125551256512575125851259512605126151262512635126451265512665126751268512695127051271512725127351274512755127651277512785127951280512815128251283512845128551286512875128851289512905129151292512935129451295512965129751298512995130051301513025130351304513055130651307513085130951310513115131251313513145131551316513175131851319513205132151322513235132451325513265132751328513295133051331513325133351334513355133651337513385133951340513415134251343513445134551346513475134851349513505135151352513535135451355513565135751358513595136051361513625136351364513655136651367513685136951370513715137251373513745137551376513775137851379513805138151382513835138451385513865138751388513895139051391513925139351394513955139651397513985139951400514015140251403514045140551406514075140851409514105141151412514135141451415514165141751418514195142051421514225142351424514255142651427514285142951430514315143251433514345143551436514375143851439514405144151442514435144451445514465144751448514495145051451514525145351454514555145651457514585145951460514615146251463514645146551466514675146851469514705147151472514735147451475514765147751478514795148051481514825148351484514855148651487514885148951490514915149251493514945149551496514975149851499515005150151502515035150451505515065150751508515095151051511515125151351514515155151651517515185151951520515215152251523515245152551526515275152851529515305153151532515335153451535515365153751538515395154051541515425154351544515455154651547515485154951550515515155251553515545155551556515575155851559515605156151562515635156451565515665156751568515695157051571515725157351574515755157651577515785157951580515815158251583515845158551586515875158851589515905159151592515935159451595515965159751598515995160051601516025160351604516055160651607516085160951610516115161251613516145161551616516175161851619516205162151622516235162451625516265162751628516295163051631516325163351634516355163651637516385163951640516415164251643516445164551646516475164851649516505165151652516535165451655516565165751658516595166051661516625166351664516655166651667516685166951670516715167251673516745167551676516775167851679516805168151682516835168451685516865168751688516895169051691516925169351694516955169651697516985169951700517015170251703517045170551706517075170851709517105171151712517135171451715517165171751718517195172051721517225172351724517255172651727517285172951730517315173251733517345173551736517375173851739517405174151742517435174451745517465174751748517495175051751517525175351754517555175651757517585175951760517615176251763517645176551766517675176851769517705177151772517735177451775517765177751778517795178051781517825178351784517855178651787517885178951790517915179251793517945179551796517975179851799518005180151802518035180451805518065180751808518095181051811518125181351814518155181651817518185181951820518215182251823518245182551826518275182851829518305183151832518335183451835518365183751838518395184051841518425184351844518455184651847518485184951850518515185251853518545185551856518575185851859518605186151862518635186451865518665186751868518695187051871518725187351874518755187651877518785187951880518815188251883518845188551886518875188851889518905189151892518935189451895518965189751898518995190051901519025190351904519055190651907519085190951910519115191251913519145191551916519175191851919519205192151922519235192451925519265192751928519295193051931519325193351934519355193651937519385193951940519415194251943519445194551946519475194851949519505195151952519535195451955519565195751958519595196051961519625196351964519655196651967519685196951970519715197251973519745197551976519775197851979519805198151982519835198451985519865198751988519895199051991519925199351994519955199651997519985199952000520015200252003520045200552006520075200852009520105201152012520135201452015520165201752018520195202052021520225202352024520255202652027520285202952030520315203252033520345203552036520375203852039520405204152042520435204452045520465204752048520495205052051520525205352054520555205652057520585205952060520615206252063520645206552066520675206852069520705207152072520735207452075520765207752078520795208052081520825208352084520855208652087520885208952090520915209252093520945209552096520975209852099521005210152102521035210452105521065210752108521095211052111521125211352114521155211652117521185211952120521215212252123521245212552126521275212852129521305213152132521335213452135521365213752138521395214052141521425214352144521455214652147521485214952150521515215252153521545215552156521575215852159521605216152162521635216452165521665216752168521695217052171521725217352174521755217652177521785217952180521815218252183521845218552186521875218852189521905219152192521935219452195521965219752198521995220052201522025220352204522055220652207522085220952210522115221252213522145221552216522175221852219522205222152222522235222452225522265222752228522295223052231522325223352234522355223652237522385223952240522415224252243522445224552246522475224852249522505225152252522535225452255522565225752258522595226052261522625226352264522655226652267522685226952270522715227252273522745227552276522775227852279522805228152282522835228452285522865228752288522895229052291522925229352294522955229652297522985229952300523015230252303523045230552306523075230852309523105231152312523135231452315523165231752318523195232052321523225232352324523255232652327523285232952330523315233252333523345233552336523375233852339523405234152342523435234452345523465234752348523495235052351523525235352354523555235652357523585235952360523615236252363523645236552366523675236852369523705237152372523735237452375523765237752378523795238052381523825238352384523855238652387523885238952390523915239252393523945239552396523975239852399524005240152402524035240452405524065240752408524095241052411524125241352414524155241652417524185241952420524215242252423524245242552426524275242852429524305243152432524335243452435524365243752438524395244052441524425244352444524455244652447524485244952450524515245252453524545245552456524575245852459524605246152462524635246452465524665246752468524695247052471524725247352474524755247652477524785247952480524815248252483524845248552486524875248852489524905249152492524935249452495524965249752498524995250052501525025250352504525055250652507525085250952510525115251252513525145251552516525175251852519525205252152522525235252452525525265252752528525295253052531525325253352534525355253652537525385253952540525415254252543525445254552546525475254852549525505255152552525535255452555525565255752558525595256052561525625256352564525655256652567525685256952570525715257252573525745257552576525775257852579525805258152582525835258452585525865258752588525895259052591525925259352594525955259652597525985259952600526015260252603526045260552606526075260852609526105261152612526135261452615526165261752618526195262052621526225262352624526255262652627526285262952630526315263252633526345263552636526375263852639526405264152642526435264452645526465264752648526495265052651526525265352654526555265652657526585265952660526615266252663526645266552666526675266852669526705267152672526735267452675526765267752678526795268052681526825268352684526855268652687526885268952690526915269252693526945269552696526975269852699527005270152702527035270452705527065270752708527095271052711527125271352714527155271652717527185271952720527215272252723527245272552726527275272852729527305273152732527335273452735527365273752738527395274052741527425274352744527455274652747527485274952750527515275252753527545275552756527575275852759527605276152762527635276452765527665276752768527695277052771527725277352774527755277652777527785277952780527815278252783527845278552786527875278852789527905279152792527935279452795527965279752798527995280052801528025280352804528055280652807528085280952810528115281252813528145281552816528175281852819528205282152822528235282452825528265282752828528295283052831528325283352834528355283652837528385283952840528415284252843528445284552846528475284852849528505285152852528535285452855528565285752858528595286052861528625286352864528655286652867528685286952870528715287252873528745287552876528775287852879528805288152882528835288452885528865288752888528895289052891528925289352894528955289652897528985289952900529015290252903529045290552906529075290852909529105291152912529135291452915529165291752918529195292052921529225292352924529255292652927529285292952930529315293252933529345293552936529375293852939529405294152942529435294452945529465294752948529495295052951529525295352954529555295652957529585295952960529615296252963529645296552966529675296852969529705297152972529735297452975529765297752978529795298052981529825298352984529855298652987529885298952990529915299252993529945299552996529975299852999530005300153002530035300453005530065300753008530095301053011530125301353014530155301653017530185301953020530215302253023530245302553026530275302853029530305303153032530335303453035530365303753038530395304053041530425304353044530455304653047530485304953050530515305253053530545305553056530575305853059530605306153062530635306453065530665306753068530695307053071530725307353074530755307653077530785307953080530815308253083530845308553086530875308853089530905309153092530935309453095530965309753098530995310053101531025310353104531055310653107531085310953110531115311253113531145311553116531175311853119531205312153122531235312453125531265312753128531295313053131531325313353134531355313653137531385313953140531415314253143531445314553146531475314853149531505315153152531535315453155531565315753158531595316053161531625316353164531655316653167531685316953170531715317253173531745317553176531775317853179531805318153182531835318453185531865318753188531895319053191531925319353194531955319653197531985319953200532015320253203532045320553206532075320853209532105321153212532135321453215532165321753218532195322053221532225322353224532255322653227532285322953230532315323253233532345323553236532375323853239532405324153242532435324453245532465324753248532495325053251532525325353254532555325653257532585325953260532615326253263532645326553266532675326853269532705327153272532735327453275532765327753278532795328053281532825328353284532855328653287532885328953290532915329253293532945329553296532975329853299533005330153302533035330453305533065330753308533095331053311533125331353314533155331653317533185331953320533215332253323533245332553326533275332853329533305333153332533335333453335533365333753338533395334053341533425334353344533455334653347533485334953350533515335253353533545335553356533575335853359533605336153362533635336453365533665336753368533695337053371533725337353374533755337653377533785337953380533815338253383533845338553386533875338853389533905339153392533935339453395533965339753398533995340053401534025340353404534055340653407534085340953410534115341253413534145341553416534175341853419534205342153422534235342453425534265342753428534295343053431534325343353434534355343653437534385343953440534415344253443534445344553446534475344853449534505345153452534535345453455534565345753458534595346053461534625346353464534655346653467534685346953470534715347253473534745347553476534775347853479534805348153482534835348453485534865348753488534895349053491534925349353494534955349653497534985349953500535015350253503535045350553506535075350853509535105351153512535135351453515535165351753518535195352053521535225352353524535255352653527535285352953530535315353253533535345353553536535375353853539535405354153542535435354453545535465354753548535495355053551535525355353554535555355653557535585355953560535615356253563535645356553566535675356853569535705357153572535735357453575535765357753578535795358053581535825358353584535855358653587535885358953590535915359253593535945359553596535975359853599536005360153602536035360453605536065360753608536095361053611536125361353614536155361653617536185361953620536215362253623536245362553626536275362853629536305363153632536335363453635536365363753638536395364053641536425364353644536455364653647536485364953650536515365253653536545365553656536575365853659536605366153662536635366453665536665366753668536695367053671536725367353674536755367653677536785367953680536815368253683536845368553686536875368853689536905369153692536935369453695536965369753698536995370053701537025370353704537055370653707537085370953710537115371253713537145371553716537175371853719537205372153722537235372453725537265372753728537295373053731537325373353734537355373653737537385373953740537415374253743537445374553746537475374853749537505375153752537535375453755537565375753758537595376053761537625376353764537655376653767537685376953770537715377253773537745377553776537775377853779537805378153782537835378453785537865378753788537895379053791537925379353794537955379653797537985379953800538015380253803538045380553806538075380853809538105381153812538135381453815538165381753818538195382053821538225382353824538255382653827538285382953830538315383253833538345383553836538375383853839538405384153842538435384453845538465384753848538495385053851538525385353854538555385653857538585385953860538615386253863538645386553866538675386853869538705387153872538735387453875538765387753878538795388053881538825388353884538855388653887538885388953890538915389253893538945389553896538975389853899539005390153902539035390453905539065390753908539095391053911539125391353914539155391653917539185391953920539215392253923539245392553926539275392853929539305393153932539335393453935539365393753938539395394053941539425394353944539455394653947539485394953950539515395253953539545395553956539575395853959539605396153962539635396453965539665396753968539695397053971539725397353974539755397653977539785397953980539815398253983539845398553986539875398853989539905399153992539935399453995539965399753998539995400054001540025400354004540055400654007540085400954010540115401254013540145401554016540175401854019540205402154022540235402454025540265402754028540295403054031540325403354034540355403654037540385403954040540415404254043540445404554046540475404854049540505405154052540535405454055540565405754058540595406054061540625406354064540655406654067540685406954070540715407254073540745407554076540775407854079540805408154082540835408454085540865408754088540895409054091540925409354094540955409654097540985409954100541015410254103541045410554106541075410854109541105411154112541135411454115541165411754118541195412054121541225412354124541255412654127541285412954130541315413254133541345413554136541375413854139541405414154142541435414454145541465414754148541495415054151541525415354154541555415654157541585415954160541615416254163541645416554166541675416854169541705417154172541735417454175541765417754178541795418054181541825418354184541855418654187541885418954190541915419254193541945419554196541975419854199542005420154202542035420454205542065420754208542095421054211542125421354214542155421654217542185421954220542215422254223542245422554226542275422854229542305423154232542335423454235542365423754238542395424054241542425424354244542455424654247542485424954250542515425254253542545425554256542575425854259542605426154262542635426454265542665426754268542695427054271542725427354274542755427654277542785427954280542815428254283542845428554286542875428854289542905429154292542935429454295542965429754298542995430054301543025430354304543055430654307543085430954310543115431254313543145431554316543175431854319543205432154322543235432454325543265432754328543295433054331543325433354334543355433654337543385433954340543415434254343543445434554346543475434854349543505435154352543535435454355543565435754358543595436054361543625436354364543655436654367543685436954370543715437254373543745437554376543775437854379543805438154382543835438454385543865438754388543895439054391543925439354394543955439654397543985439954400544015440254403544045440554406544075440854409544105441154412544135441454415544165441754418544195442054421544225442354424544255442654427544285442954430544315443254433544345443554436544375443854439544405444154442544435444454445544465444754448544495445054451544525445354454544555445654457544585445954460544615446254463544645446554466544675446854469544705447154472544735447454475544765447754478544795448054481544825448354484544855448654487544885448954490544915449254493544945449554496544975449854499545005450154502545035450454505545065450754508545095451054511545125451354514545155451654517545185451954520545215452254523545245452554526545275452854529545305453154532545335453454535545365453754538545395454054541545425454354544545455454654547545485454954550545515455254553545545455554556545575455854559545605456154562545635456454565545665456754568545695457054571545725457354574545755457654577545785457954580545815458254583545845458554586545875458854589545905459154592545935459454595545965459754598545995460054601546025460354604546055460654607546085460954610546115461254613546145461554616546175461854619546205462154622546235462454625546265462754628546295463054631546325463354634546355463654637546385463954640546415464254643546445464554646546475464854649546505465154652546535465454655546565465754658546595466054661546625466354664546655466654667546685466954670546715467254673546745467554676546775467854679546805468154682546835468454685546865468754688546895469054691546925469354694546955469654697546985469954700547015470254703547045470554706547075470854709547105471154712547135471454715547165471754718547195472054721547225472354724547255472654727547285472954730547315473254733547345473554736547375473854739547405474154742547435474454745547465474754748547495475054751547525475354754547555475654757547585475954760547615476254763547645476554766547675476854769547705477154772547735477454775547765477754778547795478054781547825478354784547855478654787547885478954790547915479254793547945479554796547975479854799548005480154802548035480454805548065480754808548095481054811548125481354814548155481654817548185481954820548215482254823548245482554826548275482854829548305483154832548335483454835548365483754838548395484054841548425484354844548455484654847548485484954850548515485254853548545485554856548575485854859548605486154862548635486454865548665486754868548695487054871548725487354874548755487654877548785487954880548815488254883548845488554886548875488854889548905489154892548935489454895548965489754898548995490054901549025490354904549055490654907549085490954910549115491254913549145491554916549175491854919549205492154922549235492454925549265492754928549295493054931549325493354934549355493654937549385493954940549415494254943549445494554946549475494854949549505495154952549535495454955549565495754958549595496054961549625496354964549655496654967549685496954970549715497254973549745497554976549775497854979549805498154982549835498454985549865498754988549895499054991549925499354994549955499654997549985499955000550015500255003550045500555006550075500855009550105501155012550135501455015550165501755018550195502055021550225502355024550255502655027550285502955030550315503255033550345503555036550375503855039550405504155042550435504455045550465504755048550495505055051550525505355054550555505655057550585505955060550615506255063550645506555066550675506855069550705507155072550735507455075550765507755078550795508055081550825508355084550855508655087550885508955090550915509255093550945509555096550975509855099551005510155102551035510455105551065510755108551095511055111551125511355114551155511655117551185511955120551215512255123551245512555126551275512855129551305513155132551335513455135551365513755138551395514055141551425514355144551455514655147551485514955150551515515255153551545515555156551575515855159551605516155162551635516455165551665516755168551695517055171551725517355174551755517655177551785517955180551815518255183551845518555186551875518855189551905519155192551935519455195551965519755198551995520055201552025520355204552055520655207552085520955210552115521255213552145521555216552175521855219552205522155222552235522455225552265522755228552295523055231552325523355234552355523655237552385523955240552415524255243552445524555246552475524855249552505525155252552535525455255552565525755258552595526055261552625526355264552655526655267552685526955270552715527255273552745527555276552775527855279552805528155282552835528455285552865528755288552895529055291552925529355294552955529655297552985529955300553015530255303553045530555306553075530855309553105531155312553135531455315553165531755318553195532055321553225532355324553255532655327553285532955330553315533255333553345533555336553375533855339553405534155342553435534455345553465534755348553495535055351553525535355354553555535655357553585535955360553615536255363553645536555366553675536855369553705537155372553735537455375553765537755378553795538055381553825538355384553855538655387553885538955390553915539255393553945539555396553975539855399554005540155402554035540455405554065540755408554095541055411554125541355414554155541655417554185541955420554215542255423554245542555426554275542855429554305543155432554335543455435554365543755438554395544055441554425544355444554455544655447554485544955450554515545255453554545545555456554575545855459554605546155462554635546455465554665546755468554695547055471554725547355474554755547655477554785547955480554815548255483554845548555486554875548855489554905549155492554935549455495554965549755498554995550055501555025550355504555055550655507555085550955510555115551255513555145551555516555175551855519555205552155522555235552455525555265552755528555295553055531555325553355534555355553655537555385553955540555415554255543555445554555546555475554855549555505555155552555535555455555555565555755558555595556055561555625556355564555655556655567555685556955570555715557255573555745557555576555775557855579555805558155582555835558455585555865558755588555895559055591555925559355594555955559655597555985559955600556015560255603556045560555606556075560855609556105561155612556135561455615556165561755618556195562055621556225562355624556255562655627556285562955630556315563255633556345563555636556375563855639556405564155642556435564455645556465564755648556495565055651556525565355654556555565655657556585565955660556615566255663556645566555666556675566855669556705567155672556735567455675556765567755678556795568055681556825568355684556855568655687556885568955690556915569255693556945569555696556975569855699557005570155702557035570455705557065570755708557095571055711557125571355714557155571655717557185571955720557215572255723557245572555726557275572855729557305573155732557335573455735557365573755738557395574055741557425574355744557455574655747557485574955750557515575255753557545575555756557575575855759557605576155762557635576455765557665576755768557695577055771557725577355774557755577655777557785577955780557815578255783557845578555786557875578855789557905579155792557935579455795557965579755798557995580055801558025580355804558055580655807558085580955810558115581255813558145581555816558175581855819558205582155822558235582455825558265582755828558295583055831558325583355834558355583655837558385583955840558415584255843558445584555846558475584855849558505585155852558535585455855558565585755858558595586055861558625586355864558655586655867558685586955870558715587255873558745587555876558775587855879558805588155882558835588455885558865588755888558895589055891558925589355894558955589655897558985589955900559015590255903559045590555906559075590855909559105591155912559135591455915559165591755918559195592055921559225592355924559255592655927559285592955930559315593255933559345593555936559375593855939559405594155942559435594455945559465594755948559495595055951559525595355954559555595655957559585595955960559615596255963559645596555966559675596855969559705597155972559735597455975559765597755978559795598055981559825598355984559855598655987559885598955990559915599255993559945599555996559975599855999560005600156002560035600456005560065600756008560095601056011560125601356014560155601656017560185601956020560215602256023560245602556026560275602856029560305603156032560335603456035560365603756038560395604056041560425604356044560455604656047560485604956050560515605256053560545605556056560575605856059560605606156062560635606456065560665606756068560695607056071560725607356074560755607656077560785607956080560815608256083560845608556086560875608856089560905609156092560935609456095560965609756098560995610056101561025610356104561055610656107561085610956110561115611256113561145611556116561175611856119561205612156122561235612456125561265612756128561295613056131561325613356134561355613656137561385613956140561415614256143561445614556146561475614856149561505615156152561535615456155561565615756158561595616056161561625616356164561655616656167561685616956170561715617256173561745617556176561775617856179561805618156182561835618456185561865618756188561895619056191561925619356194561955619656197561985619956200562015620256203562045620556206562075620856209562105621156212562135621456215562165621756218562195622056221562225622356224562255622656227562285622956230562315623256233562345623556236562375623856239562405624156242562435624456245562465624756248562495625056251562525625356254562555625656257562585625956260562615626256263562645626556266562675626856269562705627156272562735627456275562765627756278562795628056281562825628356284562855628656287562885628956290562915629256293562945629556296562975629856299563005630156302563035630456305563065630756308563095631056311563125631356314563155631656317563185631956320563215632256323563245632556326563275632856329563305633156332563335633456335563365633756338563395634056341563425634356344563455634656347563485634956350563515635256353563545635556356563575635856359563605636156362563635636456365563665636756368563695637056371563725637356374563755637656377563785637956380563815638256383563845638556386563875638856389563905639156392563935639456395563965639756398563995640056401564025640356404564055640656407564085640956410564115641256413564145641556416564175641856419564205642156422564235642456425564265642756428564295643056431564325643356434564355643656437564385643956440564415644256443564445644556446564475644856449564505645156452564535645456455564565645756458564595646056461564625646356464564655646656467564685646956470564715647256473564745647556476564775647856479564805648156482564835648456485564865648756488564895649056491564925649356494564955649656497564985649956500565015650256503565045650556506565075650856509565105651156512565135651456515565165651756518565195652056521565225652356524565255652656527565285652956530565315653256533565345653556536565375653856539565405654156542565435654456545565465654756548565495655056551565525655356554565555655656557565585655956560565615656256563565645656556566565675656856569565705657156572565735657456575565765657756578565795658056581565825658356584565855658656587565885658956590565915659256593565945659556596565975659856599566005660156602566035660456605566065660756608566095661056611566125661356614566155661656617566185661956620566215662256623566245662556626566275662856629566305663156632566335663456635566365663756638566395664056641566425664356644566455664656647566485664956650566515665256653566545665556656566575665856659566605666156662566635666456665566665666756668566695667056671566725667356674566755667656677566785667956680566815668256683566845668556686566875668856689566905669156692566935669456695566965669756698566995670056701567025670356704567055670656707567085670956710567115671256713567145671556716567175671856719567205672156722567235672456725567265672756728567295673056731567325673356734567355673656737567385673956740567415674256743567445674556746567475674856749567505675156752567535675456755567565675756758567595676056761567625676356764567655676656767567685676956770567715677256773567745677556776567775677856779567805678156782567835678456785567865678756788567895679056791567925679356794567955679656797567985679956800568015680256803568045680556806568075680856809568105681156812568135681456815568165681756818568195682056821568225682356824568255682656827568285682956830568315683256833568345683556836568375683856839568405684156842568435684456845568465684756848568495685056851568525685356854568555685656857568585685956860568615686256863568645686556866568675686856869568705687156872568735687456875568765687756878568795688056881568825688356884568855688656887568885688956890568915689256893568945689556896568975689856899569005690156902569035690456905569065690756908569095691056911569125691356914569155691656917569185691956920569215692256923569245692556926569275692856929569305693156932569335693456935569365693756938569395694056941569425694356944569455694656947569485694956950569515695256953569545695556956569575695856959569605696156962569635696456965569665696756968569695697056971569725697356974569755697656977569785697956980569815698256983569845698556986569875698856989569905699156992569935699456995569965699756998569995700057001570025700357004570055700657007570085700957010570115701257013570145701557016570175701857019570205702157022570235702457025570265702757028570295703057031570325703357034570355703657037570385703957040570415704257043570445704557046570475704857049570505705157052570535705457055570565705757058570595706057061570625706357064570655706657067570685706957070570715707257073570745707557076570775707857079570805708157082570835708457085570865708757088570895709057091570925709357094570955709657097570985709957100571015710257103571045710557106571075710857109571105711157112571135711457115571165711757118571195712057121571225712357124571255712657127571285712957130571315713257133571345713557136571375713857139571405714157142571435714457145571465714757148571495715057151571525715357154571555715657157571585715957160571615716257163571645716557166571675716857169571705717157172571735717457175571765717757178571795718057181571825718357184571855718657187571885718957190571915719257193571945719557196571975719857199572005720157202572035720457205572065720757208572095721057211572125721357214572155721657217572185721957220572215722257223572245722557226572275722857229572305723157232572335723457235572365723757238572395724057241572425724357244572455724657247572485724957250572515725257253572545725557256572575725857259572605726157262572635726457265572665726757268572695727057271572725727357274572755727657277572785727957280572815728257283572845728557286572875728857289572905729157292572935729457295572965729757298572995730057301573025730357304573055730657307573085730957310573115731257313573145731557316573175731857319573205732157322573235732457325573265732757328573295733057331573325733357334573355733657337573385733957340573415734257343573445734557346573475734857349573505735157352573535735457355573565735757358573595736057361573625736357364573655736657367573685736957370573715737257373573745737557376573775737857379573805738157382573835738457385573865738757388573895739057391573925739357394573955739657397573985739957400574015740257403574045740557406574075740857409574105741157412574135741457415574165741757418574195742057421574225742357424574255742657427574285742957430574315743257433574345743557436574375743857439574405744157442574435744457445574465744757448574495745057451574525745357454574555745657457574585745957460574615746257463574645746557466574675746857469574705747157472574735747457475574765747757478574795748057481574825748357484574855748657487574885748957490574915749257493574945749557496574975749857499575005750157502575035750457505575065750757508575095751057511575125751357514575155751657517575185751957520575215752257523575245752557526575275752857529575305753157532575335753457535575365753757538575395754057541575425754357544575455754657547575485754957550575515755257553575545755557556575575755857559575605756157562575635756457565575665756757568575695757057571575725757357574575755757657577575785757957580575815758257583575845758557586575875758857589575905759157592575935759457595575965759757598575995760057601576025760357604576055760657607576085760957610576115761257613576145761557616576175761857619576205762157622576235762457625576265762757628576295763057631576325763357634576355763657637576385763957640576415764257643576445764557646576475764857649576505765157652576535765457655576565765757658576595766057661576625766357664576655766657667576685766957670576715767257673576745767557676576775767857679576805768157682576835768457685576865768757688576895769057691576925769357694576955769657697576985769957700577015770257703577045770557706577075770857709577105771157712577135771457715577165771757718577195772057721577225772357724577255772657727577285772957730577315773257733577345773557736577375773857739577405774157742577435774457745577465774757748577495775057751577525775357754577555775657757577585775957760577615776257763577645776557766577675776857769577705777157772577735777457775577765777757778577795778057781577825778357784577855778657787577885778957790577915779257793577945779557796577975779857799578005780157802578035780457805578065780757808578095781057811578125781357814578155781657817578185781957820578215782257823578245782557826578275782857829578305783157832578335783457835578365783757838578395784057841578425784357844578455784657847578485784957850578515785257853578545785557856578575785857859578605786157862578635786457865578665786757868578695787057871578725787357874578755787657877578785787957880578815788257883578845788557886578875788857889578905789157892578935789457895578965789757898578995790057901579025790357904579055790657907579085790957910579115791257913579145791557916579175791857919579205792157922579235792457925579265792757928579295793057931579325793357934579355793657937579385793957940579415794257943579445794557946579475794857949579505795157952579535795457955579565795757958579595796057961579625796357964579655796657967579685796957970579715797257973579745797557976579775797857979579805798157982579835798457985579865798757988579895799057991579925799357994579955799657997579985799958000580015800258003580045800558006580075800858009580105801158012580135801458015580165801758018580195802058021580225802358024580255802658027580285802958030580315803258033580345803558036580375803858039580405804158042580435804458045580465804758048580495805058051580525805358054580555805658057580585805958060580615806258063580645806558066580675806858069580705807158072580735807458075580765807758078580795808058081580825808358084580855808658087580885808958090580915809258093580945809558096580975809858099581005810158102581035810458105581065810758108581095811058111581125811358114581155811658117581185811958120581215812258123581245812558126581275812858129581305813158132581335813458135581365813758138581395814058141581425814358144581455814658147581485814958150581515815258153581545815558156581575815858159581605816158162581635816458165581665816758168581695817058171581725817358174581755817658177581785817958180581815818258183581845818558186581875818858189581905819158192581935819458195581965819758198581995820058201582025820358204582055820658207582085820958210582115821258213582145821558216582175821858219582205822158222582235822458225582265822758228582295823058231582325823358234582355823658237582385823958240582415824258243582445824558246582475824858249582505825158252582535825458255582565825758258582595826058261582625826358264582655826658267582685826958270582715827258273582745827558276582775827858279582805828158282582835828458285582865828758288582895829058291582925829358294582955829658297582985829958300583015830258303583045830558306583075830858309583105831158312583135831458315583165831758318583195832058321583225832358324583255832658327583285832958330583315833258333583345833558336583375833858339583405834158342583435834458345583465834758348583495835058351583525835358354583555835658357583585835958360583615836258363583645836558366583675836858369583705837158372583735837458375583765837758378583795838058381583825838358384583855838658387583885838958390583915839258393583945839558396583975839858399584005840158402584035840458405584065840758408584095841058411584125841358414584155841658417584185841958420584215842258423584245842558426584275842858429584305843158432584335843458435584365843758438584395844058441584425844358444584455844658447584485844958450584515845258453584545845558456584575845858459584605846158462584635846458465584665846758468584695847058471584725847358474584755847658477584785847958480584815848258483584845848558486584875848858489584905849158492584935849458495584965849758498584995850058501585025850358504585055850658507585085850958510585115851258513585145851558516585175851858519585205852158522585235852458525585265852758528585295853058531585325853358534585355853658537585385853958540585415854258543585445854558546585475854858549585505855158552585535855458555585565855758558585595856058561585625856358564585655856658567585685856958570585715857258573585745857558576585775857858579585805858158582585835858458585585865858758588585895859058591585925859358594585955859658597585985859958600586015860258603586045860558606586075860858609586105861158612586135861458615586165861758618586195862058621586225862358624586255862658627586285862958630586315863258633586345863558636586375863858639586405864158642586435864458645586465864758648586495865058651586525865358654586555865658657586585865958660586615866258663586645866558666586675866858669586705867158672586735867458675586765867758678586795868058681586825868358684586855868658687586885868958690586915869258693586945869558696586975869858699587005870158702587035870458705587065870758708587095871058711587125871358714587155871658717587185871958720587215872258723587245872558726587275872858729587305873158732587335873458735587365873758738587395874058741587425874358744587455874658747587485874958750587515875258753587545875558756587575875858759587605876158762587635876458765587665876758768587695877058771587725877358774587755877658777587785877958780587815878258783587845878558786587875878858789587905879158792587935879458795587965879758798587995880058801588025880358804588055880658807588085880958810588115881258813588145881558816588175881858819588205882158822588235882458825588265882758828588295883058831588325883358834588355883658837588385883958840588415884258843588445884558846588475884858849588505885158852588535885458855588565885758858588595886058861588625886358864588655886658867588685886958870588715887258873588745887558876588775887858879588805888158882588835888458885588865888758888588895889058891588925889358894588955889658897588985889958900589015890258903589045890558906589075890858909589105891158912589135891458915589165891758918589195892058921589225892358924589255892658927589285892958930589315893258933589345893558936589375893858939589405894158942589435894458945589465894758948589495895058951589525895358954589555895658957589585895958960589615896258963589645896558966589675896858969589705897158972589735897458975589765897758978589795898058981589825898358984589855898658987589885898958990589915899258993589945899558996589975899858999590005900159002590035900459005590065900759008590095901059011590125901359014590155901659017590185901959020590215902259023590245902559026590275902859029590305903159032590335903459035590365903759038590395904059041590425904359044590455904659047590485904959050590515905259053590545905559056590575905859059590605906159062590635906459065590665906759068590695907059071590725907359074590755907659077590785907959080590815908259083590845908559086590875908859089590905909159092590935909459095590965909759098590995910059101591025910359104591055910659107591085910959110591115911259113591145911559116591175911859119591205912159122591235912459125591265912759128591295913059131591325913359134591355913659137591385913959140591415914259143591445914559146591475914859149591505915159152591535915459155591565915759158591595916059161591625916359164591655916659167591685916959170591715917259173591745917559176591775917859179591805918159182591835918459185591865918759188591895919059191591925919359194591955919659197591985919959200592015920259203592045920559206592075920859209592105921159212592135921459215592165921759218592195922059221592225922359224592255922659227592285922959230592315923259233592345923559236592375923859239592405924159242592435924459245592465924759248592495925059251592525925359254592555925659257592585925959260592615926259263592645926559266592675926859269592705927159272592735927459275592765927759278592795928059281592825928359284592855928659287592885928959290592915929259293592945929559296592975929859299593005930159302593035930459305593065930759308593095931059311593125931359314593155931659317593185931959320593215932259323593245932559326593275932859329593305933159332593335933459335593365933759338593395934059341593425934359344593455934659347593485934959350593515935259353593545935559356593575935859359593605936159362593635936459365593665936759368593695937059371593725937359374593755937659377593785937959380593815938259383593845938559386593875938859389593905939159392593935939459395593965939759398593995940059401594025940359404594055940659407594085940959410594115941259413594145941559416594175941859419594205942159422594235942459425594265942759428594295943059431594325943359434594355943659437594385943959440594415944259443594445944559446594475944859449594505945159452594535945459455594565945759458594595946059461594625946359464594655946659467594685946959470594715947259473594745947559476594775947859479594805948159482594835948459485594865948759488594895949059491594925949359494594955949659497594985949959500595015950259503595045950559506595075950859509595105951159512595135951459515595165951759518595195952059521595225952359524595255952659527595285952959530595315953259533595345953559536595375953859539595405954159542595435954459545595465954759548595495955059551595525955359554595555955659557595585955959560595615956259563595645956559566595675956859569595705957159572595735957459575595765957759578595795958059581595825958359584595855958659587595885958959590595915959259593595945959559596595975959859599596005960159602596035960459605596065960759608596095961059611596125961359614596155961659617596185961959620596215962259623596245962559626596275962859629596305963159632596335963459635596365963759638596395964059641596425964359644596455964659647596485964959650596515965259653596545965559656596575965859659596605966159662596635966459665596665966759668596695967059671596725967359674596755967659677596785967959680596815968259683596845968559686596875968859689596905969159692596935969459695596965969759698596995970059701597025970359704597055970659707597085970959710597115971259713597145971559716597175971859719597205972159722597235972459725597265972759728597295973059731597325973359734597355973659737597385973959740597415974259743597445974559746597475974859749597505975159752597535975459755597565975759758597595976059761597625976359764597655976659767597685976959770597715977259773597745977559776597775977859779597805978159782597835978459785597865978759788597895979059791597925979359794597955979659797597985979959800598015980259803598045980559806598075980859809598105981159812598135981459815598165981759818598195982059821598225982359824598255982659827598285982959830598315983259833598345983559836598375983859839598405984159842598435984459845598465984759848598495985059851598525985359854598555985659857598585985959860598615986259863598645986559866598675986859869598705987159872598735987459875598765987759878598795988059881598825988359884598855988659887598885988959890598915989259893598945989559896598975989859899599005990159902599035990459905599065990759908599095991059911599125991359914599155991659917599185991959920599215992259923599245992559926599275992859929599305993159932599335993459935599365993759938599395994059941599425994359944599455994659947599485994959950599515995259953599545995559956599575995859959599605996159962599635996459965599665996759968599695997059971599725997359974599755997659977599785997959980599815998259983599845998559986599875998859989599905999159992599935999459995599965999759998599996000060001600026000360004600056000660007600086000960010600116001260013600146001560016600176001860019600206002160022600236002460025600266002760028600296003060031600326003360034600356003660037600386003960040600416004260043600446004560046600476004860049600506005160052600536005460055600566005760058600596006060061600626006360064600656006660067600686006960070600716007260073600746007560076600776007860079600806008160082600836008460085600866008760088600896009060091600926009360094600956009660097600986009960100601016010260103601046010560106601076010860109601106011160112601136011460115601166011760118601196012060121601226012360124601256012660127601286012960130601316013260133601346013560136601376013860139601406014160142601436014460145601466014760148601496015060151601526015360154601556015660157601586015960160601616016260163601646016560166601676016860169601706017160172601736017460175601766017760178601796018060181601826018360184601856018660187601886018960190601916019260193601946019560196601976019860199602006020160202602036020460205602066020760208602096021060211602126021360214602156021660217602186021960220602216022260223602246022560226602276022860229602306023160232602336023460235602366023760238602396024060241602426024360244602456024660247602486024960250602516025260253602546025560256602576025860259602606026160262602636026460265602666026760268602696027060271602726027360274602756027660277602786027960280602816028260283602846028560286602876028860289602906029160292602936029460295602966029760298602996030060301603026030360304603056030660307603086030960310603116031260313603146031560316603176031860319603206032160322603236032460325603266032760328603296033060331603326033360334603356033660337603386033960340603416034260343603446034560346603476034860349603506035160352603536035460355603566035760358603596036060361603626036360364603656036660367603686036960370603716037260373603746037560376603776037860379603806038160382603836038460385603866038760388603896039060391603926039360394603956039660397603986039960400604016040260403604046040560406604076040860409604106041160412604136041460415604166041760418604196042060421604226042360424604256042660427604286042960430604316043260433604346043560436604376043860439604406044160442604436044460445604466044760448604496045060451604526045360454604556045660457604586045960460604616046260463604646046560466604676046860469604706047160472604736047460475604766047760478604796048060481604826048360484604856048660487604886048960490604916049260493604946049560496604976049860499605006050160502605036050460505605066050760508605096051060511605126051360514605156051660517605186051960520605216052260523605246052560526605276052860529605306053160532605336053460535605366053760538605396054060541605426054360544605456054660547605486054960550605516055260553605546055560556605576055860559605606056160562605636056460565605666056760568605696057060571605726057360574605756057660577605786057960580605816058260583605846058560586605876058860589605906059160592605936059460595605966059760598605996060060601606026060360604606056060660607606086060960610606116061260613606146061560616606176061860619606206062160622606236062460625606266062760628606296063060631606326063360634606356063660637606386063960640606416064260643606446064560646606476064860649606506065160652606536065460655606566065760658606596066060661606626066360664606656066660667606686066960670606716067260673606746067560676606776067860679606806068160682606836068460685606866068760688606896069060691606926069360694606956069660697606986069960700607016070260703607046070560706607076070860709607106071160712607136071460715607166071760718607196072060721607226072360724607256072660727607286072960730607316073260733607346073560736607376073860739607406074160742607436074460745607466074760748607496075060751607526075360754607556075660757607586075960760607616076260763607646076560766607676076860769607706077160772607736077460775607766077760778607796078060781607826078360784607856078660787607886078960790607916079260793607946079560796607976079860799608006080160802608036080460805608066080760808608096081060811608126081360814608156081660817608186081960820608216082260823608246082560826608276082860829608306083160832608336083460835608366083760838608396084060841608426084360844608456084660847608486084960850608516085260853608546085560856608576085860859608606086160862608636086460865608666086760868608696087060871608726087360874608756087660877608786087960880608816088260883608846088560886608876088860889608906089160892608936089460895608966089760898608996090060901609026090360904609056090660907609086090960910609116091260913609146091560916609176091860919609206092160922609236092460925609266092760928609296093060931609326093360934609356093660937609386093960940609416094260943609446094560946609476094860949609506095160952609536095460955609566095760958609596096060961609626096360964609656096660967609686096960970609716097260973609746097560976609776097860979609806098160982609836098460985609866098760988609896099060991609926099360994609956099660997609986099961000610016100261003610046100561006610076100861009610106101161012610136101461015610166101761018610196102061021610226102361024610256102661027610286102961030610316103261033610346103561036610376103861039610406104161042610436104461045610466104761048610496105061051610526105361054610556105661057610586105961060610616106261063610646106561066610676106861069610706107161072610736107461075610766107761078610796108061081610826108361084610856108661087610886108961090610916109261093610946109561096610976109861099611006110161102611036110461105611066110761108611096111061111611126111361114611156111661117611186111961120611216112261123611246112561126611276112861129611306113161132611336113461135611366113761138611396114061141611426114361144611456114661147611486114961150611516115261153611546115561156611576115861159611606116161162611636116461165611666116761168611696117061171611726117361174611756117661177611786117961180611816118261183611846118561186611876118861189611906119161192611936119461195611966119761198611996120061201612026120361204612056120661207612086120961210612116121261213612146121561216612176121861219612206122161222612236122461225612266122761228612296123061231612326123361234612356123661237612386123961240612416124261243612446124561246612476124861249612506125161252612536125461255612566125761258612596126061261612626126361264612656126661267612686126961270612716127261273612746127561276612776127861279612806128161282612836128461285612866128761288612896129061291612926129361294612956129661297612986129961300613016130261303613046130561306613076130861309613106131161312613136131461315613166131761318613196132061321613226132361324613256132661327613286132961330613316133261333613346133561336613376133861339613406134161342613436134461345613466134761348613496135061351613526135361354613556135661357613586135961360613616136261363613646136561366613676136861369613706137161372613736137461375613766137761378613796138061381613826138361384613856138661387613886138961390613916139261393613946139561396613976139861399614006140161402614036140461405614066140761408614096141061411614126141361414614156141661417614186141961420614216142261423614246142561426614276142861429614306143161432614336143461435614366143761438614396144061441614426144361444614456144661447614486144961450614516145261453614546145561456614576145861459614606146161462614636146461465614666146761468614696147061471614726147361474614756147661477614786147961480614816148261483614846148561486614876148861489614906149161492614936149461495614966149761498614996150061501615026150361504615056150661507615086150961510615116151261513615146151561516615176151861519615206152161522615236152461525615266152761528615296153061531615326153361534615356153661537615386153961540615416154261543615446154561546615476154861549615506155161552615536155461555615566155761558615596156061561615626156361564615656156661567615686156961570615716157261573615746157561576615776157861579615806158161582615836158461585615866158761588615896159061591615926159361594615956159661597615986159961600616016160261603616046160561606616076160861609616106161161612616136161461615616166161761618616196162061621616226162361624616256162661627616286162961630616316163261633616346163561636616376163861639616406164161642616436164461645616466164761648616496165061651616526165361654616556165661657616586165961660616616166261663616646166561666616676166861669616706167161672616736167461675616766167761678616796168061681616826168361684616856168661687616886168961690616916169261693616946169561696616976169861699617006170161702617036170461705617066170761708617096171061711617126171361714617156171661717617186171961720617216172261723617246172561726617276172861729617306173161732617336173461735617366173761738617396174061741617426174361744617456174661747617486174961750617516175261753617546175561756617576175861759617606176161762617636176461765617666176761768617696177061771617726177361774617756177661777617786177961780617816178261783617846178561786617876178861789617906179161792617936179461795617966179761798617996180061801618026180361804618056180661807618086180961810618116181261813618146181561816618176181861819618206182161822618236182461825618266182761828618296183061831618326183361834618356183661837618386183961840618416184261843618446184561846618476184861849618506185161852618536185461855618566185761858618596186061861618626186361864618656186661867618686186961870618716187261873618746187561876618776187861879618806188161882618836188461885618866188761888618896189061891618926189361894618956189661897618986189961900619016190261903619046190561906619076190861909619106191161912619136191461915619166191761918619196192061921619226192361924619256192661927619286192961930619316193261933619346193561936619376193861939619406194161942619436194461945619466194761948619496195061951619526195361954619556195661957619586195961960619616196261963619646196561966619676196861969619706197161972619736197461975619766197761978619796198061981619826198361984619856198661987619886198961990619916199261993619946199561996619976199861999620006200162002620036200462005620066200762008620096201062011620126201362014620156201662017620186201962020620216202262023620246202562026620276202862029620306203162032620336203462035620366203762038620396204062041620426204362044620456204662047620486204962050620516205262053620546205562056620576205862059620606206162062620636206462065620666206762068620696207062071620726207362074620756207662077620786207962080620816208262083620846208562086620876208862089620906209162092620936209462095620966209762098620996210062101621026210362104621056210662107621086210962110621116211262113621146211562116621176211862119621206212162122621236212462125621266212762128621296213062131621326213362134621356213662137621386213962140621416214262143621446214562146621476214862149621506215162152621536215462155621566215762158621596216062161621626216362164621656216662167621686216962170621716217262173621746217562176621776217862179621806218162182621836218462185621866218762188621896219062191621926219362194621956219662197621986219962200622016220262203622046220562206622076220862209622106221162212622136221462215622166221762218622196222062221622226222362224622256222662227622286222962230622316223262233622346223562236622376223862239622406224162242622436224462245622466224762248622496225062251622526225362254622556225662257622586225962260622616226262263622646226562266622676226862269622706227162272622736227462275622766227762278622796228062281622826228362284622856228662287622886228962290622916229262293622946229562296622976229862299623006230162302623036230462305623066230762308623096231062311623126231362314623156231662317623186231962320623216232262323623246232562326623276232862329623306233162332623336233462335623366233762338623396234062341623426234362344623456234662347623486234962350623516235262353623546235562356623576235862359623606236162362623636236462365623666236762368623696237062371623726237362374623756237662377623786237962380623816238262383623846238562386623876238862389623906239162392623936239462395623966239762398623996240062401624026240362404624056240662407624086240962410624116241262413624146241562416624176241862419624206242162422624236242462425624266242762428624296243062431624326243362434624356243662437624386243962440624416244262443624446244562446624476244862449624506245162452624536245462455624566245762458624596246062461624626246362464624656246662467624686246962470624716247262473624746247562476624776247862479624806248162482624836248462485624866248762488624896249062491624926249362494624956249662497624986249962500625016250262503625046250562506625076250862509625106251162512625136251462515625166251762518625196252062521625226252362524625256252662527625286252962530625316253262533625346253562536625376253862539625406254162542625436254462545625466254762548625496255062551625526255362554625556255662557625586255962560625616256262563625646256562566625676256862569625706257162572625736257462575625766257762578625796258062581625826258362584625856258662587625886258962590625916259262593625946259562596625976259862599626006260162602626036260462605626066260762608626096261062611626126261362614626156261662617626186261962620626216262262623626246262562626626276262862629626306263162632626336263462635626366263762638626396264062641626426264362644626456264662647626486264962650626516265262653626546265562656626576265862659626606266162662626636266462665626666266762668626696267062671626726267362674626756267662677626786267962680626816268262683626846268562686626876268862689626906269162692626936269462695626966269762698626996270062701627026270362704627056270662707627086270962710627116271262713627146271562716627176271862719627206272162722627236272462725627266272762728627296273062731627326273362734627356273662737627386273962740627416274262743627446274562746627476274862749627506275162752627536275462755627566275762758627596276062761627626276362764627656276662767627686276962770627716277262773627746277562776627776277862779627806278162782627836278462785627866278762788627896279062791627926279362794627956279662797627986279962800628016280262803628046280562806628076280862809628106281162812628136281462815628166281762818628196282062821628226282362824628256282662827628286282962830628316283262833628346283562836628376283862839628406284162842628436284462845628466284762848628496285062851628526285362854628556285662857628586285962860628616286262863628646286562866628676286862869628706287162872628736287462875628766287762878628796288062881628826288362884628856288662887628886288962890628916289262893628946289562896628976289862899629006290162902629036290462905629066290762908629096291062911629126291362914629156291662917629186291962920629216292262923629246292562926629276292862929629306293162932629336293462935629366293762938629396294062941629426294362944629456294662947629486294962950629516295262953629546295562956629576295862959629606296162962629636296462965629666296762968629696297062971629726297362974629756297662977629786297962980629816298262983629846298562986629876298862989629906299162992629936299462995629966299762998629996300063001630026300363004630056300663007630086300963010630116301263013630146301563016630176301863019630206302163022630236302463025630266302763028630296303063031630326303363034630356303663037630386303963040630416304263043630446304563046630476304863049630506305163052630536305463055630566305763058630596306063061630626306363064630656306663067630686306963070630716307263073630746307563076630776307863079630806308163082630836308463085630866308763088630896309063091630926309363094630956309663097630986309963100631016310263103631046310563106631076310863109631106311163112631136311463115631166311763118631196312063121631226312363124631256312663127631286312963130631316313263133631346313563136631376313863139631406314163142631436314463145631466314763148631496315063151631526315363154631556315663157631586315963160631616316263163631646316563166631676316863169631706317163172631736317463175631766317763178631796318063181631826318363184631856318663187631886318963190631916319263193631946319563196631976319863199632006320163202632036320463205632066320763208632096321063211632126321363214632156321663217632186321963220632216322263223632246322563226632276322863229632306323163232632336323463235632366323763238632396324063241632426324363244632456324663247632486324963250632516325263253632546325563256632576325863259632606326163262632636326463265632666326763268632696327063271632726327363274632756327663277632786327963280632816328263283632846328563286632876328863289632906329163292632936329463295632966329763298632996330063301633026330363304633056330663307633086330963310633116331263313633146331563316633176331863319633206332163322633236332463325633266332763328633296333063331633326333363334633356333663337633386333963340633416334263343633446334563346633476334863349633506335163352633536335463355633566335763358633596336063361633626336363364633656336663367633686336963370633716337263373633746337563376633776337863379633806338163382633836338463385633866338763388633896339063391633926339363394633956339663397633986339963400634016340263403634046340563406634076340863409634106341163412634136341463415634166341763418634196342063421634226342363424634256342663427634286342963430634316343263433634346343563436634376343863439634406344163442634436344463445634466344763448634496345063451634526345363454634556345663457634586345963460634616346263463634646346563466634676346863469634706347163472634736347463475634766347763478634796348063481634826348363484634856348663487634886348963490634916349263493634946349563496634976349863499635006350163502635036350463505635066350763508635096351063511635126351363514635156351663517635186351963520635216352263523635246352563526635276352863529635306353163532635336353463535635366353763538635396354063541635426354363544635456354663547635486354963550635516355263553635546355563556635576355863559635606356163562635636356463565635666356763568635696357063571635726357363574635756357663577635786357963580635816358263583635846358563586635876358863589635906359163592635936359463595635966359763598635996360063601636026360363604636056360663607636086360963610636116361263613636146361563616636176361863619636206362163622636236362463625636266362763628636296363063631636326363363634636356363663637636386363963640636416364263643636446364563646636476364863649636506365163652636536365463655636566365763658636596366063661636626366363664636656366663667636686366963670636716367263673636746367563676636776367863679636806368163682636836368463685636866368763688636896369063691636926369363694636956369663697636986369963700637016370263703637046370563706637076370863709637106371163712637136371463715637166371763718637196372063721637226372363724637256372663727637286372963730637316373263733637346373563736637376373863739637406374163742637436374463745637466374763748637496375063751637526375363754637556375663757637586375963760637616376263763637646376563766637676376863769637706377163772637736377463775637766377763778637796378063781637826378363784637856378663787637886378963790637916379263793637946379563796637976379863799638006380163802638036380463805638066380763808638096381063811638126381363814638156381663817638186381963820638216382263823638246382563826638276382863829638306383163832638336383463835638366383763838638396384063841638426384363844638456384663847638486384963850638516385263853638546385563856638576385863859638606386163862638636386463865638666386763868638696387063871638726387363874638756387663877638786387963880638816388263883638846388563886638876388863889638906389163892638936389463895638966389763898638996390063901639026390363904639056390663907639086390963910639116391263913639146391563916639176391863919639206392163922639236392463925639266392763928639296393063931639326393363934639356393663937639386393963940639416394263943639446394563946639476394863949639506395163952639536395463955639566395763958639596396063961639626396363964639656396663967639686396963970639716397263973639746397563976639776397863979639806398163982639836398463985639866398763988639896399063991639926399363994639956399663997639986399964000640016400264003640046400564006640076400864009640106401164012640136401464015640166401764018640196402064021640226402364024640256402664027640286402964030640316403264033640346403564036640376403864039640406404164042640436404464045640466404764048640496405064051640526405364054640556405664057640586405964060640616406264063640646406564066640676406864069640706407164072640736407464075640766407764078640796408064081640826408364084640856408664087640886408964090640916409264093640946409564096640976409864099641006410164102641036410464105641066410764108641096411064111641126411364114641156411664117641186411964120641216412264123641246412564126641276412864129641306413164132641336413464135641366413764138641396414064141641426414364144641456414664147641486414964150641516415264153641546415564156641576415864159641606416164162641636416464165641666416764168641696417064171641726417364174641756417664177641786417964180641816418264183641846418564186641876418864189641906419164192641936419464195641966419764198641996420064201642026420364204642056420664207642086420964210642116421264213642146421564216642176421864219642206422164222642236422464225642266422764228642296423064231642326423364234642356423664237642386423964240642416424264243642446424564246642476424864249642506425164252642536425464255642566425764258642596426064261642626426364264642656426664267642686426964270642716427264273642746427564276642776427864279642806428164282642836428464285642866428764288642896429064291642926429364294642956429664297642986429964300643016430264303643046430564306643076430864309643106431164312643136431464315643166431764318643196432064321643226432364324643256432664327643286432964330643316433264333643346433564336643376433864339643406434164342643436434464345643466434764348643496435064351643526435364354643556435664357643586435964360643616436264363643646436564366643676436864369643706437164372643736437464375643766437764378643796438064381643826438364384643856438664387643886438964390643916439264393643946439564396643976439864399644006440164402644036440464405644066440764408644096441064411644126441364414644156441664417644186441964420644216442264423644246442564426644276442864429644306443164432644336443464435644366443764438644396444064441644426444364444644456444664447644486444964450644516445264453644546445564456644576445864459644606446164462644636446464465644666446764468644696447064471644726447364474644756447664477644786447964480644816448264483644846448564486644876448864489644906449164492644936449464495644966449764498644996450064501645026450364504645056450664507645086450964510645116451264513645146451564516645176451864519645206452164522645236452464525645266452764528645296453064531645326453364534645356453664537645386453964540645416454264543645446454564546645476454864549645506455164552645536455464555645566455764558645596456064561645626456364564645656456664567645686456964570645716457264573645746457564576645776457864579645806458164582645836458464585645866458764588645896459064591645926459364594645956459664597645986459964600646016460264603646046460564606646076460864609646106461164612646136461464615646166461764618646196462064621646226462364624646256462664627646286462964630646316463264633646346463564636646376463864639646406464164642646436464464645646466464764648646496465064651646526465364654646556465664657646586465964660646616466264663646646466564666646676466864669646706467164672646736467464675646766467764678646796468064681646826468364684646856468664687646886468964690646916469264693646946469564696646976469864699647006470164702647036470464705647066470764708647096471064711647126471364714647156471664717647186471964720647216472264723647246472564726647276472864729647306473164732647336473464735647366473764738647396474064741647426474364744647456474664747647486474964750647516475264753647546475564756647576475864759647606476164762647636476464765647666476764768647696477064771647726477364774647756477664777647786477964780647816478264783647846478564786647876478864789647906479164792647936479464795647966479764798647996480064801648026480364804648056480664807648086480964810648116481264813648146481564816648176481864819648206482164822648236482464825648266482764828648296483064831648326483364834648356483664837648386483964840648416484264843648446484564846648476484864849648506485164852648536485464855648566485764858648596486064861648626486364864648656486664867648686486964870648716487264873648746487564876648776487864879648806488164882648836488464885648866488764888648896489064891648926489364894648956489664897648986489964900649016490264903649046490564906649076490864909649106491164912649136491464915649166491764918649196492064921649226492364924649256492664927649286492964930649316493264933649346493564936649376493864939649406494164942649436494464945649466494764948649496495064951649526495364954649556495664957649586495964960649616496264963649646496564966649676496864969649706497164972649736497464975649766497764978649796498064981649826498364984649856498664987649886498964990649916499264993649946499564996649976499864999650006500165002650036500465005650066500765008650096501065011650126501365014650156501665017650186501965020650216502265023650246502565026650276502865029650306503165032650336503465035650366503765038650396504065041650426504365044650456504665047650486504965050650516505265053650546505565056650576505865059650606506165062650636506465065650666506765068650696507065071650726507365074650756507665077650786507965080650816508265083650846508565086650876508865089650906509165092650936509465095650966509765098650996510065101651026510365104651056510665107651086510965110651116511265113651146511565116651176511865119651206512165122651236512465125651266512765128651296513065131651326513365134651356513665137651386513965140651416514265143651446514565146651476514865149651506515165152651536515465155651566515765158651596516065161651626516365164651656516665167651686516965170651716517265173651746517565176651776517865179651806518165182651836518465185651866518765188651896519065191651926519365194651956519665197651986519965200652016520265203652046520565206652076520865209652106521165212652136521465215652166521765218652196522065221652226522365224652256522665227652286522965230652316523265233652346523565236652376523865239652406524165242652436524465245652466524765248652496525065251652526525365254652556525665257652586525965260652616526265263652646526565266652676526865269652706527165272652736527465275652766527765278652796528065281652826528365284652856528665287652886528965290652916529265293652946529565296652976529865299653006530165302653036530465305653066530765308653096531065311653126531365314653156531665317653186531965320653216532265323653246532565326653276532865329653306533165332653336533465335653366533765338653396534065341653426534365344653456534665347653486534965350653516535265353653546535565356653576535865359653606536165362653636536465365653666536765368653696537065371653726537365374653756537665377653786537965380653816538265383653846538565386653876538865389653906539165392653936539465395653966539765398653996540065401654026540365404654056540665407654086540965410654116541265413654146541565416654176541865419654206542165422654236542465425654266542765428654296543065431654326543365434654356543665437654386543965440654416544265443654446544565446654476544865449654506545165452654536545465455654566545765458654596546065461654626546365464654656546665467654686546965470654716547265473654746547565476654776547865479654806548165482654836548465485654866548765488654896549065491654926549365494654956549665497654986549965500655016550265503655046550565506655076550865509655106551165512655136551465515655166551765518655196552065521655226552365524655256552665527655286552965530655316553265533655346553565536655376553865539655406554165542655436554465545655466554765548655496555065551655526555365554655556555665557655586555965560655616556265563655646556565566655676556865569655706557165572655736557465575655766557765578655796558065581655826558365584655856558665587655886558965590655916559265593655946559565596655976559865599656006560165602656036560465605656066560765608656096561065611656126561365614656156561665617656186561965620656216562265623656246562565626656276562865629656306563165632656336563465635656366563765638656396564065641656426564365644656456564665647656486564965650656516565265653656546565565656656576565865659656606566165662656636566465665656666566765668656696567065671656726567365674656756567665677656786567965680656816568265683656846568565686656876568865689656906569165692656936569465695656966569765698656996570065701657026570365704657056570665707657086570965710657116571265713657146571565716657176571865719657206572165722657236572465725657266572765728657296573065731657326573365734657356573665737657386573965740657416574265743657446574565746657476574865749657506575165752657536575465755657566575765758657596576065761657626576365764657656576665767657686576965770657716577265773657746577565776657776577865779657806578165782657836578465785657866578765788657896579065791657926579365794657956579665797657986579965800658016580265803658046580565806658076580865809658106581165812658136581465815658166581765818658196582065821658226582365824658256582665827658286582965830658316583265833658346583565836658376583865839658406584165842658436584465845658466584765848658496585065851658526585365854658556585665857658586585965860658616586265863658646586565866658676586865869658706587165872658736587465875658766587765878658796588065881658826588365884658856588665887658886588965890658916589265893658946589565896658976589865899659006590165902659036590465905659066590765908659096591065911659126591365914659156591665917659186591965920659216592265923659246592565926659276592865929659306593165932659336593465935659366593765938659396594065941659426594365944659456594665947659486594965950659516595265953659546595565956659576595865959659606596165962659636596465965659666596765968659696597065971659726597365974659756597665977659786597965980659816598265983659846598565986659876598865989659906599165992659936599465995659966599765998659996600066001660026600366004660056600666007660086600966010660116601266013660146601566016660176601866019660206602166022660236602466025660266602766028660296603066031660326603366034660356603666037660386603966040660416604266043660446604566046660476604866049660506605166052660536605466055660566605766058660596606066061660626606366064660656606666067660686606966070660716607266073660746607566076660776607866079660806608166082660836608466085660866608766088660896609066091660926609366094660956609666097660986609966100661016610266103661046610566106661076610866109661106611166112661136611466115661166611766118661196612066121661226612366124661256612666127661286612966130661316613266133661346613566136661376613866139661406614166142661436614466145661466614766148661496615066151661526615366154661556615666157661586615966160661616616266163661646616566166661676616866169661706617166172661736617466175661766617766178661796618066181661826618366184661856618666187661886618966190661916619266193661946619566196661976619866199662006620166202662036620466205662066620766208662096621066211662126621366214662156621666217662186621966220662216622266223662246622566226662276622866229662306623166232662336623466235662366623766238662396624066241662426624366244662456624666247662486624966250662516625266253662546625566256662576625866259662606626166262662636626466265662666626766268662696627066271662726627366274662756627666277662786627966280662816628266283662846628566286662876628866289662906629166292662936629466295662966629766298662996630066301663026630366304663056630666307663086630966310663116631266313663146631566316663176631866319663206632166322663236632466325663266632766328663296633066331663326633366334663356633666337663386633966340663416634266343663446634566346663476634866349663506635166352663536635466355663566635766358663596636066361663626636366364663656636666367663686636966370663716637266373663746637566376663776637866379663806638166382663836638466385663866638766388663896639066391663926639366394663956639666397663986639966400664016640266403664046640566406664076640866409664106641166412664136641466415664166641766418664196642066421664226642366424664256642666427664286642966430664316643266433664346643566436664376643866439664406644166442664436644466445664466644766448664496645066451664526645366454664556645666457664586645966460664616646266463664646646566466664676646866469664706647166472664736647466475664766647766478664796648066481664826648366484664856648666487664886648966490664916649266493664946649566496664976649866499665006650166502665036650466505665066650766508665096651066511665126651366514665156651666517665186651966520665216652266523665246652566526665276652866529665306653166532665336653466535665366653766538665396654066541665426654366544665456654666547665486654966550665516655266553665546655566556665576655866559665606656166562665636656466565665666656766568665696657066571665726657366574665756657666577665786657966580665816658266583665846658566586665876658866589665906659166592665936659466595665966659766598665996660066601666026660366604666056660666607666086660966610666116661266613666146661566616666176661866619666206662166622666236662466625666266662766628666296663066631666326663366634666356663666637666386663966640666416664266643666446664566646666476664866649666506665166652666536665466655666566665766658666596666066661666626666366664666656666666667666686666966670666716667266673666746667566676666776667866679666806668166682666836668466685666866668766688666896669066691666926669366694666956669666697666986669966700667016670266703667046670566706667076670866709667106671166712667136671466715667166671766718667196672066721667226672366724667256672666727667286672966730667316673266733667346673566736667376673866739667406674166742667436674466745667466674766748667496675066751667526675366754667556675666757667586675966760667616676266763667646676566766667676676866769667706677166772667736677466775667766677766778667796678066781667826678366784667856678666787667886678966790667916679266793667946679566796667976679866799668006680166802668036680466805668066680766808668096681066811668126681366814668156681666817668186681966820668216682266823668246682566826668276682866829668306683166832668336683466835668366683766838668396684066841668426684366844668456684666847668486684966850668516685266853668546685566856668576685866859668606686166862668636686466865668666686766868668696687066871668726687366874668756687666877668786687966880668816688266883668846688566886668876688866889668906689166892668936689466895668966689766898668996690066901669026690366904669056690666907669086690966910669116691266913669146691566916669176691866919669206692166922669236692466925669266692766928669296693066931669326693366934669356693666937669386693966940669416694266943669446694566946669476694866949669506695166952669536695466955669566695766958669596696066961669626696366964669656696666967669686696966970669716697266973669746697566976669776697866979669806698166982669836698466985669866698766988669896699066991669926699366994669956699666997669986699967000670016700267003670046700567006670076700867009670106701167012670136701467015670166701767018670196702067021670226702367024670256702667027670286702967030670316703267033670346703567036670376703867039670406704167042670436704467045670466704767048670496705067051670526705367054670556705667057670586705967060670616706267063670646706567066670676706867069670706707167072670736707467075670766707767078670796708067081670826708367084670856708667087670886708967090670916709267093670946709567096670976709867099671006710167102671036710467105671066710767108671096711067111671126711367114671156711667117671186711967120671216712267123671246712567126671276712867129671306713167132671336713467135671366713767138671396714067141671426714367144671456714667147671486714967150671516715267153671546715567156671576715867159671606716167162671636716467165671666716767168671696717067171671726717367174671756717667177671786717967180671816718267183671846718567186671876718867189671906719167192671936719467195671966719767198671996720067201672026720367204672056720667207672086720967210672116721267213672146721567216672176721867219672206722167222672236722467225672266722767228672296723067231672326723367234672356723667237672386723967240672416724267243672446724567246672476724867249672506725167252672536725467255672566725767258672596726067261672626726367264672656726667267672686726967270672716727267273672746727567276672776727867279672806728167282672836728467285672866728767288672896729067291672926729367294672956729667297672986729967300673016730267303673046730567306673076730867309673106731167312673136731467315673166731767318673196732067321673226732367324673256732667327673286732967330673316733267333673346733567336673376733867339673406734167342673436734467345673466734767348673496735067351673526735367354673556735667357673586735967360673616736267363673646736567366673676736867369673706737167372673736737467375673766737767378673796738067381673826738367384673856738667387673886738967390673916739267393673946739567396673976739867399674006740167402674036740467405674066740767408674096741067411674126741367414674156741667417674186741967420674216742267423674246742567426674276742867429674306743167432674336743467435674366743767438674396744067441674426744367444674456744667447674486744967450674516745267453674546745567456674576745867459674606746167462674636746467465674666746767468674696747067471674726747367474674756747667477674786747967480674816748267483674846748567486674876748867489674906749167492674936749467495674966749767498674996750067501675026750367504675056750667507675086750967510675116751267513675146751567516675176751867519675206752167522675236752467525675266752767528675296753067531675326753367534675356753667537675386753967540675416754267543675446754567546675476754867549675506755167552675536755467555675566755767558675596756067561675626756367564675656756667567675686756967570675716757267573675746757567576675776757867579675806758167582675836758467585675866758767588675896759067591675926759367594675956759667597675986759967600676016760267603676046760567606676076760867609676106761167612676136761467615676166761767618676196762067621676226762367624676256762667627676286762967630676316763267633676346763567636676376763867639676406764167642676436764467645676466764767648676496765067651676526765367654676556765667657676586765967660676616766267663676646766567666676676766867669676706767167672676736767467675676766767767678676796768067681676826768367684676856768667687676886768967690676916769267693676946769567696676976769867699677006770167702677036770467705677066770767708677096771067711677126771367714677156771667717677186771967720677216772267723677246772567726677276772867729677306773167732677336773467735677366773767738677396774067741677426774367744677456774667747677486774967750677516775267753677546775567756677576775867759677606776167762677636776467765677666776767768677696777067771677726777367774677756777667777677786777967780677816778267783677846778567786677876778867789677906779167792677936779467795677966779767798677996780067801678026780367804678056780667807678086780967810678116781267813678146781567816678176781867819678206782167822678236782467825678266782767828678296783067831678326783367834678356783667837678386783967840678416784267843678446784567846678476784867849678506785167852678536785467855678566785767858678596786067861678626786367864678656786667867678686786967870678716787267873678746787567876678776787867879678806788167882678836788467885678866788767888678896789067891678926789367894678956789667897678986789967900679016790267903679046790567906679076790867909679106791167912679136791467915679166791767918679196792067921679226792367924679256792667927679286792967930679316793267933679346793567936679376793867939679406794167942679436794467945679466794767948679496795067951679526795367954679556795667957679586795967960679616796267963679646796567966679676796867969679706797167972679736797467975679766797767978679796798067981679826798367984679856798667987679886798967990679916799267993679946799567996679976799867999680006800168002680036800468005680066800768008680096801068011680126801368014680156801668017680186801968020680216802268023680246802568026680276802868029680306803168032680336803468035680366803768038680396804068041680426804368044680456804668047680486804968050680516805268053680546805568056680576805868059680606806168062680636806468065680666806768068680696807068071680726807368074680756807668077680786807968080680816808268083680846808568086680876808868089680906809168092680936809468095680966809768098680996810068101681026810368104681056810668107681086810968110681116811268113681146811568116681176811868119681206812168122681236812468125681266812768128681296813068131681326813368134681356813668137681386813968140681416814268143681446814568146681476814868149681506815168152681536815468155681566815768158681596816068161681626816368164681656816668167681686816968170681716817268173681746817568176681776817868179681806818168182681836818468185681866818768188681896819068191681926819368194681956819668197681986819968200682016820268203682046820568206682076820868209682106821168212682136821468215682166821768218682196822068221682226822368224682256822668227682286822968230682316823268233682346823568236682376823868239682406824168242682436824468245682466824768248682496825068251682526825368254682556825668257682586825968260682616826268263682646826568266682676826868269682706827168272682736827468275682766827768278682796828068281682826828368284682856828668287682886828968290682916829268293682946829568296682976829868299683006830168302683036830468305683066830768308683096831068311683126831368314683156831668317683186831968320683216832268323683246832568326683276832868329683306833168332683336833468335683366833768338683396834068341683426834368344683456834668347683486834968350683516835268353683546835568356683576835868359683606836168362683636836468365683666836768368683696837068371683726837368374683756837668377683786837968380683816838268383683846838568386683876838868389683906839168392683936839468395683966839768398683996840068401684026840368404684056840668407684086840968410684116841268413684146841568416684176841868419684206842168422684236842468425684266842768428684296843068431684326843368434684356843668437684386843968440684416844268443684446844568446684476844868449684506845168452684536845468455684566845768458684596846068461684626846368464684656846668467684686846968470684716847268473684746847568476684776847868479684806848168482684836848468485684866848768488684896849068491684926849368494684956849668497684986849968500685016850268503685046850568506685076850868509685106851168512685136851468515685166851768518685196852068521685226852368524685256852668527685286852968530685316853268533685346853568536685376853868539685406854168542685436854468545685466854768548685496855068551685526855368554685556855668557685586855968560685616856268563685646856568566685676856868569685706857168572685736857468575685766857768578685796858068581685826858368584685856858668587685886858968590685916859268593685946859568596685976859868599686006860168602686036860468605686066860768608686096861068611686126861368614686156861668617686186861968620686216862268623686246862568626686276862868629686306863168632686336863468635686366863768638686396864068641686426864368644686456864668647686486864968650686516865268653686546865568656686576865868659686606866168662686636866468665686666866768668686696867068671686726867368674686756867668677686786867968680686816868268683686846868568686686876868868689686906869168692686936869468695686966869768698686996870068701687026870368704687056870668707687086870968710687116871268713687146871568716687176871868719687206872168722687236872468725687266872768728687296873068731687326873368734687356873668737687386873968740687416874268743687446874568746687476874868749687506875168752687536875468755687566875768758687596876068761687626876368764687656876668767687686876968770687716877268773687746877568776687776877868779687806878168782687836878468785687866878768788687896879068791687926879368794687956879668797687986879968800688016880268803688046880568806688076880868809688106881168812688136881468815688166881768818688196882068821688226882368824688256882668827688286882968830688316883268833688346883568836688376883868839688406884168842688436884468845688466884768848688496885068851688526885368854688556885668857688586885968860688616886268863688646886568866688676886868869688706887168872688736887468875688766887768878688796888068881688826888368884688856888668887688886888968890688916889268893688946889568896688976889868899689006890168902689036890468905689066890768908689096891068911689126891368914689156891668917689186891968920689216892268923689246892568926689276892868929689306893168932689336893468935689366893768938689396894068941689426894368944689456894668947689486894968950689516895268953689546895568956689576895868959689606896168962689636896468965689666896768968689696897068971689726897368974689756897668977689786897968980689816898268983689846898568986689876898868989689906899168992689936899468995689966899768998689996900069001690026900369004690056900669007690086900969010690116901269013690146901569016690176901869019690206902169022690236902469025690266902769028690296903069031690326903369034690356903669037690386903969040690416904269043690446904569046690476904869049690506905169052690536905469055690566905769058690596906069061690626906369064690656906669067690686906969070690716907269073690746907569076690776907869079690806908169082690836908469085690866908769088690896909069091690926909369094690956909669097690986909969100691016910269103691046910569106691076910869109691106911169112691136911469115691166911769118691196912069121691226912369124691256912669127691286912969130691316913269133691346913569136691376913869139691406914169142691436914469145691466914769148691496915069151691526915369154691556915669157691586915969160691616916269163691646916569166691676916869169691706917169172691736917469175691766917769178691796918069181691826918369184691856918669187691886918969190691916919269193691946919569196691976919869199692006920169202692036920469205692066920769208692096921069211692126921369214692156921669217692186921969220692216922269223692246922569226692276922869229692306923169232692336923469235692366923769238692396924069241692426924369244692456924669247692486924969250692516925269253692546925569256692576925869259692606926169262692636926469265692666926769268692696927069271692726927369274692756927669277692786927969280692816928269283692846928569286692876928869289692906929169292692936929469295692966929769298692996930069301693026930369304693056930669307693086930969310693116931269313693146931569316693176931869319693206932169322693236932469325693266932769328693296933069331693326933369334693356933669337693386933969340693416934269343693446934569346693476934869349693506935169352693536935469355693566935769358693596936069361693626936369364693656936669367693686936969370693716937269373693746937569376693776937869379693806938169382693836938469385693866938769388693896939069391693926939369394693956939669397693986939969400694016940269403694046940569406694076940869409694106941169412694136941469415694166941769418694196942069421694226942369424694256942669427694286942969430694316943269433694346943569436694376943869439694406944169442694436944469445694466944769448694496945069451694526945369454694556945669457694586945969460694616946269463694646946569466694676946869469694706947169472694736947469475694766947769478694796948069481694826948369484694856948669487694886948969490694916949269493694946949569496694976949869499695006950169502695036950469505695066950769508695096951069511695126951369514695156951669517695186951969520695216952269523695246952569526695276952869529695306953169532695336953469535695366953769538695396954069541695426954369544695456954669547695486954969550695516955269553695546955569556695576955869559695606956169562695636956469565695666956769568695696957069571695726957369574695756957669577695786957969580695816958269583695846958569586695876958869589695906959169592695936959469595695966959769598695996960069601696026960369604696056960669607696086960969610696116961269613696146961569616696176961869619696206962169622696236962469625696266962769628696296963069631696326963369634696356963669637696386963969640696416964269643696446964569646696476964869649696506965169652696536965469655696566965769658696596966069661696626966369664696656966669667696686966969670696716967269673696746967569676696776967869679696806968169682696836968469685696866968769688696896969069691696926969369694696956969669697696986969969700697016970269703697046970569706697076970869709697106971169712697136971469715697166971769718697196972069721697226972369724697256972669727697286972969730697316973269733697346973569736697376973869739697406974169742697436974469745697466974769748697496975069751697526975369754697556975669757697586975969760697616976269763697646976569766697676976869769697706977169772697736977469775697766977769778697796978069781697826978369784697856978669787697886978969790697916979269793697946979569796697976979869799698006980169802698036980469805698066980769808698096981069811698126981369814698156981669817698186981969820698216982269823698246982569826698276982869829698306983169832698336983469835698366983769838698396984069841698426984369844698456984669847698486984969850698516985269853698546985569856698576985869859698606986169862698636986469865698666986769868698696987069871698726987369874698756987669877698786987969880698816988269883698846988569886698876988869889698906989169892698936989469895698966989769898698996990069901699026990369904699056990669907699086990969910699116991269913699146991569916699176991869919699206992169922699236992469925699266992769928699296993069931699326993369934699356993669937699386993969940699416994269943699446994569946699476994869949699506995169952699536995469955699566995769958699596996069961699626996369964699656996669967699686996969970699716997269973699746997569976699776997869979699806998169982699836998469985699866998769988699896999069991699926999369994699956999669997699986999970000700017000270003700047000570006700077000870009700107001170012700137001470015700167001770018700197002070021700227002370024700257002670027700287002970030700317003270033700347003570036700377003870039700407004170042700437004470045700467004770048700497005070051700527005370054700557005670057700587005970060700617006270063700647006570066700677006870069700707007170072700737007470075700767007770078700797008070081700827008370084700857008670087700887008970090700917009270093700947009570096700977009870099701007010170102701037010470105701067010770108701097011070111701127011370114701157011670117701187011970120701217012270123701247012570126701277012870129701307013170132701337013470135701367013770138701397014070141701427014370144701457014670147701487014970150701517015270153701547015570156701577015870159701607016170162701637016470165701667016770168701697017070171701727017370174701757017670177701787017970180701817018270183701847018570186701877018870189701907019170192701937019470195701967019770198701997020070201702027020370204702057020670207702087020970210702117021270213702147021570216702177021870219702207022170222702237022470225702267022770228702297023070231702327023370234702357023670237702387023970240702417024270243702447024570246702477024870249702507025170252702537025470255702567025770258702597026070261702627026370264702657026670267702687026970270702717027270273702747027570276702777027870279702807028170282702837028470285702867028770288702897029070291702927029370294702957029670297702987029970300703017030270303703047030570306703077030870309703107031170312703137031470315703167031770318703197032070321703227032370324703257032670327703287032970330703317033270333703347033570336703377033870339703407034170342703437034470345703467034770348703497035070351703527035370354703557035670357703587035970360703617036270363703647036570366703677036870369703707037170372703737037470375703767037770378703797038070381703827038370384703857038670387703887038970390703917039270393703947039570396703977039870399704007040170402704037040470405704067040770408704097041070411704127041370414704157041670417704187041970420704217042270423704247042570426704277042870429704307043170432704337043470435704367043770438704397044070441704427044370444704457044670447704487044970450704517045270453704547045570456704577045870459704607046170462704637046470465704667046770468704697047070471704727047370474704757047670477704787047970480704817048270483704847048570486704877048870489704907049170492704937049470495704967049770498704997050070501705027050370504705057050670507705087050970510705117051270513705147051570516705177051870519705207052170522705237052470525705267052770528705297053070531705327053370534705357053670537705387053970540705417054270543705447054570546705477054870549705507055170552705537055470555705567055770558705597056070561705627056370564705657056670567705687056970570705717057270573705747057570576705777057870579705807058170582705837058470585705867058770588705897059070591705927059370594705957059670597705987059970600706017060270603706047060570606706077060870609706107061170612706137061470615706167061770618706197062070621706227062370624706257062670627706287062970630706317063270633706347063570636706377063870639706407064170642706437064470645706467064770648706497065070651706527065370654706557065670657706587065970660706617066270663706647066570666706677066870669706707067170672706737067470675706767067770678706797068070681706827068370684706857068670687706887068970690706917069270693706947069570696706977069870699707007070170702707037070470705707067070770708707097071070711707127071370714707157071670717707187071970720707217072270723707247072570726707277072870729707307073170732707337073470735707367073770738707397074070741707427074370744707457074670747707487074970750707517075270753707547075570756707577075870759707607076170762707637076470765707667076770768707697077070771707727077370774707757077670777707787077970780707817078270783707847078570786707877078870789707907079170792707937079470795707967079770798707997080070801708027080370804708057080670807708087080970810708117081270813708147081570816708177081870819708207082170822708237082470825708267082770828708297083070831708327083370834708357083670837708387083970840708417084270843708447084570846708477084870849708507085170852708537085470855708567085770858708597086070861708627086370864708657086670867708687086970870708717087270873708747087570876708777087870879708807088170882708837088470885708867088770888708897089070891708927089370894708957089670897708987089970900709017090270903709047090570906709077090870909709107091170912709137091470915709167091770918709197092070921709227092370924709257092670927709287092970930709317093270933709347093570936709377093870939709407094170942709437094470945709467094770948709497095070951709527095370954709557095670957709587095970960709617096270963709647096570966709677096870969709707097170972709737097470975709767097770978709797098070981709827098370984709857098670987709887098970990709917099270993709947099570996709977099870999710007100171002710037100471005710067100771008710097101071011710127101371014710157101671017710187101971020710217102271023710247102571026710277102871029710307103171032710337103471035710367103771038710397104071041710427104371044710457104671047710487104971050710517105271053710547105571056710577105871059710607106171062710637106471065710667106771068710697107071071710727107371074710757107671077710787107971080710817108271083710847108571086710877108871089710907109171092710937109471095710967109771098710997110071101711027110371104711057110671107711087110971110711117111271113711147111571116711177111871119711207112171122711237112471125711267112771128711297113071131711327113371134711357113671137711387113971140711417114271143711447114571146711477114871149711507115171152711537115471155711567115771158711597116071161711627116371164711657116671167711687116971170711717117271173711747117571176711777117871179711807118171182711837118471185711867118771188711897119071191711927119371194711957119671197711987119971200712017120271203712047120571206712077120871209712107121171212712137121471215712167121771218712197122071221712227122371224712257122671227712287122971230712317123271233712347123571236712377123871239712407124171242712437124471245712467124771248712497125071251712527125371254712557125671257712587125971260712617126271263712647126571266712677126871269712707127171272712737127471275712767127771278712797128071281712827128371284712857128671287712887128971290712917129271293712947129571296712977129871299713007130171302713037130471305713067130771308713097131071311713127131371314713157131671317713187131971320713217132271323713247132571326713277132871329713307133171332713337133471335713367133771338713397134071341713427134371344713457134671347713487134971350713517135271353713547135571356713577135871359713607136171362713637136471365713667136771368713697137071371713727137371374713757137671377713787137971380713817138271383713847138571386713877138871389713907139171392713937139471395713967139771398713997140071401714027140371404714057140671407714087140971410714117141271413714147141571416714177141871419714207142171422714237142471425714267142771428714297143071431714327143371434714357143671437714387143971440714417144271443714447144571446714477144871449714507145171452714537145471455714567145771458714597146071461714627146371464714657146671467714687146971470714717147271473714747147571476714777147871479714807148171482714837148471485714867148771488714897149071491714927149371494714957149671497714987149971500715017150271503715047150571506715077150871509715107151171512715137151471515715167151771518715197152071521715227152371524715257152671527715287152971530715317153271533715347153571536715377153871539715407154171542715437154471545715467154771548715497155071551715527155371554715557155671557715587155971560715617156271563715647156571566715677156871569715707157171572715737157471575715767157771578715797158071581715827158371584715857158671587715887158971590715917159271593715947159571596715977159871599716007160171602716037160471605716067160771608716097161071611716127161371614716157161671617716187161971620716217162271623716247162571626716277162871629716307163171632716337163471635716367163771638716397164071641716427164371644716457164671647716487164971650716517165271653716547165571656716577165871659716607166171662716637166471665716667166771668716697167071671716727167371674716757167671677716787167971680716817168271683716847168571686716877168871689716907169171692716937169471695716967169771698716997170071701717027170371704717057170671707717087170971710717117171271713717147171571716717177171871719717207172171722717237172471725717267172771728717297173071731717327173371734717357173671737717387173971740717417174271743717447174571746717477174871749717507175171752717537175471755717567175771758717597176071761717627176371764717657176671767717687176971770717717177271773717747177571776717777177871779717807178171782717837178471785717867178771788717897179071791717927179371794717957179671797717987179971800718017180271803718047180571806718077180871809718107181171812718137181471815718167181771818718197182071821718227182371824718257182671827718287182971830718317183271833718347183571836718377183871839718407184171842718437184471845718467184771848718497185071851718527185371854718557185671857718587185971860718617186271863718647186571866718677186871869718707187171872718737187471875718767187771878718797188071881718827188371884718857188671887718887188971890718917189271893718947189571896718977189871899719007190171902719037190471905719067190771908719097191071911719127191371914719157191671917719187191971920719217192271923719247192571926719277192871929719307193171932719337193471935719367193771938719397194071941719427194371944719457194671947719487194971950719517195271953719547195571956719577195871959719607196171962719637196471965719667196771968719697197071971719727197371974719757197671977719787197971980719817198271983719847198571986719877198871989719907199171992719937199471995719967199771998719997200072001720027200372004720057200672007720087200972010720117201272013720147201572016720177201872019720207202172022720237202472025720267202772028720297203072031720327203372034720357203672037720387203972040720417204272043720447204572046720477204872049720507205172052720537205472055720567205772058720597206072061720627206372064720657206672067720687206972070720717207272073720747207572076720777207872079720807208172082720837208472085720867208772088720897209072091720927209372094720957209672097720987209972100721017210272103721047210572106721077210872109721107211172112721137211472115721167211772118721197212072121721227212372124721257212672127721287212972130721317213272133721347213572136721377213872139721407214172142721437214472145721467214772148721497215072151721527215372154721557215672157721587215972160721617216272163721647216572166721677216872169721707217172172721737217472175721767217772178721797218072181721827218372184721857218672187721887218972190721917219272193721947219572196721977219872199722007220172202722037220472205722067220772208722097221072211722127221372214722157221672217722187221972220722217222272223722247222572226722277222872229722307223172232722337223472235722367223772238722397224072241722427224372244722457224672247722487224972250722517225272253722547225572256722577225872259722607226172262722637226472265722667226772268722697227072271722727227372274722757227672277722787227972280722817228272283722847228572286722877228872289722907229172292722937229472295722967229772298722997230072301723027230372304723057230672307723087230972310723117231272313723147231572316723177231872319723207232172322723237232472325723267232772328723297233072331723327233372334723357233672337723387233972340723417234272343723447234572346723477234872349723507235172352723537235472355723567235772358723597236072361723627236372364723657236672367723687236972370723717237272373723747237572376723777237872379723807238172382723837238472385723867238772388723897239072391723927239372394723957239672397723987239972400724017240272403724047240572406724077240872409724107241172412724137241472415724167241772418724197242072421724227242372424724257242672427724287242972430724317243272433724347243572436724377243872439724407244172442724437244472445724467244772448724497245072451724527245372454724557245672457724587245972460724617246272463724647246572466724677246872469724707247172472724737247472475724767247772478724797248072481724827248372484724857248672487724887248972490724917249272493724947249572496724977249872499725007250172502725037250472505725067250772508725097251072511725127251372514725157251672517725187251972520725217252272523725247252572526725277252872529725307253172532725337253472535725367253772538725397254072541725427254372544725457254672547725487254972550725517255272553725547255572556725577255872559725607256172562725637256472565725667256772568725697257072571725727257372574725757257672577725787257972580725817258272583725847258572586725877258872589725907259172592725937259472595725967259772598725997260072601726027260372604726057260672607726087260972610726117261272613726147261572616726177261872619726207262172622726237262472625726267262772628726297263072631726327263372634726357263672637726387263972640726417264272643726447264572646726477264872649726507265172652726537265472655726567265772658726597266072661726627266372664726657266672667726687266972670726717267272673726747267572676726777267872679726807268172682726837268472685726867268772688726897269072691726927269372694726957269672697726987269972700727017270272703727047270572706727077270872709727107271172712727137271472715727167271772718727197272072721727227272372724727257272672727727287272972730727317273272733727347273572736727377273872739727407274172742727437274472745727467274772748727497275072751727527275372754727557275672757727587275972760727617276272763727647276572766727677276872769727707277172772727737277472775727767277772778727797278072781727827278372784727857278672787727887278972790727917279272793727947279572796727977279872799728007280172802728037280472805728067280772808728097281072811728127281372814728157281672817728187281972820728217282272823728247282572826728277282872829728307283172832728337283472835728367283772838728397284072841728427284372844728457284672847728487284972850728517285272853728547285572856728577285872859728607286172862728637286472865728667286772868728697287072871728727287372874728757287672877728787287972880728817288272883728847288572886728877288872889728907289172892728937289472895728967289772898728997290072901729027290372904729057290672907729087290972910729117291272913729147291572916729177291872919729207292172922729237292472925729267292772928729297293072931729327293372934729357293672937729387293972940729417294272943729447294572946729477294872949729507295172952729537295472955729567295772958729597296072961729627296372964729657296672967729687296972970729717297272973729747297572976729777297872979729807298172982729837298472985729867298772988729897299072991729927299372994729957299672997729987299973000730017300273003730047300573006730077300873009730107301173012730137301473015730167301773018730197302073021730227302373024730257302673027730287302973030730317303273033730347303573036730377303873039730407304173042730437304473045730467304773048730497305073051730527305373054730557305673057730587305973060730617306273063730647306573066730677306873069730707307173072730737307473075730767307773078730797308073081730827308373084730857308673087730887308973090730917309273093730947309573096730977309873099731007310173102731037310473105731067310773108731097311073111731127311373114731157311673117731187311973120731217312273123731247312573126731277312873129731307313173132731337313473135731367313773138731397314073141731427314373144731457314673147731487314973150731517315273153731547315573156731577315873159731607316173162731637316473165731667316773168731697317073171731727317373174731757317673177731787317973180731817318273183731847318573186731877318873189731907319173192731937319473195731967319773198731997320073201732027320373204732057320673207732087320973210732117321273213732147321573216732177321873219732207322173222732237322473225732267322773228732297323073231732327323373234732357323673237732387323973240
  1. declare module BABYLON {
  2. /** Alias type for value that can be null */
  3. export type Nullable<T> = T | null;
  4. /**
  5. * Alias type for number that are floats
  6. * @ignorenaming
  7. */
  8. export type float = number;
  9. /**
  10. * Alias type for number that are doubles.
  11. * @ignorenaming
  12. */
  13. export type double = number;
  14. /**
  15. * Alias type for number that are integer
  16. * @ignorenaming
  17. */
  18. export type int = number;
  19. /** Alias type for number array or Float32Array */
  20. export type FloatArray = number[] | Float32Array;
  21. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  22. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  23. /**
  24. * Alias for types that can be used by a Buffer or VertexBuffer.
  25. */
  26. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  27. /**
  28. * Alias type for primitive types
  29. * @ignorenaming
  30. */
  31. type Primitive = undefined | null | boolean | string | number | Function;
  32. /**
  33. * Type modifier to make all the properties of an object Readonly
  34. */
  35. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  36. /**
  37. * Type modifier to make all the properties of an object Readonly recursively
  38. */
  39. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  40. /**
  41. * Type modifier to make object properties readonly.
  42. */
  43. export type DeepImmutableObject<T> = {
  44. readonly [K in keyof T]: DeepImmutable<T[K]>;
  45. };
  46. /** @hidden */
  47. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  48. }
  49. }
  50. declare module BABYLON {
  51. /**
  52. * A class serves as a medium between the observable and its observers
  53. */
  54. export class EventState {
  55. /**
  56. * Create a new EventState
  57. * @param mask defines the mask associated with this state
  58. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  59. * @param target defines the original target of the state
  60. * @param currentTarget defines the current target of the state
  61. */
  62. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  63. /**
  64. * Initialize the current event state
  65. * @param mask defines the mask associated with this state
  66. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  67. * @param target defines the original target of the state
  68. * @param currentTarget defines the current target of the state
  69. * @returns the current event state
  70. */
  71. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  72. /**
  73. * An Observer can set this property to true to prevent subsequent observers of being notified
  74. */
  75. skipNextObservers: boolean;
  76. /**
  77. * Get the mask value that were used to trigger the event corresponding to this EventState object
  78. */
  79. mask: number;
  80. /**
  81. * The object that originally notified the event
  82. */
  83. target?: any;
  84. /**
  85. * The current object in the bubbling phase
  86. */
  87. currentTarget?: any;
  88. /**
  89. * This will be populated with the return value of the last function that was executed.
  90. * If it is the first function in the callback chain it will be the event data.
  91. */
  92. lastReturnValue?: any;
  93. }
  94. /**
  95. * Represent an Observer registered to a given Observable object.
  96. */
  97. export class Observer<T> {
  98. /**
  99. * Defines the callback to call when the observer is notified
  100. */
  101. callback: (eventData: T, eventState: EventState) => void;
  102. /**
  103. * Defines the mask of the observer (used to filter notifications)
  104. */
  105. mask: number;
  106. /**
  107. * Defines the current scope used to restore the JS context
  108. */
  109. scope: any;
  110. /** @hidden */
  111. _willBeUnregistered: boolean;
  112. /**
  113. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  114. */
  115. unregisterOnNextCall: boolean;
  116. /**
  117. * Creates a new observer
  118. * @param callback defines the callback to call when the observer is notified
  119. * @param mask defines the mask of the observer (used to filter notifications)
  120. * @param scope defines the current scope used to restore the JS context
  121. */
  122. constructor(
  123. /**
  124. * Defines the callback to call when the observer is notified
  125. */
  126. callback: (eventData: T, eventState: EventState) => void,
  127. /**
  128. * Defines the mask of the observer (used to filter notifications)
  129. */
  130. mask: number,
  131. /**
  132. * Defines the current scope used to restore the JS context
  133. */
  134. scope?: any);
  135. }
  136. /**
  137. * Represent a list of observers registered to multiple Observables object.
  138. */
  139. export class MultiObserver<T> {
  140. private _observers;
  141. private _observables;
  142. /**
  143. * Release associated resources
  144. */
  145. dispose(): void;
  146. /**
  147. * Raise a callback when one of the observable will notify
  148. * @param observables defines a list of observables to watch
  149. * @param callback defines the callback to call on notification
  150. * @param mask defines the mask used to filter notifications
  151. * @param scope defines the current scope used to restore the JS context
  152. * @returns the new MultiObserver
  153. */
  154. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  155. }
  156. /**
  157. * The Observable class is a simple implementation of the Observable pattern.
  158. *
  159. * There's one slight particularity though: a given Observable can notify its observer using a particular mask value, only the Observers registered with this mask value will be notified.
  160. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  161. * For instance you may have a given Observable that have four different types of notifications: Move (mask = 0x01), Stop (mask = 0x02), Turn Right (mask = 0X04), Turn Left (mask = 0X08).
  162. * A given observer can register itself with only Move and Stop (mask = 0x03), then it will only be notified when one of these two occurs and will never be for Turn Left/Right.
  163. */
  164. export class Observable<T> {
  165. private _observers;
  166. private _eventState;
  167. private _onObserverAdded;
  168. /**
  169. * Gets the list of observers
  170. */
  171. readonly observers: Array<Observer<T>>;
  172. /**
  173. * Creates a new observable
  174. * @param onObserverAdded defines a callback to call when a new observer is added
  175. */
  176. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  177. /**
  178. * Create a new Observer with the specified callback
  179. * @param callback the callback that will be executed for that Observer
  180. * @param mask the mask used to filter observers
  181. * @param insertFirst if true the callback will be inserted at the first position, hence executed before the others ones. If false (default behavior) the callback will be inserted at the last position, executed after all the others already present.
  182. * @param scope optional scope for the callback to be called from
  183. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  184. * @returns the new observer created for the callback
  185. */
  186. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  187. /**
  188. * Create a new Observer with the specified callback and unregisters after the next notification
  189. * @param callback the callback that will be executed for that Observer
  190. * @returns the new observer created for the callback
  191. */
  192. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  193. /**
  194. * Remove an Observer from the Observable object
  195. * @param observer the instance of the Observer to remove
  196. * @returns false if it doesn't belong to this Observable
  197. */
  198. remove(observer: Nullable<Observer<T>>): boolean;
  199. /**
  200. * Remove a callback from the Observable object
  201. * @param callback the callback to remove
  202. * @param scope optional scope. If used only the callbacks with this scope will be removed
  203. * @returns false if it doesn't belong to this Observable
  204. */
  205. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  206. private _deferUnregister;
  207. private _remove;
  208. /**
  209. * Moves the observable to the top of the observer list making it get called first when notified
  210. * @param observer the observer to move
  211. */
  212. makeObserverTopPriority(observer: Observer<T>): void;
  213. /**
  214. * Moves the observable to the bottom of the observer list making it get called last when notified
  215. * @param observer the observer to move
  216. */
  217. makeObserverBottomPriority(observer: Observer<T>): void;
  218. /**
  219. * Notify all Observers by calling their respective callback with the given data
  220. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  221. * @param eventData defines the data to send to all observers
  222. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  223. * @param target defines the original target of the state
  224. * @param currentTarget defines the current target of the state
  225. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  226. */
  227. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  228. /**
  229. * Calling this will execute each callback, expecting it to be a promise or return a value.
  230. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  231. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  232. * and it is crucial that all callbacks will be executed.
  233. * The order of the callbacks is kept, callbacks are not executed parallel.
  234. *
  235. * @param eventData The data to be sent to each callback
  236. * @param mask is used to filter observers defaults to -1
  237. * @param target defines the callback target (see EventState)
  238. * @param currentTarget defines he current object in the bubbling phase
  239. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  240. */
  241. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  242. /**
  243. * Notify a specific observer
  244. * @param observer defines the observer to notify
  245. * @param eventData defines the data to be sent to each callback
  246. * @param mask is used to filter observers defaults to -1
  247. */
  248. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  249. /**
  250. * Gets a boolean indicating if the observable has at least one observer
  251. * @returns true is the Observable has at least one Observer registered
  252. */
  253. hasObservers(): boolean;
  254. /**
  255. * Clear the list of observers
  256. */
  257. clear(): void;
  258. /**
  259. * Clone the current observable
  260. * @returns a new observable
  261. */
  262. clone(): Observable<T>;
  263. /**
  264. * Does this observable handles observer registered with a given mask
  265. * @param mask defines the mask to be tested
  266. * @return whether or not one observer registered with the given mask is handeled
  267. **/
  268. hasSpecificMask(mask?: number): boolean;
  269. }
  270. }
  271. declare module BABYLON {
  272. /**
  273. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  274. * Babylon.js
  275. */
  276. export class DomManagement {
  277. /**
  278. * Checks if the window object exists
  279. * @returns true if the window object exists
  280. */
  281. static IsWindowObjectExist(): boolean;
  282. /**
  283. * Checks if the navigator object exists
  284. * @returns true if the navigator object exists
  285. */
  286. static IsNavigatorAvailable(): boolean;
  287. /**
  288. * Extracts text content from a DOM element hierarchy
  289. * @param element defines the root element
  290. * @returns a string
  291. */
  292. static GetDOMTextContent(element: HTMLElement): string;
  293. }
  294. }
  295. declare module BABYLON {
  296. /**
  297. * Logger used througouht the application to allow configuration of
  298. * the log level required for the messages.
  299. */
  300. export class Logger {
  301. /**
  302. * No log
  303. */
  304. static readonly NoneLogLevel: number;
  305. /**
  306. * Only message logs
  307. */
  308. static readonly MessageLogLevel: number;
  309. /**
  310. * Only warning logs
  311. */
  312. static readonly WarningLogLevel: number;
  313. /**
  314. * Only error logs
  315. */
  316. static readonly ErrorLogLevel: number;
  317. /**
  318. * All logs
  319. */
  320. static readonly AllLogLevel: number;
  321. private static _LogCache;
  322. /**
  323. * Gets a value indicating the number of loading errors
  324. * @ignorenaming
  325. */
  326. static errorsCount: number;
  327. /**
  328. * Callback called when a new log is added
  329. */
  330. static OnNewCacheEntry: (entry: string) => void;
  331. private static _AddLogEntry;
  332. private static _FormatMessage;
  333. private static _LogDisabled;
  334. private static _LogEnabled;
  335. private static _WarnDisabled;
  336. private static _WarnEnabled;
  337. private static _ErrorDisabled;
  338. private static _ErrorEnabled;
  339. /**
  340. * Log a message to the console
  341. */
  342. static Log: (message: string) => void;
  343. /**
  344. * Write a warning message to the console
  345. */
  346. static Warn: (message: string) => void;
  347. /**
  348. * Write an error message to the console
  349. */
  350. static Error: (message: string) => void;
  351. /**
  352. * Gets current log cache (list of logs)
  353. */
  354. static readonly LogCache: string;
  355. /**
  356. * Clears the log cache
  357. */
  358. static ClearLogCache(): void;
  359. /**
  360. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  361. */
  362. static LogLevels: number;
  363. }
  364. }
  365. declare module BABYLON {
  366. /** @hidden */
  367. export class _TypeStore {
  368. /** @hidden */
  369. static RegisteredTypes: {
  370. [key: string]: Object;
  371. };
  372. /** @hidden */
  373. static GetClass(fqdn: string): any;
  374. }
  375. }
  376. declare module BABYLON {
  377. /**
  378. * Class containing a set of static utilities functions for deep copy.
  379. */
  380. export class DeepCopier {
  381. /**
  382. * Tries to copy an object by duplicating every property
  383. * @param source defines the source object
  384. * @param destination defines the target object
  385. * @param doNotCopyList defines a list of properties to avoid
  386. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  387. */
  388. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  389. }
  390. }
  391. declare module BABYLON {
  392. /**
  393. * Class containing a set of static utilities functions for precision date
  394. */
  395. export class PrecisionDate {
  396. /**
  397. * Gets either window.performance.now() if supported or Date.now() else
  398. */
  399. static readonly Now: number;
  400. }
  401. }
  402. declare module BABYLON {
  403. /** @hidden */
  404. export class _DevTools {
  405. static WarnImport(name: string): string;
  406. }
  407. }
  408. declare module BABYLON {
  409. /**
  410. * Interface used to define the mechanism to get data from the network
  411. */
  412. export interface IWebRequest {
  413. /**
  414. * Returns client's response url
  415. */
  416. responseURL: string;
  417. /**
  418. * Returns client's status
  419. */
  420. status: number;
  421. /**
  422. * Returns client's status as a text
  423. */
  424. statusText: string;
  425. }
  426. }
  427. declare module BABYLON {
  428. /**
  429. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  430. */
  431. export class WebRequest implements IWebRequest {
  432. private _xhr;
  433. /**
  434. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  435. * i.e. when loading files, where the server/service expects an Authorization header
  436. */
  437. static CustomRequestHeaders: {
  438. [key: string]: string;
  439. };
  440. /**
  441. * Add callback functions in this array to update all the requests before they get sent to the network
  442. */
  443. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  444. private _injectCustomRequestHeaders;
  445. /**
  446. * Gets or sets a function to be called when loading progress changes
  447. */
  448. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  449. /**
  450. * Returns client's state
  451. */
  452. readonly readyState: number;
  453. /**
  454. * Returns client's status
  455. */
  456. readonly status: number;
  457. /**
  458. * Returns client's status as a text
  459. */
  460. readonly statusText: string;
  461. /**
  462. * Returns client's response
  463. */
  464. readonly response: any;
  465. /**
  466. * Returns client's response url
  467. */
  468. readonly responseURL: string;
  469. /**
  470. * Returns client's response as text
  471. */
  472. readonly responseText: string;
  473. /**
  474. * Gets or sets the expected response type
  475. */
  476. responseType: XMLHttpRequestResponseType;
  477. /** @hidden */
  478. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  479. /** @hidden */
  480. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  481. /**
  482. * Cancels any network activity
  483. */
  484. abort(): void;
  485. /**
  486. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  487. * @param body defines an optional request body
  488. */
  489. send(body?: Document | BodyInit | null): void;
  490. /**
  491. * Sets the request method, request URL
  492. * @param method defines the method to use (GET, POST, etc..)
  493. * @param url defines the url to connect with
  494. */
  495. open(method: string, url: string): void;
  496. }
  497. }
  498. declare module BABYLON {
  499. /**
  500. * File request interface
  501. */
  502. export interface IFileRequest {
  503. /**
  504. * Raised when the request is complete (success or error).
  505. */
  506. onCompleteObservable: Observable<IFileRequest>;
  507. /**
  508. * Aborts the request for a file.
  509. */
  510. abort: () => void;
  511. }
  512. }
  513. declare module BABYLON {
  514. /**
  515. * Define options used to create a render target texture
  516. */
  517. export class RenderTargetCreationOptions {
  518. /**
  519. * Specifies is mipmaps must be generated
  520. */
  521. generateMipMaps?: boolean;
  522. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  523. generateDepthBuffer?: boolean;
  524. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  525. generateStencilBuffer?: boolean;
  526. /** Defines texture type (int by default) */
  527. type?: number;
  528. /** Defines sampling mode (trilinear by default) */
  529. samplingMode?: number;
  530. /** Defines format (RGBA by default) */
  531. format?: number;
  532. }
  533. }
  534. declare module BABYLON {
  535. /**
  536. * @hidden
  537. **/
  538. export class _TimeToken {
  539. _startTimeQuery: Nullable<WebGLQuery>;
  540. _endTimeQuery: Nullable<WebGLQuery>;
  541. _timeElapsedQuery: Nullable<WebGLQuery>;
  542. _timeElapsedQueryEnded: boolean;
  543. }
  544. }
  545. declare module BABYLON {
  546. /** Defines the cross module used constants to avoid circular dependncies */
  547. export class Constants {
  548. /** Defines that alpha blending is disabled */
  549. static readonly ALPHA_DISABLE: number;
  550. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  551. static readonly ALPHA_ADD: number;
  552. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  553. static readonly ALPHA_COMBINE: number;
  554. /** Defines that alpha blending to DEST - SRC * DEST */
  555. static readonly ALPHA_SUBTRACT: number;
  556. /** Defines that alpha blending to SRC * DEST */
  557. static readonly ALPHA_MULTIPLY: number;
  558. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  559. static readonly ALPHA_MAXIMIZED: number;
  560. /** Defines that alpha blending to SRC + DEST */
  561. static readonly ALPHA_ONEONE: number;
  562. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  563. static readonly ALPHA_PREMULTIPLIED: number;
  564. /**
  565. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  566. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  567. */
  568. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  569. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  570. static readonly ALPHA_INTERPOLATE: number;
  571. /**
  572. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  573. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  574. */
  575. static readonly ALPHA_SCREENMODE: number;
  576. /**
  577. * Defines that alpha blending to SRC + DST
  578. * Alpha will be set to SRC ALPHA + DST ALPHA
  579. */
  580. static readonly ALPHA_ONEONE_ONEONE: number;
  581. /**
  582. * Defines that alpha blending to SRC * DST ALPHA + DST
  583. * Alpha will be set to 0
  584. */
  585. static readonly ALPHA_ALPHATOCOLOR: number;
  586. /**
  587. * Defines that alpha blending to SRC * (1 - DST) + DST * (1 - SRC)
  588. */
  589. static readonly ALPHA_REVERSEONEMINUS: number;
  590. /**
  591. * Defines that alpha blending to SRC + DST * (1 - SRC ALPHA)
  592. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  593. */
  594. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  595. /**
  596. * Defines that alpha blending to SRC + DST
  597. * Alpha will be set to SRC ALPHA
  598. */
  599. static readonly ALPHA_ONEONE_ONEZERO: number;
  600. /** Defines that alpha blending equation a SUM */
  601. static readonly ALPHA_EQUATION_ADD: number;
  602. /** Defines that alpha blending equation a SUBSTRACTION */
  603. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  604. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  605. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  606. /** Defines that alpha blending equation a MAX operation */
  607. static readonly ALPHA_EQUATION_MAX: number;
  608. /** Defines that alpha blending equation a MIN operation */
  609. static readonly ALPHA_EQUATION_MIN: number;
  610. /**
  611. * Defines that alpha blending equation a DARKEN operation:
  612. * It takes the min of the src and sums the alpha channels.
  613. */
  614. static readonly ALPHA_EQUATION_DARKEN: number;
  615. /** Defines that the ressource is not delayed*/
  616. static readonly DELAYLOADSTATE_NONE: number;
  617. /** Defines that the ressource was successfully delay loaded */
  618. static readonly DELAYLOADSTATE_LOADED: number;
  619. /** Defines that the ressource is currently delay loading */
  620. static readonly DELAYLOADSTATE_LOADING: number;
  621. /** Defines that the ressource is delayed and has not started loading */
  622. static readonly DELAYLOADSTATE_NOTLOADED: number;
  623. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  624. static readonly NEVER: number;
  625. /** 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 */
  626. static readonly ALWAYS: number;
  627. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  628. static readonly LESS: number;
  629. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  630. static readonly EQUAL: number;
  631. /** 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 */
  632. static readonly LEQUAL: number;
  633. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  634. static readonly GREATER: number;
  635. /** 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 */
  636. static readonly GEQUAL: number;
  637. /** 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 */
  638. static readonly NOTEQUAL: number;
  639. /** Passed to stencilOperation to specify that stencil value must be kept */
  640. static readonly KEEP: number;
  641. /** Passed to stencilOperation to specify that stencil value must be replaced */
  642. static readonly REPLACE: number;
  643. /** Passed to stencilOperation to specify that stencil value must be incremented */
  644. static readonly INCR: number;
  645. /** Passed to stencilOperation to specify that stencil value must be decremented */
  646. static readonly DECR: number;
  647. /** Passed to stencilOperation to specify that stencil value must be inverted */
  648. static readonly INVERT: number;
  649. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  650. static readonly INCR_WRAP: number;
  651. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  652. static readonly DECR_WRAP: number;
  653. /** Texture is not repeating outside of 0..1 UVs */
  654. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  655. /** Texture is repeating outside of 0..1 UVs */
  656. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  657. /** Texture is repeating and mirrored */
  658. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  659. /** ALPHA */
  660. static readonly TEXTUREFORMAT_ALPHA: number;
  661. /** LUMINANCE */
  662. static readonly TEXTUREFORMAT_LUMINANCE: number;
  663. /** LUMINANCE_ALPHA */
  664. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  665. /** RGB */
  666. static readonly TEXTUREFORMAT_RGB: number;
  667. /** RGBA */
  668. static readonly TEXTUREFORMAT_RGBA: number;
  669. /** RED */
  670. static readonly TEXTUREFORMAT_RED: number;
  671. /** RED (2nd reference) */
  672. static readonly TEXTUREFORMAT_R: number;
  673. /** RG */
  674. static readonly TEXTUREFORMAT_RG: number;
  675. /** RED_INTEGER */
  676. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  677. /** RED_INTEGER (2nd reference) */
  678. static readonly TEXTUREFORMAT_R_INTEGER: number;
  679. /** RG_INTEGER */
  680. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  681. /** RGB_INTEGER */
  682. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  683. /** RGBA_INTEGER */
  684. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  685. /** UNSIGNED_BYTE */
  686. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  687. /** UNSIGNED_BYTE (2nd reference) */
  688. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  689. /** FLOAT */
  690. static readonly TEXTURETYPE_FLOAT: number;
  691. /** HALF_FLOAT */
  692. static readonly TEXTURETYPE_HALF_FLOAT: number;
  693. /** BYTE */
  694. static readonly TEXTURETYPE_BYTE: number;
  695. /** SHORT */
  696. static readonly TEXTURETYPE_SHORT: number;
  697. /** UNSIGNED_SHORT */
  698. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  699. /** INT */
  700. static readonly TEXTURETYPE_INT: number;
  701. /** UNSIGNED_INT */
  702. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  703. /** UNSIGNED_SHORT_4_4_4_4 */
  704. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  705. /** UNSIGNED_SHORT_5_5_5_1 */
  706. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  707. /** UNSIGNED_SHORT_5_6_5 */
  708. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  709. /** UNSIGNED_INT_2_10_10_10_REV */
  710. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  711. /** UNSIGNED_INT_24_8 */
  712. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  713. /** UNSIGNED_INT_10F_11F_11F_REV */
  714. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  715. /** UNSIGNED_INT_5_9_9_9_REV */
  716. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  717. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  718. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  719. /** nearest is mag = nearest and min = nearest and mip = linear */
  720. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  721. /** Bilinear is mag = linear and min = linear and mip = nearest */
  722. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  723. /** Trilinear is mag = linear and min = linear and mip = linear */
  724. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  725. /** nearest is mag = nearest and min = nearest and mip = linear */
  726. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  727. /** Bilinear is mag = linear and min = linear and mip = nearest */
  728. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  729. /** Trilinear is mag = linear and min = linear and mip = linear */
  730. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  731. /** mag = nearest and min = nearest and mip = nearest */
  732. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  733. /** mag = nearest and min = linear and mip = nearest */
  734. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  735. /** mag = nearest and min = linear and mip = linear */
  736. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  737. /** mag = nearest and min = linear and mip = none */
  738. static readonly TEXTURE_NEAREST_LINEAR: number;
  739. /** mag = nearest and min = nearest and mip = none */
  740. static readonly TEXTURE_NEAREST_NEAREST: number;
  741. /** mag = linear and min = nearest and mip = nearest */
  742. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  743. /** mag = linear and min = nearest and mip = linear */
  744. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  745. /** mag = linear and min = linear and mip = none */
  746. static readonly TEXTURE_LINEAR_LINEAR: number;
  747. /** mag = linear and min = nearest and mip = none */
  748. static readonly TEXTURE_LINEAR_NEAREST: number;
  749. /** Explicit coordinates mode */
  750. static readonly TEXTURE_EXPLICIT_MODE: number;
  751. /** Spherical coordinates mode */
  752. static readonly TEXTURE_SPHERICAL_MODE: number;
  753. /** Planar coordinates mode */
  754. static readonly TEXTURE_PLANAR_MODE: number;
  755. /** Cubic coordinates mode */
  756. static readonly TEXTURE_CUBIC_MODE: number;
  757. /** Projection coordinates mode */
  758. static readonly TEXTURE_PROJECTION_MODE: number;
  759. /** Skybox coordinates mode */
  760. static readonly TEXTURE_SKYBOX_MODE: number;
  761. /** Inverse Cubic coordinates mode */
  762. static readonly TEXTURE_INVCUBIC_MODE: number;
  763. /** Equirectangular coordinates mode */
  764. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  765. /** Equirectangular Fixed coordinates mode */
  766. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  767. /** Equirectangular Fixed Mirrored coordinates mode */
  768. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  769. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  770. static readonly SCALEMODE_FLOOR: number;
  771. /** Defines that texture rescaling will look for the nearest power of 2 size */
  772. static readonly SCALEMODE_NEAREST: number;
  773. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  774. static readonly SCALEMODE_CEILING: number;
  775. /**
  776. * The dirty texture flag value
  777. */
  778. static readonly MATERIAL_TextureDirtyFlag: number;
  779. /**
  780. * The dirty light flag value
  781. */
  782. static readonly MATERIAL_LightDirtyFlag: number;
  783. /**
  784. * The dirty fresnel flag value
  785. */
  786. static readonly MATERIAL_FresnelDirtyFlag: number;
  787. /**
  788. * The dirty attribute flag value
  789. */
  790. static readonly MATERIAL_AttributesDirtyFlag: number;
  791. /**
  792. * The dirty misc flag value
  793. */
  794. static readonly MATERIAL_MiscDirtyFlag: number;
  795. /**
  796. * The all dirty flag value
  797. */
  798. static readonly MATERIAL_AllDirtyFlag: number;
  799. /**
  800. * Returns the triangle fill mode
  801. */
  802. static readonly MATERIAL_TriangleFillMode: number;
  803. /**
  804. * Returns the wireframe mode
  805. */
  806. static readonly MATERIAL_WireFrameFillMode: number;
  807. /**
  808. * Returns the point fill mode
  809. */
  810. static readonly MATERIAL_PointFillMode: number;
  811. /**
  812. * Returns the point list draw mode
  813. */
  814. static readonly MATERIAL_PointListDrawMode: number;
  815. /**
  816. * Returns the line list draw mode
  817. */
  818. static readonly MATERIAL_LineListDrawMode: number;
  819. /**
  820. * Returns the line loop draw mode
  821. */
  822. static readonly MATERIAL_LineLoopDrawMode: number;
  823. /**
  824. * Returns the line strip draw mode
  825. */
  826. static readonly MATERIAL_LineStripDrawMode: number;
  827. /**
  828. * Returns the triangle strip draw mode
  829. */
  830. static readonly MATERIAL_TriangleStripDrawMode: number;
  831. /**
  832. * Returns the triangle fan draw mode
  833. */
  834. static readonly MATERIAL_TriangleFanDrawMode: number;
  835. /**
  836. * Stores the clock-wise side orientation
  837. */
  838. static readonly MATERIAL_ClockWiseSideOrientation: number;
  839. /**
  840. * Stores the counter clock-wise side orientation
  841. */
  842. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  843. /**
  844. * Nothing
  845. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  846. */
  847. static readonly ACTION_NothingTrigger: number;
  848. /**
  849. * On pick
  850. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  851. */
  852. static readonly ACTION_OnPickTrigger: number;
  853. /**
  854. * On left pick
  855. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  856. */
  857. static readonly ACTION_OnLeftPickTrigger: number;
  858. /**
  859. * On right pick
  860. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  861. */
  862. static readonly ACTION_OnRightPickTrigger: number;
  863. /**
  864. * On center pick
  865. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  866. */
  867. static readonly ACTION_OnCenterPickTrigger: number;
  868. /**
  869. * On pick down
  870. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  871. */
  872. static readonly ACTION_OnPickDownTrigger: number;
  873. /**
  874. * On double pick
  875. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  876. */
  877. static readonly ACTION_OnDoublePickTrigger: number;
  878. /**
  879. * On pick up
  880. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  881. */
  882. static readonly ACTION_OnPickUpTrigger: number;
  883. /**
  884. * On pick out.
  885. * This trigger will only be raised if you also declared a OnPickDown
  886. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  887. */
  888. static readonly ACTION_OnPickOutTrigger: number;
  889. /**
  890. * On long press
  891. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  892. */
  893. static readonly ACTION_OnLongPressTrigger: number;
  894. /**
  895. * On pointer over
  896. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  897. */
  898. static readonly ACTION_OnPointerOverTrigger: number;
  899. /**
  900. * On pointer out
  901. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  902. */
  903. static readonly ACTION_OnPointerOutTrigger: number;
  904. /**
  905. * On every frame
  906. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  907. */
  908. static readonly ACTION_OnEveryFrameTrigger: number;
  909. /**
  910. * On intersection enter
  911. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  912. */
  913. static readonly ACTION_OnIntersectionEnterTrigger: number;
  914. /**
  915. * On intersection exit
  916. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  917. */
  918. static readonly ACTION_OnIntersectionExitTrigger: number;
  919. /**
  920. * On key down
  921. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  922. */
  923. static readonly ACTION_OnKeyDownTrigger: number;
  924. /**
  925. * On key up
  926. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  927. */
  928. static readonly ACTION_OnKeyUpTrigger: number;
  929. /**
  930. * Billboard mode will only apply to Y axis
  931. */
  932. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  933. /**
  934. * Billboard mode will apply to all axes
  935. */
  936. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  937. /**
  938. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  939. */
  940. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  941. /**
  942. * Gets or sets base Assets URL
  943. */
  944. static PARTICLES_BaseAssetsUrl: string;
  945. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  946. * Test order :
  947. * Is the bounding sphere outside the frustum ?
  948. * If not, are the bounding box vertices outside the frustum ?
  949. * It not, then the cullable object is in the frustum.
  950. */
  951. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  952. /** Culling strategy : Bounding Sphere Only.
  953. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  954. * It's also less accurate than the standard because some not visible objects can still be selected.
  955. * Test : is the bounding sphere outside the frustum ?
  956. * If not, then the cullable object is in the frustum.
  957. */
  958. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  959. /** Culling strategy : Optimistic Inclusion.
  960. * This in an inclusion test first, then the standard exclusion test.
  961. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  962. * 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.
  963. * Anyway, it's as accurate as the standard strategy.
  964. * Test :
  965. * Is the cullable object bounding sphere center in the frustum ?
  966. * If not, apply the default culling strategy.
  967. */
  968. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  969. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  970. * This in an inclusion test first, then the bounding sphere only exclusion test.
  971. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  972. * 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.
  973. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  974. * Test :
  975. * Is the cullable object bounding sphere center in the frustum ?
  976. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  977. */
  978. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  979. /**
  980. * No logging while loading
  981. */
  982. static readonly SCENELOADER_NO_LOGGING: number;
  983. /**
  984. * Minimal logging while loading
  985. */
  986. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  987. /**
  988. * Summary logging while loading
  989. */
  990. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  991. /**
  992. * Detailled logging while loading
  993. */
  994. static readonly SCENELOADER_DETAILED_LOGGING: number;
  995. }
  996. }
  997. declare module BABYLON {
  998. /**
  999. * This represents the required contract to create a new type of texture loader.
  1000. */
  1001. export interface IInternalTextureLoader {
  1002. /**
  1003. * Defines wether the loader supports cascade loading the different faces.
  1004. */
  1005. supportCascades: boolean;
  1006. /**
  1007. * This returns if the loader support the current file information.
  1008. * @param extension defines the file extension of the file being loaded
  1009. * @param textureFormatInUse defines the current compressed format in use iun the engine
  1010. * @param fallback defines the fallback internal texture if any
  1011. * @param isBase64 defines whether the texture is encoded as a base64
  1012. * @param isBuffer defines whether the texture data are stored as a buffer
  1013. * @returns true if the loader can load the specified file
  1014. */
  1015. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  1016. /**
  1017. * Transform the url before loading if required.
  1018. * @param rootUrl the url of the texture
  1019. * @param textureFormatInUse defines the current compressed format in use iun the engine
  1020. * @returns the transformed texture
  1021. */
  1022. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  1023. /**
  1024. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  1025. * @param rootUrl the url of the texture
  1026. * @param textureFormatInUse defines the current compressed format in use iun the engine
  1027. * @returns the fallback texture
  1028. */
  1029. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  1030. /**
  1031. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  1032. * @param data contains the texture data
  1033. * @param texture defines the BabylonJS internal texture
  1034. * @param createPolynomials will be true if polynomials have been requested
  1035. * @param onLoad defines the callback to trigger once the texture is ready
  1036. * @param onError defines the callback to trigger in case of error
  1037. */
  1038. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  1039. /**
  1040. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  1041. * @param data contains the texture data
  1042. * @param texture defines the BabylonJS internal texture
  1043. * @param callback defines the method to call once ready to upload
  1044. */
  1045. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  1046. }
  1047. }
  1048. declare module BABYLON {
  1049. /**
  1050. * Class used to store and describe the pipeline context associated with an effect
  1051. */
  1052. export interface IPipelineContext {
  1053. /**
  1054. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  1055. */
  1056. isAsync: boolean;
  1057. /**
  1058. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  1059. */
  1060. isReady: boolean;
  1061. /** @hidden */
  1062. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  1063. }
  1064. }
  1065. declare module BABYLON {
  1066. /**
  1067. * Class used to store gfx data (like WebGLBuffer)
  1068. */
  1069. export class DataBuffer {
  1070. /**
  1071. * Gets or sets the number of objects referencing this buffer
  1072. */
  1073. references: number;
  1074. /** Gets or sets the size of the underlying buffer */
  1075. capacity: number;
  1076. /**
  1077. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  1078. */
  1079. is32Bits: boolean;
  1080. /**
  1081. * Gets the underlying buffer
  1082. */
  1083. readonly underlyingResource: any;
  1084. }
  1085. }
  1086. declare module BABYLON {
  1087. /** @hidden */
  1088. export interface IShaderProcessor {
  1089. attributeProcessor?: (attribute: string) => string;
  1090. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  1091. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  1092. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  1093. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  1094. lineProcessor?: (line: string, isFragment: boolean) => string;
  1095. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1096. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1097. }
  1098. }
  1099. declare module BABYLON {
  1100. /** @hidden */
  1101. export interface ProcessingOptions {
  1102. defines: string[];
  1103. indexParameters: any;
  1104. isFragment: boolean;
  1105. shouldUseHighPrecisionShader: boolean;
  1106. supportsUniformBuffers: boolean;
  1107. shadersRepository: string;
  1108. includesShadersStore: {
  1109. [key: string]: string;
  1110. };
  1111. processor?: IShaderProcessor;
  1112. version: string;
  1113. platformName: string;
  1114. lookForClosingBracketForUniformBuffer?: boolean;
  1115. }
  1116. }
  1117. declare module BABYLON {
  1118. /**
  1119. * Helper to manipulate strings
  1120. */
  1121. export class StringTools {
  1122. /**
  1123. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  1124. * @param str Source string
  1125. * @param suffix Suffix to search for in the source string
  1126. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  1127. */
  1128. static EndsWith(str: string, suffix: string): boolean;
  1129. /**
  1130. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  1131. * @param str Source string
  1132. * @param suffix Suffix to search for in the source string
  1133. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  1134. */
  1135. static StartsWith(str: string, suffix: string): boolean;
  1136. }
  1137. }
  1138. declare module BABYLON {
  1139. /** @hidden */
  1140. export class ShaderCodeNode {
  1141. line: string;
  1142. children: ShaderCodeNode[];
  1143. additionalDefineKey?: string;
  1144. additionalDefineValue?: string;
  1145. isValid(preprocessors: {
  1146. [key: string]: string;
  1147. }): boolean;
  1148. process(preprocessors: {
  1149. [key: string]: string;
  1150. }, options: ProcessingOptions): string;
  1151. }
  1152. }
  1153. declare module BABYLON {
  1154. /** @hidden */
  1155. export class ShaderCodeCursor {
  1156. private _lines;
  1157. lineIndex: number;
  1158. readonly currentLine: string;
  1159. readonly canRead: boolean;
  1160. lines: string[];
  1161. }
  1162. }
  1163. declare module BABYLON {
  1164. /** @hidden */
  1165. export class ShaderCodeConditionNode extends ShaderCodeNode {
  1166. process(preprocessors: {
  1167. [key: string]: string;
  1168. }, options: ProcessingOptions): string;
  1169. }
  1170. }
  1171. declare module BABYLON {
  1172. /** @hidden */
  1173. export class ShaderDefineExpression {
  1174. isTrue(preprocessors: {
  1175. [key: string]: string;
  1176. }): boolean;
  1177. }
  1178. }
  1179. declare module BABYLON {
  1180. /** @hidden */
  1181. export class ShaderCodeTestNode extends ShaderCodeNode {
  1182. testExpression: ShaderDefineExpression;
  1183. isValid(preprocessors: {
  1184. [key: string]: string;
  1185. }): boolean;
  1186. }
  1187. }
  1188. declare module BABYLON {
  1189. /** @hidden */
  1190. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  1191. define: string;
  1192. not: boolean;
  1193. constructor(define: string, not?: boolean);
  1194. isTrue(preprocessors: {
  1195. [key: string]: string;
  1196. }): boolean;
  1197. }
  1198. }
  1199. declare module BABYLON {
  1200. /** @hidden */
  1201. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  1202. leftOperand: ShaderDefineExpression;
  1203. rightOperand: ShaderDefineExpression;
  1204. isTrue(preprocessors: {
  1205. [key: string]: string;
  1206. }): boolean;
  1207. }
  1208. }
  1209. declare module BABYLON {
  1210. /** @hidden */
  1211. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  1212. leftOperand: ShaderDefineExpression;
  1213. rightOperand: ShaderDefineExpression;
  1214. isTrue(preprocessors: {
  1215. [key: string]: string;
  1216. }): boolean;
  1217. }
  1218. }
  1219. declare module BABYLON {
  1220. /** @hidden */
  1221. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  1222. define: string;
  1223. operand: string;
  1224. testValue: string;
  1225. constructor(define: string, operand: string, testValue: string);
  1226. isTrue(preprocessors: {
  1227. [key: string]: string;
  1228. }): boolean;
  1229. }
  1230. }
  1231. declare module BABYLON {
  1232. /**
  1233. * @ignore
  1234. * Application error to support additional information when loading a file
  1235. */
  1236. export class LoadFileError extends Error {
  1237. /** defines the optional web request */
  1238. request?: WebRequest | undefined;
  1239. private static _setPrototypeOf;
  1240. /**
  1241. * Creates a new LoadFileError
  1242. * @param message defines the message of the error
  1243. * @param request defines the optional web request
  1244. */
  1245. constructor(message: string,
  1246. /** defines the optional web request */
  1247. request?: WebRequest | undefined);
  1248. }
  1249. }
  1250. declare module BABYLON {
  1251. /**
  1252. * Class used to enable access to offline support
  1253. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1254. */
  1255. export interface IOfflineProvider {
  1256. /**
  1257. * Gets a boolean indicating if scene must be saved in the database
  1258. */
  1259. enableSceneOffline: boolean;
  1260. /**
  1261. * Gets a boolean indicating if textures must be saved in the database
  1262. */
  1263. enableTexturesOffline: boolean;
  1264. /**
  1265. * Open the offline support and make it available
  1266. * @param successCallback defines the callback to call on success
  1267. * @param errorCallback defines the callback to call on error
  1268. */
  1269. open(successCallback: () => void, errorCallback: () => void): void;
  1270. /**
  1271. * Loads an image from the offline support
  1272. * @param url defines the url to load from
  1273. * @param image defines the target DOM image
  1274. */
  1275. loadImage(url: string, image: HTMLImageElement): void;
  1276. /**
  1277. * Loads a file from offline support
  1278. * @param url defines the URL to load from
  1279. * @param sceneLoaded defines a callback to call on success
  1280. * @param progressCallBack defines a callback to call when progress changed
  1281. * @param errorCallback defines a callback to call on error
  1282. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  1283. */
  1284. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  1285. }
  1286. }
  1287. declare module BABYLON {
  1288. /**
  1289. * Class used to help managing file picking and drag'n'drop
  1290. * File Storage
  1291. */
  1292. export class FilesInputStore {
  1293. /**
  1294. * List of files ready to be loaded
  1295. */
  1296. static FilesToLoad: {
  1297. [key: string]: File;
  1298. };
  1299. }
  1300. }
  1301. declare module BABYLON {
  1302. /**
  1303. * Class used to define a retry strategy when error happens while loading assets
  1304. */
  1305. export class RetryStrategy {
  1306. /**
  1307. * Function used to defines an exponential back off strategy
  1308. * @param maxRetries defines the maximum number of retries (3 by default)
  1309. * @param baseInterval defines the interval between retries
  1310. * @returns the strategy function to use
  1311. */
  1312. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  1313. }
  1314. }
  1315. declare module BABYLON {
  1316. /**
  1317. * @hidden
  1318. */
  1319. export class FileTools {
  1320. /**
  1321. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  1322. */
  1323. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  1324. /**
  1325. * Gets or sets the base URL to use to load assets
  1326. */
  1327. static BaseUrl: string;
  1328. /**
  1329. * Default behaviour for cors in the application.
  1330. * It can be a string if the expected behavior is identical in the entire app.
  1331. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  1332. */
  1333. static CorsBehavior: string | ((url: string | string[]) => string);
  1334. /**
  1335. * Gets or sets a function used to pre-process url before using them to load assets
  1336. */
  1337. static PreprocessUrl: (url: string) => string;
  1338. /**
  1339. * Removes unwanted characters from an url
  1340. * @param url defines the url to clean
  1341. * @returns the cleaned url
  1342. */
  1343. private static _CleanUrl;
  1344. /**
  1345. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  1346. * @param url define the url we are trying
  1347. * @param element define the dom element where to configure the cors policy
  1348. */
  1349. static SetCorsBehavior(url: string | string[], element: {
  1350. crossOrigin: string | null;
  1351. }): void;
  1352. /**
  1353. * Loads an image as an HTMLImageElement.
  1354. * @param input url string, ArrayBuffer, or Blob to load
  1355. * @param onLoad callback called when the image successfully loads
  1356. * @param onError callback called when the image fails to load
  1357. * @param offlineProvider offline provider for caching
  1358. * @returns the HTMLImageElement of the loaded image
  1359. */
  1360. static LoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  1361. /**
  1362. * Loads a file
  1363. * @param fileToLoad defines the file to load
  1364. * @param callback defines the callback to call when data is loaded
  1365. * @param progressCallBack defines the callback to call during loading process
  1366. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  1367. * @returns a file request object
  1368. */
  1369. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  1370. /**
  1371. * Loads a file
  1372. * @param url url string, ArrayBuffer, or Blob to load
  1373. * @param onSuccess callback called when the file successfully loads
  1374. * @param onProgress callback called while file is loading (if the server supports this mode)
  1375. * @param offlineProvider defines the offline provider for caching
  1376. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1377. * @param onError callback called when the file fails to load
  1378. * @returns a file request object
  1379. */
  1380. 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;
  1381. /**
  1382. * Checks if the loaded document was accessed via `file:`-Protocol.
  1383. * @returns boolean
  1384. */
  1385. static IsFileURL(): boolean;
  1386. }
  1387. }
  1388. declare module BABYLON {
  1389. /** @hidden */
  1390. export class ShaderProcessor {
  1391. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  1392. private static _ProcessPrecision;
  1393. private static _ExtractOperation;
  1394. private static _BuildSubExpression;
  1395. private static _BuildExpression;
  1396. private static _MoveCursorWithinIf;
  1397. private static _MoveCursor;
  1398. private static _EvaluatePreProcessors;
  1399. private static _PreparePreProcessors;
  1400. private static _ProcessShaderConversion;
  1401. private static _ProcessIncludes;
  1402. }
  1403. }
  1404. declare module BABYLON {
  1405. /**
  1406. * @hidden
  1407. */
  1408. export interface IColor4Like {
  1409. r: float;
  1410. g: float;
  1411. b: float;
  1412. a: float;
  1413. }
  1414. /**
  1415. * @hidden
  1416. */
  1417. export interface IColor3Like {
  1418. r: float;
  1419. g: float;
  1420. b: float;
  1421. }
  1422. /**
  1423. * @hidden
  1424. */
  1425. export interface IVector4Like {
  1426. x: float;
  1427. y: float;
  1428. z: float;
  1429. w: float;
  1430. }
  1431. /**
  1432. * @hidden
  1433. */
  1434. export interface IVector3Like {
  1435. x: float;
  1436. y: float;
  1437. z: float;
  1438. }
  1439. /**
  1440. * @hidden
  1441. */
  1442. export interface IVector2Like {
  1443. x: float;
  1444. y: float;
  1445. }
  1446. /**
  1447. * @hidden
  1448. */
  1449. export interface IMatrixLike {
  1450. toArray(): DeepImmutable<Float32Array>;
  1451. updateFlag: int;
  1452. }
  1453. /**
  1454. * @hidden
  1455. */
  1456. export interface IViewportLike {
  1457. x: float;
  1458. y: float;
  1459. width: float;
  1460. height: float;
  1461. }
  1462. /**
  1463. * @hidden
  1464. */
  1465. export interface IPlaneLike {
  1466. normal: IVector3Like;
  1467. d: float;
  1468. normalize(): void;
  1469. }
  1470. }
  1471. declare module BABYLON {
  1472. /**
  1473. * Interface used to define common properties for effect fallbacks
  1474. */
  1475. export interface IEffectFallbacks {
  1476. /**
  1477. * Removes the defines that should be removed when falling back.
  1478. * @param currentDefines defines the current define statements for the shader.
  1479. * @param effect defines the current effect we try to compile
  1480. * @returns The resulting defines with defines of the current rank removed.
  1481. */
  1482. reduce(currentDefines: string, effect: Effect): string;
  1483. /**
  1484. * Removes the fallback from the bound mesh.
  1485. */
  1486. unBindMesh(): void;
  1487. /**
  1488. * Checks to see if more fallbacks are still availible.
  1489. */
  1490. hasMoreFallbacks: boolean;
  1491. }
  1492. }
  1493. declare module BABYLON {
  1494. /**
  1495. * Class used to evalaute queries containing `and` and `or` operators
  1496. */
  1497. export class AndOrNotEvaluator {
  1498. /**
  1499. * Evaluate a query
  1500. * @param query defines the query to evaluate
  1501. * @param evaluateCallback defines the callback used to filter result
  1502. * @returns true if the query matches
  1503. */
  1504. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  1505. private static _HandleParenthesisContent;
  1506. private static _SimplifyNegation;
  1507. }
  1508. }
  1509. declare module BABYLON {
  1510. /**
  1511. * Class used to store custom tags
  1512. */
  1513. export class Tags {
  1514. /**
  1515. * Adds support for tags on the given object
  1516. * @param obj defines the object to use
  1517. */
  1518. static EnableFor(obj: any): void;
  1519. /**
  1520. * Removes tags support
  1521. * @param obj defines the object to use
  1522. */
  1523. static DisableFor(obj: any): void;
  1524. /**
  1525. * Gets a boolean indicating if the given object has tags
  1526. * @param obj defines the object to use
  1527. * @returns a boolean
  1528. */
  1529. static HasTags(obj: any): boolean;
  1530. /**
  1531. * Gets the tags available on a given object
  1532. * @param obj defines the object to use
  1533. * @param asString defines if the tags must be returned as a string instead of an array of strings
  1534. * @returns the tags
  1535. */
  1536. static GetTags(obj: any, asString?: boolean): any;
  1537. /**
  1538. * Adds tags to an object
  1539. * @param obj defines the object to use
  1540. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  1541. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  1542. */
  1543. static AddTagsTo(obj: any, tagsString: string): void;
  1544. /**
  1545. * @hidden
  1546. */
  1547. static _AddTagTo(obj: any, tag: string): void;
  1548. /**
  1549. * Removes specific tags from a specific object
  1550. * @param obj defines the object to use
  1551. * @param tagsString defines the tags to remove
  1552. */
  1553. static RemoveTagsFrom(obj: any, tagsString: string): void;
  1554. /**
  1555. * @hidden
  1556. */
  1557. static _RemoveTagFrom(obj: any, tag: string): void;
  1558. /**
  1559. * Defines if tags hosted on an object match a given query
  1560. * @param obj defines the object to use
  1561. * @param tagsQuery defines the tag query
  1562. * @returns a boolean
  1563. */
  1564. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  1565. }
  1566. }
  1567. declare module BABYLON {
  1568. /**
  1569. * Scalar computation library
  1570. */
  1571. export class Scalar {
  1572. /**
  1573. * Two pi constants convenient for computation.
  1574. */
  1575. static TwoPi: number;
  1576. /**
  1577. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1578. * @param a number
  1579. * @param b number
  1580. * @param epsilon (default = 1.401298E-45)
  1581. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1582. */
  1583. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1584. /**
  1585. * Returns a string : the upper case translation of the number i to hexadecimal.
  1586. * @param i number
  1587. * @returns the upper case translation of the number i to hexadecimal.
  1588. */
  1589. static ToHex(i: number): string;
  1590. /**
  1591. * Returns -1 if value is negative and +1 is value is positive.
  1592. * @param value the value
  1593. * @returns the value itself if it's equal to zero.
  1594. */
  1595. static Sign(value: number): number;
  1596. /**
  1597. * Returns the value itself if it's between min and max.
  1598. * Returns min if the value is lower than min.
  1599. * Returns max if the value is greater than max.
  1600. * @param value the value to clmap
  1601. * @param min the min value to clamp to (default: 0)
  1602. * @param max the max value to clamp to (default: 1)
  1603. * @returns the clamped value
  1604. */
  1605. static Clamp(value: number, min?: number, max?: number): number;
  1606. /**
  1607. * the log2 of value.
  1608. * @param value the value to compute log2 of
  1609. * @returns the log2 of value.
  1610. */
  1611. static Log2(value: number): number;
  1612. /**
  1613. * Loops the value, so that it is never larger than length and never smaller than 0.
  1614. *
  1615. * This is similar to the modulo operator but it works with floating point numbers.
  1616. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1617. * With t = 5 and length = 2.5, the result would be 0.0.
  1618. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1619. * @param value the value
  1620. * @param length the length
  1621. * @returns the looped value
  1622. */
  1623. static Repeat(value: number, length: number): number;
  1624. /**
  1625. * Normalize the value between 0.0 and 1.0 using min and max values
  1626. * @param value value to normalize
  1627. * @param min max to normalize between
  1628. * @param max min to normalize between
  1629. * @returns the normalized value
  1630. */
  1631. static Normalize(value: number, min: number, max: number): number;
  1632. /**
  1633. * Denormalize the value from 0.0 and 1.0 using min and max values
  1634. * @param normalized value to denormalize
  1635. * @param min max to denormalize between
  1636. * @param max min to denormalize between
  1637. * @returns the denormalized value
  1638. */
  1639. static Denormalize(normalized: number, min: number, max: number): number;
  1640. /**
  1641. * Calculates the shortest difference between two given angles given in degrees.
  1642. * @param current current angle in degrees
  1643. * @param target target angle in degrees
  1644. * @returns the delta
  1645. */
  1646. static DeltaAngle(current: number, target: number): number;
  1647. /**
  1648. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1649. * @param tx value
  1650. * @param length length
  1651. * @returns The returned value will move back and forth between 0 and length
  1652. */
  1653. static PingPong(tx: number, length: number): number;
  1654. /**
  1655. * Interpolates between min and max with smoothing at the limits.
  1656. *
  1657. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1658. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1659. * @param from from
  1660. * @param to to
  1661. * @param tx value
  1662. * @returns the smooth stepped value
  1663. */
  1664. static SmoothStep(from: number, to: number, tx: number): number;
  1665. /**
  1666. * Moves a value current towards target.
  1667. *
  1668. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1669. * Negative values of maxDelta pushes the value away from target.
  1670. * @param current current value
  1671. * @param target target value
  1672. * @param maxDelta max distance to move
  1673. * @returns resulting value
  1674. */
  1675. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1676. /**
  1677. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1678. *
  1679. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1680. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1681. * @param current current value
  1682. * @param target target value
  1683. * @param maxDelta max distance to move
  1684. * @returns resulting angle
  1685. */
  1686. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1687. /**
  1688. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1689. * @param start start value
  1690. * @param end target value
  1691. * @param amount amount to lerp between
  1692. * @returns the lerped value
  1693. */
  1694. static Lerp(start: number, end: number, amount: number): number;
  1695. /**
  1696. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1697. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1698. * @param start start value
  1699. * @param end target value
  1700. * @param amount amount to lerp between
  1701. * @returns the lerped value
  1702. */
  1703. static LerpAngle(start: number, end: number, amount: number): number;
  1704. /**
  1705. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1706. * @param a start value
  1707. * @param b target value
  1708. * @param value value between a and b
  1709. * @returns the inverseLerp value
  1710. */
  1711. static InverseLerp(a: number, b: number, value: number): number;
  1712. /**
  1713. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1714. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1715. * @param value1 spline value
  1716. * @param tangent1 spline value
  1717. * @param value2 spline value
  1718. * @param tangent2 spline value
  1719. * @param amount input value
  1720. * @returns hermite result
  1721. */
  1722. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1723. /**
  1724. * Returns a random float number between and min and max values
  1725. * @param min min value of random
  1726. * @param max max value of random
  1727. * @returns random value
  1728. */
  1729. static RandomRange(min: number, max: number): number;
  1730. /**
  1731. * This function returns percentage of a number in a given range.
  1732. *
  1733. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1734. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1735. * @param number to convert to percentage
  1736. * @param min min range
  1737. * @param max max range
  1738. * @returns the percentage
  1739. */
  1740. static RangeToPercent(number: number, min: number, max: number): number;
  1741. /**
  1742. * This function returns number that corresponds to the percentage in a given range.
  1743. *
  1744. * PercentToRange(0.34,0,100) will return 34.
  1745. * @param percent to convert to number
  1746. * @param min min range
  1747. * @param max max range
  1748. * @returns the number
  1749. */
  1750. static PercentToRange(percent: number, min: number, max: number): number;
  1751. /**
  1752. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1753. * @param angle The angle to normalize in radian.
  1754. * @return The converted angle.
  1755. */
  1756. static NormalizeRadians(angle: number): number;
  1757. }
  1758. }
  1759. declare module BABYLON {
  1760. /**
  1761. * Constant used to convert a value to gamma space
  1762. * @ignorenaming
  1763. */
  1764. export const ToGammaSpace: number;
  1765. /**
  1766. * Constant used to convert a value to linear space
  1767. * @ignorenaming
  1768. */
  1769. export const ToLinearSpace = 2.2;
  1770. /**
  1771. * Constant used to define the minimal number value in Babylon.js
  1772. * @ignorenaming
  1773. */
  1774. let Epsilon: number;
  1775. }
  1776. declare module BABYLON {
  1777. /**
  1778. * Class used to represent a viewport on screen
  1779. */
  1780. export class Viewport {
  1781. /** viewport left coordinate */
  1782. x: number;
  1783. /** viewport top coordinate */
  1784. y: number;
  1785. /**viewport width */
  1786. width: number;
  1787. /** viewport height */
  1788. height: number;
  1789. /**
  1790. * Creates a Viewport object located at (x, y) and sized (width, height)
  1791. * @param x defines viewport left coordinate
  1792. * @param y defines viewport top coordinate
  1793. * @param width defines the viewport width
  1794. * @param height defines the viewport height
  1795. */
  1796. constructor(
  1797. /** viewport left coordinate */
  1798. x: number,
  1799. /** viewport top coordinate */
  1800. y: number,
  1801. /**viewport width */
  1802. width: number,
  1803. /** viewport height */
  1804. height: number);
  1805. /**
  1806. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1807. * @param renderWidth defines the rendering width
  1808. * @param renderHeight defines the rendering height
  1809. * @returns a new Viewport
  1810. */
  1811. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1812. /**
  1813. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1814. * @param renderWidth defines the rendering width
  1815. * @param renderHeight defines the rendering height
  1816. * @param ref defines the target viewport
  1817. * @returns the current viewport
  1818. */
  1819. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1820. /**
  1821. * Returns a new Viewport copied from the current one
  1822. * @returns a new Viewport
  1823. */
  1824. clone(): Viewport;
  1825. }
  1826. }
  1827. declare module BABYLON {
  1828. /**
  1829. * Class containing a set of static utilities functions for arrays.
  1830. */
  1831. export class ArrayTools {
  1832. /**
  1833. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1834. * @param size the number of element to construct and put in the array
  1835. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1836. * @returns a new array filled with new objects
  1837. */
  1838. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1839. }
  1840. }
  1841. declare module BABYLON {
  1842. /**
  1843. * Class representing a vector containing 2 coordinates
  1844. */
  1845. export class Vector2 {
  1846. /** defines the first coordinate */
  1847. x: number;
  1848. /** defines the second coordinate */
  1849. y: number;
  1850. /**
  1851. * Creates a new Vector2 from the given x and y coordinates
  1852. * @param x defines the first coordinate
  1853. * @param y defines the second coordinate
  1854. */
  1855. constructor(
  1856. /** defines the first coordinate */
  1857. x?: number,
  1858. /** defines the second coordinate */
  1859. y?: number);
  1860. /**
  1861. * Gets a string with the Vector2 coordinates
  1862. * @returns a string with the Vector2 coordinates
  1863. */
  1864. toString(): string;
  1865. /**
  1866. * Gets class name
  1867. * @returns the string "Vector2"
  1868. */
  1869. getClassName(): string;
  1870. /**
  1871. * Gets current vector hash code
  1872. * @returns the Vector2 hash code as a number
  1873. */
  1874. getHashCode(): number;
  1875. /**
  1876. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  1877. * @param array defines the source array
  1878. * @param index defines the offset in source array
  1879. * @returns the current Vector2
  1880. */
  1881. toArray(array: FloatArray, index?: number): Vector2;
  1882. /**
  1883. * Copy the current vector to an array
  1884. * @returns a new array with 2 elements: the Vector2 coordinates.
  1885. */
  1886. asArray(): number[];
  1887. /**
  1888. * Sets the Vector2 coordinates with the given Vector2 coordinates
  1889. * @param source defines the source Vector2
  1890. * @returns the current updated Vector2
  1891. */
  1892. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  1893. /**
  1894. * Sets the Vector2 coordinates with the given floats
  1895. * @param x defines the first coordinate
  1896. * @param y defines the second coordinate
  1897. * @returns the current updated Vector2
  1898. */
  1899. copyFromFloats(x: number, y: number): Vector2;
  1900. /**
  1901. * Sets the Vector2 coordinates with the given floats
  1902. * @param x defines the first coordinate
  1903. * @param y defines the second coordinate
  1904. * @returns the current updated Vector2
  1905. */
  1906. set(x: number, y: number): Vector2;
  1907. /**
  1908. * Add another vector with the current one
  1909. * @param otherVector defines the other vector
  1910. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  1911. */
  1912. add(otherVector: DeepImmutable<Vector2>): Vector2;
  1913. /**
  1914. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  1915. * @param otherVector defines the other vector
  1916. * @param result defines the target vector
  1917. * @returns the unmodified current Vector2
  1918. */
  1919. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1920. /**
  1921. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  1922. * @param otherVector defines the other vector
  1923. * @returns the current updated Vector2
  1924. */
  1925. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1926. /**
  1927. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  1928. * @param otherVector defines the other vector
  1929. * @returns a new Vector2
  1930. */
  1931. addVector3(otherVector: Vector3): Vector2;
  1932. /**
  1933. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  1934. * @param otherVector defines the other vector
  1935. * @returns a new Vector2
  1936. */
  1937. subtract(otherVector: Vector2): Vector2;
  1938. /**
  1939. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  1940. * @param otherVector defines the other vector
  1941. * @param result defines the target vector
  1942. * @returns the unmodified current Vector2
  1943. */
  1944. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1945. /**
  1946. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  1947. * @param otherVector defines the other vector
  1948. * @returns the current updated Vector2
  1949. */
  1950. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1951. /**
  1952. * Multiplies in place the current Vector2 coordinates by the given ones
  1953. * @param otherVector defines the other vector
  1954. * @returns the current updated Vector2
  1955. */
  1956. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1957. /**
  1958. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  1959. * @param otherVector defines the other vector
  1960. * @returns a new Vector2
  1961. */
  1962. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  1963. /**
  1964. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  1965. * @param otherVector defines the other vector
  1966. * @param result defines the target vector
  1967. * @returns the unmodified current Vector2
  1968. */
  1969. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1970. /**
  1971. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  1972. * @param x defines the first coordinate
  1973. * @param y defines the second coordinate
  1974. * @returns a new Vector2
  1975. */
  1976. multiplyByFloats(x: number, y: number): Vector2;
  1977. /**
  1978. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  1979. * @param otherVector defines the other vector
  1980. * @returns a new Vector2
  1981. */
  1982. divide(otherVector: Vector2): Vector2;
  1983. /**
  1984. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  1985. * @param otherVector defines the other vector
  1986. * @param result defines the target vector
  1987. * @returns the unmodified current Vector2
  1988. */
  1989. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1990. /**
  1991. * Divides the current Vector2 coordinates by the given ones
  1992. * @param otherVector defines the other vector
  1993. * @returns the current updated Vector2
  1994. */
  1995. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1996. /**
  1997. * Gets a new Vector2 with current Vector2 negated coordinates
  1998. * @returns a new Vector2
  1999. */
  2000. negate(): Vector2;
  2001. /**
  2002. * Multiply the Vector2 coordinates by scale
  2003. * @param scale defines the scaling factor
  2004. * @returns the current updated Vector2
  2005. */
  2006. scaleInPlace(scale: number): Vector2;
  2007. /**
  2008. * Returns a new Vector2 scaled by "scale" from the current Vector2
  2009. * @param scale defines the scaling factor
  2010. * @returns a new Vector2
  2011. */
  2012. scale(scale: number): Vector2;
  2013. /**
  2014. * Scale the current Vector2 values by a factor to a given Vector2
  2015. * @param scale defines the scale factor
  2016. * @param result defines the Vector2 object where to store the result
  2017. * @returns the unmodified current Vector2
  2018. */
  2019. scaleToRef(scale: number, result: Vector2): Vector2;
  2020. /**
  2021. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  2022. * @param scale defines the scale factor
  2023. * @param result defines the Vector2 object where to store the result
  2024. * @returns the unmodified current Vector2
  2025. */
  2026. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  2027. /**
  2028. * Gets a boolean if two vectors are equals
  2029. * @param otherVector defines the other vector
  2030. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  2031. */
  2032. equals(otherVector: DeepImmutable<Vector2>): boolean;
  2033. /**
  2034. * Gets a boolean if two vectors are equals (using an epsilon value)
  2035. * @param otherVector defines the other vector
  2036. * @param epsilon defines the minimal distance to consider equality
  2037. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  2038. */
  2039. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  2040. /**
  2041. * Gets a new Vector2 from current Vector2 floored values
  2042. * @returns a new Vector2
  2043. */
  2044. floor(): Vector2;
  2045. /**
  2046. * Gets a new Vector2 from current Vector2 floored values
  2047. * @returns a new Vector2
  2048. */
  2049. fract(): Vector2;
  2050. /**
  2051. * Gets the length of the vector
  2052. * @returns the vector length (float)
  2053. */
  2054. length(): number;
  2055. /**
  2056. * Gets the vector squared length
  2057. * @returns the vector squared length (float)
  2058. */
  2059. lengthSquared(): number;
  2060. /**
  2061. * Normalize the vector
  2062. * @returns the current updated Vector2
  2063. */
  2064. normalize(): Vector2;
  2065. /**
  2066. * Gets a new Vector2 copied from the Vector2
  2067. * @returns a new Vector2
  2068. */
  2069. clone(): Vector2;
  2070. /**
  2071. * Gets a new Vector2(0, 0)
  2072. * @returns a new Vector2
  2073. */
  2074. static Zero(): Vector2;
  2075. /**
  2076. * Gets a new Vector2(1, 1)
  2077. * @returns a new Vector2
  2078. */
  2079. static One(): Vector2;
  2080. /**
  2081. * Gets a new Vector2 set from the given index element of the given array
  2082. * @param array defines the data source
  2083. * @param offset defines the offset in the data source
  2084. * @returns a new Vector2
  2085. */
  2086. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  2087. /**
  2088. * Sets "result" from the given index element of the given array
  2089. * @param array defines the data source
  2090. * @param offset defines the offset in the data source
  2091. * @param result defines the target vector
  2092. */
  2093. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  2094. /**
  2095. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  2096. * @param value1 defines 1st point of control
  2097. * @param value2 defines 2nd point of control
  2098. * @param value3 defines 3rd point of control
  2099. * @param value4 defines 4th point of control
  2100. * @param amount defines the interpolation factor
  2101. * @returns a new Vector2
  2102. */
  2103. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  2104. /**
  2105. * 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".
  2106. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  2107. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  2108. * @param value defines the value to clamp
  2109. * @param min defines the lower limit
  2110. * @param max defines the upper limit
  2111. * @returns a new Vector2
  2112. */
  2113. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  2114. /**
  2115. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  2116. * @param value1 defines the 1st control point
  2117. * @param tangent1 defines the outgoing tangent
  2118. * @param value2 defines the 2nd control point
  2119. * @param tangent2 defines the incoming tangent
  2120. * @param amount defines the interpolation factor
  2121. * @returns a new Vector2
  2122. */
  2123. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  2124. /**
  2125. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  2126. * @param start defines the start vector
  2127. * @param end defines the end vector
  2128. * @param amount defines the interpolation factor
  2129. * @returns a new Vector2
  2130. */
  2131. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  2132. /**
  2133. * Gets the dot product of the vector "left" and the vector "right"
  2134. * @param left defines first vector
  2135. * @param right defines second vector
  2136. * @returns the dot product (float)
  2137. */
  2138. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  2139. /**
  2140. * Returns a new Vector2 equal to the normalized given vector
  2141. * @param vector defines the vector to normalize
  2142. * @returns a new Vector2
  2143. */
  2144. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  2145. /**
  2146. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  2147. * @param left defines 1st vector
  2148. * @param right defines 2nd vector
  2149. * @returns a new Vector2
  2150. */
  2151. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2152. /**
  2153. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  2154. * @param left defines 1st vector
  2155. * @param right defines 2nd vector
  2156. * @returns a new Vector2
  2157. */
  2158. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2159. /**
  2160. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  2161. * @param vector defines the vector to transform
  2162. * @param transformation defines the matrix to apply
  2163. * @returns a new Vector2
  2164. */
  2165. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  2166. /**
  2167. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  2168. * @param vector defines the vector to transform
  2169. * @param transformation defines the matrix to apply
  2170. * @param result defines the target vector
  2171. */
  2172. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  2173. /**
  2174. * Determines if a given vector is included in a triangle
  2175. * @param p defines the vector to test
  2176. * @param p0 defines 1st triangle point
  2177. * @param p1 defines 2nd triangle point
  2178. * @param p2 defines 3rd triangle point
  2179. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  2180. */
  2181. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  2182. /**
  2183. * Gets the distance between the vectors "value1" and "value2"
  2184. * @param value1 defines first vector
  2185. * @param value2 defines second vector
  2186. * @returns the distance between vectors
  2187. */
  2188. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2189. /**
  2190. * Returns the squared distance between the vectors "value1" and "value2"
  2191. * @param value1 defines first vector
  2192. * @param value2 defines second vector
  2193. * @returns the squared distance between vectors
  2194. */
  2195. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2196. /**
  2197. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  2198. * @param value1 defines first vector
  2199. * @param value2 defines second vector
  2200. * @returns a new Vector2
  2201. */
  2202. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  2203. /**
  2204. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  2205. * @param p defines the middle point
  2206. * @param segA defines one point of the segment
  2207. * @param segB defines the other point of the segment
  2208. * @returns the shortest distance
  2209. */
  2210. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  2211. }
  2212. /**
  2213. * Classed used to store (x,y,z) vector representation
  2214. * A Vector3 is the main object used in 3D geometry
  2215. * It can represent etiher the coordinates of a point the space, either a direction
  2216. * Reminder: js uses a left handed forward facing system
  2217. */
  2218. export class Vector3 {
  2219. /**
  2220. * Defines the first coordinates (on X axis)
  2221. */
  2222. x: number;
  2223. /**
  2224. * Defines the second coordinates (on Y axis)
  2225. */
  2226. y: number;
  2227. /**
  2228. * Defines the third coordinates (on Z axis)
  2229. */
  2230. z: number;
  2231. private static _UpReadOnly;
  2232. private static _ZeroReadOnly;
  2233. /**
  2234. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  2235. * @param x defines the first coordinates (on X axis)
  2236. * @param y defines the second coordinates (on Y axis)
  2237. * @param z defines the third coordinates (on Z axis)
  2238. */
  2239. constructor(
  2240. /**
  2241. * Defines the first coordinates (on X axis)
  2242. */
  2243. x?: number,
  2244. /**
  2245. * Defines the second coordinates (on Y axis)
  2246. */
  2247. y?: number,
  2248. /**
  2249. * Defines the third coordinates (on Z axis)
  2250. */
  2251. z?: number);
  2252. /**
  2253. * Creates a string representation of the Vector3
  2254. * @returns a string with the Vector3 coordinates.
  2255. */
  2256. toString(): string;
  2257. /**
  2258. * Gets the class name
  2259. * @returns the string "Vector3"
  2260. */
  2261. getClassName(): string;
  2262. /**
  2263. * Creates the Vector3 hash code
  2264. * @returns a number which tends to be unique between Vector3 instances
  2265. */
  2266. getHashCode(): number;
  2267. /**
  2268. * Creates an array containing three elements : the coordinates of the Vector3
  2269. * @returns a new array of numbers
  2270. */
  2271. asArray(): number[];
  2272. /**
  2273. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  2274. * @param array defines the destination array
  2275. * @param index defines the offset in the destination array
  2276. * @returns the current Vector3
  2277. */
  2278. toArray(array: FloatArray, index?: number): Vector3;
  2279. /**
  2280. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  2281. * @returns a new Quaternion object, computed from the Vector3 coordinates
  2282. */
  2283. toQuaternion(): Quaternion;
  2284. /**
  2285. * Adds the given vector to the current Vector3
  2286. * @param otherVector defines the second operand
  2287. * @returns the current updated Vector3
  2288. */
  2289. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2290. /**
  2291. * Adds the given coordinates to the current Vector3
  2292. * @param x defines the x coordinate of the operand
  2293. * @param y defines the y coordinate of the operand
  2294. * @param z defines the z coordinate of the operand
  2295. * @returns the current updated Vector3
  2296. */
  2297. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2298. /**
  2299. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  2300. * @param otherVector defines the second operand
  2301. * @returns the resulting Vector3
  2302. */
  2303. add(otherVector: DeepImmutable<Vector3>): Vector3;
  2304. /**
  2305. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  2306. * @param otherVector defines the second operand
  2307. * @param result defines the Vector3 object where to store the result
  2308. * @returns the current Vector3
  2309. */
  2310. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2311. /**
  2312. * Subtract the given vector from the current Vector3
  2313. * @param otherVector defines the second operand
  2314. * @returns the current updated Vector3
  2315. */
  2316. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2317. /**
  2318. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  2319. * @param otherVector defines the second operand
  2320. * @returns the resulting Vector3
  2321. */
  2322. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  2323. /**
  2324. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  2325. * @param otherVector defines the second operand
  2326. * @param result defines the Vector3 object where to store the result
  2327. * @returns the current Vector3
  2328. */
  2329. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2330. /**
  2331. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  2332. * @param x defines the x coordinate of the operand
  2333. * @param y defines the y coordinate of the operand
  2334. * @param z defines the z coordinate of the operand
  2335. * @returns the resulting Vector3
  2336. */
  2337. subtractFromFloats(x: number, y: number, z: number): Vector3;
  2338. /**
  2339. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  2340. * @param x defines the x coordinate of the operand
  2341. * @param y defines the y coordinate of the operand
  2342. * @param z defines the z coordinate of the operand
  2343. * @param result defines the Vector3 object where to store the result
  2344. * @returns the current Vector3
  2345. */
  2346. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  2347. /**
  2348. * Gets a new Vector3 set with the current Vector3 negated coordinates
  2349. * @returns a new Vector3
  2350. */
  2351. negate(): Vector3;
  2352. /**
  2353. * Multiplies the Vector3 coordinates by the float "scale"
  2354. * @param scale defines the multiplier factor
  2355. * @returns the current updated Vector3
  2356. */
  2357. scaleInPlace(scale: number): Vector3;
  2358. /**
  2359. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  2360. * @param scale defines the multiplier factor
  2361. * @returns a new Vector3
  2362. */
  2363. scale(scale: number): Vector3;
  2364. /**
  2365. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  2366. * @param scale defines the multiplier factor
  2367. * @param result defines the Vector3 object where to store the result
  2368. * @returns the current Vector3
  2369. */
  2370. scaleToRef(scale: number, result: Vector3): Vector3;
  2371. /**
  2372. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  2373. * @param scale defines the scale factor
  2374. * @param result defines the Vector3 object where to store the result
  2375. * @returns the unmodified current Vector3
  2376. */
  2377. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  2378. /**
  2379. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  2380. * @param otherVector defines the second operand
  2381. * @returns true if both vectors are equals
  2382. */
  2383. equals(otherVector: DeepImmutable<Vector3>): boolean;
  2384. /**
  2385. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  2386. * @param otherVector defines the second operand
  2387. * @param epsilon defines the minimal distance to define values as equals
  2388. * @returns true if both vectors are distant less than epsilon
  2389. */
  2390. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  2391. /**
  2392. * Returns true if the current Vector3 coordinates equals the given floats
  2393. * @param x defines the x coordinate of the operand
  2394. * @param y defines the y coordinate of the operand
  2395. * @param z defines the z coordinate of the operand
  2396. * @returns true if both vectors are equals
  2397. */
  2398. equalsToFloats(x: number, y: number, z: number): boolean;
  2399. /**
  2400. * Multiplies the current Vector3 coordinates by the given ones
  2401. * @param otherVector defines the second operand
  2402. * @returns the current updated Vector3
  2403. */
  2404. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2405. /**
  2406. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  2407. * @param otherVector defines the second operand
  2408. * @returns the new Vector3
  2409. */
  2410. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  2411. /**
  2412. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  2413. * @param otherVector defines the second operand
  2414. * @param result defines the Vector3 object where to store the result
  2415. * @returns the current Vector3
  2416. */
  2417. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2418. /**
  2419. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  2420. * @param x defines the x coordinate of the operand
  2421. * @param y defines the y coordinate of the operand
  2422. * @param z defines the z coordinate of the operand
  2423. * @returns the new Vector3
  2424. */
  2425. multiplyByFloats(x: number, y: number, z: number): Vector3;
  2426. /**
  2427. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  2428. * @param otherVector defines the second operand
  2429. * @returns the new Vector3
  2430. */
  2431. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  2432. /**
  2433. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  2434. * @param otherVector defines the second operand
  2435. * @param result defines the Vector3 object where to store the result
  2436. * @returns the current Vector3
  2437. */
  2438. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2439. /**
  2440. * Divides the current Vector3 coordinates by the given ones.
  2441. * @param otherVector defines the second operand
  2442. * @returns the current updated Vector3
  2443. */
  2444. divideInPlace(otherVector: Vector3): Vector3;
  2445. /**
  2446. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  2447. * @param other defines the second operand
  2448. * @returns the current updated Vector3
  2449. */
  2450. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2451. /**
  2452. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  2453. * @param other defines the second operand
  2454. * @returns the current updated Vector3
  2455. */
  2456. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2457. /**
  2458. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  2459. * @param x defines the x coordinate of the operand
  2460. * @param y defines the y coordinate of the operand
  2461. * @param z defines the z coordinate of the operand
  2462. * @returns the current updated Vector3
  2463. */
  2464. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2465. /**
  2466. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2467. * @param x defines the x coordinate of the operand
  2468. * @param y defines the y coordinate of the operand
  2469. * @param z defines the z coordinate of the operand
  2470. * @returns the current updated Vector3
  2471. */
  2472. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2473. /**
  2474. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2475. * Check if is non uniform within a certain amount of decimal places to account for this
  2476. * @param epsilon the amount the values can differ
  2477. * @returns if the the vector is non uniform to a certain number of decimal places
  2478. */
  2479. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2480. /**
  2481. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2482. */
  2483. readonly isNonUniform: boolean;
  2484. /**
  2485. * Gets a new Vector3 from current Vector3 floored values
  2486. * @returns a new Vector3
  2487. */
  2488. floor(): Vector3;
  2489. /**
  2490. * Gets a new Vector3 from current Vector3 floored values
  2491. * @returns a new Vector3
  2492. */
  2493. fract(): Vector3;
  2494. /**
  2495. * Gets the length of the Vector3
  2496. * @returns the length of the Vector3
  2497. */
  2498. length(): number;
  2499. /**
  2500. * Gets the squared length of the Vector3
  2501. * @returns squared length of the Vector3
  2502. */
  2503. lengthSquared(): number;
  2504. /**
  2505. * Normalize the current Vector3.
  2506. * Please note that this is an in place operation.
  2507. * @returns the current updated Vector3
  2508. */
  2509. normalize(): Vector3;
  2510. /**
  2511. * Reorders the x y z properties of the vector in place
  2512. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2513. * @returns the current updated vector
  2514. */
  2515. reorderInPlace(order: string): this;
  2516. /**
  2517. * Rotates the vector around 0,0,0 by a quaternion
  2518. * @param quaternion the rotation quaternion
  2519. * @param result vector to store the result
  2520. * @returns the resulting vector
  2521. */
  2522. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2523. /**
  2524. * Rotates a vector around a given point
  2525. * @param quaternion the rotation quaternion
  2526. * @param point the point to rotate around
  2527. * @param result vector to store the result
  2528. * @returns the resulting vector
  2529. */
  2530. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2531. /**
  2532. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  2533. * The cross product is then orthogonal to both current and "other"
  2534. * @param other defines the right operand
  2535. * @returns the cross product
  2536. */
  2537. cross(other: Vector3): Vector3;
  2538. /**
  2539. * Normalize the current Vector3 with the given input length.
  2540. * Please note that this is an in place operation.
  2541. * @param len the length of the vector
  2542. * @returns the current updated Vector3
  2543. */
  2544. normalizeFromLength(len: number): Vector3;
  2545. /**
  2546. * Normalize the current Vector3 to a new vector
  2547. * @returns the new Vector3
  2548. */
  2549. normalizeToNew(): Vector3;
  2550. /**
  2551. * Normalize the current Vector3 to the reference
  2552. * @param reference define the Vector3 to update
  2553. * @returns the updated Vector3
  2554. */
  2555. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  2556. /**
  2557. * Creates a new Vector3 copied from the current Vector3
  2558. * @returns the new Vector3
  2559. */
  2560. clone(): Vector3;
  2561. /**
  2562. * Copies the given vector coordinates to the current Vector3 ones
  2563. * @param source defines the source Vector3
  2564. * @returns the current updated Vector3
  2565. */
  2566. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2567. /**
  2568. * Copies the given floats to the current Vector3 coordinates
  2569. * @param x defines the x coordinate of the operand
  2570. * @param y defines the y coordinate of the operand
  2571. * @param z defines the z coordinate of the operand
  2572. * @returns the current updated Vector3
  2573. */
  2574. copyFromFloats(x: number, y: number, z: number): Vector3;
  2575. /**
  2576. * Copies the given floats to the current Vector3 coordinates
  2577. * @param x defines the x coordinate of the operand
  2578. * @param y defines the y coordinate of the operand
  2579. * @param z defines the z coordinate of the operand
  2580. * @returns the current updated Vector3
  2581. */
  2582. set(x: number, y: number, z: number): Vector3;
  2583. /**
  2584. * Copies the given float to the current Vector3 coordinates
  2585. * @param v defines the x, y and z coordinates of the operand
  2586. * @returns the current updated Vector3
  2587. */
  2588. setAll(v: number): Vector3;
  2589. /**
  2590. * Get the clip factor between two vectors
  2591. * @param vector0 defines the first operand
  2592. * @param vector1 defines the second operand
  2593. * @param axis defines the axis to use
  2594. * @param size defines the size along the axis
  2595. * @returns the clip factor
  2596. */
  2597. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2598. /**
  2599. * Get angle between two vectors
  2600. * @param vector0 angle between vector0 and vector1
  2601. * @param vector1 angle between vector0 and vector1
  2602. * @param normal direction of the normal
  2603. * @return the angle between vector0 and vector1
  2604. */
  2605. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2606. /**
  2607. * Returns a new Vector3 set from the index "offset" of the given array
  2608. * @param array defines the source array
  2609. * @param offset defines the offset in the source array
  2610. * @returns the new Vector3
  2611. */
  2612. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2613. /**
  2614. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2615. * This function is deprecated. Use FromArray instead
  2616. * @param array defines the source array
  2617. * @param offset defines the offset in the source array
  2618. * @returns the new Vector3
  2619. */
  2620. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2621. /**
  2622. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2623. * @param array defines the source array
  2624. * @param offset defines the offset in the source array
  2625. * @param result defines the Vector3 where to store the result
  2626. */
  2627. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2628. /**
  2629. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2630. * This function is deprecated. Use FromArrayToRef instead.
  2631. * @param array defines the source array
  2632. * @param offset defines the offset in the source array
  2633. * @param result defines the Vector3 where to store the result
  2634. */
  2635. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2636. /**
  2637. * Sets the given vector "result" with the given floats.
  2638. * @param x defines the x coordinate of the source
  2639. * @param y defines the y coordinate of the source
  2640. * @param z defines the z coordinate of the source
  2641. * @param result defines the Vector3 where to store the result
  2642. */
  2643. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2644. /**
  2645. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2646. * @returns a new empty Vector3
  2647. */
  2648. static Zero(): Vector3;
  2649. /**
  2650. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2651. * @returns a new unit Vector3
  2652. */
  2653. static One(): Vector3;
  2654. /**
  2655. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2656. * @returns a new up Vector3
  2657. */
  2658. static Up(): Vector3;
  2659. /**
  2660. * Gets a up Vector3 that must not be updated
  2661. */
  2662. static readonly UpReadOnly: DeepImmutable<Vector3>;
  2663. /**
  2664. * Gets a zero Vector3 that must not be updated
  2665. */
  2666. static readonly ZeroReadOnly: DeepImmutable<Vector3>;
  2667. /**
  2668. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2669. * @returns a new down Vector3
  2670. */
  2671. static Down(): Vector3;
  2672. /**
  2673. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2674. * @returns a new forward Vector3
  2675. */
  2676. static Forward(): Vector3;
  2677. /**
  2678. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2679. * @returns a new forward Vector3
  2680. */
  2681. static Backward(): Vector3;
  2682. /**
  2683. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2684. * @returns a new right Vector3
  2685. */
  2686. static Right(): Vector3;
  2687. /**
  2688. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2689. * @returns a new left Vector3
  2690. */
  2691. static Left(): Vector3;
  2692. /**
  2693. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  2694. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2695. * @param vector defines the Vector3 to transform
  2696. * @param transformation defines the transformation matrix
  2697. * @returns the transformed Vector3
  2698. */
  2699. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2700. /**
  2701. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2702. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2703. * @param vector defines the Vector3 to transform
  2704. * @param transformation defines the transformation matrix
  2705. * @param result defines the Vector3 where to store the result
  2706. */
  2707. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2708. /**
  2709. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  2710. * This method computes tranformed coordinates only, not transformed direction vectors
  2711. * @param x define the x coordinate of the source vector
  2712. * @param y define the y coordinate of the source vector
  2713. * @param z define the z coordinate of the source vector
  2714. * @param transformation defines the transformation matrix
  2715. * @param result defines the Vector3 where to store the result
  2716. */
  2717. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2718. /**
  2719. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  2720. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2721. * @param vector defines the Vector3 to transform
  2722. * @param transformation defines the transformation matrix
  2723. * @returns the new Vector3
  2724. */
  2725. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2726. /**
  2727. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  2728. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2729. * @param vector defines the Vector3 to transform
  2730. * @param transformation defines the transformation matrix
  2731. * @param result defines the Vector3 where to store the result
  2732. */
  2733. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2734. /**
  2735. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  2736. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2737. * @param x define the x coordinate of the source vector
  2738. * @param y define the y coordinate of the source vector
  2739. * @param z define the z coordinate of the source vector
  2740. * @param transformation defines the transformation matrix
  2741. * @param result defines the Vector3 where to store the result
  2742. */
  2743. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2744. /**
  2745. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  2746. * @param value1 defines the first control point
  2747. * @param value2 defines the second control point
  2748. * @param value3 defines the third control point
  2749. * @param value4 defines the fourth control point
  2750. * @param amount defines the amount on the spline to use
  2751. * @returns the new Vector3
  2752. */
  2753. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  2754. /**
  2755. * 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"
  2756. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2757. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2758. * @param value defines the current value
  2759. * @param min defines the lower range value
  2760. * @param max defines the upper range value
  2761. * @returns the new Vector3
  2762. */
  2763. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  2764. /**
  2765. * 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"
  2766. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2767. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2768. * @param value defines the current value
  2769. * @param min defines the lower range value
  2770. * @param max defines the upper range value
  2771. * @param result defines the Vector3 where to store the result
  2772. */
  2773. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  2774. /**
  2775. * Checks if a given vector is inside a specific range
  2776. * @param v defines the vector to test
  2777. * @param min defines the minimum range
  2778. * @param max defines the maximum range
  2779. */
  2780. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  2781. /**
  2782. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  2783. * @param value1 defines the first control point
  2784. * @param tangent1 defines the first tangent vector
  2785. * @param value2 defines the second control point
  2786. * @param tangent2 defines the second tangent vector
  2787. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  2788. * @returns the new Vector3
  2789. */
  2790. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  2791. /**
  2792. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  2793. * @param start defines the start value
  2794. * @param end defines the end value
  2795. * @param amount max defines amount between both (between 0 and 1)
  2796. * @returns the new Vector3
  2797. */
  2798. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  2799. /**
  2800. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  2801. * @param start defines the start value
  2802. * @param end defines the end value
  2803. * @param amount max defines amount between both (between 0 and 1)
  2804. * @param result defines the Vector3 where to store the result
  2805. */
  2806. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  2807. /**
  2808. * Returns the dot product (float) between the vectors "left" and "right"
  2809. * @param left defines the left operand
  2810. * @param right defines the right operand
  2811. * @returns the dot product
  2812. */
  2813. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  2814. /**
  2815. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  2816. * The cross product is then orthogonal to both "left" and "right"
  2817. * @param left defines the left operand
  2818. * @param right defines the right operand
  2819. * @returns the cross product
  2820. */
  2821. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2822. /**
  2823. * Sets the given vector "result" with the cross product of "left" and "right"
  2824. * The cross product is then orthogonal to both "left" and "right"
  2825. * @param left defines the left operand
  2826. * @param right defines the right operand
  2827. * @param result defines the Vector3 where to store the result
  2828. */
  2829. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  2830. /**
  2831. * Returns a new Vector3 as the normalization of the given vector
  2832. * @param vector defines the Vector3 to normalize
  2833. * @returns the new Vector3
  2834. */
  2835. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  2836. /**
  2837. * Sets the given vector "result" with the normalization of the given first vector
  2838. * @param vector defines the Vector3 to normalize
  2839. * @param result defines the Vector3 where to store the result
  2840. */
  2841. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  2842. /**
  2843. * Project a Vector3 onto screen space
  2844. * @param vector defines the Vector3 to project
  2845. * @param world defines the world matrix to use
  2846. * @param transform defines the transform (view x projection) matrix to use
  2847. * @param viewport defines the screen viewport to use
  2848. * @returns the new Vector3
  2849. */
  2850. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  2851. /** @hidden */
  2852. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  2853. /**
  2854. * Unproject from screen space to object space
  2855. * @param source defines the screen space Vector3 to use
  2856. * @param viewportWidth defines the current width of the viewport
  2857. * @param viewportHeight defines the current height of the viewport
  2858. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2859. * @param transform defines the transform (view x projection) matrix to use
  2860. * @returns the new Vector3
  2861. */
  2862. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  2863. /**
  2864. * Unproject from screen space to object space
  2865. * @param source defines the screen space Vector3 to use
  2866. * @param viewportWidth defines the current width of the viewport
  2867. * @param viewportHeight defines the current height of the viewport
  2868. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2869. * @param view defines the view matrix to use
  2870. * @param projection defines the projection matrix to use
  2871. * @returns the new Vector3
  2872. */
  2873. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  2874. /**
  2875. * Unproject from screen space to object space
  2876. * @param source defines the screen space Vector3 to use
  2877. * @param viewportWidth defines the current width of the viewport
  2878. * @param viewportHeight defines the current height of the viewport
  2879. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2880. * @param view defines the view matrix to use
  2881. * @param projection defines the projection matrix to use
  2882. * @param result defines the Vector3 where to store the result
  2883. */
  2884. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2885. /**
  2886. * Unproject from screen space to object space
  2887. * @param sourceX defines the screen space x coordinate to use
  2888. * @param sourceY defines the screen space y coordinate to use
  2889. * @param sourceZ defines the screen space z coordinate to use
  2890. * @param viewportWidth defines the current width of the viewport
  2891. * @param viewportHeight defines the current height of the viewport
  2892. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2893. * @param view defines the view matrix to use
  2894. * @param projection defines the projection matrix to use
  2895. * @param result defines the Vector3 where to store the result
  2896. */
  2897. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2898. /**
  2899. * Gets the minimal coordinate values between two Vector3
  2900. * @param left defines the first operand
  2901. * @param right defines the second operand
  2902. * @returns the new Vector3
  2903. */
  2904. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2905. /**
  2906. * Gets the maximal coordinate values between two Vector3
  2907. * @param left defines the first operand
  2908. * @param right defines the second operand
  2909. * @returns the new Vector3
  2910. */
  2911. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2912. /**
  2913. * Returns the distance between the vectors "value1" and "value2"
  2914. * @param value1 defines the first operand
  2915. * @param value2 defines the second operand
  2916. * @returns the distance
  2917. */
  2918. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  2919. /**
  2920. * Returns the squared distance between the vectors "value1" and "value2"
  2921. * @param value1 defines the first operand
  2922. * @param value2 defines the second operand
  2923. * @returns the squared distance
  2924. */
  2925. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  2926. /**
  2927. * Returns a new Vector3 located at the center between "value1" and "value2"
  2928. * @param value1 defines the first operand
  2929. * @param value2 defines the second operand
  2930. * @returns the new Vector3
  2931. */
  2932. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  2933. /**
  2934. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  2935. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  2936. * to something in order to rotate it from its local system to the given target system
  2937. * Note: axis1, axis2 and axis3 are normalized during this operation
  2938. * @param axis1 defines the first axis
  2939. * @param axis2 defines the second axis
  2940. * @param axis3 defines the third axis
  2941. * @returns a new Vector3
  2942. */
  2943. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  2944. /**
  2945. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  2946. * @param axis1 defines the first axis
  2947. * @param axis2 defines the second axis
  2948. * @param axis3 defines the third axis
  2949. * @param ref defines the Vector3 where to store the result
  2950. */
  2951. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  2952. }
  2953. /**
  2954. * Vector4 class created for EulerAngle class conversion to Quaternion
  2955. */
  2956. export class Vector4 {
  2957. /** x value of the vector */
  2958. x: number;
  2959. /** y value of the vector */
  2960. y: number;
  2961. /** z value of the vector */
  2962. z: number;
  2963. /** w value of the vector */
  2964. w: number;
  2965. /**
  2966. * Creates a Vector4 object from the given floats.
  2967. * @param x x value of the vector
  2968. * @param y y value of the vector
  2969. * @param z z value of the vector
  2970. * @param w w value of the vector
  2971. */
  2972. constructor(
  2973. /** x value of the vector */
  2974. x: number,
  2975. /** y value of the vector */
  2976. y: number,
  2977. /** z value of the vector */
  2978. z: number,
  2979. /** w value of the vector */
  2980. w: number);
  2981. /**
  2982. * Returns the string with the Vector4 coordinates.
  2983. * @returns a string containing all the vector values
  2984. */
  2985. toString(): string;
  2986. /**
  2987. * Returns the string "Vector4".
  2988. * @returns "Vector4"
  2989. */
  2990. getClassName(): string;
  2991. /**
  2992. * Returns the Vector4 hash code.
  2993. * @returns a unique hash code
  2994. */
  2995. getHashCode(): number;
  2996. /**
  2997. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  2998. * @returns the resulting array
  2999. */
  3000. asArray(): number[];
  3001. /**
  3002. * Populates the given array from the given index with the Vector4 coordinates.
  3003. * @param array array to populate
  3004. * @param index index of the array to start at (default: 0)
  3005. * @returns the Vector4.
  3006. */
  3007. toArray(array: FloatArray, index?: number): Vector4;
  3008. /**
  3009. * Adds the given vector to the current Vector4.
  3010. * @param otherVector the vector to add
  3011. * @returns the updated Vector4.
  3012. */
  3013. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3014. /**
  3015. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3016. * @param otherVector the vector to add
  3017. * @returns the resulting vector
  3018. */
  3019. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3020. /**
  3021. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  3022. * @param otherVector the vector to add
  3023. * @param result the vector to store the result
  3024. * @returns the current Vector4.
  3025. */
  3026. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3027. /**
  3028. * Subtract in place the given vector from the current Vector4.
  3029. * @param otherVector the vector to subtract
  3030. * @returns the updated Vector4.
  3031. */
  3032. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3033. /**
  3034. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  3035. * @param otherVector the vector to add
  3036. * @returns the new vector with the result
  3037. */
  3038. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  3039. /**
  3040. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  3041. * @param otherVector the vector to subtract
  3042. * @param result the vector to store the result
  3043. * @returns the current Vector4.
  3044. */
  3045. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3046. /**
  3047. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3048. */
  3049. /**
  3050. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3051. * @param x value to subtract
  3052. * @param y value to subtract
  3053. * @param z value to subtract
  3054. * @param w value to subtract
  3055. * @returns new vector containing the result
  3056. */
  3057. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3058. /**
  3059. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3060. * @param x value to subtract
  3061. * @param y value to subtract
  3062. * @param z value to subtract
  3063. * @param w value to subtract
  3064. * @param result the vector to store the result in
  3065. * @returns the current Vector4.
  3066. */
  3067. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  3068. /**
  3069. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  3070. * @returns a new vector with the negated values
  3071. */
  3072. negate(): Vector4;
  3073. /**
  3074. * Multiplies the current Vector4 coordinates by scale (float).
  3075. * @param scale the number to scale with
  3076. * @returns the updated Vector4.
  3077. */
  3078. scaleInPlace(scale: number): Vector4;
  3079. /**
  3080. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  3081. * @param scale the number to scale with
  3082. * @returns a new vector with the result
  3083. */
  3084. scale(scale: number): Vector4;
  3085. /**
  3086. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  3087. * @param scale the number to scale with
  3088. * @param result a vector to store the result in
  3089. * @returns the current Vector4.
  3090. */
  3091. scaleToRef(scale: number, result: Vector4): Vector4;
  3092. /**
  3093. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  3094. * @param scale defines the scale factor
  3095. * @param result defines the Vector4 object where to store the result
  3096. * @returns the unmodified current Vector4
  3097. */
  3098. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  3099. /**
  3100. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  3101. * @param otherVector the vector to compare against
  3102. * @returns true if they are equal
  3103. */
  3104. equals(otherVector: DeepImmutable<Vector4>): boolean;
  3105. /**
  3106. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  3107. * @param otherVector vector to compare against
  3108. * @param epsilon (Default: very small number)
  3109. * @returns true if they are equal
  3110. */
  3111. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  3112. /**
  3113. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  3114. * @param x x value to compare against
  3115. * @param y y value to compare against
  3116. * @param z z value to compare against
  3117. * @param w w value to compare against
  3118. * @returns true if equal
  3119. */
  3120. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  3121. /**
  3122. * Multiplies in place the current Vector4 by the given one.
  3123. * @param otherVector vector to multiple with
  3124. * @returns the updated Vector4.
  3125. */
  3126. multiplyInPlace(otherVector: Vector4): Vector4;
  3127. /**
  3128. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  3129. * @param otherVector vector to multiple with
  3130. * @returns resulting new vector
  3131. */
  3132. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  3133. /**
  3134. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  3135. * @param otherVector vector to multiple with
  3136. * @param result vector to store the result
  3137. * @returns the current Vector4.
  3138. */
  3139. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3140. /**
  3141. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  3142. * @param x x value multiply with
  3143. * @param y y value multiply with
  3144. * @param z z value multiply with
  3145. * @param w w value multiply with
  3146. * @returns resulting new vector
  3147. */
  3148. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  3149. /**
  3150. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  3151. * @param otherVector vector to devide with
  3152. * @returns resulting new vector
  3153. */
  3154. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  3155. /**
  3156. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  3157. * @param otherVector vector to devide with
  3158. * @param result vector to store the result
  3159. * @returns the current Vector4.
  3160. */
  3161. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3162. /**
  3163. * Divides the current Vector3 coordinates by the given ones.
  3164. * @param otherVector vector to devide with
  3165. * @returns the updated Vector3.
  3166. */
  3167. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3168. /**
  3169. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  3170. * @param other defines the second operand
  3171. * @returns the current updated Vector4
  3172. */
  3173. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3174. /**
  3175. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  3176. * @param other defines the second operand
  3177. * @returns the current updated Vector4
  3178. */
  3179. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3180. /**
  3181. * Gets a new Vector4 from current Vector4 floored values
  3182. * @returns a new Vector4
  3183. */
  3184. floor(): Vector4;
  3185. /**
  3186. * Gets a new Vector4 from current Vector3 floored values
  3187. * @returns a new Vector4
  3188. */
  3189. fract(): Vector4;
  3190. /**
  3191. * Returns the Vector4 length (float).
  3192. * @returns the length
  3193. */
  3194. length(): number;
  3195. /**
  3196. * Returns the Vector4 squared length (float).
  3197. * @returns the length squared
  3198. */
  3199. lengthSquared(): number;
  3200. /**
  3201. * Normalizes in place the Vector4.
  3202. * @returns the updated Vector4.
  3203. */
  3204. normalize(): Vector4;
  3205. /**
  3206. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  3207. * @returns this converted to a new vector3
  3208. */
  3209. toVector3(): Vector3;
  3210. /**
  3211. * Returns a new Vector4 copied from the current one.
  3212. * @returns the new cloned vector
  3213. */
  3214. clone(): Vector4;
  3215. /**
  3216. * Updates the current Vector4 with the given one coordinates.
  3217. * @param source the source vector to copy from
  3218. * @returns the updated Vector4.
  3219. */
  3220. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  3221. /**
  3222. * Updates the current Vector4 coordinates with the given floats.
  3223. * @param x float to copy from
  3224. * @param y float to copy from
  3225. * @param z float to copy from
  3226. * @param w float to copy from
  3227. * @returns the updated Vector4.
  3228. */
  3229. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3230. /**
  3231. * Updates the current Vector4 coordinates with the given floats.
  3232. * @param x float to set from
  3233. * @param y float to set from
  3234. * @param z float to set from
  3235. * @param w float to set from
  3236. * @returns the updated Vector4.
  3237. */
  3238. set(x: number, y: number, z: number, w: number): Vector4;
  3239. /**
  3240. * Copies the given float to the current Vector3 coordinates
  3241. * @param v defines the x, y, z and w coordinates of the operand
  3242. * @returns the current updated Vector3
  3243. */
  3244. setAll(v: number): Vector4;
  3245. /**
  3246. * Returns a new Vector4 set from the starting index of the given array.
  3247. * @param array the array to pull values from
  3248. * @param offset the offset into the array to start at
  3249. * @returns the new vector
  3250. */
  3251. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  3252. /**
  3253. * Updates the given vector "result" from the starting index of the given array.
  3254. * @param array the array to pull values from
  3255. * @param offset the offset into the array to start at
  3256. * @param result the vector to store the result in
  3257. */
  3258. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  3259. /**
  3260. * Updates the given vector "result" from the starting index of the given Float32Array.
  3261. * @param array the array to pull values from
  3262. * @param offset the offset into the array to start at
  3263. * @param result the vector to store the result in
  3264. */
  3265. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  3266. /**
  3267. * Updates the given vector "result" coordinates from the given floats.
  3268. * @param x float to set from
  3269. * @param y float to set from
  3270. * @param z float to set from
  3271. * @param w float to set from
  3272. * @param result the vector to the floats in
  3273. */
  3274. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  3275. /**
  3276. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  3277. * @returns the new vector
  3278. */
  3279. static Zero(): Vector4;
  3280. /**
  3281. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  3282. * @returns the new vector
  3283. */
  3284. static One(): Vector4;
  3285. /**
  3286. * Returns a new normalized Vector4 from the given one.
  3287. * @param vector the vector to normalize
  3288. * @returns the vector
  3289. */
  3290. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  3291. /**
  3292. * Updates the given vector "result" from the normalization of the given one.
  3293. * @param vector the vector to normalize
  3294. * @param result the vector to store the result in
  3295. */
  3296. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  3297. /**
  3298. * Returns a vector with the minimum values from the left and right vectors
  3299. * @param left left vector to minimize
  3300. * @param right right vector to minimize
  3301. * @returns a new vector with the minimum of the left and right vector values
  3302. */
  3303. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3304. /**
  3305. * Returns a vector with the maximum values from the left and right vectors
  3306. * @param left left vector to maximize
  3307. * @param right right vector to maximize
  3308. * @returns a new vector with the maximum of the left and right vector values
  3309. */
  3310. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3311. /**
  3312. * Returns the distance (float) between the vectors "value1" and "value2".
  3313. * @param value1 value to calulate the distance between
  3314. * @param value2 value to calulate the distance between
  3315. * @return the distance between the two vectors
  3316. */
  3317. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3318. /**
  3319. * Returns the squared distance (float) between the vectors "value1" and "value2".
  3320. * @param value1 value to calulate the distance between
  3321. * @param value2 value to calulate the distance between
  3322. * @return the distance between the two vectors squared
  3323. */
  3324. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3325. /**
  3326. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  3327. * @param value1 value to calulate the center between
  3328. * @param value2 value to calulate the center between
  3329. * @return the center between the two vectors
  3330. */
  3331. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  3332. /**
  3333. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  3334. * This methods computes transformed normalized direction vectors only.
  3335. * @param vector the vector to transform
  3336. * @param transformation the transformation matrix to apply
  3337. * @returns the new vector
  3338. */
  3339. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  3340. /**
  3341. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  3342. * This methods computes transformed normalized direction vectors only.
  3343. * @param vector the vector to transform
  3344. * @param transformation the transformation matrix to apply
  3345. * @param result the vector to store the result in
  3346. */
  3347. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3348. /**
  3349. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  3350. * This methods computes transformed normalized direction vectors only.
  3351. * @param x value to transform
  3352. * @param y value to transform
  3353. * @param z value to transform
  3354. * @param w value to transform
  3355. * @param transformation the transformation matrix to apply
  3356. * @param result the vector to store the results in
  3357. */
  3358. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3359. /**
  3360. * Creates a new Vector4 from a Vector3
  3361. * @param source defines the source data
  3362. * @param w defines the 4th component (default is 0)
  3363. * @returns a new Vector4
  3364. */
  3365. static FromVector3(source: Vector3, w?: number): Vector4;
  3366. }
  3367. /**
  3368. * Class used to store quaternion data
  3369. * @see https://en.wikipedia.org/wiki/Quaternion
  3370. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  3371. */
  3372. export class Quaternion {
  3373. /** defines the first component (0 by default) */
  3374. x: number;
  3375. /** defines the second component (0 by default) */
  3376. y: number;
  3377. /** defines the third component (0 by default) */
  3378. z: number;
  3379. /** defines the fourth component (1.0 by default) */
  3380. w: number;
  3381. /**
  3382. * Creates a new Quaternion from the given floats
  3383. * @param x defines the first component (0 by default)
  3384. * @param y defines the second component (0 by default)
  3385. * @param z defines the third component (0 by default)
  3386. * @param w defines the fourth component (1.0 by default)
  3387. */
  3388. constructor(
  3389. /** defines the first component (0 by default) */
  3390. x?: number,
  3391. /** defines the second component (0 by default) */
  3392. y?: number,
  3393. /** defines the third component (0 by default) */
  3394. z?: number,
  3395. /** defines the fourth component (1.0 by default) */
  3396. w?: number);
  3397. /**
  3398. * Gets a string representation for the current quaternion
  3399. * @returns a string with the Quaternion coordinates
  3400. */
  3401. toString(): string;
  3402. /**
  3403. * Gets the class name of the quaternion
  3404. * @returns the string "Quaternion"
  3405. */
  3406. getClassName(): string;
  3407. /**
  3408. * Gets a hash code for this quaternion
  3409. * @returns the quaternion hash code
  3410. */
  3411. getHashCode(): number;
  3412. /**
  3413. * Copy the quaternion to an array
  3414. * @returns a new array populated with 4 elements from the quaternion coordinates
  3415. */
  3416. asArray(): number[];
  3417. /**
  3418. * Check if two quaternions are equals
  3419. * @param otherQuaternion defines the second operand
  3420. * @return true if the current quaternion and the given one coordinates are strictly equals
  3421. */
  3422. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  3423. /**
  3424. * Clone the current quaternion
  3425. * @returns a new quaternion copied from the current one
  3426. */
  3427. clone(): Quaternion;
  3428. /**
  3429. * Copy a quaternion to the current one
  3430. * @param other defines the other quaternion
  3431. * @returns the updated current quaternion
  3432. */
  3433. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  3434. /**
  3435. * Updates the current quaternion with the given float coordinates
  3436. * @param x defines the x coordinate
  3437. * @param y defines the y coordinate
  3438. * @param z defines the z coordinate
  3439. * @param w defines the w coordinate
  3440. * @returns the updated current quaternion
  3441. */
  3442. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  3443. /**
  3444. * Updates the current quaternion from the given float coordinates
  3445. * @param x defines the x coordinate
  3446. * @param y defines the y coordinate
  3447. * @param z defines the z coordinate
  3448. * @param w defines the w coordinate
  3449. * @returns the updated current quaternion
  3450. */
  3451. set(x: number, y: number, z: number, w: number): Quaternion;
  3452. /**
  3453. * Adds two quaternions
  3454. * @param other defines the second operand
  3455. * @returns a new quaternion as the addition result of the given one and the current quaternion
  3456. */
  3457. add(other: DeepImmutable<Quaternion>): Quaternion;
  3458. /**
  3459. * Add a quaternion to the current one
  3460. * @param other defines the quaternion to add
  3461. * @returns the current quaternion
  3462. */
  3463. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3464. /**
  3465. * Subtract two quaternions
  3466. * @param other defines the second operand
  3467. * @returns a new quaternion as the subtraction result of the given one from the current one
  3468. */
  3469. subtract(other: Quaternion): Quaternion;
  3470. /**
  3471. * Multiplies the current quaternion by a scale factor
  3472. * @param value defines the scale factor
  3473. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3474. */
  3475. scale(value: number): Quaternion;
  3476. /**
  3477. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3478. * @param scale defines the scale factor
  3479. * @param result defines the Quaternion object where to store the result
  3480. * @returns the unmodified current quaternion
  3481. */
  3482. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3483. /**
  3484. * Multiplies in place the current quaternion by a scale factor
  3485. * @param value defines the scale factor
  3486. * @returns the current modified quaternion
  3487. */
  3488. scaleInPlace(value: number): Quaternion;
  3489. /**
  3490. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3491. * @param scale defines the scale factor
  3492. * @param result defines the Quaternion object where to store the result
  3493. * @returns the unmodified current quaternion
  3494. */
  3495. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3496. /**
  3497. * Multiplies two quaternions
  3498. * @param q1 defines the second operand
  3499. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3500. */
  3501. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3502. /**
  3503. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3504. * @param q1 defines the second operand
  3505. * @param result defines the target quaternion
  3506. * @returns the current quaternion
  3507. */
  3508. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3509. /**
  3510. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3511. * @param q1 defines the second operand
  3512. * @returns the currentupdated quaternion
  3513. */
  3514. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3515. /**
  3516. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3517. * @param ref defines the target quaternion
  3518. * @returns the current quaternion
  3519. */
  3520. conjugateToRef(ref: Quaternion): Quaternion;
  3521. /**
  3522. * Conjugates in place (1-q) the current quaternion
  3523. * @returns the current updated quaternion
  3524. */
  3525. conjugateInPlace(): Quaternion;
  3526. /**
  3527. * Conjugates in place (1-q) the current quaternion
  3528. * @returns a new quaternion
  3529. */
  3530. conjugate(): Quaternion;
  3531. /**
  3532. * Gets length of current quaternion
  3533. * @returns the quaternion length (float)
  3534. */
  3535. length(): number;
  3536. /**
  3537. * Normalize in place the current quaternion
  3538. * @returns the current updated quaternion
  3539. */
  3540. normalize(): Quaternion;
  3541. /**
  3542. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3543. * @param order is a reserved parameter and is ignore for now
  3544. * @returns a new Vector3 containing the Euler angles
  3545. */
  3546. toEulerAngles(order?: string): Vector3;
  3547. /**
  3548. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3549. * @param result defines the vector which will be filled with the Euler angles
  3550. * @param order is a reserved parameter and is ignore for now
  3551. * @returns the current unchanged quaternion
  3552. */
  3553. toEulerAnglesToRef(result: Vector3): Quaternion;
  3554. /**
  3555. * Updates the given rotation matrix with the current quaternion values
  3556. * @param result defines the target matrix
  3557. * @returns the current unchanged quaternion
  3558. */
  3559. toRotationMatrix(result: Matrix): Quaternion;
  3560. /**
  3561. * Updates the current quaternion from the given rotation matrix values
  3562. * @param matrix defines the source matrix
  3563. * @returns the current updated quaternion
  3564. */
  3565. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3566. /**
  3567. * Creates a new quaternion from a rotation matrix
  3568. * @param matrix defines the source matrix
  3569. * @returns a new quaternion created from the given rotation matrix values
  3570. */
  3571. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3572. /**
  3573. * Updates the given quaternion with the given rotation matrix values
  3574. * @param matrix defines the source matrix
  3575. * @param result defines the target quaternion
  3576. */
  3577. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3578. /**
  3579. * Returns the dot product (float) between the quaternions "left" and "right"
  3580. * @param left defines the left operand
  3581. * @param right defines the right operand
  3582. * @returns the dot product
  3583. */
  3584. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3585. /**
  3586. * Checks if the two quaternions are close to each other
  3587. * @param quat0 defines the first quaternion to check
  3588. * @param quat1 defines the second quaternion to check
  3589. * @returns true if the two quaternions are close to each other
  3590. */
  3591. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3592. /**
  3593. * Creates an empty quaternion
  3594. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3595. */
  3596. static Zero(): Quaternion;
  3597. /**
  3598. * Inverse a given quaternion
  3599. * @param q defines the source quaternion
  3600. * @returns a new quaternion as the inverted current quaternion
  3601. */
  3602. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3603. /**
  3604. * Inverse a given quaternion
  3605. * @param q defines the source quaternion
  3606. * @param result the quaternion the result will be stored in
  3607. * @returns the result quaternion
  3608. */
  3609. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3610. /**
  3611. * Creates an identity quaternion
  3612. * @returns the identity quaternion
  3613. */
  3614. static Identity(): Quaternion;
  3615. /**
  3616. * Gets a boolean indicating if the given quaternion is identity
  3617. * @param quaternion defines the quaternion to check
  3618. * @returns true if the quaternion is identity
  3619. */
  3620. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3621. /**
  3622. * Creates a quaternion from a rotation around an axis
  3623. * @param axis defines the axis to use
  3624. * @param angle defines the angle to use
  3625. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3626. */
  3627. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3628. /**
  3629. * Creates a rotation around an axis and stores it into the given quaternion
  3630. * @param axis defines the axis to use
  3631. * @param angle defines the angle to use
  3632. * @param result defines the target quaternion
  3633. * @returns the target quaternion
  3634. */
  3635. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3636. /**
  3637. * Creates a new quaternion from data stored into an array
  3638. * @param array defines the data source
  3639. * @param offset defines the offset in the source array where the data starts
  3640. * @returns a new quaternion
  3641. */
  3642. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3643. /**
  3644. * Create a quaternion from Euler rotation angles
  3645. * @param x Pitch
  3646. * @param y Yaw
  3647. * @param z Roll
  3648. * @returns the new Quaternion
  3649. */
  3650. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  3651. /**
  3652. * Updates a quaternion from Euler rotation angles
  3653. * @param x Pitch
  3654. * @param y Yaw
  3655. * @param z Roll
  3656. * @param result the quaternion to store the result
  3657. * @returns the updated quaternion
  3658. */
  3659. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  3660. /**
  3661. * Create a quaternion from Euler rotation vector
  3662. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3663. * @returns the new Quaternion
  3664. */
  3665. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  3666. /**
  3667. * Updates a quaternion from Euler rotation vector
  3668. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3669. * @param result the quaternion to store the result
  3670. * @returns the updated quaternion
  3671. */
  3672. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  3673. /**
  3674. * Creates a new quaternion from the given Euler float angles (y, x, z)
  3675. * @param yaw defines the rotation around Y axis
  3676. * @param pitch defines the rotation around X axis
  3677. * @param roll defines the rotation around Z axis
  3678. * @returns the new quaternion
  3679. */
  3680. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  3681. /**
  3682. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  3683. * @param yaw defines the rotation around Y axis
  3684. * @param pitch defines the rotation around X axis
  3685. * @param roll defines the rotation around Z axis
  3686. * @param result defines the target quaternion
  3687. */
  3688. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  3689. /**
  3690. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  3691. * @param alpha defines the rotation around first axis
  3692. * @param beta defines the rotation around second axis
  3693. * @param gamma defines the rotation around third axis
  3694. * @returns the new quaternion
  3695. */
  3696. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  3697. /**
  3698. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  3699. * @param alpha defines the rotation around first axis
  3700. * @param beta defines the rotation around second axis
  3701. * @param gamma defines the rotation around third axis
  3702. * @param result defines the target quaternion
  3703. */
  3704. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  3705. /**
  3706. * 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)
  3707. * @param axis1 defines the first axis
  3708. * @param axis2 defines the second axis
  3709. * @param axis3 defines the third axis
  3710. * @returns the new quaternion
  3711. */
  3712. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  3713. /**
  3714. * 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
  3715. * @param axis1 defines the first axis
  3716. * @param axis2 defines the second axis
  3717. * @param axis3 defines the third axis
  3718. * @param ref defines the target quaternion
  3719. */
  3720. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  3721. /**
  3722. * Interpolates between two quaternions
  3723. * @param left defines first quaternion
  3724. * @param right defines second quaternion
  3725. * @param amount defines the gradient to use
  3726. * @returns the new interpolated quaternion
  3727. */
  3728. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3729. /**
  3730. * Interpolates between two quaternions and stores it into a target quaternion
  3731. * @param left defines first quaternion
  3732. * @param right defines second quaternion
  3733. * @param amount defines the gradient to use
  3734. * @param result defines the target quaternion
  3735. */
  3736. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  3737. /**
  3738. * Interpolate between two quaternions using Hermite interpolation
  3739. * @param value1 defines first quaternion
  3740. * @param tangent1 defines the incoming tangent
  3741. * @param value2 defines second quaternion
  3742. * @param tangent2 defines the outgoing tangent
  3743. * @param amount defines the target quaternion
  3744. * @returns the new interpolated quaternion
  3745. */
  3746. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3747. }
  3748. /**
  3749. * Class used to store matrix data (4x4)
  3750. */
  3751. export class Matrix {
  3752. private static _updateFlagSeed;
  3753. private static _identityReadOnly;
  3754. private _isIdentity;
  3755. private _isIdentityDirty;
  3756. private _isIdentity3x2;
  3757. private _isIdentity3x2Dirty;
  3758. /**
  3759. * Gets the update flag of the matrix which is an unique number for the matrix.
  3760. * It will be incremented every time the matrix data change.
  3761. * You can use it to speed the comparison between two versions of the same matrix.
  3762. */
  3763. updateFlag: number;
  3764. private readonly _m;
  3765. /**
  3766. * Gets the internal data of the matrix
  3767. */
  3768. readonly m: DeepImmutable<Float32Array>;
  3769. /** @hidden */
  3770. _markAsUpdated(): void;
  3771. /** @hidden */
  3772. private _updateIdentityStatus;
  3773. /**
  3774. * Creates an empty matrix (filled with zeros)
  3775. */
  3776. constructor();
  3777. /**
  3778. * Check if the current matrix is identity
  3779. * @returns true is the matrix is the identity matrix
  3780. */
  3781. isIdentity(): boolean;
  3782. /**
  3783. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  3784. * @returns true is the matrix is the identity matrix
  3785. */
  3786. isIdentityAs3x2(): boolean;
  3787. /**
  3788. * Gets the determinant of the matrix
  3789. * @returns the matrix determinant
  3790. */
  3791. determinant(): number;
  3792. /**
  3793. * Returns the matrix as a Float32Array
  3794. * @returns the matrix underlying array
  3795. */
  3796. toArray(): DeepImmutable<Float32Array>;
  3797. /**
  3798. * Returns the matrix as a Float32Array
  3799. * @returns the matrix underlying array.
  3800. */
  3801. asArray(): DeepImmutable<Float32Array>;
  3802. /**
  3803. * Inverts the current matrix in place
  3804. * @returns the current inverted matrix
  3805. */
  3806. invert(): Matrix;
  3807. /**
  3808. * Sets all the matrix elements to zero
  3809. * @returns the current matrix
  3810. */
  3811. reset(): Matrix;
  3812. /**
  3813. * Adds the current matrix with a second one
  3814. * @param other defines the matrix to add
  3815. * @returns a new matrix as the addition of the current matrix and the given one
  3816. */
  3817. add(other: DeepImmutable<Matrix>): Matrix;
  3818. /**
  3819. * Sets the given matrix "result" to the addition of the current matrix and the given one
  3820. * @param other defines the matrix to add
  3821. * @param result defines the target matrix
  3822. * @returns the current matrix
  3823. */
  3824. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3825. /**
  3826. * Adds in place the given matrix to the current matrix
  3827. * @param other defines the second operand
  3828. * @returns the current updated matrix
  3829. */
  3830. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  3831. /**
  3832. * Sets the given matrix to the current inverted Matrix
  3833. * @param other defines the target matrix
  3834. * @returns the unmodified current matrix
  3835. */
  3836. invertToRef(other: Matrix): Matrix;
  3837. /**
  3838. * add a value at the specified position in the current Matrix
  3839. * @param index the index of the value within the matrix. between 0 and 15.
  3840. * @param value the value to be added
  3841. * @returns the current updated matrix
  3842. */
  3843. addAtIndex(index: number, value: number): Matrix;
  3844. /**
  3845. * mutiply the specified position in the current Matrix by a value
  3846. * @param index the index of the value within the matrix. between 0 and 15.
  3847. * @param value the value to be added
  3848. * @returns the current updated matrix
  3849. */
  3850. multiplyAtIndex(index: number, value: number): Matrix;
  3851. /**
  3852. * Inserts the translation vector (using 3 floats) in the current matrix
  3853. * @param x defines the 1st component of the translation
  3854. * @param y defines the 2nd component of the translation
  3855. * @param z defines the 3rd component of the translation
  3856. * @returns the current updated matrix
  3857. */
  3858. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3859. /**
  3860. * Adds the translation vector (using 3 floats) in the current matrix
  3861. * @param x defines the 1st component of the translation
  3862. * @param y defines the 2nd component of the translation
  3863. * @param z defines the 3rd component of the translation
  3864. * @returns the current updated matrix
  3865. */
  3866. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3867. /**
  3868. * Inserts the translation vector in the current matrix
  3869. * @param vector3 defines the translation to insert
  3870. * @returns the current updated matrix
  3871. */
  3872. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  3873. /**
  3874. * Gets the translation value of the current matrix
  3875. * @returns a new Vector3 as the extracted translation from the matrix
  3876. */
  3877. getTranslation(): Vector3;
  3878. /**
  3879. * Fill a Vector3 with the extracted translation from the matrix
  3880. * @param result defines the Vector3 where to store the translation
  3881. * @returns the current matrix
  3882. */
  3883. getTranslationToRef(result: Vector3): Matrix;
  3884. /**
  3885. * Remove rotation and scaling part from the matrix
  3886. * @returns the updated matrix
  3887. */
  3888. removeRotationAndScaling(): Matrix;
  3889. /**
  3890. * Multiply two matrices
  3891. * @param other defines the second operand
  3892. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  3893. */
  3894. multiply(other: DeepImmutable<Matrix>): Matrix;
  3895. /**
  3896. * Copy the current matrix from the given one
  3897. * @param other defines the source matrix
  3898. * @returns the current updated matrix
  3899. */
  3900. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  3901. /**
  3902. * Populates the given array from the starting index with the current matrix values
  3903. * @param array defines the target array
  3904. * @param offset defines the offset in the target array where to start storing values
  3905. * @returns the current matrix
  3906. */
  3907. copyToArray(array: Float32Array, offset?: number): Matrix;
  3908. /**
  3909. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  3910. * @param other defines the second operand
  3911. * @param result defines the matrix where to store the multiplication
  3912. * @returns the current matrix
  3913. */
  3914. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3915. /**
  3916. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  3917. * @param other defines the second operand
  3918. * @param result defines the array where to store the multiplication
  3919. * @param offset defines the offset in the target array where to start storing values
  3920. * @returns the current matrix
  3921. */
  3922. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  3923. /**
  3924. * Check equality between this matrix and a second one
  3925. * @param value defines the second matrix to compare
  3926. * @returns true is the current matrix and the given one values are strictly equal
  3927. */
  3928. equals(value: DeepImmutable<Matrix>): boolean;
  3929. /**
  3930. * Clone the current matrix
  3931. * @returns a new matrix from the current matrix
  3932. */
  3933. clone(): Matrix;
  3934. /**
  3935. * Returns the name of the current matrix class
  3936. * @returns the string "Matrix"
  3937. */
  3938. getClassName(): string;
  3939. /**
  3940. * Gets the hash code of the current matrix
  3941. * @returns the hash code
  3942. */
  3943. getHashCode(): number;
  3944. /**
  3945. * Decomposes the current Matrix into a translation, rotation and scaling components
  3946. * @param scale defines the scale vector3 given as a reference to update
  3947. * @param rotation defines the rotation quaternion given as a reference to update
  3948. * @param translation defines the translation vector3 given as a reference to update
  3949. * @returns true if operation was successful
  3950. */
  3951. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  3952. /**
  3953. * Gets specific row of the matrix
  3954. * @param index defines the number of the row to get
  3955. * @returns the index-th row of the current matrix as a new Vector4
  3956. */
  3957. getRow(index: number): Nullable<Vector4>;
  3958. /**
  3959. * Sets the index-th row of the current matrix to the vector4 values
  3960. * @param index defines the number of the row to set
  3961. * @param row defines the target vector4
  3962. * @returns the updated current matrix
  3963. */
  3964. setRow(index: number, row: Vector4): Matrix;
  3965. /**
  3966. * Compute the transpose of the matrix
  3967. * @returns the new transposed matrix
  3968. */
  3969. transpose(): Matrix;
  3970. /**
  3971. * Compute the transpose of the matrix and store it in a given matrix
  3972. * @param result defines the target matrix
  3973. * @returns the current matrix
  3974. */
  3975. transposeToRef(result: Matrix): Matrix;
  3976. /**
  3977. * Sets the index-th row of the current matrix with the given 4 x float values
  3978. * @param index defines the row index
  3979. * @param x defines the x component to set
  3980. * @param y defines the y component to set
  3981. * @param z defines the z component to set
  3982. * @param w defines the w component to set
  3983. * @returns the updated current matrix
  3984. */
  3985. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  3986. /**
  3987. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  3988. * @param scale defines the scale factor
  3989. * @returns a new matrix
  3990. */
  3991. scale(scale: number): Matrix;
  3992. /**
  3993. * Scale the current matrix values by a factor to a given result matrix
  3994. * @param scale defines the scale factor
  3995. * @param result defines the matrix to store the result
  3996. * @returns the current matrix
  3997. */
  3998. scaleToRef(scale: number, result: Matrix): Matrix;
  3999. /**
  4000. * Scale the current matrix values by a factor and add the result to a given matrix
  4001. * @param scale defines the scale factor
  4002. * @param result defines the Matrix to store the result
  4003. * @returns the current matrix
  4004. */
  4005. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  4006. /**
  4007. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  4008. * @param ref matrix to store the result
  4009. */
  4010. toNormalMatrix(ref: Matrix): void;
  4011. /**
  4012. * Gets only rotation part of the current matrix
  4013. * @returns a new matrix sets to the extracted rotation matrix from the current one
  4014. */
  4015. getRotationMatrix(): Matrix;
  4016. /**
  4017. * Extracts the rotation matrix from the current one and sets it as the given "result"
  4018. * @param result defines the target matrix to store data to
  4019. * @returns the current matrix
  4020. */
  4021. getRotationMatrixToRef(result: Matrix): Matrix;
  4022. /**
  4023. * Toggles model matrix from being right handed to left handed in place and vice versa
  4024. */
  4025. toggleModelMatrixHandInPlace(): void;
  4026. /**
  4027. * Toggles projection matrix from being right handed to left handed in place and vice versa
  4028. */
  4029. toggleProjectionMatrixHandInPlace(): void;
  4030. /**
  4031. * Creates a matrix from an array
  4032. * @param array defines the source array
  4033. * @param offset defines an offset in the source array
  4034. * @returns a new Matrix set from the starting index of the given array
  4035. */
  4036. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  4037. /**
  4038. * Copy the content of an array into a given matrix
  4039. * @param array defines the source array
  4040. * @param offset defines an offset in the source array
  4041. * @param result defines the target matrix
  4042. */
  4043. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  4044. /**
  4045. * Stores an array into a matrix after having multiplied each component by a given factor
  4046. * @param array defines the source array
  4047. * @param offset defines the offset in the source array
  4048. * @param scale defines the scaling factor
  4049. * @param result defines the target matrix
  4050. */
  4051. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  4052. /**
  4053. * Gets an identity matrix that must not be updated
  4054. */
  4055. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  4056. /**
  4057. * Stores a list of values (16) inside a given matrix
  4058. * @param initialM11 defines 1st value of 1st row
  4059. * @param initialM12 defines 2nd value of 1st row
  4060. * @param initialM13 defines 3rd value of 1st row
  4061. * @param initialM14 defines 4th value of 1st row
  4062. * @param initialM21 defines 1st value of 2nd row
  4063. * @param initialM22 defines 2nd value of 2nd row
  4064. * @param initialM23 defines 3rd value of 2nd row
  4065. * @param initialM24 defines 4th value of 2nd row
  4066. * @param initialM31 defines 1st value of 3rd row
  4067. * @param initialM32 defines 2nd value of 3rd row
  4068. * @param initialM33 defines 3rd value of 3rd row
  4069. * @param initialM34 defines 4th value of 3rd row
  4070. * @param initialM41 defines 1st value of 4th row
  4071. * @param initialM42 defines 2nd value of 4th row
  4072. * @param initialM43 defines 3rd value of 4th row
  4073. * @param initialM44 defines 4th value of 4th row
  4074. * @param result defines the target matrix
  4075. */
  4076. 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;
  4077. /**
  4078. * Creates new matrix from a list of values (16)
  4079. * @param initialM11 defines 1st value of 1st row
  4080. * @param initialM12 defines 2nd value of 1st row
  4081. * @param initialM13 defines 3rd value of 1st row
  4082. * @param initialM14 defines 4th value of 1st row
  4083. * @param initialM21 defines 1st value of 2nd row
  4084. * @param initialM22 defines 2nd value of 2nd row
  4085. * @param initialM23 defines 3rd value of 2nd row
  4086. * @param initialM24 defines 4th value of 2nd row
  4087. * @param initialM31 defines 1st value of 3rd row
  4088. * @param initialM32 defines 2nd value of 3rd row
  4089. * @param initialM33 defines 3rd value of 3rd row
  4090. * @param initialM34 defines 4th value of 3rd row
  4091. * @param initialM41 defines 1st value of 4th row
  4092. * @param initialM42 defines 2nd value of 4th row
  4093. * @param initialM43 defines 3rd value of 4th row
  4094. * @param initialM44 defines 4th value of 4th row
  4095. * @returns the new matrix
  4096. */
  4097. 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;
  4098. /**
  4099. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4100. * @param scale defines the scale vector3
  4101. * @param rotation defines the rotation quaternion
  4102. * @param translation defines the translation vector3
  4103. * @returns a new matrix
  4104. */
  4105. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  4106. /**
  4107. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4108. * @param scale defines the scale vector3
  4109. * @param rotation defines the rotation quaternion
  4110. * @param translation defines the translation vector3
  4111. * @param result defines the target matrix
  4112. */
  4113. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  4114. /**
  4115. * Creates a new identity matrix
  4116. * @returns a new identity matrix
  4117. */
  4118. static Identity(): Matrix;
  4119. /**
  4120. * Creates a new identity matrix and stores the result in a given matrix
  4121. * @param result defines the target matrix
  4122. */
  4123. static IdentityToRef(result: Matrix): void;
  4124. /**
  4125. * Creates a new zero matrix
  4126. * @returns a new zero matrix
  4127. */
  4128. static Zero(): Matrix;
  4129. /**
  4130. * Creates a new rotation matrix for "angle" radians around the X axis
  4131. * @param angle defines the angle (in radians) to use
  4132. * @return the new matrix
  4133. */
  4134. static RotationX(angle: number): Matrix;
  4135. /**
  4136. * Creates a new matrix as the invert of a given matrix
  4137. * @param source defines the source matrix
  4138. * @returns the new matrix
  4139. */
  4140. static Invert(source: DeepImmutable<Matrix>): Matrix;
  4141. /**
  4142. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  4143. * @param angle defines the angle (in radians) to use
  4144. * @param result defines the target matrix
  4145. */
  4146. static RotationXToRef(angle: number, result: Matrix): void;
  4147. /**
  4148. * Creates a new rotation matrix for "angle" radians around the Y axis
  4149. * @param angle defines the angle (in radians) to use
  4150. * @return the new matrix
  4151. */
  4152. static RotationY(angle: number): Matrix;
  4153. /**
  4154. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  4155. * @param angle defines the angle (in radians) to use
  4156. * @param result defines the target matrix
  4157. */
  4158. static RotationYToRef(angle: number, result: Matrix): void;
  4159. /**
  4160. * Creates a new rotation matrix for "angle" radians around the Z axis
  4161. * @param angle defines the angle (in radians) to use
  4162. * @return the new matrix
  4163. */
  4164. static RotationZ(angle: number): Matrix;
  4165. /**
  4166. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  4167. * @param angle defines the angle (in radians) to use
  4168. * @param result defines the target matrix
  4169. */
  4170. static RotationZToRef(angle: number, result: Matrix): void;
  4171. /**
  4172. * Creates a new rotation matrix for "angle" radians around the given axis
  4173. * @param axis defines the axis to use
  4174. * @param angle defines the angle (in radians) to use
  4175. * @return the new matrix
  4176. */
  4177. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  4178. /**
  4179. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  4180. * @param axis defines the axis to use
  4181. * @param angle defines the angle (in radians) to use
  4182. * @param result defines the target matrix
  4183. */
  4184. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  4185. /**
  4186. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  4187. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  4188. * @param from defines the vector to align
  4189. * @param to defines the vector to align to
  4190. * @param result defines the target matrix
  4191. */
  4192. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  4193. /**
  4194. * Creates a rotation matrix
  4195. * @param yaw defines the yaw angle in radians (Y axis)
  4196. * @param pitch defines the pitch angle in radians (X axis)
  4197. * @param roll defines the roll angle in radians (X axis)
  4198. * @returns the new rotation matrix
  4199. */
  4200. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  4201. /**
  4202. * Creates a rotation matrix and stores it in a given matrix
  4203. * @param yaw defines the yaw angle in radians (Y axis)
  4204. * @param pitch defines the pitch angle in radians (X axis)
  4205. * @param roll defines the roll angle in radians (X axis)
  4206. * @param result defines the target matrix
  4207. */
  4208. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  4209. /**
  4210. * Creates a scaling matrix
  4211. * @param x defines the scale factor on X axis
  4212. * @param y defines the scale factor on Y axis
  4213. * @param z defines the scale factor on Z axis
  4214. * @returns the new matrix
  4215. */
  4216. static Scaling(x: number, y: number, z: number): Matrix;
  4217. /**
  4218. * Creates a scaling matrix and stores it in a given matrix
  4219. * @param x defines the scale factor on X axis
  4220. * @param y defines the scale factor on Y axis
  4221. * @param z defines the scale factor on Z axis
  4222. * @param result defines the target matrix
  4223. */
  4224. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  4225. /**
  4226. * Creates a translation matrix
  4227. * @param x defines the translation on X axis
  4228. * @param y defines the translation on Y axis
  4229. * @param z defines the translationon Z axis
  4230. * @returns the new matrix
  4231. */
  4232. static Translation(x: number, y: number, z: number): Matrix;
  4233. /**
  4234. * Creates a translation matrix and stores it in a given matrix
  4235. * @param x defines the translation on X axis
  4236. * @param y defines the translation on Y axis
  4237. * @param z defines the translationon Z axis
  4238. * @param result defines the target matrix
  4239. */
  4240. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  4241. /**
  4242. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4243. * @param startValue defines the start value
  4244. * @param endValue defines the end value
  4245. * @param gradient defines the gradient factor
  4246. * @returns the new matrix
  4247. */
  4248. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4249. /**
  4250. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4251. * @param startValue defines the start value
  4252. * @param endValue defines the end value
  4253. * @param gradient defines the gradient factor
  4254. * @param result defines the Matrix object where to store data
  4255. */
  4256. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4257. /**
  4258. * Builds a new matrix whose values are computed by:
  4259. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4260. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4261. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4262. * @param startValue defines the first matrix
  4263. * @param endValue defines the second matrix
  4264. * @param gradient defines the gradient between the two matrices
  4265. * @returns the new matrix
  4266. */
  4267. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4268. /**
  4269. * Update a matrix to values which are computed by:
  4270. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4271. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4272. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4273. * @param startValue defines the first matrix
  4274. * @param endValue defines the second matrix
  4275. * @param gradient defines the gradient between the two matrices
  4276. * @param result defines the target matrix
  4277. */
  4278. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4279. /**
  4280. * 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"
  4281. * This function works in left handed mode
  4282. * @param eye defines the final position of the entity
  4283. * @param target defines where the entity should look at
  4284. * @param up defines the up vector for the entity
  4285. * @returns the new matrix
  4286. */
  4287. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4288. /**
  4289. * 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".
  4290. * This function works in left handed mode
  4291. * @param eye defines the final position of the entity
  4292. * @param target defines where the entity should look at
  4293. * @param up defines the up vector for the entity
  4294. * @param result defines the target matrix
  4295. */
  4296. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4297. /**
  4298. * 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"
  4299. * This function works in right handed mode
  4300. * @param eye defines the final position of the entity
  4301. * @param target defines where the entity should look at
  4302. * @param up defines the up vector for the entity
  4303. * @returns the new matrix
  4304. */
  4305. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4306. /**
  4307. * 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".
  4308. * This function works in right handed mode
  4309. * @param eye defines the final position of the entity
  4310. * @param target defines where the entity should look at
  4311. * @param up defines the up vector for the entity
  4312. * @param result defines the target matrix
  4313. */
  4314. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4315. /**
  4316. * Create a left-handed orthographic projection matrix
  4317. * @param width defines the viewport width
  4318. * @param height defines the viewport height
  4319. * @param znear defines the near clip plane
  4320. * @param zfar defines the far clip plane
  4321. * @returns a new matrix as a left-handed orthographic projection matrix
  4322. */
  4323. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4324. /**
  4325. * Store a left-handed orthographic projection to a given matrix
  4326. * @param width defines the viewport width
  4327. * @param height defines the viewport height
  4328. * @param znear defines the near clip plane
  4329. * @param zfar defines the far clip plane
  4330. * @param result defines the target matrix
  4331. */
  4332. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  4333. /**
  4334. * Create a left-handed orthographic projection matrix
  4335. * @param left defines the viewport left coordinate
  4336. * @param right defines the viewport right coordinate
  4337. * @param bottom defines the viewport bottom coordinate
  4338. * @param top defines the viewport top coordinate
  4339. * @param znear defines the near clip plane
  4340. * @param zfar defines the far clip plane
  4341. * @returns a new matrix as a left-handed orthographic projection matrix
  4342. */
  4343. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4344. /**
  4345. * Stores a left-handed orthographic projection into a given matrix
  4346. * @param left defines the viewport left coordinate
  4347. * @param right defines the viewport right coordinate
  4348. * @param bottom defines the viewport bottom coordinate
  4349. * @param top defines the viewport top coordinate
  4350. * @param znear defines the near clip plane
  4351. * @param zfar defines the far clip plane
  4352. * @param result defines the target matrix
  4353. */
  4354. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4355. /**
  4356. * Creates a right-handed orthographic projection matrix
  4357. * @param left defines the viewport left coordinate
  4358. * @param right defines the viewport right coordinate
  4359. * @param bottom defines the viewport bottom coordinate
  4360. * @param top defines the viewport top coordinate
  4361. * @param znear defines the near clip plane
  4362. * @param zfar defines the far clip plane
  4363. * @returns a new matrix as a right-handed orthographic projection matrix
  4364. */
  4365. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4366. /**
  4367. * Stores a right-handed orthographic projection into a given matrix
  4368. * @param left defines the viewport left coordinate
  4369. * @param right defines the viewport right coordinate
  4370. * @param bottom defines the viewport bottom coordinate
  4371. * @param top defines the viewport top coordinate
  4372. * @param znear defines the near clip plane
  4373. * @param zfar defines the far clip plane
  4374. * @param result defines the target matrix
  4375. */
  4376. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4377. /**
  4378. * Creates a left-handed perspective projection matrix
  4379. * @param width defines the viewport width
  4380. * @param height defines the viewport height
  4381. * @param znear defines the near clip plane
  4382. * @param zfar defines the far clip plane
  4383. * @returns a new matrix as a left-handed perspective projection matrix
  4384. */
  4385. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4386. /**
  4387. * Creates a left-handed perspective projection matrix
  4388. * @param fov defines the horizontal field of view
  4389. * @param aspect defines the aspect ratio
  4390. * @param znear defines the near clip plane
  4391. * @param zfar defines the far clip plane
  4392. * @returns a new matrix as a left-handed perspective projection matrix
  4393. */
  4394. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4395. /**
  4396. * Stores a left-handed perspective projection into a given matrix
  4397. * @param fov defines the horizontal field of view
  4398. * @param aspect defines the aspect ratio
  4399. * @param znear defines the near clip plane
  4400. * @param zfar defines the far clip plane
  4401. * @param result defines the target matrix
  4402. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4403. */
  4404. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4405. /**
  4406. * Creates a right-handed perspective projection matrix
  4407. * @param fov defines the horizontal field of view
  4408. * @param aspect defines the aspect ratio
  4409. * @param znear defines the near clip plane
  4410. * @param zfar defines the far clip plane
  4411. * @returns a new matrix as a right-handed perspective projection matrix
  4412. */
  4413. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4414. /**
  4415. * Stores a right-handed perspective projection into a given matrix
  4416. * @param fov defines the horizontal field of view
  4417. * @param aspect defines the aspect ratio
  4418. * @param znear defines the near clip plane
  4419. * @param zfar defines the far clip plane
  4420. * @param result defines the target matrix
  4421. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4422. */
  4423. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4424. /**
  4425. * Stores a perspective projection for WebVR info a given matrix
  4426. * @param fov defines the field of view
  4427. * @param znear defines the near clip plane
  4428. * @param zfar defines the far clip plane
  4429. * @param result defines the target matrix
  4430. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  4431. */
  4432. static PerspectiveFovWebVRToRef(fov: {
  4433. upDegrees: number;
  4434. downDegrees: number;
  4435. leftDegrees: number;
  4436. rightDegrees: number;
  4437. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  4438. /**
  4439. * Computes a complete transformation matrix
  4440. * @param viewport defines the viewport to use
  4441. * @param world defines the world matrix
  4442. * @param view defines the view matrix
  4443. * @param projection defines the projection matrix
  4444. * @param zmin defines the near clip plane
  4445. * @param zmax defines the far clip plane
  4446. * @returns the transformation matrix
  4447. */
  4448. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  4449. /**
  4450. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  4451. * @param matrix defines the matrix to use
  4452. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  4453. */
  4454. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  4455. /**
  4456. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  4457. * @param matrix defines the matrix to use
  4458. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  4459. */
  4460. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  4461. /**
  4462. * Compute the transpose of a given matrix
  4463. * @param matrix defines the matrix to transpose
  4464. * @returns the new matrix
  4465. */
  4466. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4467. /**
  4468. * Compute the transpose of a matrix and store it in a target matrix
  4469. * @param matrix defines the matrix to transpose
  4470. * @param result defines the target matrix
  4471. */
  4472. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4473. /**
  4474. * Computes a reflection matrix from a plane
  4475. * @param plane defines the reflection plane
  4476. * @returns a new matrix
  4477. */
  4478. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4479. /**
  4480. * Computes a reflection matrix from a plane
  4481. * @param plane defines the reflection plane
  4482. * @param result defines the target matrix
  4483. */
  4484. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4485. /**
  4486. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4487. * @param xaxis defines the value of the 1st axis
  4488. * @param yaxis defines the value of the 2nd axis
  4489. * @param zaxis defines the value of the 3rd axis
  4490. * @param result defines the target matrix
  4491. */
  4492. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4493. /**
  4494. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4495. * @param quat defines the quaternion to use
  4496. * @param result defines the target matrix
  4497. */
  4498. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4499. }
  4500. /**
  4501. * @hidden
  4502. */
  4503. export class TmpVectors {
  4504. static Vector2: Vector2[];
  4505. static Vector3: Vector3[];
  4506. static Vector4: Vector4[];
  4507. static Quaternion: Quaternion[];
  4508. static Matrix: Matrix[];
  4509. }
  4510. }
  4511. declare module BABYLON {
  4512. /**
  4513. * Defines potential orientation for back face culling
  4514. */
  4515. export enum Orientation {
  4516. /**
  4517. * Clockwise
  4518. */
  4519. CW = 0,
  4520. /** Counter clockwise */
  4521. CCW = 1
  4522. }
  4523. /** Class used to represent a Bezier curve */
  4524. export class BezierCurve {
  4525. /**
  4526. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  4527. * @param t defines the time
  4528. * @param x1 defines the left coordinate on X axis
  4529. * @param y1 defines the left coordinate on Y axis
  4530. * @param x2 defines the right coordinate on X axis
  4531. * @param y2 defines the right coordinate on Y axis
  4532. * @returns the interpolated value
  4533. */
  4534. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  4535. }
  4536. /**
  4537. * Defines angle representation
  4538. */
  4539. export class Angle {
  4540. private _radians;
  4541. /**
  4542. * Creates an Angle object of "radians" radians (float).
  4543. * @param radians the angle in radians
  4544. */
  4545. constructor(radians: number);
  4546. /**
  4547. * Get value in degrees
  4548. * @returns the Angle value in degrees (float)
  4549. */
  4550. degrees(): number;
  4551. /**
  4552. * Get value in radians
  4553. * @returns the Angle value in radians (float)
  4554. */
  4555. radians(): number;
  4556. /**
  4557. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  4558. * @param a defines first vector
  4559. * @param b defines second vector
  4560. * @returns a new Angle
  4561. */
  4562. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  4563. /**
  4564. * Gets a new Angle object from the given float in radians
  4565. * @param radians defines the angle value in radians
  4566. * @returns a new Angle
  4567. */
  4568. static FromRadians(radians: number): Angle;
  4569. /**
  4570. * Gets a new Angle object from the given float in degrees
  4571. * @param degrees defines the angle value in degrees
  4572. * @returns a new Angle
  4573. */
  4574. static FromDegrees(degrees: number): Angle;
  4575. }
  4576. /**
  4577. * This represents an arc in a 2d space.
  4578. */
  4579. export class Arc2 {
  4580. /** Defines the start point of the arc */
  4581. startPoint: Vector2;
  4582. /** Defines the mid point of the arc */
  4583. midPoint: Vector2;
  4584. /** Defines the end point of the arc */
  4585. endPoint: Vector2;
  4586. /**
  4587. * Defines the center point of the arc.
  4588. */
  4589. centerPoint: Vector2;
  4590. /**
  4591. * Defines the radius of the arc.
  4592. */
  4593. radius: number;
  4594. /**
  4595. * Defines the angle of the arc (from mid point to end point).
  4596. */
  4597. angle: Angle;
  4598. /**
  4599. * Defines the start angle of the arc (from start point to middle point).
  4600. */
  4601. startAngle: Angle;
  4602. /**
  4603. * Defines the orientation of the arc (clock wise/counter clock wise).
  4604. */
  4605. orientation: Orientation;
  4606. /**
  4607. * Creates an Arc object from the three given points : start, middle and end.
  4608. * @param startPoint Defines the start point of the arc
  4609. * @param midPoint Defines the midlle point of the arc
  4610. * @param endPoint Defines the end point of the arc
  4611. */
  4612. constructor(
  4613. /** Defines the start point of the arc */
  4614. startPoint: Vector2,
  4615. /** Defines the mid point of the arc */
  4616. midPoint: Vector2,
  4617. /** Defines the end point of the arc */
  4618. endPoint: Vector2);
  4619. }
  4620. /**
  4621. * Represents a 2D path made up of multiple 2D points
  4622. */
  4623. export class Path2 {
  4624. private _points;
  4625. private _length;
  4626. /**
  4627. * If the path start and end point are the same
  4628. */
  4629. closed: boolean;
  4630. /**
  4631. * Creates a Path2 object from the starting 2D coordinates x and y.
  4632. * @param x the starting points x value
  4633. * @param y the starting points y value
  4634. */
  4635. constructor(x: number, y: number);
  4636. /**
  4637. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  4638. * @param x the added points x value
  4639. * @param y the added points y value
  4640. * @returns the updated Path2.
  4641. */
  4642. addLineTo(x: number, y: number): Path2;
  4643. /**
  4644. * 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.
  4645. * @param midX middle point x value
  4646. * @param midY middle point y value
  4647. * @param endX end point x value
  4648. * @param endY end point y value
  4649. * @param numberOfSegments (default: 36)
  4650. * @returns the updated Path2.
  4651. */
  4652. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  4653. /**
  4654. * Closes the Path2.
  4655. * @returns the Path2.
  4656. */
  4657. close(): Path2;
  4658. /**
  4659. * Gets the sum of the distance between each sequential point in the path
  4660. * @returns the Path2 total length (float).
  4661. */
  4662. length(): number;
  4663. /**
  4664. * Gets the points which construct the path
  4665. * @returns the Path2 internal array of points.
  4666. */
  4667. getPoints(): Vector2[];
  4668. /**
  4669. * Retreives the point at the distance aways from the starting point
  4670. * @param normalizedLengthPosition the length along the path to retreive the point from
  4671. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  4672. */
  4673. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  4674. /**
  4675. * Creates a new path starting from an x and y position
  4676. * @param x starting x value
  4677. * @param y starting y value
  4678. * @returns a new Path2 starting at the coordinates (x, y).
  4679. */
  4680. static StartingAt(x: number, y: number): Path2;
  4681. }
  4682. /**
  4683. * Represents a 3D path made up of multiple 3D points
  4684. */
  4685. export class Path3D {
  4686. /**
  4687. * an array of Vector3, the curve axis of the Path3D
  4688. */
  4689. path: Vector3[];
  4690. private _curve;
  4691. private _distances;
  4692. private _tangents;
  4693. private _normals;
  4694. private _binormals;
  4695. private _raw;
  4696. /**
  4697. * new Path3D(path, normal, raw)
  4698. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  4699. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  4700. * @param path an array of Vector3, the curve axis of the Path3D
  4701. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  4702. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  4703. */
  4704. constructor(
  4705. /**
  4706. * an array of Vector3, the curve axis of the Path3D
  4707. */
  4708. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  4709. /**
  4710. * Returns the Path3D array of successive Vector3 designing its curve.
  4711. * @returns the Path3D array of successive Vector3 designing its curve.
  4712. */
  4713. getCurve(): Vector3[];
  4714. /**
  4715. * Returns an array populated with tangent vectors on each Path3D curve point.
  4716. * @returns an array populated with tangent vectors on each Path3D curve point.
  4717. */
  4718. getTangents(): Vector3[];
  4719. /**
  4720. * Returns an array populated with normal vectors on each Path3D curve point.
  4721. * @returns an array populated with normal vectors on each Path3D curve point.
  4722. */
  4723. getNormals(): Vector3[];
  4724. /**
  4725. * Returns an array populated with binormal vectors on each Path3D curve point.
  4726. * @returns an array populated with binormal vectors on each Path3D curve point.
  4727. */
  4728. getBinormals(): Vector3[];
  4729. /**
  4730. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  4731. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  4732. */
  4733. getDistances(): number[];
  4734. /**
  4735. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  4736. * @param path path which all values are copied into the curves points
  4737. * @param firstNormal which should be projected onto the curve
  4738. * @returns the same object updated.
  4739. */
  4740. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  4741. private _compute;
  4742. private _getFirstNonNullVector;
  4743. private _getLastNonNullVector;
  4744. private _normalVector;
  4745. }
  4746. /**
  4747. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4748. * A Curve3 is designed from a series of successive Vector3.
  4749. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  4750. */
  4751. export class Curve3 {
  4752. private _points;
  4753. private _length;
  4754. /**
  4755. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  4756. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  4757. * @param v1 (Vector3) the control point
  4758. * @param v2 (Vector3) the end point of the Quadratic Bezier
  4759. * @param nbPoints (integer) the wanted number of points in the curve
  4760. * @returns the created Curve3
  4761. */
  4762. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4763. /**
  4764. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  4765. * @param v0 (Vector3) the origin point of the Cubic Bezier
  4766. * @param v1 (Vector3) the first control point
  4767. * @param v2 (Vector3) the second control point
  4768. * @param v3 (Vector3) the end point of the Cubic Bezier
  4769. * @param nbPoints (integer) the wanted number of points in the curve
  4770. * @returns the created Curve3
  4771. */
  4772. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4773. /**
  4774. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  4775. * @param p1 (Vector3) the origin point of the Hermite Spline
  4776. * @param t1 (Vector3) the tangent vector at the origin point
  4777. * @param p2 (Vector3) the end point of the Hermite Spline
  4778. * @param t2 (Vector3) the tangent vector at the end point
  4779. * @param nbPoints (integer) the wanted number of points in the curve
  4780. * @returns the created Curve3
  4781. */
  4782. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4783. /**
  4784. * Returns a Curve3 object along a CatmullRom Spline curve :
  4785. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  4786. * @param nbPoints (integer) the wanted number of points between each curve control points
  4787. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  4788. * @returns the created Curve3
  4789. */
  4790. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  4791. /**
  4792. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4793. * A Curve3 is designed from a series of successive Vector3.
  4794. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  4795. * @param points points which make up the curve
  4796. */
  4797. constructor(points: Vector3[]);
  4798. /**
  4799. * @returns the Curve3 stored array of successive Vector3
  4800. */
  4801. getPoints(): Vector3[];
  4802. /**
  4803. * @returns the computed length (float) of the curve.
  4804. */
  4805. length(): number;
  4806. /**
  4807. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  4808. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  4809. * curveA and curveB keep unchanged.
  4810. * @param curve the curve to continue from this curve
  4811. * @returns the newly constructed curve
  4812. */
  4813. continue(curve: DeepImmutable<Curve3>): Curve3;
  4814. private _computeLength;
  4815. }
  4816. }
  4817. declare module BABYLON {
  4818. /**
  4819. * This represents the main contract an easing function should follow.
  4820. * Easing functions are used throughout the animation system.
  4821. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4822. */
  4823. export interface IEasingFunction {
  4824. /**
  4825. * Given an input gradient between 0 and 1, this returns the corrseponding value
  4826. * of the easing function.
  4827. * The link below provides some of the most common examples of easing functions.
  4828. * @see https://easings.net/
  4829. * @param gradient Defines the value between 0 and 1 we want the easing value for
  4830. * @returns the corresponding value on the curve defined by the easing function
  4831. */
  4832. ease(gradient: number): number;
  4833. }
  4834. /**
  4835. * Base class used for every default easing function.
  4836. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4837. */
  4838. export class EasingFunction implements IEasingFunction {
  4839. /**
  4840. * Interpolation follows the mathematical formula associated with the easing function.
  4841. */
  4842. static readonly EASINGMODE_EASEIN: number;
  4843. /**
  4844. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  4845. */
  4846. static readonly EASINGMODE_EASEOUT: number;
  4847. /**
  4848. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  4849. */
  4850. static readonly EASINGMODE_EASEINOUT: number;
  4851. private _easingMode;
  4852. /**
  4853. * Sets the easing mode of the current function.
  4854. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  4855. */
  4856. setEasingMode(easingMode: number): void;
  4857. /**
  4858. * Gets the current easing mode.
  4859. * @returns the easing mode
  4860. */
  4861. getEasingMode(): number;
  4862. /**
  4863. * @hidden
  4864. */
  4865. easeInCore(gradient: number): number;
  4866. /**
  4867. * Given an input gradient between 0 and 1, this returns the corresponding value
  4868. * of the easing function.
  4869. * @param gradient Defines the value between 0 and 1 we want the easing value for
  4870. * @returns the corresponding value on the curve defined by the easing function
  4871. */
  4872. ease(gradient: number): number;
  4873. }
  4874. /**
  4875. * Easing function with a circle shape (see link below).
  4876. * @see https://easings.net/#easeInCirc
  4877. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4878. */
  4879. export class CircleEase extends EasingFunction implements IEasingFunction {
  4880. /** @hidden */
  4881. easeInCore(gradient: number): number;
  4882. }
  4883. /**
  4884. * Easing function with a ease back shape (see link below).
  4885. * @see https://easings.net/#easeInBack
  4886. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4887. */
  4888. export class BackEase extends EasingFunction implements IEasingFunction {
  4889. /** Defines the amplitude of the function */
  4890. amplitude: number;
  4891. /**
  4892. * Instantiates a back ease easing
  4893. * @see https://easings.net/#easeInBack
  4894. * @param amplitude Defines the amplitude of the function
  4895. */
  4896. constructor(
  4897. /** Defines the amplitude of the function */
  4898. amplitude?: number);
  4899. /** @hidden */
  4900. easeInCore(gradient: number): number;
  4901. }
  4902. /**
  4903. * Easing function with a bouncing shape (see link below).
  4904. * @see https://easings.net/#easeInBounce
  4905. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4906. */
  4907. export class BounceEase extends EasingFunction implements IEasingFunction {
  4908. /** Defines the number of bounces */
  4909. bounces: number;
  4910. /** Defines the amplitude of the bounce */
  4911. bounciness: number;
  4912. /**
  4913. * Instantiates a bounce easing
  4914. * @see https://easings.net/#easeInBounce
  4915. * @param bounces Defines the number of bounces
  4916. * @param bounciness Defines the amplitude of the bounce
  4917. */
  4918. constructor(
  4919. /** Defines the number of bounces */
  4920. bounces?: number,
  4921. /** Defines the amplitude of the bounce */
  4922. bounciness?: number);
  4923. /** @hidden */
  4924. easeInCore(gradient: number): number;
  4925. }
  4926. /**
  4927. * Easing function with a power of 3 shape (see link below).
  4928. * @see https://easings.net/#easeInCubic
  4929. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4930. */
  4931. export class CubicEase extends EasingFunction implements IEasingFunction {
  4932. /** @hidden */
  4933. easeInCore(gradient: number): number;
  4934. }
  4935. /**
  4936. * Easing function with an elastic shape (see link below).
  4937. * @see https://easings.net/#easeInElastic
  4938. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4939. */
  4940. export class ElasticEase extends EasingFunction implements IEasingFunction {
  4941. /** Defines the number of oscillations*/
  4942. oscillations: number;
  4943. /** Defines the amplitude of the oscillations*/
  4944. springiness: number;
  4945. /**
  4946. * Instantiates an elastic easing function
  4947. * @see https://easings.net/#easeInElastic
  4948. * @param oscillations Defines the number of oscillations
  4949. * @param springiness Defines the amplitude of the oscillations
  4950. */
  4951. constructor(
  4952. /** Defines the number of oscillations*/
  4953. oscillations?: number,
  4954. /** Defines the amplitude of the oscillations*/
  4955. springiness?: number);
  4956. /** @hidden */
  4957. easeInCore(gradient: number): number;
  4958. }
  4959. /**
  4960. * Easing function with an exponential shape (see link below).
  4961. * @see https://easings.net/#easeInExpo
  4962. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4963. */
  4964. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  4965. /** Defines the exponent of the function */
  4966. exponent: number;
  4967. /**
  4968. * Instantiates an exponential easing function
  4969. * @see https://easings.net/#easeInExpo
  4970. * @param exponent Defines the exponent of the function
  4971. */
  4972. constructor(
  4973. /** Defines the exponent of the function */
  4974. exponent?: number);
  4975. /** @hidden */
  4976. easeInCore(gradient: number): number;
  4977. }
  4978. /**
  4979. * Easing function with a power shape (see link below).
  4980. * @see https://easings.net/#easeInQuad
  4981. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4982. */
  4983. export class PowerEase extends EasingFunction implements IEasingFunction {
  4984. /** Defines the power of the function */
  4985. power: number;
  4986. /**
  4987. * Instantiates an power base easing function
  4988. * @see https://easings.net/#easeInQuad
  4989. * @param power Defines the power of the function
  4990. */
  4991. constructor(
  4992. /** Defines the power of the function */
  4993. power?: number);
  4994. /** @hidden */
  4995. easeInCore(gradient: number): number;
  4996. }
  4997. /**
  4998. * Easing function with a power of 2 shape (see link below).
  4999. * @see https://easings.net/#easeInQuad
  5000. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5001. */
  5002. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5003. /** @hidden */
  5004. easeInCore(gradient: number): number;
  5005. }
  5006. /**
  5007. * Easing function with a power of 4 shape (see link below).
  5008. * @see https://easings.net/#easeInQuart
  5009. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5010. */
  5011. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5012. /** @hidden */
  5013. easeInCore(gradient: number): number;
  5014. }
  5015. /**
  5016. * Easing function with a power of 5 shape (see link below).
  5017. * @see https://easings.net/#easeInQuint
  5018. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5019. */
  5020. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5021. /** @hidden */
  5022. easeInCore(gradient: number): number;
  5023. }
  5024. /**
  5025. * Easing function with a sin shape (see link below).
  5026. * @see https://easings.net/#easeInSine
  5027. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5028. */
  5029. export class SineEase extends EasingFunction implements IEasingFunction {
  5030. /** @hidden */
  5031. easeInCore(gradient: number): number;
  5032. }
  5033. /**
  5034. * Easing function with a bezier shape (see link below).
  5035. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5036. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5037. */
  5038. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5039. /** Defines the x component of the start tangent in the bezier curve */
  5040. x1: number;
  5041. /** Defines the y component of the start tangent in the bezier curve */
  5042. y1: number;
  5043. /** Defines the x component of the end tangent in the bezier curve */
  5044. x2: number;
  5045. /** Defines the y component of the end tangent in the bezier curve */
  5046. y2: number;
  5047. /**
  5048. * Instantiates a bezier function
  5049. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5050. * @param x1 Defines the x component of the start tangent in the bezier curve
  5051. * @param y1 Defines the y component of the start tangent in the bezier curve
  5052. * @param x2 Defines the x component of the end tangent in the bezier curve
  5053. * @param y2 Defines the y component of the end tangent in the bezier curve
  5054. */
  5055. constructor(
  5056. /** Defines the x component of the start tangent in the bezier curve */
  5057. x1?: number,
  5058. /** Defines the y component of the start tangent in the bezier curve */
  5059. y1?: number,
  5060. /** Defines the x component of the end tangent in the bezier curve */
  5061. x2?: number,
  5062. /** Defines the y component of the end tangent in the bezier curve */
  5063. y2?: number);
  5064. /** @hidden */
  5065. easeInCore(gradient: number): number;
  5066. }
  5067. }
  5068. declare module BABYLON {
  5069. /**
  5070. * Class used to hold a RBG color
  5071. */
  5072. export class Color3 {
  5073. /**
  5074. * Defines the red component (between 0 and 1, default is 0)
  5075. */
  5076. r: number;
  5077. /**
  5078. * Defines the green component (between 0 and 1, default is 0)
  5079. */
  5080. g: number;
  5081. /**
  5082. * Defines the blue component (between 0 and 1, default is 0)
  5083. */
  5084. b: number;
  5085. /**
  5086. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  5087. * @param r defines the red component (between 0 and 1, default is 0)
  5088. * @param g defines the green component (between 0 and 1, default is 0)
  5089. * @param b defines the blue component (between 0 and 1, default is 0)
  5090. */
  5091. constructor(
  5092. /**
  5093. * Defines the red component (between 0 and 1, default is 0)
  5094. */
  5095. r?: number,
  5096. /**
  5097. * Defines the green component (between 0 and 1, default is 0)
  5098. */
  5099. g?: number,
  5100. /**
  5101. * Defines the blue component (between 0 and 1, default is 0)
  5102. */
  5103. b?: number);
  5104. /**
  5105. * Creates a string with the Color3 current values
  5106. * @returns the string representation of the Color3 object
  5107. */
  5108. toString(): string;
  5109. /**
  5110. * Returns the string "Color3"
  5111. * @returns "Color3"
  5112. */
  5113. getClassName(): string;
  5114. /**
  5115. * Compute the Color3 hash code
  5116. * @returns an unique number that can be used to hash Color3 objects
  5117. */
  5118. getHashCode(): number;
  5119. /**
  5120. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  5121. * @param array defines the array where to store the r,g,b components
  5122. * @param index defines an optional index in the target array to define where to start storing values
  5123. * @returns the current Color3 object
  5124. */
  5125. toArray(array: FloatArray, index?: number): Color3;
  5126. /**
  5127. * Returns a new Color4 object from the current Color3 and the given alpha
  5128. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  5129. * @returns a new Color4 object
  5130. */
  5131. toColor4(alpha?: number): Color4;
  5132. /**
  5133. * Returns a new array populated with 3 numeric elements : red, green and blue values
  5134. * @returns the new array
  5135. */
  5136. asArray(): number[];
  5137. /**
  5138. * Returns the luminance value
  5139. * @returns a float value
  5140. */
  5141. toLuminance(): number;
  5142. /**
  5143. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  5144. * @param otherColor defines the second operand
  5145. * @returns the new Color3 object
  5146. */
  5147. multiply(otherColor: DeepImmutable<Color3>): Color3;
  5148. /**
  5149. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  5150. * @param otherColor defines the second operand
  5151. * @param result defines the Color3 object where to store the result
  5152. * @returns the current Color3
  5153. */
  5154. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5155. /**
  5156. * Determines equality between Color3 objects
  5157. * @param otherColor defines the second operand
  5158. * @returns true if the rgb values are equal to the given ones
  5159. */
  5160. equals(otherColor: DeepImmutable<Color3>): boolean;
  5161. /**
  5162. * Determines equality between the current Color3 object and a set of r,b,g values
  5163. * @param r defines the red component to check
  5164. * @param g defines the green component to check
  5165. * @param b defines the blue component to check
  5166. * @returns true if the rgb values are equal to the given ones
  5167. */
  5168. equalsFloats(r: number, g: number, b: number): boolean;
  5169. /**
  5170. * Multiplies in place each rgb value by scale
  5171. * @param scale defines the scaling factor
  5172. * @returns the updated Color3
  5173. */
  5174. scale(scale: number): Color3;
  5175. /**
  5176. * Multiplies the rgb values by scale and stores the result into "result"
  5177. * @param scale defines the scaling factor
  5178. * @param result defines the Color3 object where to store the result
  5179. * @returns the unmodified current Color3
  5180. */
  5181. scaleToRef(scale: number, result: Color3): Color3;
  5182. /**
  5183. * Scale the current Color3 values by a factor and add the result to a given Color3
  5184. * @param scale defines the scale factor
  5185. * @param result defines color to store the result into
  5186. * @returns the unmodified current Color3
  5187. */
  5188. scaleAndAddToRef(scale: number, result: Color3): Color3;
  5189. /**
  5190. * Clamps the rgb values by the min and max values and stores the result into "result"
  5191. * @param min defines minimum clamping value (default is 0)
  5192. * @param max defines maximum clamping value (default is 1)
  5193. * @param result defines color to store the result into
  5194. * @returns the original Color3
  5195. */
  5196. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  5197. /**
  5198. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  5199. * @param otherColor defines the second operand
  5200. * @returns the new Color3
  5201. */
  5202. add(otherColor: DeepImmutable<Color3>): Color3;
  5203. /**
  5204. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  5205. * @param otherColor defines the second operand
  5206. * @param result defines Color3 object to store the result into
  5207. * @returns the unmodified current Color3
  5208. */
  5209. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5210. /**
  5211. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  5212. * @param otherColor defines the second operand
  5213. * @returns the new Color3
  5214. */
  5215. subtract(otherColor: DeepImmutable<Color3>): Color3;
  5216. /**
  5217. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  5218. * @param otherColor defines the second operand
  5219. * @param result defines Color3 object to store the result into
  5220. * @returns the unmodified current Color3
  5221. */
  5222. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5223. /**
  5224. * Copy the current object
  5225. * @returns a new Color3 copied the current one
  5226. */
  5227. clone(): Color3;
  5228. /**
  5229. * Copies the rgb values from the source in the current Color3
  5230. * @param source defines the source Color3 object
  5231. * @returns the updated Color3 object
  5232. */
  5233. copyFrom(source: DeepImmutable<Color3>): Color3;
  5234. /**
  5235. * Updates the Color3 rgb values from the given floats
  5236. * @param r defines the red component to read from
  5237. * @param g defines the green component to read from
  5238. * @param b defines the blue component to read from
  5239. * @returns the current Color3 object
  5240. */
  5241. copyFromFloats(r: number, g: number, b: number): Color3;
  5242. /**
  5243. * Updates the Color3 rgb values from the given floats
  5244. * @param r defines the red component to read from
  5245. * @param g defines the green component to read from
  5246. * @param b defines the blue component to read from
  5247. * @returns the current Color3 object
  5248. */
  5249. set(r: number, g: number, b: number): Color3;
  5250. /**
  5251. * Compute the Color3 hexadecimal code as a string
  5252. * @returns a string containing the hexadecimal representation of the Color3 object
  5253. */
  5254. toHexString(): string;
  5255. /**
  5256. * Computes a new Color3 converted from the current one to linear space
  5257. * @returns a new Color3 object
  5258. */
  5259. toLinearSpace(): Color3;
  5260. /**
  5261. * Converts current color in rgb space to HSV values
  5262. * @returns a new color3 representing the HSV values
  5263. */
  5264. toHSV(): Color3;
  5265. /**
  5266. * Converts current color in rgb space to HSV values
  5267. * @param result defines the Color3 where to store the HSV values
  5268. */
  5269. toHSVToRef(result: Color3): void;
  5270. /**
  5271. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5272. * @param convertedColor defines the Color3 object where to store the linear space version
  5273. * @returns the unmodified Color3
  5274. */
  5275. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5276. /**
  5277. * Computes a new Color3 converted from the current one to gamma space
  5278. * @returns a new Color3 object
  5279. */
  5280. toGammaSpace(): Color3;
  5281. /**
  5282. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5283. * @param convertedColor defines the Color3 object where to store the gamma space version
  5284. * @returns the unmodified Color3
  5285. */
  5286. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5287. private static _BlackReadOnly;
  5288. /**
  5289. * Convert Hue, saturation and value to a Color3 (RGB)
  5290. * @param hue defines the hue
  5291. * @param saturation defines the saturation
  5292. * @param value defines the value
  5293. * @param result defines the Color3 where to store the RGB values
  5294. */
  5295. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5296. /**
  5297. * Creates a new Color3 from the string containing valid hexadecimal values
  5298. * @param hex defines a string containing valid hexadecimal values
  5299. * @returns a new Color3 object
  5300. */
  5301. static FromHexString(hex: string): Color3;
  5302. /**
  5303. * Creates a new Color3 from the starting index of the given array
  5304. * @param array defines the source array
  5305. * @param offset defines an offset in the source array
  5306. * @returns a new Color3 object
  5307. */
  5308. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5309. /**
  5310. * Creates a new Color3 from integer values (< 256)
  5311. * @param r defines the red component to read from (value between 0 and 255)
  5312. * @param g defines the green component to read from (value between 0 and 255)
  5313. * @param b defines the blue component to read from (value between 0 and 255)
  5314. * @returns a new Color3 object
  5315. */
  5316. static FromInts(r: number, g: number, b: number): Color3;
  5317. /**
  5318. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5319. * @param start defines the start Color3 value
  5320. * @param end defines the end Color3 value
  5321. * @param amount defines the gradient value between start and end
  5322. * @returns a new Color3 object
  5323. */
  5324. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5325. /**
  5326. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5327. * @param left defines the start value
  5328. * @param right defines the end value
  5329. * @param amount defines the gradient factor
  5330. * @param result defines the Color3 object where to store the result
  5331. */
  5332. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5333. /**
  5334. * Returns a Color3 value containing a red color
  5335. * @returns a new Color3 object
  5336. */
  5337. static Red(): Color3;
  5338. /**
  5339. * Returns a Color3 value containing a green color
  5340. * @returns a new Color3 object
  5341. */
  5342. static Green(): Color3;
  5343. /**
  5344. * Returns a Color3 value containing a blue color
  5345. * @returns a new Color3 object
  5346. */
  5347. static Blue(): Color3;
  5348. /**
  5349. * Returns a Color3 value containing a black color
  5350. * @returns a new Color3 object
  5351. */
  5352. static Black(): Color3;
  5353. /**
  5354. * Gets a Color3 value containing a black color that must not be updated
  5355. */
  5356. static readonly BlackReadOnly: DeepImmutable<Color3>;
  5357. /**
  5358. * Returns a Color3 value containing a white color
  5359. * @returns a new Color3 object
  5360. */
  5361. static White(): Color3;
  5362. /**
  5363. * Returns a Color3 value containing a purple color
  5364. * @returns a new Color3 object
  5365. */
  5366. static Purple(): Color3;
  5367. /**
  5368. * Returns a Color3 value containing a magenta color
  5369. * @returns a new Color3 object
  5370. */
  5371. static Magenta(): Color3;
  5372. /**
  5373. * Returns a Color3 value containing a yellow color
  5374. * @returns a new Color3 object
  5375. */
  5376. static Yellow(): Color3;
  5377. /**
  5378. * Returns a Color3 value containing a gray color
  5379. * @returns a new Color3 object
  5380. */
  5381. static Gray(): Color3;
  5382. /**
  5383. * Returns a Color3 value containing a teal color
  5384. * @returns a new Color3 object
  5385. */
  5386. static Teal(): Color3;
  5387. /**
  5388. * Returns a Color3 value containing a random color
  5389. * @returns a new Color3 object
  5390. */
  5391. static Random(): Color3;
  5392. }
  5393. /**
  5394. * Class used to hold a RBGA color
  5395. */
  5396. export class Color4 {
  5397. /**
  5398. * Defines the red component (between 0 and 1, default is 0)
  5399. */
  5400. r: number;
  5401. /**
  5402. * Defines the green component (between 0 and 1, default is 0)
  5403. */
  5404. g: number;
  5405. /**
  5406. * Defines the blue component (between 0 and 1, default is 0)
  5407. */
  5408. b: number;
  5409. /**
  5410. * Defines the alpha component (between 0 and 1, default is 1)
  5411. */
  5412. a: number;
  5413. /**
  5414. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5415. * @param r defines the red component (between 0 and 1, default is 0)
  5416. * @param g defines the green component (between 0 and 1, default is 0)
  5417. * @param b defines the blue component (between 0 and 1, default is 0)
  5418. * @param a defines the alpha component (between 0 and 1, default is 1)
  5419. */
  5420. constructor(
  5421. /**
  5422. * Defines the red component (between 0 and 1, default is 0)
  5423. */
  5424. r?: number,
  5425. /**
  5426. * Defines the green component (between 0 and 1, default is 0)
  5427. */
  5428. g?: number,
  5429. /**
  5430. * Defines the blue component (between 0 and 1, default is 0)
  5431. */
  5432. b?: number,
  5433. /**
  5434. * Defines the alpha component (between 0 and 1, default is 1)
  5435. */
  5436. a?: number);
  5437. /**
  5438. * Adds in place the given Color4 values to the current Color4 object
  5439. * @param right defines the second operand
  5440. * @returns the current updated Color4 object
  5441. */
  5442. addInPlace(right: DeepImmutable<Color4>): Color4;
  5443. /**
  5444. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5445. * @returns the new array
  5446. */
  5447. asArray(): number[];
  5448. /**
  5449. * Stores from the starting index in the given array the Color4 successive values
  5450. * @param array defines the array where to store the r,g,b components
  5451. * @param index defines an optional index in the target array to define where to start storing values
  5452. * @returns the current Color4 object
  5453. */
  5454. toArray(array: number[], index?: number): Color4;
  5455. /**
  5456. * Determines equality between Color4 objects
  5457. * @param otherColor defines the second operand
  5458. * @returns true if the rgba values are equal to the given ones
  5459. */
  5460. equals(otherColor: DeepImmutable<Color4>): boolean;
  5461. /**
  5462. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5463. * @param right defines the second operand
  5464. * @returns a new Color4 object
  5465. */
  5466. add(right: DeepImmutable<Color4>): Color4;
  5467. /**
  5468. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5469. * @param right defines the second operand
  5470. * @returns a new Color4 object
  5471. */
  5472. subtract(right: DeepImmutable<Color4>): Color4;
  5473. /**
  5474. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5475. * @param right defines the second operand
  5476. * @param result defines the Color4 object where to store the result
  5477. * @returns the current Color4 object
  5478. */
  5479. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5480. /**
  5481. * Creates a new Color4 with the current Color4 values multiplied by scale
  5482. * @param scale defines the scaling factor to apply
  5483. * @returns a new Color4 object
  5484. */
  5485. scale(scale: number): Color4;
  5486. /**
  5487. * Multiplies the current Color4 values by scale and stores the result in "result"
  5488. * @param scale defines the scaling factor to apply
  5489. * @param result defines the Color4 object where to store the result
  5490. * @returns the current unmodified Color4
  5491. */
  5492. scaleToRef(scale: number, result: Color4): Color4;
  5493. /**
  5494. * Scale the current Color4 values by a factor and add the result to a given Color4
  5495. * @param scale defines the scale factor
  5496. * @param result defines the Color4 object where to store the result
  5497. * @returns the unmodified current Color4
  5498. */
  5499. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5500. /**
  5501. * Clamps the rgb values by the min and max values and stores the result into "result"
  5502. * @param min defines minimum clamping value (default is 0)
  5503. * @param max defines maximum clamping value (default is 1)
  5504. * @param result defines color to store the result into.
  5505. * @returns the cuurent Color4
  5506. */
  5507. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5508. /**
  5509. * Multipy an Color4 value by another and return a new Color4 object
  5510. * @param color defines the Color4 value to multiply by
  5511. * @returns a new Color4 object
  5512. */
  5513. multiply(color: Color4): Color4;
  5514. /**
  5515. * Multipy a Color4 value by another and push the result in a reference value
  5516. * @param color defines the Color4 value to multiply by
  5517. * @param result defines the Color4 to fill the result in
  5518. * @returns the result Color4
  5519. */
  5520. multiplyToRef(color: Color4, result: Color4): Color4;
  5521. /**
  5522. * Creates a string with the Color4 current values
  5523. * @returns the string representation of the Color4 object
  5524. */
  5525. toString(): string;
  5526. /**
  5527. * Returns the string "Color4"
  5528. * @returns "Color4"
  5529. */
  5530. getClassName(): string;
  5531. /**
  5532. * Compute the Color4 hash code
  5533. * @returns an unique number that can be used to hash Color4 objects
  5534. */
  5535. getHashCode(): number;
  5536. /**
  5537. * Creates a new Color4 copied from the current one
  5538. * @returns a new Color4 object
  5539. */
  5540. clone(): Color4;
  5541. /**
  5542. * Copies the given Color4 values into the current one
  5543. * @param source defines the source Color4 object
  5544. * @returns the current updated Color4 object
  5545. */
  5546. copyFrom(source: Color4): Color4;
  5547. /**
  5548. * Copies the given float values into the current one
  5549. * @param r defines the red component to read from
  5550. * @param g defines the green component to read from
  5551. * @param b defines the blue component to read from
  5552. * @param a defines the alpha component to read from
  5553. * @returns the current updated Color4 object
  5554. */
  5555. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  5556. /**
  5557. * Copies the given float values into the current one
  5558. * @param r defines the red component to read from
  5559. * @param g defines the green component to read from
  5560. * @param b defines the blue component to read from
  5561. * @param a defines the alpha component to read from
  5562. * @returns the current updated Color4 object
  5563. */
  5564. set(r: number, g: number, b: number, a: number): Color4;
  5565. /**
  5566. * Compute the Color4 hexadecimal code as a string
  5567. * @returns a string containing the hexadecimal representation of the Color4 object
  5568. */
  5569. toHexString(): string;
  5570. /**
  5571. * Computes a new Color4 converted from the current one to linear space
  5572. * @returns a new Color4 object
  5573. */
  5574. toLinearSpace(): Color4;
  5575. /**
  5576. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  5577. * @param convertedColor defines the Color4 object where to store the linear space version
  5578. * @returns the unmodified Color4
  5579. */
  5580. toLinearSpaceToRef(convertedColor: Color4): Color4;
  5581. /**
  5582. * Computes a new Color4 converted from the current one to gamma space
  5583. * @returns a new Color4 object
  5584. */
  5585. toGammaSpace(): Color4;
  5586. /**
  5587. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  5588. * @param convertedColor defines the Color4 object where to store the gamma space version
  5589. * @returns the unmodified Color4
  5590. */
  5591. toGammaSpaceToRef(convertedColor: Color4): Color4;
  5592. /**
  5593. * Creates a new Color4 from the string containing valid hexadecimal values
  5594. * @param hex defines a string containing valid hexadecimal values
  5595. * @returns a new Color4 object
  5596. */
  5597. static FromHexString(hex: string): Color4;
  5598. /**
  5599. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5600. * @param left defines the start value
  5601. * @param right defines the end value
  5602. * @param amount defines the gradient factor
  5603. * @returns a new Color4 object
  5604. */
  5605. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  5606. /**
  5607. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5608. * @param left defines the start value
  5609. * @param right defines the end value
  5610. * @param amount defines the gradient factor
  5611. * @param result defines the Color4 object where to store data
  5612. */
  5613. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  5614. /**
  5615. * Creates a new Color4 from a Color3 and an alpha value
  5616. * @param color3 defines the source Color3 to read from
  5617. * @param alpha defines the alpha component (1.0 by default)
  5618. * @returns a new Color4 object
  5619. */
  5620. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  5621. /**
  5622. * Creates a new Color4 from the starting index element of the given array
  5623. * @param array defines the source array to read from
  5624. * @param offset defines the offset in the source array
  5625. * @returns a new Color4 object
  5626. */
  5627. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5628. /**
  5629. * Creates a new Color3 from integer values (< 256)
  5630. * @param r defines the red component to read from (value between 0 and 255)
  5631. * @param g defines the green component to read from (value between 0 and 255)
  5632. * @param b defines the blue component to read from (value between 0 and 255)
  5633. * @param a defines the alpha component to read from (value between 0 and 255)
  5634. * @returns a new Color3 object
  5635. */
  5636. static FromInts(r: number, g: number, b: number, a: number): Color4;
  5637. /**
  5638. * Check the content of a given array and convert it to an array containing RGBA data
  5639. * If the original array was already containing count * 4 values then it is returned directly
  5640. * @param colors defines the array to check
  5641. * @param count defines the number of RGBA data to expect
  5642. * @returns an array containing count * 4 values (RGBA)
  5643. */
  5644. static CheckColors4(colors: number[], count: number): number[];
  5645. }
  5646. /**
  5647. * @hidden
  5648. */
  5649. export class TmpColors {
  5650. static Color3: Color3[];
  5651. static Color4: Color4[];
  5652. }
  5653. }
  5654. declare module BABYLON {
  5655. /**
  5656. * Defines an interface which represents an animation key frame
  5657. */
  5658. export interface IAnimationKey {
  5659. /**
  5660. * Frame of the key frame
  5661. */
  5662. frame: number;
  5663. /**
  5664. * Value at the specifies key frame
  5665. */
  5666. value: any;
  5667. /**
  5668. * The input tangent for the cubic hermite spline
  5669. */
  5670. inTangent?: any;
  5671. /**
  5672. * The output tangent for the cubic hermite spline
  5673. */
  5674. outTangent?: any;
  5675. /**
  5676. * The animation interpolation type
  5677. */
  5678. interpolation?: AnimationKeyInterpolation;
  5679. }
  5680. /**
  5681. * Enum for the animation key frame interpolation type
  5682. */
  5683. export enum AnimationKeyInterpolation {
  5684. /**
  5685. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  5686. */
  5687. STEP = 1
  5688. }
  5689. }
  5690. declare module BABYLON {
  5691. /**
  5692. * Represents the range of an animation
  5693. */
  5694. export class AnimationRange {
  5695. /**The name of the animation range**/
  5696. name: string;
  5697. /**The starting frame of the animation */
  5698. from: number;
  5699. /**The ending frame of the animation*/
  5700. to: number;
  5701. /**
  5702. * Initializes the range of an animation
  5703. * @param name The name of the animation range
  5704. * @param from The starting frame of the animation
  5705. * @param to The ending frame of the animation
  5706. */
  5707. constructor(
  5708. /**The name of the animation range**/
  5709. name: string,
  5710. /**The starting frame of the animation */
  5711. from: number,
  5712. /**The ending frame of the animation*/
  5713. to: number);
  5714. /**
  5715. * Makes a copy of the animation range
  5716. * @returns A copy of the animation range
  5717. */
  5718. clone(): AnimationRange;
  5719. }
  5720. }
  5721. declare module BABYLON {
  5722. /**
  5723. * Composed of a frame, and an action function
  5724. */
  5725. export class AnimationEvent {
  5726. /** The frame for which the event is triggered **/
  5727. frame: number;
  5728. /** The event to perform when triggered **/
  5729. action: (currentFrame: number) => void;
  5730. /** Specifies if the event should be triggered only once**/
  5731. onlyOnce?: boolean | undefined;
  5732. /**
  5733. * Specifies if the animation event is done
  5734. */
  5735. isDone: boolean;
  5736. /**
  5737. * Initializes the animation event
  5738. * @param frame The frame for which the event is triggered
  5739. * @param action The event to perform when triggered
  5740. * @param onlyOnce Specifies if the event should be triggered only once
  5741. */
  5742. constructor(
  5743. /** The frame for which the event is triggered **/
  5744. frame: number,
  5745. /** The event to perform when triggered **/
  5746. action: (currentFrame: number) => void,
  5747. /** Specifies if the event should be triggered only once**/
  5748. onlyOnce?: boolean | undefined);
  5749. /** @hidden */
  5750. _clone(): AnimationEvent;
  5751. }
  5752. }
  5753. declare module BABYLON {
  5754. /**
  5755. * Interface used to define a behavior
  5756. */
  5757. export interface Behavior<T> {
  5758. /** gets or sets behavior's name */
  5759. name: string;
  5760. /**
  5761. * Function called when the behavior needs to be initialized (after attaching it to a target)
  5762. */
  5763. init(): void;
  5764. /**
  5765. * Called when the behavior is attached to a target
  5766. * @param target defines the target where the behavior is attached to
  5767. */
  5768. attach(target: T): void;
  5769. /**
  5770. * Called when the behavior is detached from its target
  5771. */
  5772. detach(): void;
  5773. }
  5774. /**
  5775. * Interface implemented by classes supporting behaviors
  5776. */
  5777. export interface IBehaviorAware<T> {
  5778. /**
  5779. * Attach a behavior
  5780. * @param behavior defines the behavior to attach
  5781. * @returns the current host
  5782. */
  5783. addBehavior(behavior: Behavior<T>): T;
  5784. /**
  5785. * Remove a behavior from the current object
  5786. * @param behavior defines the behavior to detach
  5787. * @returns the current host
  5788. */
  5789. removeBehavior(behavior: Behavior<T>): T;
  5790. /**
  5791. * Gets a behavior using its name to search
  5792. * @param name defines the name to search
  5793. * @returns the behavior or null if not found
  5794. */
  5795. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  5796. }
  5797. }
  5798. declare module BABYLON {
  5799. /**
  5800. * Defines an array and its length.
  5801. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  5802. */
  5803. export interface ISmartArrayLike<T> {
  5804. /**
  5805. * The data of the array.
  5806. */
  5807. data: Array<T>;
  5808. /**
  5809. * The active length of the array.
  5810. */
  5811. length: number;
  5812. }
  5813. /**
  5814. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  5815. */
  5816. export class SmartArray<T> implements ISmartArrayLike<T> {
  5817. /**
  5818. * The full set of data from the array.
  5819. */
  5820. data: Array<T>;
  5821. /**
  5822. * The active length of the array.
  5823. */
  5824. length: number;
  5825. protected _id: number;
  5826. /**
  5827. * Instantiates a Smart Array.
  5828. * @param capacity defines the default capacity of the array.
  5829. */
  5830. constructor(capacity: number);
  5831. /**
  5832. * Pushes a value at the end of the active data.
  5833. * @param value defines the object to push in the array.
  5834. */
  5835. push(value: T): void;
  5836. /**
  5837. * Iterates over the active data and apply the lambda to them.
  5838. * @param func defines the action to apply on each value.
  5839. */
  5840. forEach(func: (content: T) => void): void;
  5841. /**
  5842. * Sorts the full sets of data.
  5843. * @param compareFn defines the comparison function to apply.
  5844. */
  5845. sort(compareFn: (a: T, b: T) => number): void;
  5846. /**
  5847. * Resets the active data to an empty array.
  5848. */
  5849. reset(): void;
  5850. /**
  5851. * Releases all the data from the array as well as the array.
  5852. */
  5853. dispose(): void;
  5854. /**
  5855. * Concats the active data with a given array.
  5856. * @param array defines the data to concatenate with.
  5857. */
  5858. concat(array: any): void;
  5859. /**
  5860. * Returns the position of a value in the active data.
  5861. * @param value defines the value to find the index for
  5862. * @returns the index if found in the active data otherwise -1
  5863. */
  5864. indexOf(value: T): number;
  5865. /**
  5866. * Returns whether an element is part of the active data.
  5867. * @param value defines the value to look for
  5868. * @returns true if found in the active data otherwise false
  5869. */
  5870. contains(value: T): boolean;
  5871. private static _GlobalId;
  5872. }
  5873. /**
  5874. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  5875. * The data in this array can only be present once
  5876. */
  5877. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  5878. private _duplicateId;
  5879. /**
  5880. * Pushes a value at the end of the active data.
  5881. * THIS DOES NOT PREVENT DUPPLICATE DATA
  5882. * @param value defines the object to push in the array.
  5883. */
  5884. push(value: T): void;
  5885. /**
  5886. * Pushes a value at the end of the active data.
  5887. * If the data is already present, it won t be added again
  5888. * @param value defines the object to push in the array.
  5889. * @returns true if added false if it was already present
  5890. */
  5891. pushNoDuplicate(value: T): boolean;
  5892. /**
  5893. * Resets the active data to an empty array.
  5894. */
  5895. reset(): void;
  5896. /**
  5897. * Concats the active data with a given array.
  5898. * This ensures no dupplicate will be present in the result.
  5899. * @param array defines the data to concatenate with.
  5900. */
  5901. concatWithNoDuplicate(array: any): void;
  5902. }
  5903. }
  5904. declare module BABYLON {
  5905. /**
  5906. * @ignore
  5907. * This is a list of all the different input types that are available in the application.
  5908. * Fo instance: ArcRotateCameraGamepadInput...
  5909. */
  5910. export var CameraInputTypes: {};
  5911. /**
  5912. * This is the contract to implement in order to create a new input class.
  5913. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  5914. */
  5915. export interface ICameraInput<TCamera extends Camera> {
  5916. /**
  5917. * Defines the camera the input is attached to.
  5918. */
  5919. camera: Nullable<TCamera>;
  5920. /**
  5921. * Gets the class name of the current intput.
  5922. * @returns the class name
  5923. */
  5924. getClassName(): string;
  5925. /**
  5926. * Get the friendly name associated with the input class.
  5927. * @returns the input friendly name
  5928. */
  5929. getSimpleName(): string;
  5930. /**
  5931. * Attach the input controls to a specific dom element to get the input from.
  5932. * @param element Defines the element the controls should be listened from
  5933. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  5934. */
  5935. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  5936. /**
  5937. * Detach the current controls from the specified dom element.
  5938. * @param element Defines the element to stop listening the inputs from
  5939. */
  5940. detachControl(element: Nullable<HTMLElement>): void;
  5941. /**
  5942. * Update the current camera state depending on the inputs that have been used this frame.
  5943. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  5944. */
  5945. checkInputs?: () => void;
  5946. }
  5947. /**
  5948. * Represents a map of input types to input instance or input index to input instance.
  5949. */
  5950. export interface CameraInputsMap<TCamera extends Camera> {
  5951. /**
  5952. * Accessor to the input by input type.
  5953. */
  5954. [name: string]: ICameraInput<TCamera>;
  5955. /**
  5956. * Accessor to the input by input index.
  5957. */
  5958. [idx: number]: ICameraInput<TCamera>;
  5959. }
  5960. /**
  5961. * This represents the input manager used within a camera.
  5962. * It helps dealing with all the different kind of input attached to a camera.
  5963. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  5964. */
  5965. export class CameraInputsManager<TCamera extends Camera> {
  5966. /**
  5967. * Defines the list of inputs attahed to the camera.
  5968. */
  5969. attached: CameraInputsMap<TCamera>;
  5970. /**
  5971. * Defines the dom element the camera is collecting inputs from.
  5972. * This is null if the controls have not been attached.
  5973. */
  5974. attachedElement: Nullable<HTMLElement>;
  5975. /**
  5976. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  5977. */
  5978. noPreventDefault: boolean;
  5979. /**
  5980. * Defined the camera the input manager belongs to.
  5981. */
  5982. camera: TCamera;
  5983. /**
  5984. * Update the current camera state depending on the inputs that have been used this frame.
  5985. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  5986. */
  5987. checkInputs: () => void;
  5988. /**
  5989. * Instantiate a new Camera Input Manager.
  5990. * @param camera Defines the camera the input manager blongs to
  5991. */
  5992. constructor(camera: TCamera);
  5993. /**
  5994. * Add an input method to a camera
  5995. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  5996. * @param input camera input method
  5997. */
  5998. add(input: ICameraInput<TCamera>): void;
  5999. /**
  6000. * Remove a specific input method from a camera
  6001. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6002. * @param inputToRemove camera input method
  6003. */
  6004. remove(inputToRemove: ICameraInput<TCamera>): void;
  6005. /**
  6006. * Remove a specific input type from a camera
  6007. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6008. * @param inputType the type of the input to remove
  6009. */
  6010. removeByType(inputType: string): void;
  6011. private _addCheckInputs;
  6012. /**
  6013. * Attach the input controls to the currently attached dom element to listen the events from.
  6014. * @param input Defines the input to attach
  6015. */
  6016. attachInput(input: ICameraInput<TCamera>): void;
  6017. /**
  6018. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6019. * @param element Defines the dom element to collect the events from
  6020. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6021. */
  6022. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6023. /**
  6024. * Detach the current manager inputs controls from a specific dom element.
  6025. * @param element Defines the dom element to collect the events from
  6026. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6027. */
  6028. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6029. /**
  6030. * Rebuild the dynamic inputCheck function from the current list of
  6031. * defined inputs in the manager.
  6032. */
  6033. rebuildInputCheck(): void;
  6034. /**
  6035. * Remove all attached input methods from a camera
  6036. */
  6037. clear(): void;
  6038. /**
  6039. * Serialize the current input manager attached to a camera.
  6040. * This ensures than once parsed,
  6041. * the input associated to the camera will be identical to the current ones
  6042. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6043. */
  6044. serialize(serializedCamera: any): void;
  6045. /**
  6046. * Parses an input manager serialized JSON to restore the previous list of inputs
  6047. * and states associated to a camera.
  6048. * @param parsedCamera Defines the JSON to parse
  6049. */
  6050. parse(parsedCamera: any): void;
  6051. }
  6052. }
  6053. declare module BABYLON {
  6054. /**
  6055. * Class used to store data that will be store in GPU memory
  6056. */
  6057. export class Buffer {
  6058. private _engine;
  6059. private _buffer;
  6060. /** @hidden */
  6061. _data: Nullable<DataArray>;
  6062. private _updatable;
  6063. private _instanced;
  6064. /**
  6065. * Gets the byte stride.
  6066. */
  6067. readonly byteStride: number;
  6068. /**
  6069. * Constructor
  6070. * @param engine the engine
  6071. * @param data the data to use for this buffer
  6072. * @param updatable whether the data is updatable
  6073. * @param stride the stride (optional)
  6074. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6075. * @param instanced whether the buffer is instanced (optional)
  6076. * @param useBytes set to true if the stride in in bytes (optional)
  6077. */
  6078. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  6079. /**
  6080. * Create a new VertexBuffer based on the current buffer
  6081. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6082. * @param offset defines offset in the buffer (0 by default)
  6083. * @param size defines the size in floats of attributes (position is 3 for instance)
  6084. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6085. * @param instanced defines if the vertex buffer contains indexed data
  6086. * @param useBytes defines if the offset and stride are in bytes
  6087. * @returns the new vertex buffer
  6088. */
  6089. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  6090. /**
  6091. * Gets a boolean indicating if the Buffer is updatable?
  6092. * @returns true if the buffer is updatable
  6093. */
  6094. isUpdatable(): boolean;
  6095. /**
  6096. * Gets current buffer's data
  6097. * @returns a DataArray or null
  6098. */
  6099. getData(): Nullable<DataArray>;
  6100. /**
  6101. * Gets underlying native buffer
  6102. * @returns underlying native buffer
  6103. */
  6104. getBuffer(): Nullable<DataBuffer>;
  6105. /**
  6106. * Gets the stride in float32 units (i.e. byte stride / 4).
  6107. * May not be an integer if the byte stride is not divisible by 4.
  6108. * DEPRECATED. Use byteStride instead.
  6109. * @returns the stride in float32 units
  6110. */
  6111. getStrideSize(): number;
  6112. /**
  6113. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6114. * @param data defines the data to store
  6115. */
  6116. create(data?: Nullable<DataArray>): void;
  6117. /** @hidden */
  6118. _rebuild(): void;
  6119. /**
  6120. * Update current buffer data
  6121. * @param data defines the data to store
  6122. */
  6123. update(data: DataArray): void;
  6124. /**
  6125. * Updates the data directly.
  6126. * @param data the new data
  6127. * @param offset the new offset
  6128. * @param vertexCount the vertex count (optional)
  6129. * @param useBytes set to true if the offset is in bytes
  6130. */
  6131. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6132. /**
  6133. * Release all resources
  6134. */
  6135. dispose(): void;
  6136. }
  6137. /**
  6138. * Specialized buffer used to store vertex data
  6139. */
  6140. export class VertexBuffer {
  6141. /** @hidden */
  6142. _buffer: Buffer;
  6143. private _kind;
  6144. private _size;
  6145. private _ownsBuffer;
  6146. private _instanced;
  6147. private _instanceDivisor;
  6148. /**
  6149. * The byte type.
  6150. */
  6151. static readonly BYTE: number;
  6152. /**
  6153. * The unsigned byte type.
  6154. */
  6155. static readonly UNSIGNED_BYTE: number;
  6156. /**
  6157. * The short type.
  6158. */
  6159. static readonly SHORT: number;
  6160. /**
  6161. * The unsigned short type.
  6162. */
  6163. static readonly UNSIGNED_SHORT: number;
  6164. /**
  6165. * The integer type.
  6166. */
  6167. static readonly INT: number;
  6168. /**
  6169. * The unsigned integer type.
  6170. */
  6171. static readonly UNSIGNED_INT: number;
  6172. /**
  6173. * The float type.
  6174. */
  6175. static readonly FLOAT: number;
  6176. /**
  6177. * Gets or sets the instance divisor when in instanced mode
  6178. */
  6179. instanceDivisor: number;
  6180. /**
  6181. * Gets the byte stride.
  6182. */
  6183. readonly byteStride: number;
  6184. /**
  6185. * Gets the byte offset.
  6186. */
  6187. readonly byteOffset: number;
  6188. /**
  6189. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6190. */
  6191. readonly normalized: boolean;
  6192. /**
  6193. * Gets the data type of each component in the array.
  6194. */
  6195. readonly type: number;
  6196. /**
  6197. * Constructor
  6198. * @param engine the engine
  6199. * @param data the data to use for this vertex buffer
  6200. * @param kind the vertex buffer kind
  6201. * @param updatable whether the data is updatable
  6202. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6203. * @param stride the stride (optional)
  6204. * @param instanced whether the buffer is instanced (optional)
  6205. * @param offset the offset of the data (optional)
  6206. * @param size the number of components (optional)
  6207. * @param type the type of the component (optional)
  6208. * @param normalized whether the data contains normalized data (optional)
  6209. * @param useBytes set to true if stride and offset are in bytes (optional)
  6210. */
  6211. 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);
  6212. /** @hidden */
  6213. _rebuild(): void;
  6214. /**
  6215. * Returns the kind of the VertexBuffer (string)
  6216. * @returns a string
  6217. */
  6218. getKind(): string;
  6219. /**
  6220. * Gets a boolean indicating if the VertexBuffer is updatable?
  6221. * @returns true if the buffer is updatable
  6222. */
  6223. isUpdatable(): boolean;
  6224. /**
  6225. * Gets current buffer's data
  6226. * @returns a DataArray or null
  6227. */
  6228. getData(): Nullable<DataArray>;
  6229. /**
  6230. * Gets underlying native buffer
  6231. * @returns underlying native buffer
  6232. */
  6233. getBuffer(): Nullable<DataBuffer>;
  6234. /**
  6235. * Gets the stride in float32 units (i.e. byte stride / 4).
  6236. * May not be an integer if the byte stride is not divisible by 4.
  6237. * DEPRECATED. Use byteStride instead.
  6238. * @returns the stride in float32 units
  6239. */
  6240. getStrideSize(): number;
  6241. /**
  6242. * Returns the offset as a multiple of the type byte length.
  6243. * DEPRECATED. Use byteOffset instead.
  6244. * @returns the offset in bytes
  6245. */
  6246. getOffset(): number;
  6247. /**
  6248. * Returns the number of components per vertex attribute (integer)
  6249. * @returns the size in float
  6250. */
  6251. getSize(): number;
  6252. /**
  6253. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6254. * @returns true if this buffer is instanced
  6255. */
  6256. getIsInstanced(): boolean;
  6257. /**
  6258. * Returns the instancing divisor, zero for non-instanced (integer).
  6259. * @returns a number
  6260. */
  6261. getInstanceDivisor(): number;
  6262. /**
  6263. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6264. * @param data defines the data to store
  6265. */
  6266. create(data?: DataArray): void;
  6267. /**
  6268. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6269. * This function will create a new buffer if the current one is not updatable
  6270. * @param data defines the data to store
  6271. */
  6272. update(data: DataArray): void;
  6273. /**
  6274. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6275. * Returns the directly updated WebGLBuffer.
  6276. * @param data the new data
  6277. * @param offset the new offset
  6278. * @param useBytes set to true if the offset is in bytes
  6279. */
  6280. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6281. /**
  6282. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6283. */
  6284. dispose(): void;
  6285. /**
  6286. * Enumerates each value of this vertex buffer as numbers.
  6287. * @param count the number of values to enumerate
  6288. * @param callback the callback function called for each value
  6289. */
  6290. forEach(count: number, callback: (value: number, index: number) => void): void;
  6291. /**
  6292. * Positions
  6293. */
  6294. static readonly PositionKind: string;
  6295. /**
  6296. * Normals
  6297. */
  6298. static readonly NormalKind: string;
  6299. /**
  6300. * Tangents
  6301. */
  6302. static readonly TangentKind: string;
  6303. /**
  6304. * Texture coordinates
  6305. */
  6306. static readonly UVKind: string;
  6307. /**
  6308. * Texture coordinates 2
  6309. */
  6310. static readonly UV2Kind: string;
  6311. /**
  6312. * Texture coordinates 3
  6313. */
  6314. static readonly UV3Kind: string;
  6315. /**
  6316. * Texture coordinates 4
  6317. */
  6318. static readonly UV4Kind: string;
  6319. /**
  6320. * Texture coordinates 5
  6321. */
  6322. static readonly UV5Kind: string;
  6323. /**
  6324. * Texture coordinates 6
  6325. */
  6326. static readonly UV6Kind: string;
  6327. /**
  6328. * Colors
  6329. */
  6330. static readonly ColorKind: string;
  6331. /**
  6332. * Matrix indices (for bones)
  6333. */
  6334. static readonly MatricesIndicesKind: string;
  6335. /**
  6336. * Matrix weights (for bones)
  6337. */
  6338. static readonly MatricesWeightsKind: string;
  6339. /**
  6340. * Additional matrix indices (for bones)
  6341. */
  6342. static readonly MatricesIndicesExtraKind: string;
  6343. /**
  6344. * Additional matrix weights (for bones)
  6345. */
  6346. static readonly MatricesWeightsExtraKind: string;
  6347. /**
  6348. * Deduces the stride given a kind.
  6349. * @param kind The kind string to deduce
  6350. * @returns The deduced stride
  6351. */
  6352. static DeduceStride(kind: string): number;
  6353. /**
  6354. * Gets the byte length of the given type.
  6355. * @param type the type
  6356. * @returns the number of bytes
  6357. */
  6358. static GetTypeByteLength(type: number): number;
  6359. /**
  6360. * Enumerates each value of the given parameters as numbers.
  6361. * @param data the data to enumerate
  6362. * @param byteOffset the byte offset of the data
  6363. * @param byteStride the byte stride of the data
  6364. * @param componentCount the number of components per element
  6365. * @param componentType the type of the component
  6366. * @param count the number of values to enumerate
  6367. * @param normalized whether the data is normalized
  6368. * @param callback the callback function called for each value
  6369. */
  6370. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6371. private static _GetFloatValue;
  6372. }
  6373. }
  6374. declare module BABYLON {
  6375. /**
  6376. * @hidden
  6377. */
  6378. export class IntersectionInfo {
  6379. bu: Nullable<number>;
  6380. bv: Nullable<number>;
  6381. distance: number;
  6382. faceId: number;
  6383. subMeshId: number;
  6384. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6385. }
  6386. }
  6387. declare module BABYLON {
  6388. /**
  6389. * Represens a plane by the equation ax + by + cz + d = 0
  6390. */
  6391. export class Plane {
  6392. private static _TmpMatrix;
  6393. /**
  6394. * Normal of the plane (a,b,c)
  6395. */
  6396. normal: Vector3;
  6397. /**
  6398. * d component of the plane
  6399. */
  6400. d: number;
  6401. /**
  6402. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  6403. * @param a a component of the plane
  6404. * @param b b component of the plane
  6405. * @param c c component of the plane
  6406. * @param d d component of the plane
  6407. */
  6408. constructor(a: number, b: number, c: number, d: number);
  6409. /**
  6410. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  6411. */
  6412. asArray(): number[];
  6413. /**
  6414. * @returns a new plane copied from the current Plane.
  6415. */
  6416. clone(): Plane;
  6417. /**
  6418. * @returns the string "Plane".
  6419. */
  6420. getClassName(): string;
  6421. /**
  6422. * @returns the Plane hash code.
  6423. */
  6424. getHashCode(): number;
  6425. /**
  6426. * Normalize the current Plane in place.
  6427. * @returns the updated Plane.
  6428. */
  6429. normalize(): Plane;
  6430. /**
  6431. * Applies a transformation the plane and returns the result
  6432. * @param transformation the transformation matrix to be applied to the plane
  6433. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  6434. */
  6435. transform(transformation: DeepImmutable<Matrix>): Plane;
  6436. /**
  6437. * Calcualtte the dot product between the point and the plane normal
  6438. * @param point point to calculate the dot product with
  6439. * @returns the dot product (float) of the point coordinates and the plane normal.
  6440. */
  6441. dotCoordinate(point: DeepImmutable<Vector3>): number;
  6442. /**
  6443. * Updates the current Plane from the plane defined by the three given points.
  6444. * @param point1 one of the points used to contruct the plane
  6445. * @param point2 one of the points used to contruct the plane
  6446. * @param point3 one of the points used to contruct the plane
  6447. * @returns the updated Plane.
  6448. */
  6449. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6450. /**
  6451. * Checks if the plane is facing a given direction
  6452. * @param direction the direction to check if the plane is facing
  6453. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  6454. * @returns True is the vector "direction" is the same side than the plane normal.
  6455. */
  6456. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  6457. /**
  6458. * Calculates the distance to a point
  6459. * @param point point to calculate distance to
  6460. * @returns the signed distance (float) from the given point to the Plane.
  6461. */
  6462. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  6463. /**
  6464. * Creates a plane from an array
  6465. * @param array the array to create a plane from
  6466. * @returns a new Plane from the given array.
  6467. */
  6468. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  6469. /**
  6470. * Creates a plane from three points
  6471. * @param point1 point used to create the plane
  6472. * @param point2 point used to create the plane
  6473. * @param point3 point used to create the plane
  6474. * @returns a new Plane defined by the three given points.
  6475. */
  6476. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6477. /**
  6478. * Creates a plane from an origin point and a normal
  6479. * @param origin origin of the plane to be constructed
  6480. * @param normal normal of the plane to be constructed
  6481. * @returns a new Plane the normal vector to this plane at the given origin point.
  6482. * Note : the vector "normal" is updated because normalized.
  6483. */
  6484. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  6485. /**
  6486. * Calculates the distance from a plane and a point
  6487. * @param origin origin of the plane to be constructed
  6488. * @param normal normal of the plane to be constructed
  6489. * @param point point to calculate distance to
  6490. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  6491. */
  6492. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  6493. }
  6494. }
  6495. declare module BABYLON {
  6496. /**
  6497. * Class used to store bounding sphere information
  6498. */
  6499. export class BoundingSphere {
  6500. /**
  6501. * Gets the center of the bounding sphere in local space
  6502. */
  6503. readonly center: Vector3;
  6504. /**
  6505. * Radius of the bounding sphere in local space
  6506. */
  6507. radius: number;
  6508. /**
  6509. * Gets the center of the bounding sphere in world space
  6510. */
  6511. readonly centerWorld: Vector3;
  6512. /**
  6513. * Radius of the bounding sphere in world space
  6514. */
  6515. radiusWorld: number;
  6516. /**
  6517. * Gets the minimum vector in local space
  6518. */
  6519. readonly minimum: Vector3;
  6520. /**
  6521. * Gets the maximum vector in local space
  6522. */
  6523. readonly maximum: Vector3;
  6524. private _worldMatrix;
  6525. private static readonly TmpVector3;
  6526. /**
  6527. * Creates a new bounding sphere
  6528. * @param min defines the minimum vector (in local space)
  6529. * @param max defines the maximum vector (in local space)
  6530. * @param worldMatrix defines the new world matrix
  6531. */
  6532. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6533. /**
  6534. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6535. * @param min defines the new minimum vector (in local space)
  6536. * @param max defines the new maximum vector (in local space)
  6537. * @param worldMatrix defines the new world matrix
  6538. */
  6539. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6540. /**
  6541. * Scale the current bounding sphere by applying a scale factor
  6542. * @param factor defines the scale factor to apply
  6543. * @returns the current bounding box
  6544. */
  6545. scale(factor: number): BoundingSphere;
  6546. /**
  6547. * Gets the world matrix of the bounding box
  6548. * @returns a matrix
  6549. */
  6550. getWorldMatrix(): DeepImmutable<Matrix>;
  6551. /** @hidden */
  6552. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6553. /**
  6554. * Tests if the bounding sphere is intersecting the frustum planes
  6555. * @param frustumPlanes defines the frustum planes to test
  6556. * @returns true if there is an intersection
  6557. */
  6558. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6559. /**
  6560. * Tests if the bounding sphere center is in between the frustum planes.
  6561. * Used for optimistic fast inclusion.
  6562. * @param frustumPlanes defines the frustum planes to test
  6563. * @returns true if the sphere center is in between the frustum planes
  6564. */
  6565. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6566. /**
  6567. * Tests if a point is inside the bounding sphere
  6568. * @param point defines the point to test
  6569. * @returns true if the point is inside the bounding sphere
  6570. */
  6571. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6572. /**
  6573. * Checks if two sphere intersct
  6574. * @param sphere0 sphere 0
  6575. * @param sphere1 sphere 1
  6576. * @returns true if the speres intersect
  6577. */
  6578. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6579. }
  6580. }
  6581. declare module BABYLON {
  6582. /**
  6583. * Class used to store bounding box information
  6584. */
  6585. export class BoundingBox implements ICullable {
  6586. /**
  6587. * Gets the 8 vectors representing the bounding box in local space
  6588. */
  6589. readonly vectors: Vector3[];
  6590. /**
  6591. * Gets the center of the bounding box in local space
  6592. */
  6593. readonly center: Vector3;
  6594. /**
  6595. * Gets the center of the bounding box in world space
  6596. */
  6597. readonly centerWorld: Vector3;
  6598. /**
  6599. * Gets the extend size in local space
  6600. */
  6601. readonly extendSize: Vector3;
  6602. /**
  6603. * Gets the extend size in world space
  6604. */
  6605. readonly extendSizeWorld: Vector3;
  6606. /**
  6607. * Gets the OBB (object bounding box) directions
  6608. */
  6609. readonly directions: Vector3[];
  6610. /**
  6611. * Gets the 8 vectors representing the bounding box in world space
  6612. */
  6613. readonly vectorsWorld: Vector3[];
  6614. /**
  6615. * Gets the minimum vector in world space
  6616. */
  6617. readonly minimumWorld: Vector3;
  6618. /**
  6619. * Gets the maximum vector in world space
  6620. */
  6621. readonly maximumWorld: Vector3;
  6622. /**
  6623. * Gets the minimum vector in local space
  6624. */
  6625. readonly minimum: Vector3;
  6626. /**
  6627. * Gets the maximum vector in local space
  6628. */
  6629. readonly maximum: Vector3;
  6630. private _worldMatrix;
  6631. private static readonly TmpVector3;
  6632. /**
  6633. * @hidden
  6634. */
  6635. _tag: number;
  6636. /**
  6637. * Creates a new bounding box
  6638. * @param min defines the minimum vector (in local space)
  6639. * @param max defines the maximum vector (in local space)
  6640. * @param worldMatrix defines the new world matrix
  6641. */
  6642. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6643. /**
  6644. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6645. * @param min defines the new minimum vector (in local space)
  6646. * @param max defines the new maximum vector (in local space)
  6647. * @param worldMatrix defines the new world matrix
  6648. */
  6649. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6650. /**
  6651. * Scale the current bounding box by applying a scale factor
  6652. * @param factor defines the scale factor to apply
  6653. * @returns the current bounding box
  6654. */
  6655. scale(factor: number): BoundingBox;
  6656. /**
  6657. * Gets the world matrix of the bounding box
  6658. * @returns a matrix
  6659. */
  6660. getWorldMatrix(): DeepImmutable<Matrix>;
  6661. /** @hidden */
  6662. _update(world: DeepImmutable<Matrix>): void;
  6663. /**
  6664. * Tests if the bounding box is intersecting the frustum planes
  6665. * @param frustumPlanes defines the frustum planes to test
  6666. * @returns true if there is an intersection
  6667. */
  6668. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6669. /**
  6670. * Tests if the bounding box is entirely inside the frustum planes
  6671. * @param frustumPlanes defines the frustum planes to test
  6672. * @returns true if there is an inclusion
  6673. */
  6674. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6675. /**
  6676. * Tests if a point is inside the bounding box
  6677. * @param point defines the point to test
  6678. * @returns true if the point is inside the bounding box
  6679. */
  6680. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6681. /**
  6682. * Tests if the bounding box intersects with a bounding sphere
  6683. * @param sphere defines the sphere to test
  6684. * @returns true if there is an intersection
  6685. */
  6686. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  6687. /**
  6688. * Tests if the bounding box intersects with a box defined by a min and max vectors
  6689. * @param min defines the min vector to use
  6690. * @param max defines the max vector to use
  6691. * @returns true if there is an intersection
  6692. */
  6693. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  6694. /**
  6695. * Tests if two bounding boxes are intersections
  6696. * @param box0 defines the first box to test
  6697. * @param box1 defines the second box to test
  6698. * @returns true if there is an intersection
  6699. */
  6700. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  6701. /**
  6702. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  6703. * @param minPoint defines the minimum vector of the bounding box
  6704. * @param maxPoint defines the maximum vector of the bounding box
  6705. * @param sphereCenter defines the sphere center
  6706. * @param sphereRadius defines the sphere radius
  6707. * @returns true if there is an intersection
  6708. */
  6709. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  6710. /**
  6711. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  6712. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6713. * @param frustumPlanes defines the frustum planes to test
  6714. * @return true if there is an inclusion
  6715. */
  6716. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6717. /**
  6718. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  6719. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6720. * @param frustumPlanes defines the frustum planes to test
  6721. * @return true if there is an intersection
  6722. */
  6723. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6724. }
  6725. }
  6726. declare module BABYLON {
  6727. /** @hidden */
  6728. export class Collider {
  6729. /** Define if a collision was found */
  6730. collisionFound: boolean;
  6731. /**
  6732. * Define last intersection point in local space
  6733. */
  6734. intersectionPoint: Vector3;
  6735. /**
  6736. * Define last collided mesh
  6737. */
  6738. collidedMesh: Nullable<AbstractMesh>;
  6739. private _collisionPoint;
  6740. private _planeIntersectionPoint;
  6741. private _tempVector;
  6742. private _tempVector2;
  6743. private _tempVector3;
  6744. private _tempVector4;
  6745. private _edge;
  6746. private _baseToVertex;
  6747. private _destinationPoint;
  6748. private _slidePlaneNormal;
  6749. private _displacementVector;
  6750. /** @hidden */
  6751. _radius: Vector3;
  6752. /** @hidden */
  6753. _retry: number;
  6754. private _velocity;
  6755. private _basePoint;
  6756. private _epsilon;
  6757. /** @hidden */
  6758. _velocityWorldLength: number;
  6759. /** @hidden */
  6760. _basePointWorld: Vector3;
  6761. private _velocityWorld;
  6762. private _normalizedVelocity;
  6763. /** @hidden */
  6764. _initialVelocity: Vector3;
  6765. /** @hidden */
  6766. _initialPosition: Vector3;
  6767. private _nearestDistance;
  6768. private _collisionMask;
  6769. collisionMask: number;
  6770. /**
  6771. * Gets the plane normal used to compute the sliding response (in local space)
  6772. */
  6773. readonly slidePlaneNormal: Vector3;
  6774. /** @hidden */
  6775. _initialize(source: Vector3, dir: Vector3, e: number): void;
  6776. /** @hidden */
  6777. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  6778. /** @hidden */
  6779. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  6780. /** @hidden */
  6781. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  6782. /** @hidden */
  6783. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  6784. /** @hidden */
  6785. _getResponse(pos: Vector3, vel: Vector3): void;
  6786. }
  6787. }
  6788. declare module BABYLON {
  6789. /**
  6790. * Interface for cullable objects
  6791. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  6792. */
  6793. export interface ICullable {
  6794. /**
  6795. * Checks if the object or part of the object is in the frustum
  6796. * @param frustumPlanes Camera near/planes
  6797. * @returns true if the object is in frustum otherwise false
  6798. */
  6799. isInFrustum(frustumPlanes: Plane[]): boolean;
  6800. /**
  6801. * Checks if a cullable object (mesh...) is in the camera frustum
  6802. * Unlike isInFrustum this cheks the full bounding box
  6803. * @param frustumPlanes Camera near/planes
  6804. * @returns true if the object is in frustum otherwise false
  6805. */
  6806. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  6807. }
  6808. /**
  6809. * Info for a bounding data of a mesh
  6810. */
  6811. export class BoundingInfo implements ICullable {
  6812. /**
  6813. * Bounding box for the mesh
  6814. */
  6815. readonly boundingBox: BoundingBox;
  6816. /**
  6817. * Bounding sphere for the mesh
  6818. */
  6819. readonly boundingSphere: BoundingSphere;
  6820. private _isLocked;
  6821. private static readonly TmpVector3;
  6822. /**
  6823. * Constructs bounding info
  6824. * @param minimum min vector of the bounding box/sphere
  6825. * @param maximum max vector of the bounding box/sphere
  6826. * @param worldMatrix defines the new world matrix
  6827. */
  6828. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6829. /**
  6830. * Recreates the entire bounding info from scratch as if we call the constructor in place
  6831. * @param min defines the new minimum vector (in local space)
  6832. * @param max defines the new maximum vector (in local space)
  6833. * @param worldMatrix defines the new world matrix
  6834. */
  6835. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6836. /**
  6837. * min vector of the bounding box/sphere
  6838. */
  6839. readonly minimum: Vector3;
  6840. /**
  6841. * max vector of the bounding box/sphere
  6842. */
  6843. readonly maximum: Vector3;
  6844. /**
  6845. * If the info is locked and won't be updated to avoid perf overhead
  6846. */
  6847. isLocked: boolean;
  6848. /**
  6849. * Updates the bounding sphere and box
  6850. * @param world world matrix to be used to update
  6851. */
  6852. update(world: DeepImmutable<Matrix>): void;
  6853. /**
  6854. * Recreate the bounding info to be centered around a specific point given a specific extend.
  6855. * @param center New center of the bounding info
  6856. * @param extend New extend of the bounding info
  6857. * @returns the current bounding info
  6858. */
  6859. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  6860. /**
  6861. * Scale the current bounding info by applying a scale factor
  6862. * @param factor defines the scale factor to apply
  6863. * @returns the current bounding info
  6864. */
  6865. scale(factor: number): BoundingInfo;
  6866. /**
  6867. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  6868. * @param frustumPlanes defines the frustum to test
  6869. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  6870. * @returns true if the bounding info is in the frustum planes
  6871. */
  6872. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  6873. /**
  6874. * Gets the world distance between the min and max points of the bounding box
  6875. */
  6876. readonly diagonalLength: number;
  6877. /**
  6878. * Checks if a cullable object (mesh...) is in the camera frustum
  6879. * Unlike isInFrustum this cheks the full bounding box
  6880. * @param frustumPlanes Camera near/planes
  6881. * @returns true if the object is in frustum otherwise false
  6882. */
  6883. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6884. /** @hidden */
  6885. _checkCollision(collider: Collider): boolean;
  6886. /**
  6887. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  6888. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  6889. * @param point the point to check intersection with
  6890. * @returns if the point intersects
  6891. */
  6892. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6893. /**
  6894. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  6895. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  6896. * @param boundingInfo the bounding info to check intersection with
  6897. * @param precise if the intersection should be done using OBB
  6898. * @returns if the bounding info intersects
  6899. */
  6900. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  6901. }
  6902. }
  6903. declare module BABYLON {
  6904. /**
  6905. * Extracts minimum and maximum values from a list of indexed positions
  6906. * @param positions defines the positions to use
  6907. * @param indices defines the indices to the positions
  6908. * @param indexStart defines the start index
  6909. * @param indexCount defines the end index
  6910. * @param bias defines bias value to add to the result
  6911. * @return minimum and maximum values
  6912. */
  6913. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  6914. minimum: Vector3;
  6915. maximum: Vector3;
  6916. };
  6917. /**
  6918. * Extracts minimum and maximum values from a list of positions
  6919. * @param positions defines the positions to use
  6920. * @param start defines the start index in the positions array
  6921. * @param count defines the number of positions to handle
  6922. * @param bias defines bias value to add to the result
  6923. * @param stride defines the stride size to use (distance between two positions in the positions array)
  6924. * @return minimum and maximum values
  6925. */
  6926. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  6927. minimum: Vector3;
  6928. maximum: Vector3;
  6929. };
  6930. }
  6931. declare module BABYLON {
  6932. /** @hidden */
  6933. export class WebGLDataBuffer extends DataBuffer {
  6934. private _buffer;
  6935. constructor(resource: WebGLBuffer);
  6936. readonly underlyingResource: any;
  6937. }
  6938. }
  6939. declare module BABYLON {
  6940. /** @hidden */
  6941. export class WebGLPipelineContext implements IPipelineContext {
  6942. engine: ThinEngine;
  6943. program: Nullable<WebGLProgram>;
  6944. context?: WebGLRenderingContext;
  6945. vertexShader?: WebGLShader;
  6946. fragmentShader?: WebGLShader;
  6947. isParallelCompiled: boolean;
  6948. onCompiled?: () => void;
  6949. transformFeedback?: WebGLTransformFeedback | null;
  6950. readonly isAsync: boolean;
  6951. readonly isReady: boolean;
  6952. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  6953. }
  6954. }
  6955. declare module BABYLON {
  6956. interface ThinEngine {
  6957. /**
  6958. * Create an uniform buffer
  6959. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  6960. * @param elements defines the content of the uniform buffer
  6961. * @returns the webGL uniform buffer
  6962. */
  6963. createUniformBuffer(elements: FloatArray): DataBuffer;
  6964. /**
  6965. * Create a dynamic uniform buffer
  6966. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  6967. * @param elements defines the content of the uniform buffer
  6968. * @returns the webGL uniform buffer
  6969. */
  6970. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  6971. /**
  6972. * Update an existing uniform buffer
  6973. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  6974. * @param uniformBuffer defines the target uniform buffer
  6975. * @param elements defines the content to update
  6976. * @param offset defines the offset in the uniform buffer where update should start
  6977. * @param count defines the size of the data to update
  6978. */
  6979. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  6980. /**
  6981. * Bind an uniform buffer to the current webGL context
  6982. * @param buffer defines the buffer to bind
  6983. */
  6984. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  6985. /**
  6986. * Bind a buffer to the current webGL context at a given location
  6987. * @param buffer defines the buffer to bind
  6988. * @param location defines the index where to bind the buffer
  6989. */
  6990. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  6991. /**
  6992. * Bind a specific block at a given index in a specific shader program
  6993. * @param pipelineContext defines the pipeline context to use
  6994. * @param blockName defines the block name
  6995. * @param index defines the index where to bind the block
  6996. */
  6997. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  6998. }
  6999. }
  7000. declare module BABYLON {
  7001. /**
  7002. * Uniform buffer objects.
  7003. *
  7004. * Handles blocks of uniform on the GPU.
  7005. *
  7006. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7007. *
  7008. * For more information, please refer to :
  7009. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7010. */
  7011. export class UniformBuffer {
  7012. private _engine;
  7013. private _buffer;
  7014. private _data;
  7015. private _bufferData;
  7016. private _dynamic?;
  7017. private _uniformLocations;
  7018. private _uniformSizes;
  7019. private _uniformLocationPointer;
  7020. private _needSync;
  7021. private _noUBO;
  7022. private _currentEffect;
  7023. private static _MAX_UNIFORM_SIZE;
  7024. private static _tempBuffer;
  7025. /**
  7026. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7027. * This is dynamic to allow compat with webgl 1 and 2.
  7028. * You will need to pass the name of the uniform as well as the value.
  7029. */
  7030. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7031. /**
  7032. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7033. * This is dynamic to allow compat with webgl 1 and 2.
  7034. * You will need to pass the name of the uniform as well as the value.
  7035. */
  7036. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7037. /**
  7038. * Lambda to Update a single float in a uniform buffer.
  7039. * This is dynamic to allow compat with webgl 1 and 2.
  7040. * You will need to pass the name of the uniform as well as the value.
  7041. */
  7042. updateFloat: (name: string, x: number) => void;
  7043. /**
  7044. * Lambda to Update a vec2 of float in a uniform buffer.
  7045. * This is dynamic to allow compat with webgl 1 and 2.
  7046. * You will need to pass the name of the uniform as well as the value.
  7047. */
  7048. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7049. /**
  7050. * Lambda to Update a vec3 of float in a uniform buffer.
  7051. * This is dynamic to allow compat with webgl 1 and 2.
  7052. * You will need to pass the name of the uniform as well as the value.
  7053. */
  7054. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7055. /**
  7056. * Lambda to Update a vec4 of float in a uniform buffer.
  7057. * This is dynamic to allow compat with webgl 1 and 2.
  7058. * You will need to pass the name of the uniform as well as the value.
  7059. */
  7060. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7061. /**
  7062. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  7063. * This is dynamic to allow compat with webgl 1 and 2.
  7064. * You will need to pass the name of the uniform as well as the value.
  7065. */
  7066. updateMatrix: (name: string, mat: Matrix) => void;
  7067. /**
  7068. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  7069. * This is dynamic to allow compat with webgl 1 and 2.
  7070. * You will need to pass the name of the uniform as well as the value.
  7071. */
  7072. updateVector3: (name: string, vector: Vector3) => void;
  7073. /**
  7074. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7075. * This is dynamic to allow compat with webgl 1 and 2.
  7076. * You will need to pass the name of the uniform as well as the value.
  7077. */
  7078. updateVector4: (name: string, vector: Vector4) => void;
  7079. /**
  7080. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7081. * This is dynamic to allow compat with webgl 1 and 2.
  7082. * You will need to pass the name of the uniform as well as the value.
  7083. */
  7084. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7085. /**
  7086. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7087. * This is dynamic to allow compat with webgl 1 and 2.
  7088. * You will need to pass the name of the uniform as well as the value.
  7089. */
  7090. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7091. /**
  7092. * Instantiates a new Uniform buffer objects.
  7093. *
  7094. * Handles blocks of uniform on the GPU.
  7095. *
  7096. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7097. *
  7098. * For more information, please refer to :
  7099. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7100. * @param engine Define the engine the buffer is associated with
  7101. * @param data Define the data contained in the buffer
  7102. * @param dynamic Define if the buffer is updatable
  7103. */
  7104. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7105. /**
  7106. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7107. * or just falling back on setUniformXXX calls.
  7108. */
  7109. readonly useUbo: boolean;
  7110. /**
  7111. * Indicates if the WebGL underlying uniform buffer is in sync
  7112. * with the javascript cache data.
  7113. */
  7114. readonly isSync: boolean;
  7115. /**
  7116. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7117. * Also, a dynamic UniformBuffer will disable cache verification and always
  7118. * update the underlying WebGL uniform buffer to the GPU.
  7119. * @returns if Dynamic, otherwise false
  7120. */
  7121. isDynamic(): boolean;
  7122. /**
  7123. * The data cache on JS side.
  7124. * @returns the underlying data as a float array
  7125. */
  7126. getData(): Float32Array;
  7127. /**
  7128. * The underlying WebGL Uniform buffer.
  7129. * @returns the webgl buffer
  7130. */
  7131. getBuffer(): Nullable<DataBuffer>;
  7132. /**
  7133. * std140 layout specifies how to align data within an UBO structure.
  7134. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7135. * for specs.
  7136. */
  7137. private _fillAlignment;
  7138. /**
  7139. * Adds an uniform in the buffer.
  7140. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7141. * for the layout to be correct !
  7142. * @param name Name of the uniform, as used in the uniform block in the shader.
  7143. * @param size Data size, or data directly.
  7144. */
  7145. addUniform(name: string, size: number | number[]): void;
  7146. /**
  7147. * Adds a Matrix 4x4 to the uniform buffer.
  7148. * @param name Name of the uniform, as used in the uniform block in the shader.
  7149. * @param mat A 4x4 matrix.
  7150. */
  7151. addMatrix(name: string, mat: Matrix): void;
  7152. /**
  7153. * Adds a vec2 to the uniform buffer.
  7154. * @param name Name of the uniform, as used in the uniform block in the shader.
  7155. * @param x Define the x component value of the vec2
  7156. * @param y Define the y component value of the vec2
  7157. */
  7158. addFloat2(name: string, x: number, y: number): void;
  7159. /**
  7160. * Adds a vec3 to the uniform buffer.
  7161. * @param name Name of the uniform, as used in the uniform block in the shader.
  7162. * @param x Define the x component value of the vec3
  7163. * @param y Define the y component value of the vec3
  7164. * @param z Define the z component value of the vec3
  7165. */
  7166. addFloat3(name: string, x: number, y: number, z: number): void;
  7167. /**
  7168. * Adds a vec3 to the uniform buffer.
  7169. * @param name Name of the uniform, as used in the uniform block in the shader.
  7170. * @param color Define the vec3 from a Color
  7171. */
  7172. addColor3(name: string, color: Color3): void;
  7173. /**
  7174. * Adds a vec4 to the uniform buffer.
  7175. * @param name Name of the uniform, as used in the uniform block in the shader.
  7176. * @param color Define the rgb components from a Color
  7177. * @param alpha Define the a component of the vec4
  7178. */
  7179. addColor4(name: string, color: Color3, alpha: number): void;
  7180. /**
  7181. * Adds a vec3 to the uniform buffer.
  7182. * @param name Name of the uniform, as used in the uniform block in the shader.
  7183. * @param vector Define the vec3 components from a Vector
  7184. */
  7185. addVector3(name: string, vector: Vector3): void;
  7186. /**
  7187. * Adds a Matrix 3x3 to the uniform buffer.
  7188. * @param name Name of the uniform, as used in the uniform block in the shader.
  7189. */
  7190. addMatrix3x3(name: string): void;
  7191. /**
  7192. * Adds a Matrix 2x2 to the uniform buffer.
  7193. * @param name Name of the uniform, as used in the uniform block in the shader.
  7194. */
  7195. addMatrix2x2(name: string): void;
  7196. /**
  7197. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7198. */
  7199. create(): void;
  7200. /** @hidden */
  7201. _rebuild(): void;
  7202. /**
  7203. * Updates the WebGL Uniform Buffer on the GPU.
  7204. * If the `dynamic` flag is set to true, no cache comparison is done.
  7205. * Otherwise, the buffer will be updated only if the cache differs.
  7206. */
  7207. update(): void;
  7208. /**
  7209. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7210. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7211. * @param data Define the flattened data
  7212. * @param size Define the size of the data.
  7213. */
  7214. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7215. private _valueCache;
  7216. private _cacheMatrix;
  7217. private _updateMatrix3x3ForUniform;
  7218. private _updateMatrix3x3ForEffect;
  7219. private _updateMatrix2x2ForEffect;
  7220. private _updateMatrix2x2ForUniform;
  7221. private _updateFloatForEffect;
  7222. private _updateFloatForUniform;
  7223. private _updateFloat2ForEffect;
  7224. private _updateFloat2ForUniform;
  7225. private _updateFloat3ForEffect;
  7226. private _updateFloat3ForUniform;
  7227. private _updateFloat4ForEffect;
  7228. private _updateFloat4ForUniform;
  7229. private _updateMatrixForEffect;
  7230. private _updateMatrixForUniform;
  7231. private _updateVector3ForEffect;
  7232. private _updateVector3ForUniform;
  7233. private _updateVector4ForEffect;
  7234. private _updateVector4ForUniform;
  7235. private _updateColor3ForEffect;
  7236. private _updateColor3ForUniform;
  7237. private _updateColor4ForEffect;
  7238. private _updateColor4ForUniform;
  7239. /**
  7240. * Sets a sampler uniform on the effect.
  7241. * @param name Define the name of the sampler.
  7242. * @param texture Define the texture to set in the sampler
  7243. */
  7244. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7245. /**
  7246. * Directly updates the value of the uniform in the cache AND on the GPU.
  7247. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7248. * @param data Define the flattened data
  7249. */
  7250. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7251. /**
  7252. * Binds this uniform buffer to an effect.
  7253. * @param effect Define the effect to bind the buffer to
  7254. * @param name Name of the uniform block in the shader.
  7255. */
  7256. bindToEffect(effect: Effect, name: string): void;
  7257. /**
  7258. * Disposes the uniform buffer.
  7259. */
  7260. dispose(): void;
  7261. }
  7262. }
  7263. declare module BABYLON {
  7264. /**
  7265. * Enum that determines the text-wrapping mode to use.
  7266. */
  7267. export enum InspectableType {
  7268. /**
  7269. * Checkbox for booleans
  7270. */
  7271. Checkbox = 0,
  7272. /**
  7273. * Sliders for numbers
  7274. */
  7275. Slider = 1,
  7276. /**
  7277. * Vector3
  7278. */
  7279. Vector3 = 2,
  7280. /**
  7281. * Quaternions
  7282. */
  7283. Quaternion = 3,
  7284. /**
  7285. * Color3
  7286. */
  7287. Color3 = 4,
  7288. /**
  7289. * String
  7290. */
  7291. String = 5
  7292. }
  7293. /**
  7294. * Interface used to define custom inspectable properties.
  7295. * This interface is used by the inspector to display custom property grids
  7296. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7297. */
  7298. export interface IInspectable {
  7299. /**
  7300. * Gets the label to display
  7301. */
  7302. label: string;
  7303. /**
  7304. * Gets the name of the property to edit
  7305. */
  7306. propertyName: string;
  7307. /**
  7308. * Gets the type of the editor to use
  7309. */
  7310. type: InspectableType;
  7311. /**
  7312. * Gets the minimum value of the property when using in "slider" mode
  7313. */
  7314. min?: number;
  7315. /**
  7316. * Gets the maximum value of the property when using in "slider" mode
  7317. */
  7318. max?: number;
  7319. /**
  7320. * Gets the setp to use when using in "slider" mode
  7321. */
  7322. step?: number;
  7323. }
  7324. }
  7325. declare module BABYLON {
  7326. /**
  7327. * Class used to provide helper for timing
  7328. */
  7329. export class TimingTools {
  7330. /**
  7331. * Polyfill for setImmediate
  7332. * @param action defines the action to execute after the current execution block
  7333. */
  7334. static SetImmediate(action: () => void): void;
  7335. }
  7336. }
  7337. declare module BABYLON {
  7338. /**
  7339. * Class used to enable instatition of objects by class name
  7340. */
  7341. export class InstantiationTools {
  7342. /**
  7343. * Use this object to register external classes like custom textures or material
  7344. * to allow the laoders to instantiate them
  7345. */
  7346. static RegisteredExternalClasses: {
  7347. [key: string]: Object;
  7348. };
  7349. /**
  7350. * Tries to instantiate a new object from a given class name
  7351. * @param className defines the class name to instantiate
  7352. * @returns the new object or null if the system was not able to do the instantiation
  7353. */
  7354. static Instantiate(className: string): any;
  7355. }
  7356. }
  7357. declare module BABYLON {
  7358. /**
  7359. * Define options used to create a depth texture
  7360. */
  7361. export class DepthTextureCreationOptions {
  7362. /** Specifies whether or not a stencil should be allocated in the texture */
  7363. generateStencil?: boolean;
  7364. /** Specifies whether or not bilinear filtering is enable on the texture */
  7365. bilinearFiltering?: boolean;
  7366. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7367. comparisonFunction?: number;
  7368. /** Specifies if the created texture is a cube texture */
  7369. isCube?: boolean;
  7370. }
  7371. }
  7372. declare module BABYLON {
  7373. interface ThinEngine {
  7374. /**
  7375. * Creates a depth stencil cube texture.
  7376. * This is only available in WebGL 2.
  7377. * @param size The size of face edge in the cube texture.
  7378. * @param options The options defining the cube texture.
  7379. * @returns The cube texture
  7380. */
  7381. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7382. /**
  7383. * Creates a cube texture
  7384. * @param rootUrl defines the url where the files to load is located
  7385. * @param scene defines the current scene
  7386. * @param files defines the list of files to load (1 per face)
  7387. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7388. * @param onLoad defines an optional callback raised when the texture is loaded
  7389. * @param onError defines an optional callback raised if there is an issue to load the texture
  7390. * @param format defines the format of the data
  7391. * @param forcedExtension defines the extension to use to pick the right loader
  7392. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7393. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7394. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7395. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7396. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  7397. * @returns the cube texture as an InternalTexture
  7398. */
  7399. 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;
  7400. /**
  7401. * Creates a cube texture
  7402. * @param rootUrl defines the url where the files to load is located
  7403. * @param scene defines the current scene
  7404. * @param files defines the list of files to load (1 per face)
  7405. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7406. * @param onLoad defines an optional callback raised when the texture is loaded
  7407. * @param onError defines an optional callback raised if there is an issue to load the texture
  7408. * @param format defines the format of the data
  7409. * @param forcedExtension defines the extension to use to pick the right loader
  7410. * @returns the cube texture as an InternalTexture
  7411. */
  7412. 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;
  7413. /**
  7414. * Creates a cube texture
  7415. * @param rootUrl defines the url where the files to load is located
  7416. * @param scene defines the current scene
  7417. * @param files defines the list of files to load (1 per face)
  7418. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7419. * @param onLoad defines an optional callback raised when the texture is loaded
  7420. * @param onError defines an optional callback raised if there is an issue to load the texture
  7421. * @param format defines the format of the data
  7422. * @param forcedExtension defines the extension to use to pick the right loader
  7423. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7424. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7425. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7426. * @returns the cube texture as an InternalTexture
  7427. */
  7428. 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;
  7429. /** @hidden */
  7430. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7431. /** @hidden */
  7432. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7433. /** @hidden */
  7434. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7435. /** @hidden */
  7436. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7437. }
  7438. }
  7439. declare module BABYLON {
  7440. /**
  7441. * Class for creating a cube texture
  7442. */
  7443. export class CubeTexture extends BaseTexture {
  7444. private _delayedOnLoad;
  7445. /**
  7446. * The url of the texture
  7447. */
  7448. url: string;
  7449. /**
  7450. * Gets or sets the center of the bounding box associated with the cube texture.
  7451. * It must define where the camera used to render the texture was set
  7452. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7453. */
  7454. boundingBoxPosition: Vector3;
  7455. private _boundingBoxSize;
  7456. /**
  7457. * Gets or sets the size of the bounding box associated with the cube texture
  7458. * When defined, the cubemap will switch to local mode
  7459. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7460. * @example https://www.babylonjs-playground.com/#RNASML
  7461. */
  7462. /**
  7463. * Returns the bounding box size
  7464. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7465. */
  7466. boundingBoxSize: Vector3;
  7467. protected _rotationY: number;
  7468. /**
  7469. * Sets texture matrix rotation angle around Y axis in radians.
  7470. */
  7471. /**
  7472. * Gets texture matrix rotation angle around Y axis radians.
  7473. */
  7474. rotationY: number;
  7475. /**
  7476. * Are mip maps generated for this texture or not.
  7477. */
  7478. readonly noMipmap: boolean;
  7479. private _noMipmap;
  7480. private _files;
  7481. protected _forcedExtension: Nullable<string>;
  7482. private _extensions;
  7483. private _textureMatrix;
  7484. private _format;
  7485. private _createPolynomials;
  7486. /** @hidden */
  7487. _prefiltered: boolean;
  7488. /**
  7489. * Creates a cube texture from an array of image urls
  7490. * @param files defines an array of image urls
  7491. * @param scene defines the hosting scene
  7492. * @param noMipmap specifies if mip maps are not used
  7493. * @returns a cube texture
  7494. */
  7495. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7496. /**
  7497. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7498. * @param url defines the url of the prefiltered texture
  7499. * @param scene defines the scene the texture is attached to
  7500. * @param forcedExtension defines the extension of the file if different from the url
  7501. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7502. * @return the prefiltered texture
  7503. */
  7504. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7505. /**
  7506. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7507. * as prefiltered data.
  7508. * @param rootUrl defines the url of the texture or the root name of the six images
  7509. * @param scene defines the scene the texture is attached to
  7510. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7511. * @param noMipmap defines if mipmaps should be created or not
  7512. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7513. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7514. * @param onError defines a callback triggered in case of error during load
  7515. * @param format defines the internal format to use for the texture once loaded
  7516. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7517. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7518. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7519. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7520. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7521. * @return the cube texture
  7522. */
  7523. 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);
  7524. /**
  7525. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  7526. */
  7527. readonly isPrefiltered: boolean;
  7528. /**
  7529. * Get the current class name of the texture useful for serialization or dynamic coding.
  7530. * @returns "CubeTexture"
  7531. */
  7532. getClassName(): string;
  7533. /**
  7534. * Update the url (and optional buffer) of this texture if url was null during construction.
  7535. * @param url the url of the texture
  7536. * @param forcedExtension defines the extension to use
  7537. * @param onLoad callback called when the texture is loaded (defaults to null)
  7538. */
  7539. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  7540. /**
  7541. * Delays loading of the cube texture
  7542. * @param forcedExtension defines the extension to use
  7543. */
  7544. delayLoad(forcedExtension?: string): void;
  7545. /**
  7546. * Returns the reflection texture matrix
  7547. * @returns the reflection texture matrix
  7548. */
  7549. getReflectionTextureMatrix(): Matrix;
  7550. /**
  7551. * Sets the reflection texture matrix
  7552. * @param value Reflection texture matrix
  7553. */
  7554. setReflectionTextureMatrix(value: Matrix): void;
  7555. /**
  7556. * Parses text to create a cube texture
  7557. * @param parsedTexture define the serialized text to read from
  7558. * @param scene defines the hosting scene
  7559. * @param rootUrl defines the root url of the cube texture
  7560. * @returns a cube texture
  7561. */
  7562. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7563. /**
  7564. * Makes a clone, or deep copy, of the cube texture
  7565. * @returns a new cube texture
  7566. */
  7567. clone(): CubeTexture;
  7568. }
  7569. }
  7570. declare module BABYLON {
  7571. /**
  7572. * Manages the defines for the Material
  7573. */
  7574. export class MaterialDefines {
  7575. /** @hidden */
  7576. protected _keys: string[];
  7577. private _isDirty;
  7578. /** @hidden */
  7579. _renderId: number;
  7580. /** @hidden */
  7581. _areLightsDirty: boolean;
  7582. /** @hidden */
  7583. _areLightsDisposed: boolean;
  7584. /** @hidden */
  7585. _areAttributesDirty: boolean;
  7586. /** @hidden */
  7587. _areTexturesDirty: boolean;
  7588. /** @hidden */
  7589. _areFresnelDirty: boolean;
  7590. /** @hidden */
  7591. _areMiscDirty: boolean;
  7592. /** @hidden */
  7593. _areImageProcessingDirty: boolean;
  7594. /** @hidden */
  7595. _normals: boolean;
  7596. /** @hidden */
  7597. _uvs: boolean;
  7598. /** @hidden */
  7599. _needNormals: boolean;
  7600. /** @hidden */
  7601. _needUVs: boolean;
  7602. [id: string]: any;
  7603. /**
  7604. * Specifies if the material needs to be re-calculated
  7605. */
  7606. readonly isDirty: boolean;
  7607. /**
  7608. * Marks the material to indicate that it has been re-calculated
  7609. */
  7610. markAsProcessed(): void;
  7611. /**
  7612. * Marks the material to indicate that it needs to be re-calculated
  7613. */
  7614. markAsUnprocessed(): void;
  7615. /**
  7616. * Marks the material to indicate all of its defines need to be re-calculated
  7617. */
  7618. markAllAsDirty(): void;
  7619. /**
  7620. * Marks the material to indicate that image processing needs to be re-calculated
  7621. */
  7622. markAsImageProcessingDirty(): void;
  7623. /**
  7624. * Marks the material to indicate the lights need to be re-calculated
  7625. * @param disposed Defines whether the light is dirty due to dispose or not
  7626. */
  7627. markAsLightDirty(disposed?: boolean): void;
  7628. /**
  7629. * Marks the attribute state as changed
  7630. */
  7631. markAsAttributesDirty(): void;
  7632. /**
  7633. * Marks the texture state as changed
  7634. */
  7635. markAsTexturesDirty(): void;
  7636. /**
  7637. * Marks the fresnel state as changed
  7638. */
  7639. markAsFresnelDirty(): void;
  7640. /**
  7641. * Marks the misc state as changed
  7642. */
  7643. markAsMiscDirty(): void;
  7644. /**
  7645. * Rebuilds the material defines
  7646. */
  7647. rebuild(): void;
  7648. /**
  7649. * Specifies if two material defines are equal
  7650. * @param other - A material define instance to compare to
  7651. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  7652. */
  7653. isEqual(other: MaterialDefines): boolean;
  7654. /**
  7655. * Clones this instance's defines to another instance
  7656. * @param other - material defines to clone values to
  7657. */
  7658. cloneTo(other: MaterialDefines): void;
  7659. /**
  7660. * Resets the material define values
  7661. */
  7662. reset(): void;
  7663. /**
  7664. * Converts the material define values to a string
  7665. * @returns - String of material define information
  7666. */
  7667. toString(): string;
  7668. }
  7669. }
  7670. declare module BABYLON {
  7671. /**
  7672. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  7673. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  7674. * 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;
  7675. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  7676. */
  7677. export class ColorCurves {
  7678. private _dirty;
  7679. private _tempColor;
  7680. private _globalCurve;
  7681. private _highlightsCurve;
  7682. private _midtonesCurve;
  7683. private _shadowsCurve;
  7684. private _positiveCurve;
  7685. private _negativeCurve;
  7686. private _globalHue;
  7687. private _globalDensity;
  7688. private _globalSaturation;
  7689. private _globalExposure;
  7690. /**
  7691. * Gets the global Hue value.
  7692. * 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).
  7693. */
  7694. /**
  7695. * Sets the global Hue value.
  7696. * 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).
  7697. */
  7698. globalHue: number;
  7699. /**
  7700. * Gets the global Density value.
  7701. * 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.
  7702. * Values less than zero provide a filter of opposite hue.
  7703. */
  7704. /**
  7705. * Sets the global Density value.
  7706. * 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.
  7707. * Values less than zero provide a filter of opposite hue.
  7708. */
  7709. globalDensity: number;
  7710. /**
  7711. * Gets the global Saturation value.
  7712. * 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.
  7713. */
  7714. /**
  7715. * Sets the global Saturation value.
  7716. * 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.
  7717. */
  7718. globalSaturation: number;
  7719. /**
  7720. * Gets the global Exposure value.
  7721. * 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.
  7722. */
  7723. /**
  7724. * Sets the global Exposure value.
  7725. * 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.
  7726. */
  7727. globalExposure: number;
  7728. private _highlightsHue;
  7729. private _highlightsDensity;
  7730. private _highlightsSaturation;
  7731. private _highlightsExposure;
  7732. /**
  7733. * Gets the highlights Hue value.
  7734. * 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).
  7735. */
  7736. /**
  7737. * Sets the highlights Hue value.
  7738. * 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).
  7739. */
  7740. highlightsHue: number;
  7741. /**
  7742. * Gets the highlights Density value.
  7743. * 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.
  7744. * Values less than zero provide a filter of opposite hue.
  7745. */
  7746. /**
  7747. * Sets the highlights Density value.
  7748. * 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.
  7749. * Values less than zero provide a filter of opposite hue.
  7750. */
  7751. highlightsDensity: number;
  7752. /**
  7753. * Gets the highlights Saturation value.
  7754. * 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.
  7755. */
  7756. /**
  7757. * Sets the highlights Saturation value.
  7758. * 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.
  7759. */
  7760. highlightsSaturation: number;
  7761. /**
  7762. * Gets the highlights Exposure value.
  7763. * 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.
  7764. */
  7765. /**
  7766. * Sets the highlights Exposure value.
  7767. * 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.
  7768. */
  7769. highlightsExposure: number;
  7770. private _midtonesHue;
  7771. private _midtonesDensity;
  7772. private _midtonesSaturation;
  7773. private _midtonesExposure;
  7774. /**
  7775. * Gets the midtones Hue value.
  7776. * 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).
  7777. */
  7778. /**
  7779. * Sets the midtones Hue value.
  7780. * 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).
  7781. */
  7782. midtonesHue: number;
  7783. /**
  7784. * Gets the midtones Density value.
  7785. * 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.
  7786. * Values less than zero provide a filter of opposite hue.
  7787. */
  7788. /**
  7789. * Sets the midtones Density value.
  7790. * 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.
  7791. * Values less than zero provide a filter of opposite hue.
  7792. */
  7793. midtonesDensity: number;
  7794. /**
  7795. * Gets the midtones Saturation value.
  7796. * 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.
  7797. */
  7798. /**
  7799. * Sets the midtones Saturation value.
  7800. * 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.
  7801. */
  7802. midtonesSaturation: number;
  7803. /**
  7804. * Gets the midtones Exposure value.
  7805. * 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.
  7806. */
  7807. /**
  7808. * Sets the midtones Exposure value.
  7809. * 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.
  7810. */
  7811. midtonesExposure: number;
  7812. private _shadowsHue;
  7813. private _shadowsDensity;
  7814. private _shadowsSaturation;
  7815. private _shadowsExposure;
  7816. /**
  7817. * Gets the shadows Hue value.
  7818. * 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).
  7819. */
  7820. /**
  7821. * Sets the shadows Hue value.
  7822. * 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).
  7823. */
  7824. shadowsHue: number;
  7825. /**
  7826. * Gets the shadows Density value.
  7827. * 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.
  7828. * Values less than zero provide a filter of opposite hue.
  7829. */
  7830. /**
  7831. * Sets the shadows Density value.
  7832. * 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.
  7833. * Values less than zero provide a filter of opposite hue.
  7834. */
  7835. shadowsDensity: number;
  7836. /**
  7837. * Gets the shadows Saturation value.
  7838. * 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.
  7839. */
  7840. /**
  7841. * Sets the shadows Saturation value.
  7842. * 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.
  7843. */
  7844. shadowsSaturation: number;
  7845. /**
  7846. * Gets the shadows Exposure value.
  7847. * 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.
  7848. */
  7849. /**
  7850. * Sets the shadows Exposure value.
  7851. * 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.
  7852. */
  7853. shadowsExposure: number;
  7854. /**
  7855. * Returns the class name
  7856. * @returns The class name
  7857. */
  7858. getClassName(): string;
  7859. /**
  7860. * Binds the color curves to the shader.
  7861. * @param colorCurves The color curve to bind
  7862. * @param effect The effect to bind to
  7863. * @param positiveUniform The positive uniform shader parameter
  7864. * @param neutralUniform The neutral uniform shader parameter
  7865. * @param negativeUniform The negative uniform shader parameter
  7866. */
  7867. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  7868. /**
  7869. * Prepare the list of uniforms associated with the ColorCurves effects.
  7870. * @param uniformsList The list of uniforms used in the effect
  7871. */
  7872. static PrepareUniforms(uniformsList: string[]): void;
  7873. /**
  7874. * Returns color grading data based on a hue, density, saturation and exposure value.
  7875. * @param filterHue The hue of the color filter.
  7876. * @param filterDensity The density of the color filter.
  7877. * @param saturation The saturation.
  7878. * @param exposure The exposure.
  7879. * @param result The result data container.
  7880. */
  7881. private getColorGradingDataToRef;
  7882. /**
  7883. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  7884. * @param value The input slider value in range [-100,100].
  7885. * @returns Adjusted value.
  7886. */
  7887. private static applyColorGradingSliderNonlinear;
  7888. /**
  7889. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  7890. * @param hue The hue (H) input.
  7891. * @param saturation The saturation (S) input.
  7892. * @param brightness The brightness (B) input.
  7893. * @result An RGBA color represented as Vector4.
  7894. */
  7895. private static fromHSBToRef;
  7896. /**
  7897. * Returns a value clamped between min and max
  7898. * @param value The value to clamp
  7899. * @param min The minimum of value
  7900. * @param max The maximum of value
  7901. * @returns The clamped value.
  7902. */
  7903. private static clamp;
  7904. /**
  7905. * Clones the current color curve instance.
  7906. * @return The cloned curves
  7907. */
  7908. clone(): ColorCurves;
  7909. /**
  7910. * Serializes the current color curve instance to a json representation.
  7911. * @return a JSON representation
  7912. */
  7913. serialize(): any;
  7914. /**
  7915. * Parses the color curve from a json representation.
  7916. * @param source the JSON source to parse
  7917. * @return The parsed curves
  7918. */
  7919. static Parse(source: any): ColorCurves;
  7920. }
  7921. }
  7922. declare module BABYLON {
  7923. /**
  7924. * Interface to follow in your material defines to integrate easily the
  7925. * Image proccessing functions.
  7926. * @hidden
  7927. */
  7928. export interface IImageProcessingConfigurationDefines {
  7929. IMAGEPROCESSING: boolean;
  7930. VIGNETTE: boolean;
  7931. VIGNETTEBLENDMODEMULTIPLY: boolean;
  7932. VIGNETTEBLENDMODEOPAQUE: boolean;
  7933. TONEMAPPING: boolean;
  7934. TONEMAPPING_ACES: boolean;
  7935. CONTRAST: boolean;
  7936. EXPOSURE: boolean;
  7937. COLORCURVES: boolean;
  7938. COLORGRADING: boolean;
  7939. COLORGRADING3D: boolean;
  7940. SAMPLER3DGREENDEPTH: boolean;
  7941. SAMPLER3DBGRMAP: boolean;
  7942. IMAGEPROCESSINGPOSTPROCESS: boolean;
  7943. }
  7944. /**
  7945. * @hidden
  7946. */
  7947. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  7948. IMAGEPROCESSING: boolean;
  7949. VIGNETTE: boolean;
  7950. VIGNETTEBLENDMODEMULTIPLY: boolean;
  7951. VIGNETTEBLENDMODEOPAQUE: boolean;
  7952. TONEMAPPING: boolean;
  7953. TONEMAPPING_ACES: boolean;
  7954. CONTRAST: boolean;
  7955. COLORCURVES: boolean;
  7956. COLORGRADING: boolean;
  7957. COLORGRADING3D: boolean;
  7958. SAMPLER3DGREENDEPTH: boolean;
  7959. SAMPLER3DBGRMAP: boolean;
  7960. IMAGEPROCESSINGPOSTPROCESS: boolean;
  7961. EXPOSURE: boolean;
  7962. constructor();
  7963. }
  7964. /**
  7965. * This groups together the common properties used for image processing either in direct forward pass
  7966. * or through post processing effect depending on the use of the image processing pipeline in your scene
  7967. * or not.
  7968. */
  7969. export class ImageProcessingConfiguration {
  7970. /**
  7971. * Default tone mapping applied in BabylonJS.
  7972. */
  7973. static readonly TONEMAPPING_STANDARD: number;
  7974. /**
  7975. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  7976. * to other engines rendering to increase portability.
  7977. */
  7978. static readonly TONEMAPPING_ACES: number;
  7979. /**
  7980. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  7981. */
  7982. colorCurves: Nullable<ColorCurves>;
  7983. private _colorCurvesEnabled;
  7984. /**
  7985. * Gets wether the color curves effect is enabled.
  7986. */
  7987. /**
  7988. * Sets wether the color curves effect is enabled.
  7989. */
  7990. colorCurvesEnabled: boolean;
  7991. private _colorGradingTexture;
  7992. /**
  7993. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  7994. */
  7995. /**
  7996. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  7997. */
  7998. colorGradingTexture: Nullable<BaseTexture>;
  7999. private _colorGradingEnabled;
  8000. /**
  8001. * Gets wether the color grading effect is enabled.
  8002. */
  8003. /**
  8004. * Sets wether the color grading effect is enabled.
  8005. */
  8006. colorGradingEnabled: boolean;
  8007. private _colorGradingWithGreenDepth;
  8008. /**
  8009. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8010. */
  8011. /**
  8012. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8013. */
  8014. colorGradingWithGreenDepth: boolean;
  8015. private _colorGradingBGR;
  8016. /**
  8017. * Gets wether the color grading texture contains BGR values.
  8018. */
  8019. /**
  8020. * Sets wether the color grading texture contains BGR values.
  8021. */
  8022. colorGradingBGR: boolean;
  8023. /** @hidden */
  8024. _exposure: number;
  8025. /**
  8026. * Gets the Exposure used in the effect.
  8027. */
  8028. /**
  8029. * Sets the Exposure used in the effect.
  8030. */
  8031. exposure: number;
  8032. private _toneMappingEnabled;
  8033. /**
  8034. * Gets wether the tone mapping effect is enabled.
  8035. */
  8036. /**
  8037. * Sets wether the tone mapping effect is enabled.
  8038. */
  8039. toneMappingEnabled: boolean;
  8040. private _toneMappingType;
  8041. /**
  8042. * Gets the type of tone mapping effect.
  8043. */
  8044. /**
  8045. * Sets the type of tone mapping effect used in BabylonJS.
  8046. */
  8047. toneMappingType: number;
  8048. protected _contrast: number;
  8049. /**
  8050. * Gets the contrast used in the effect.
  8051. */
  8052. /**
  8053. * Sets the contrast used in the effect.
  8054. */
  8055. contrast: number;
  8056. /**
  8057. * Vignette stretch size.
  8058. */
  8059. vignetteStretch: number;
  8060. /**
  8061. * Vignette centre X Offset.
  8062. */
  8063. vignetteCentreX: number;
  8064. /**
  8065. * Vignette centre Y Offset.
  8066. */
  8067. vignetteCentreY: number;
  8068. /**
  8069. * Vignette weight or intensity of the vignette effect.
  8070. */
  8071. vignetteWeight: number;
  8072. /**
  8073. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8074. * if vignetteEnabled is set to true.
  8075. */
  8076. vignetteColor: Color4;
  8077. /**
  8078. * Camera field of view used by the Vignette effect.
  8079. */
  8080. vignetteCameraFov: number;
  8081. private _vignetteBlendMode;
  8082. /**
  8083. * Gets the vignette blend mode allowing different kind of effect.
  8084. */
  8085. /**
  8086. * Sets the vignette blend mode allowing different kind of effect.
  8087. */
  8088. vignetteBlendMode: number;
  8089. private _vignetteEnabled;
  8090. /**
  8091. * Gets wether the vignette effect is enabled.
  8092. */
  8093. /**
  8094. * Sets wether the vignette effect is enabled.
  8095. */
  8096. vignetteEnabled: boolean;
  8097. private _applyByPostProcess;
  8098. /**
  8099. * Gets wether the image processing is applied through a post process or not.
  8100. */
  8101. /**
  8102. * Sets wether the image processing is applied through a post process or not.
  8103. */
  8104. applyByPostProcess: boolean;
  8105. private _isEnabled;
  8106. /**
  8107. * Gets wether the image processing is enabled or not.
  8108. */
  8109. /**
  8110. * Sets wether the image processing is enabled or not.
  8111. */
  8112. isEnabled: boolean;
  8113. /**
  8114. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8115. */
  8116. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8117. /**
  8118. * Method called each time the image processing information changes requires to recompile the effect.
  8119. */
  8120. protected _updateParameters(): void;
  8121. /**
  8122. * Gets the current class name.
  8123. * @return "ImageProcessingConfiguration"
  8124. */
  8125. getClassName(): string;
  8126. /**
  8127. * Prepare the list of uniforms associated with the Image Processing effects.
  8128. * @param uniforms The list of uniforms used in the effect
  8129. * @param defines the list of defines currently in use
  8130. */
  8131. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8132. /**
  8133. * Prepare the list of samplers associated with the Image Processing effects.
  8134. * @param samplersList The list of uniforms used in the effect
  8135. * @param defines the list of defines currently in use
  8136. */
  8137. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8138. /**
  8139. * Prepare the list of defines associated to the shader.
  8140. * @param defines the list of defines to complete
  8141. * @param forPostProcess Define if we are currently in post process mode or not
  8142. */
  8143. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8144. /**
  8145. * Returns true if all the image processing information are ready.
  8146. * @returns True if ready, otherwise, false
  8147. */
  8148. isReady(): boolean;
  8149. /**
  8150. * Binds the image processing to the shader.
  8151. * @param effect The effect to bind to
  8152. * @param aspectRatio Define the current aspect ratio of the effect
  8153. */
  8154. bind(effect: Effect, aspectRatio?: number): void;
  8155. /**
  8156. * Clones the current image processing instance.
  8157. * @return The cloned image processing
  8158. */
  8159. clone(): ImageProcessingConfiguration;
  8160. /**
  8161. * Serializes the current image processing instance to a json representation.
  8162. * @return a JSON representation
  8163. */
  8164. serialize(): any;
  8165. /**
  8166. * Parses the image processing from a json representation.
  8167. * @param source the JSON source to parse
  8168. * @return The parsed image processing
  8169. */
  8170. static Parse(source: any): ImageProcessingConfiguration;
  8171. private static _VIGNETTEMODE_MULTIPLY;
  8172. private static _VIGNETTEMODE_OPAQUE;
  8173. /**
  8174. * Used to apply the vignette as a mix with the pixel color.
  8175. */
  8176. static readonly VIGNETTEMODE_MULTIPLY: number;
  8177. /**
  8178. * Used to apply the vignette as a replacement of the pixel color.
  8179. */
  8180. static readonly VIGNETTEMODE_OPAQUE: number;
  8181. }
  8182. }
  8183. declare module BABYLON {
  8184. /** @hidden */
  8185. export var postprocessVertexShader: {
  8186. name: string;
  8187. shader: string;
  8188. };
  8189. }
  8190. declare module BABYLON {
  8191. interface ThinEngine {
  8192. /**
  8193. * Creates a new render target texture
  8194. * @param size defines the size of the texture
  8195. * @param options defines the options used to create the texture
  8196. * @returns a new render target texture stored in an InternalTexture
  8197. */
  8198. createRenderTargetTexture(size: number | {
  8199. width: number;
  8200. height: number;
  8201. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8202. }
  8203. }
  8204. declare module BABYLON {
  8205. /** Defines supported spaces */
  8206. export enum Space {
  8207. /** Local (object) space */
  8208. LOCAL = 0,
  8209. /** World space */
  8210. WORLD = 1,
  8211. /** Bone space */
  8212. BONE = 2
  8213. }
  8214. /** Defines the 3 main axes */
  8215. export class Axis {
  8216. /** X axis */
  8217. static X: Vector3;
  8218. /** Y axis */
  8219. static Y: Vector3;
  8220. /** Z axis */
  8221. static Z: Vector3;
  8222. }
  8223. }
  8224. declare module BABYLON {
  8225. /**
  8226. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8227. * This is the base of the follow, arc rotate cameras and Free camera
  8228. * @see http://doc.babylonjs.com/features/cameras
  8229. */
  8230. export class TargetCamera extends Camera {
  8231. private static _RigCamTransformMatrix;
  8232. private static _TargetTransformMatrix;
  8233. private static _TargetFocalPoint;
  8234. /**
  8235. * Define the current direction the camera is moving to
  8236. */
  8237. cameraDirection: Vector3;
  8238. /**
  8239. * Define the current rotation the camera is rotating to
  8240. */
  8241. cameraRotation: Vector2;
  8242. /**
  8243. * When set, the up vector of the camera will be updated by the rotation of the camera
  8244. */
  8245. updateUpVectorFromRotation: boolean;
  8246. private _tmpQuaternion;
  8247. /**
  8248. * Define the current rotation of the camera
  8249. */
  8250. rotation: Vector3;
  8251. /**
  8252. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8253. */
  8254. rotationQuaternion: Quaternion;
  8255. /**
  8256. * Define the current speed of the camera
  8257. */
  8258. speed: number;
  8259. /**
  8260. * Add cconstraint to the camera to prevent it to move freely in all directions and
  8261. * around all axis.
  8262. */
  8263. noRotationConstraint: boolean;
  8264. /**
  8265. * Define the current target of the camera as an object or a position.
  8266. */
  8267. lockedTarget: any;
  8268. /** @hidden */
  8269. _currentTarget: Vector3;
  8270. /** @hidden */
  8271. _initialFocalDistance: number;
  8272. /** @hidden */
  8273. _viewMatrix: Matrix;
  8274. /** @hidden */
  8275. _camMatrix: Matrix;
  8276. /** @hidden */
  8277. _cameraTransformMatrix: Matrix;
  8278. /** @hidden */
  8279. _cameraRotationMatrix: Matrix;
  8280. /** @hidden */
  8281. _referencePoint: Vector3;
  8282. /** @hidden */
  8283. _transformedReferencePoint: Vector3;
  8284. protected _globalCurrentTarget: Vector3;
  8285. protected _globalCurrentUpVector: Vector3;
  8286. /** @hidden */
  8287. _reset: () => void;
  8288. private _defaultUp;
  8289. /**
  8290. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  8291. * This is the base of the follow, arc rotate cameras and Free camera
  8292. * @see http://doc.babylonjs.com/features/cameras
  8293. * @param name Defines the name of the camera in the scene
  8294. * @param position Defines the start position of the camera in the scene
  8295. * @param scene Defines the scene the camera belongs to
  8296. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8297. */
  8298. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8299. /**
  8300. * Gets the position in front of the camera at a given distance.
  8301. * @param distance The distance from the camera we want the position to be
  8302. * @returns the position
  8303. */
  8304. getFrontPosition(distance: number): Vector3;
  8305. /** @hidden */
  8306. _getLockedTargetPosition(): Nullable<Vector3>;
  8307. private _storedPosition;
  8308. private _storedRotation;
  8309. private _storedRotationQuaternion;
  8310. /**
  8311. * Store current camera state of the camera (fov, position, rotation, etc..)
  8312. * @returns the camera
  8313. */
  8314. storeState(): Camera;
  8315. /**
  8316. * Restored camera state. You must call storeState() first
  8317. * @returns whether it was successful or not
  8318. * @hidden
  8319. */
  8320. _restoreStateValues(): boolean;
  8321. /** @hidden */
  8322. _initCache(): void;
  8323. /** @hidden */
  8324. _updateCache(ignoreParentClass?: boolean): void;
  8325. /** @hidden */
  8326. _isSynchronizedViewMatrix(): boolean;
  8327. /** @hidden */
  8328. _computeLocalCameraSpeed(): number;
  8329. /**
  8330. * Defines the target the camera should look at.
  8331. * @param target Defines the new target as a Vector or a mesh
  8332. */
  8333. setTarget(target: Vector3): void;
  8334. /**
  8335. * Return the current target position of the camera. This value is expressed in local space.
  8336. * @returns the target position
  8337. */
  8338. getTarget(): Vector3;
  8339. /** @hidden */
  8340. _decideIfNeedsToMove(): boolean;
  8341. /** @hidden */
  8342. _updatePosition(): void;
  8343. /** @hidden */
  8344. _checkInputs(): void;
  8345. protected _updateCameraRotationMatrix(): void;
  8346. /**
  8347. * 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)
  8348. * @returns the current camera
  8349. */
  8350. private _rotateUpVectorWithCameraRotationMatrix;
  8351. private _cachedRotationZ;
  8352. private _cachedQuaternionRotationZ;
  8353. /** @hidden */
  8354. _getViewMatrix(): Matrix;
  8355. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8356. /**
  8357. * @hidden
  8358. */
  8359. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8360. /**
  8361. * @hidden
  8362. */
  8363. _updateRigCameras(): void;
  8364. private _getRigCamPositionAndTarget;
  8365. /**
  8366. * Gets the current object class name.
  8367. * @return the class name
  8368. */
  8369. getClassName(): string;
  8370. }
  8371. }
  8372. declare module BABYLON {
  8373. /**
  8374. * Gather the list of keyboard event types as constants.
  8375. */
  8376. export class KeyboardEventTypes {
  8377. /**
  8378. * The keydown event is fired when a key becomes active (pressed).
  8379. */
  8380. static readonly KEYDOWN: number;
  8381. /**
  8382. * The keyup event is fired when a key has been released.
  8383. */
  8384. static readonly KEYUP: number;
  8385. }
  8386. /**
  8387. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8388. */
  8389. export class KeyboardInfo {
  8390. /**
  8391. * Defines the type of event (KeyboardEventTypes)
  8392. */
  8393. type: number;
  8394. /**
  8395. * Defines the related dom event
  8396. */
  8397. event: KeyboardEvent;
  8398. /**
  8399. * Instantiates a new keyboard info.
  8400. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8401. * @param type Defines the type of event (KeyboardEventTypes)
  8402. * @param event Defines the related dom event
  8403. */
  8404. constructor(
  8405. /**
  8406. * Defines the type of event (KeyboardEventTypes)
  8407. */
  8408. type: number,
  8409. /**
  8410. * Defines the related dom event
  8411. */
  8412. event: KeyboardEvent);
  8413. }
  8414. /**
  8415. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8416. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8417. */
  8418. export class KeyboardInfoPre extends KeyboardInfo {
  8419. /**
  8420. * Defines the type of event (KeyboardEventTypes)
  8421. */
  8422. type: number;
  8423. /**
  8424. * Defines the related dom event
  8425. */
  8426. event: KeyboardEvent;
  8427. /**
  8428. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8429. */
  8430. skipOnPointerObservable: boolean;
  8431. /**
  8432. * Instantiates a new keyboard pre info.
  8433. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8434. * @param type Defines the type of event (KeyboardEventTypes)
  8435. * @param event Defines the related dom event
  8436. */
  8437. constructor(
  8438. /**
  8439. * Defines the type of event (KeyboardEventTypes)
  8440. */
  8441. type: number,
  8442. /**
  8443. * Defines the related dom event
  8444. */
  8445. event: KeyboardEvent);
  8446. }
  8447. }
  8448. declare module BABYLON {
  8449. /**
  8450. * Manage the keyboard inputs to control the movement of a free camera.
  8451. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8452. */
  8453. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8454. /**
  8455. * Defines the camera the input is attached to.
  8456. */
  8457. camera: FreeCamera;
  8458. /**
  8459. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8460. */
  8461. keysUp: number[];
  8462. /**
  8463. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8464. */
  8465. keysDown: number[];
  8466. /**
  8467. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8468. */
  8469. keysLeft: number[];
  8470. /**
  8471. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8472. */
  8473. keysRight: number[];
  8474. private _keys;
  8475. private _onCanvasBlurObserver;
  8476. private _onKeyboardObserver;
  8477. private _engine;
  8478. private _scene;
  8479. /**
  8480. * Attach the input controls to a specific dom element to get the input from.
  8481. * @param element Defines the element the controls should be listened from
  8482. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8483. */
  8484. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8485. /**
  8486. * Detach the current controls from the specified dom element.
  8487. * @param element Defines the element to stop listening the inputs from
  8488. */
  8489. detachControl(element: Nullable<HTMLElement>): void;
  8490. /**
  8491. * Update the current camera state depending on the inputs that have been used this frame.
  8492. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8493. */
  8494. checkInputs(): void;
  8495. /**
  8496. * Gets the class name of the current intput.
  8497. * @returns the class name
  8498. */
  8499. getClassName(): string;
  8500. /** @hidden */
  8501. _onLostFocus(): void;
  8502. /**
  8503. * Get the friendly name associated with the input class.
  8504. * @returns the input friendly name
  8505. */
  8506. getSimpleName(): string;
  8507. }
  8508. }
  8509. declare module BABYLON {
  8510. /**
  8511. * Interface describing all the common properties and methods a shadow light needs to implement.
  8512. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8513. * as well as binding the different shadow properties to the effects.
  8514. */
  8515. export interface IShadowLight extends Light {
  8516. /**
  8517. * The light id in the scene (used in scene.findLighById for instance)
  8518. */
  8519. id: string;
  8520. /**
  8521. * The position the shdow will be casted from.
  8522. */
  8523. position: Vector3;
  8524. /**
  8525. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8526. */
  8527. direction: Vector3;
  8528. /**
  8529. * The transformed position. Position of the light in world space taking parenting in account.
  8530. */
  8531. transformedPosition: Vector3;
  8532. /**
  8533. * The transformed direction. Direction of the light in world space taking parenting in account.
  8534. */
  8535. transformedDirection: Vector3;
  8536. /**
  8537. * The friendly name of the light in the scene.
  8538. */
  8539. name: string;
  8540. /**
  8541. * Defines the shadow projection clipping minimum z value.
  8542. */
  8543. shadowMinZ: number;
  8544. /**
  8545. * Defines the shadow projection clipping maximum z value.
  8546. */
  8547. shadowMaxZ: number;
  8548. /**
  8549. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8550. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8551. */
  8552. computeTransformedInformation(): boolean;
  8553. /**
  8554. * Gets the scene the light belongs to.
  8555. * @returns The scene
  8556. */
  8557. getScene(): Scene;
  8558. /**
  8559. * Callback defining a custom Projection Matrix Builder.
  8560. * This can be used to override the default projection matrix computation.
  8561. */
  8562. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8563. /**
  8564. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8565. * @param matrix The materix to updated with the projection information
  8566. * @param viewMatrix The transform matrix of the light
  8567. * @param renderList The list of mesh to render in the map
  8568. * @returns The current light
  8569. */
  8570. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8571. /**
  8572. * Gets the current depth scale used in ESM.
  8573. * @returns The scale
  8574. */
  8575. getDepthScale(): number;
  8576. /**
  8577. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8578. * @returns true if a cube texture needs to be use
  8579. */
  8580. needCube(): boolean;
  8581. /**
  8582. * Detects if the projection matrix requires to be recomputed this frame.
  8583. * @returns true if it requires to be recomputed otherwise, false.
  8584. */
  8585. needProjectionMatrixCompute(): boolean;
  8586. /**
  8587. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8588. */
  8589. forceProjectionMatrixCompute(): void;
  8590. /**
  8591. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8592. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8593. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8594. */
  8595. getShadowDirection(faceIndex?: number): Vector3;
  8596. /**
  8597. * Gets the minZ used for shadow according to both the scene and the light.
  8598. * @param activeCamera The camera we are returning the min for
  8599. * @returns the depth min z
  8600. */
  8601. getDepthMinZ(activeCamera: Camera): number;
  8602. /**
  8603. * Gets the maxZ used for shadow according to both the scene and the light.
  8604. * @param activeCamera The camera we are returning the max for
  8605. * @returns the depth max z
  8606. */
  8607. getDepthMaxZ(activeCamera: Camera): number;
  8608. }
  8609. /**
  8610. * Base implementation IShadowLight
  8611. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8612. */
  8613. export abstract class ShadowLight extends Light implements IShadowLight {
  8614. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8615. protected _position: Vector3;
  8616. protected _setPosition(value: Vector3): void;
  8617. /**
  8618. * Sets the position the shadow will be casted from. Also use as the light position for both
  8619. * point and spot lights.
  8620. */
  8621. /**
  8622. * Sets the position the shadow will be casted from. Also use as the light position for both
  8623. * point and spot lights.
  8624. */
  8625. position: Vector3;
  8626. protected _direction: Vector3;
  8627. protected _setDirection(value: Vector3): void;
  8628. /**
  8629. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  8630. * Also use as the light direction on spot and directional lights.
  8631. */
  8632. /**
  8633. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  8634. * Also use as the light direction on spot and directional lights.
  8635. */
  8636. direction: Vector3;
  8637. private _shadowMinZ;
  8638. /**
  8639. * Gets the shadow projection clipping minimum z value.
  8640. */
  8641. /**
  8642. * Sets the shadow projection clipping minimum z value.
  8643. */
  8644. shadowMinZ: number;
  8645. private _shadowMaxZ;
  8646. /**
  8647. * Sets the shadow projection clipping maximum z value.
  8648. */
  8649. /**
  8650. * Gets the shadow projection clipping maximum z value.
  8651. */
  8652. shadowMaxZ: number;
  8653. /**
  8654. * Callback defining a custom Projection Matrix Builder.
  8655. * This can be used to override the default projection matrix computation.
  8656. */
  8657. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8658. /**
  8659. * The transformed position. Position of the light in world space taking parenting in account.
  8660. */
  8661. transformedPosition: Vector3;
  8662. /**
  8663. * The transformed direction. Direction of the light in world space taking parenting in account.
  8664. */
  8665. transformedDirection: Vector3;
  8666. private _needProjectionMatrixCompute;
  8667. /**
  8668. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8669. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8670. */
  8671. computeTransformedInformation(): boolean;
  8672. /**
  8673. * Return the depth scale used for the shadow map.
  8674. * @returns the depth scale.
  8675. */
  8676. getDepthScale(): number;
  8677. /**
  8678. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8679. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8680. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8681. */
  8682. getShadowDirection(faceIndex?: number): Vector3;
  8683. /**
  8684. * Returns the ShadowLight absolute position in the World.
  8685. * @returns the position vector in world space
  8686. */
  8687. getAbsolutePosition(): Vector3;
  8688. /**
  8689. * Sets the ShadowLight direction toward the passed target.
  8690. * @param target The point to target in local space
  8691. * @returns the updated ShadowLight direction
  8692. */
  8693. setDirectionToTarget(target: Vector3): Vector3;
  8694. /**
  8695. * Returns the light rotation in euler definition.
  8696. * @returns the x y z rotation in local space.
  8697. */
  8698. getRotation(): Vector3;
  8699. /**
  8700. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8701. * @returns true if a cube texture needs to be use
  8702. */
  8703. needCube(): boolean;
  8704. /**
  8705. * Detects if the projection matrix requires to be recomputed this frame.
  8706. * @returns true if it requires to be recomputed otherwise, false.
  8707. */
  8708. needProjectionMatrixCompute(): boolean;
  8709. /**
  8710. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8711. */
  8712. forceProjectionMatrixCompute(): void;
  8713. /** @hidden */
  8714. _initCache(): void;
  8715. /** @hidden */
  8716. _isSynchronized(): boolean;
  8717. /**
  8718. * Computes the world matrix of the node
  8719. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  8720. * @returns the world matrix
  8721. */
  8722. computeWorldMatrix(force?: boolean): Matrix;
  8723. /**
  8724. * Gets the minZ used for shadow according to both the scene and the light.
  8725. * @param activeCamera The camera we are returning the min for
  8726. * @returns the depth min z
  8727. */
  8728. getDepthMinZ(activeCamera: Camera): number;
  8729. /**
  8730. * Gets the maxZ used for shadow according to both the scene and the light.
  8731. * @param activeCamera The camera we are returning the max for
  8732. * @returns the depth max z
  8733. */
  8734. getDepthMaxZ(activeCamera: Camera): number;
  8735. /**
  8736. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8737. * @param matrix The materix to updated with the projection information
  8738. * @param viewMatrix The transform matrix of the light
  8739. * @param renderList The list of mesh to render in the map
  8740. * @returns The current light
  8741. */
  8742. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8743. }
  8744. }
  8745. declare module BABYLON {
  8746. /**
  8747. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  8748. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  8749. */
  8750. export class EffectFallbacks implements IEffectFallbacks {
  8751. private _defines;
  8752. private _currentRank;
  8753. private _maxRank;
  8754. private _mesh;
  8755. /**
  8756. * Removes the fallback from the bound mesh.
  8757. */
  8758. unBindMesh(): void;
  8759. /**
  8760. * Adds a fallback on the specified property.
  8761. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  8762. * @param define The name of the define in the shader
  8763. */
  8764. addFallback(rank: number, define: string): void;
  8765. /**
  8766. * Sets the mesh to use CPU skinning when needing to fallback.
  8767. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  8768. * @param mesh The mesh to use the fallbacks.
  8769. */
  8770. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  8771. /**
  8772. * Checks to see if more fallbacks are still availible.
  8773. */
  8774. readonly hasMoreFallbacks: boolean;
  8775. /**
  8776. * Removes the defines that should be removed when falling back.
  8777. * @param currentDefines defines the current define statements for the shader.
  8778. * @param effect defines the current effect we try to compile
  8779. * @returns The resulting defines with defines of the current rank removed.
  8780. */
  8781. reduce(currentDefines: string, effect: Effect): string;
  8782. }
  8783. }
  8784. declare module BABYLON {
  8785. /**
  8786. * "Static Class" containing the most commonly used helper while dealing with material for
  8787. * rendering purpose.
  8788. *
  8789. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  8790. *
  8791. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  8792. */
  8793. export class MaterialHelper {
  8794. /**
  8795. * Bind the current view position to an effect.
  8796. * @param effect The effect to be bound
  8797. * @param scene The scene the eyes position is used from
  8798. */
  8799. static BindEyePosition(effect: Effect, scene: Scene): void;
  8800. /**
  8801. * Helps preparing the defines values about the UVs in used in the effect.
  8802. * UVs are shared as much as we can accross channels in the shaders.
  8803. * @param texture The texture we are preparing the UVs for
  8804. * @param defines The defines to update
  8805. * @param key The channel key "diffuse", "specular"... used in the shader
  8806. */
  8807. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  8808. /**
  8809. * Binds a texture matrix value to its corrsponding uniform
  8810. * @param texture The texture to bind the matrix for
  8811. * @param uniformBuffer The uniform buffer receivin the data
  8812. * @param key The channel key "diffuse", "specular"... used in the shader
  8813. */
  8814. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  8815. /**
  8816. * Gets the current status of the fog (should it be enabled?)
  8817. * @param mesh defines the mesh to evaluate for fog support
  8818. * @param scene defines the hosting scene
  8819. * @returns true if fog must be enabled
  8820. */
  8821. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  8822. /**
  8823. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  8824. * @param mesh defines the current mesh
  8825. * @param scene defines the current scene
  8826. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  8827. * @param pointsCloud defines if point cloud rendering has to be turned on
  8828. * @param fogEnabled defines if fog has to be turned on
  8829. * @param alphaTest defines if alpha testing has to be turned on
  8830. * @param defines defines the current list of defines
  8831. */
  8832. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  8833. /**
  8834. * Helper used to prepare the list of defines associated with frame values for shader compilation
  8835. * @param scene defines the current scene
  8836. * @param engine defines the current engine
  8837. * @param defines specifies the list of active defines
  8838. * @param useInstances defines if instances have to be turned on
  8839. * @param useClipPlane defines if clip plane have to be turned on
  8840. */
  8841. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  8842. /**
  8843. * Prepares the defines for bones
  8844. * @param mesh The mesh containing the geometry data we will draw
  8845. * @param defines The defines to update
  8846. */
  8847. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  8848. /**
  8849. * Prepares the defines for morph targets
  8850. * @param mesh The mesh containing the geometry data we will draw
  8851. * @param defines The defines to update
  8852. */
  8853. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  8854. /**
  8855. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  8856. * @param mesh The mesh containing the geometry data we will draw
  8857. * @param defines The defines to update
  8858. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  8859. * @param useBones Precise whether bones should be used or not (override mesh info)
  8860. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  8861. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  8862. * @returns false if defines are considered not dirty and have not been checked
  8863. */
  8864. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  8865. /**
  8866. * Prepares the defines related to multiview
  8867. * @param scene The scene we are intending to draw
  8868. * @param defines The defines to update
  8869. */
  8870. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  8871. /**
  8872. * Prepares the defines related to the light information passed in parameter
  8873. * @param scene The scene we are intending to draw
  8874. * @param mesh The mesh the effect is compiling for
  8875. * @param light The light the effect is compiling for
  8876. * @param lightIndex The index of the light
  8877. * @param defines The defines to update
  8878. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  8879. * @param state Defines the current state regarding what is needed (normals, etc...)
  8880. */
  8881. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  8882. needNormals: boolean;
  8883. needRebuild: boolean;
  8884. shadowEnabled: boolean;
  8885. specularEnabled: boolean;
  8886. lightmapMode: boolean;
  8887. }): void;
  8888. /**
  8889. * Prepares the defines related to the light information passed in parameter
  8890. * @param scene The scene we are intending to draw
  8891. * @param mesh The mesh the effect is compiling for
  8892. * @param defines The defines to update
  8893. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  8894. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  8895. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  8896. * @returns true if normals will be required for the rest of the effect
  8897. */
  8898. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  8899. /**
  8900. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  8901. * @param lightIndex defines the light index
  8902. * @param uniformsList The uniform list
  8903. * @param samplersList The sampler list
  8904. * @param projectedLightTexture defines if projected texture must be used
  8905. * @param uniformBuffersList defines an optional list of uniform buffers
  8906. */
  8907. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  8908. /**
  8909. * Prepares the uniforms and samplers list to be used in the effect
  8910. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  8911. * @param samplersList The sampler list
  8912. * @param defines The defines helping in the list generation
  8913. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  8914. */
  8915. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  8916. /**
  8917. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  8918. * @param defines The defines to update while falling back
  8919. * @param fallbacks The authorized effect fallbacks
  8920. * @param maxSimultaneousLights The maximum number of lights allowed
  8921. * @param rank the current rank of the Effect
  8922. * @returns The newly affected rank
  8923. */
  8924. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  8925. private static _TmpMorphInfluencers;
  8926. /**
  8927. * Prepares the list of attributes required for morph targets according to the effect defines.
  8928. * @param attribs The current list of supported attribs
  8929. * @param mesh The mesh to prepare the morph targets attributes for
  8930. * @param influencers The number of influencers
  8931. */
  8932. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  8933. /**
  8934. * Prepares the list of attributes required for morph targets according to the effect defines.
  8935. * @param attribs The current list of supported attribs
  8936. * @param mesh The mesh to prepare the morph targets attributes for
  8937. * @param defines The current Defines of the effect
  8938. */
  8939. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  8940. /**
  8941. * Prepares the list of attributes required for bones according to the effect defines.
  8942. * @param attribs The current list of supported attribs
  8943. * @param mesh The mesh to prepare the bones attributes for
  8944. * @param defines The current Defines of the effect
  8945. * @param fallbacks The current efffect fallback strategy
  8946. */
  8947. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  8948. /**
  8949. * Check and prepare the list of attributes required for instances according to the effect defines.
  8950. * @param attribs The current list of supported attribs
  8951. * @param defines The current MaterialDefines of the effect
  8952. */
  8953. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  8954. /**
  8955. * Add the list of attributes required for instances to the attribs array.
  8956. * @param attribs The current list of supported attribs
  8957. */
  8958. static PushAttributesForInstances(attribs: string[]): void;
  8959. /**
  8960. * Binds the light shadow information to the effect for the given mesh.
  8961. * @param light The light containing the generator
  8962. * @param scene The scene the lights belongs to
  8963. * @param mesh The mesh we are binding the information to render
  8964. * @param lightIndex The light index in the effect used to render the mesh
  8965. * @param effect The effect we are binding the data to
  8966. */
  8967. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  8968. /**
  8969. * Binds the light information to the effect.
  8970. * @param light The light containing the generator
  8971. * @param effect The effect we are binding the data to
  8972. * @param lightIndex The light index in the effect used to render
  8973. */
  8974. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  8975. /**
  8976. * Binds the lights information from the scene to the effect for the given mesh.
  8977. * @param light Light to bind
  8978. * @param lightIndex Light index
  8979. * @param scene The scene where the light belongs to
  8980. * @param mesh The mesh we are binding the information to render
  8981. * @param effect The effect we are binding the data to
  8982. * @param useSpecular Defines if specular is supported
  8983. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  8984. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  8985. */
  8986. static BindLight(light: Light, lightIndex: number, scene: Scene, mesh: AbstractMesh, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  8987. /**
  8988. * Binds the lights information from the scene to the effect for the given mesh.
  8989. * @param scene The scene the lights belongs to
  8990. * @param mesh The mesh we are binding the information to render
  8991. * @param effect The effect we are binding the data to
  8992. * @param defines The generated defines for the effect
  8993. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  8994. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  8995. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  8996. */
  8997. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  8998. private static _tempFogColor;
  8999. /**
  9000. * Binds the fog information from the scene to the effect for the given mesh.
  9001. * @param scene The scene the lights belongs to
  9002. * @param mesh The mesh we are binding the information to render
  9003. * @param effect The effect we are binding the data to
  9004. * @param linearSpace Defines if the fog effect is applied in linear space
  9005. */
  9006. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9007. /**
  9008. * Binds the bones information from the mesh to the effect.
  9009. * @param mesh The mesh we are binding the information to render
  9010. * @param effect The effect we are binding the data to
  9011. */
  9012. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9013. /**
  9014. * Binds the morph targets information from the mesh to the effect.
  9015. * @param abstractMesh The mesh we are binding the information to render
  9016. * @param effect The effect we are binding the data to
  9017. */
  9018. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9019. /**
  9020. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9021. * @param defines The generated defines used in the effect
  9022. * @param effect The effect we are binding the data to
  9023. * @param scene The scene we are willing to render with logarithmic scale for
  9024. */
  9025. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9026. /**
  9027. * Binds the clip plane information from the scene to the effect.
  9028. * @param scene The scene the clip plane information are extracted from
  9029. * @param effect The effect we are binding the data to
  9030. */
  9031. static BindClipPlane(effect: Effect, scene: Scene): void;
  9032. }
  9033. }
  9034. declare module BABYLON {
  9035. /** @hidden */
  9036. export var packingFunctions: {
  9037. name: string;
  9038. shader: string;
  9039. };
  9040. }
  9041. declare module BABYLON {
  9042. /** @hidden */
  9043. export var shadowMapPixelShader: {
  9044. name: string;
  9045. shader: string;
  9046. };
  9047. }
  9048. declare module BABYLON {
  9049. /** @hidden */
  9050. export var bonesDeclaration: {
  9051. name: string;
  9052. shader: string;
  9053. };
  9054. }
  9055. declare module BABYLON {
  9056. /** @hidden */
  9057. export var morphTargetsVertexGlobalDeclaration: {
  9058. name: string;
  9059. shader: string;
  9060. };
  9061. }
  9062. declare module BABYLON {
  9063. /** @hidden */
  9064. export var morphTargetsVertexDeclaration: {
  9065. name: string;
  9066. shader: string;
  9067. };
  9068. }
  9069. declare module BABYLON {
  9070. /** @hidden */
  9071. export var instancesDeclaration: {
  9072. name: string;
  9073. shader: string;
  9074. };
  9075. }
  9076. declare module BABYLON {
  9077. /** @hidden */
  9078. export var helperFunctions: {
  9079. name: string;
  9080. shader: string;
  9081. };
  9082. }
  9083. declare module BABYLON {
  9084. /** @hidden */
  9085. export var morphTargetsVertex: {
  9086. name: string;
  9087. shader: string;
  9088. };
  9089. }
  9090. declare module BABYLON {
  9091. /** @hidden */
  9092. export var instancesVertex: {
  9093. name: string;
  9094. shader: string;
  9095. };
  9096. }
  9097. declare module BABYLON {
  9098. /** @hidden */
  9099. export var bonesVertex: {
  9100. name: string;
  9101. shader: string;
  9102. };
  9103. }
  9104. declare module BABYLON {
  9105. /** @hidden */
  9106. export var shadowMapVertexShader: {
  9107. name: string;
  9108. shader: string;
  9109. };
  9110. }
  9111. declare module BABYLON {
  9112. /** @hidden */
  9113. export var depthBoxBlurPixelShader: {
  9114. name: string;
  9115. shader: string;
  9116. };
  9117. }
  9118. declare module BABYLON {
  9119. /**
  9120. * Defines the options associated with the creation of a custom shader for a shadow generator.
  9121. */
  9122. export interface ICustomShaderOptions {
  9123. /**
  9124. * Gets or sets the custom shader name to use
  9125. */
  9126. shaderName: string;
  9127. /**
  9128. * The list of attribute names used in the shader
  9129. */
  9130. attributes?: string[];
  9131. /**
  9132. * The list of unifrom names used in the shader
  9133. */
  9134. uniforms?: string[];
  9135. /**
  9136. * The list of sampler names used in the shader
  9137. */
  9138. samplers?: string[];
  9139. /**
  9140. * The list of defines used in the shader
  9141. */
  9142. defines?: string[];
  9143. }
  9144. /**
  9145. * Interface to implement to create a shadow generator compatible with BJS.
  9146. */
  9147. export interface IShadowGenerator {
  9148. /**
  9149. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9150. * @returns The render target texture if present otherwise, null
  9151. */
  9152. getShadowMap(): Nullable<RenderTargetTexture>;
  9153. /**
  9154. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9155. * @returns The render target texture if the shadow map is present otherwise, null
  9156. */
  9157. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9158. /**
  9159. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9160. * @param subMesh The submesh we want to render in the shadow map
  9161. * @param useInstances Defines wether will draw in the map using instances
  9162. * @returns true if ready otherwise, false
  9163. */
  9164. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9165. /**
  9166. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9167. * @param defines Defines of the material we want to update
  9168. * @param lightIndex Index of the light in the enabled light list of the material
  9169. */
  9170. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  9171. /**
  9172. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9173. * defined in the generator but impacting the effect).
  9174. * It implies the unifroms available on the materials are the standard BJS ones.
  9175. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9176. * @param effect The effect we are binfing the information for
  9177. */
  9178. bindShadowLight(lightIndex: string, effect: Effect): void;
  9179. /**
  9180. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9181. * (eq to shadow prjection matrix * light transform matrix)
  9182. * @returns The transform matrix used to create the shadow map
  9183. */
  9184. getTransformMatrix(): Matrix;
  9185. /**
  9186. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9187. * Cube and 2D textures for instance.
  9188. */
  9189. recreateShadowMap(): void;
  9190. /**
  9191. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9192. * @param onCompiled Callback triggered at the and of the effects compilation
  9193. * @param options Sets of optional options forcing the compilation with different modes
  9194. */
  9195. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9196. useInstances: boolean;
  9197. }>): void;
  9198. /**
  9199. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9200. * @param options Sets of optional options forcing the compilation with different modes
  9201. * @returns A promise that resolves when the compilation completes
  9202. */
  9203. forceCompilationAsync(options?: Partial<{
  9204. useInstances: boolean;
  9205. }>): Promise<void>;
  9206. /**
  9207. * Serializes the shadow generator setup to a json object.
  9208. * @returns The serialized JSON object
  9209. */
  9210. serialize(): any;
  9211. /**
  9212. * Disposes the Shadow map and related Textures and effects.
  9213. */
  9214. dispose(): void;
  9215. }
  9216. /**
  9217. * Default implementation IShadowGenerator.
  9218. * This is the main object responsible of generating shadows in the framework.
  9219. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  9220. */
  9221. export class ShadowGenerator implements IShadowGenerator {
  9222. /**
  9223. * Shadow generator mode None: no filtering applied.
  9224. */
  9225. static readonly FILTER_NONE: number;
  9226. /**
  9227. * Shadow generator mode ESM: Exponential Shadow Mapping.
  9228. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9229. */
  9230. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  9231. /**
  9232. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  9233. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  9234. */
  9235. static readonly FILTER_POISSONSAMPLING: number;
  9236. /**
  9237. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  9238. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9239. */
  9240. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  9241. /**
  9242. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  9243. * edge artifacts on steep falloff.
  9244. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9245. */
  9246. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  9247. /**
  9248. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  9249. * edge artifacts on steep falloff.
  9250. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9251. */
  9252. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  9253. /**
  9254. * Shadow generator mode PCF: Percentage Closer Filtering
  9255. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9256. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  9257. */
  9258. static readonly FILTER_PCF: number;
  9259. /**
  9260. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  9261. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9262. * Contact Hardening
  9263. */
  9264. static readonly FILTER_PCSS: number;
  9265. /**
  9266. * Reserved for PCF and PCSS
  9267. * Highest Quality.
  9268. *
  9269. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  9270. *
  9271. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  9272. */
  9273. static readonly QUALITY_HIGH: number;
  9274. /**
  9275. * Reserved for PCF and PCSS
  9276. * Good tradeoff for quality/perf cross devices
  9277. *
  9278. * Execute PCF on a 3*3 kernel.
  9279. *
  9280. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  9281. */
  9282. static readonly QUALITY_MEDIUM: number;
  9283. /**
  9284. * Reserved for PCF and PCSS
  9285. * The lowest quality but the fastest.
  9286. *
  9287. * Execute PCF on a 1*1 kernel.
  9288. *
  9289. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  9290. */
  9291. static readonly QUALITY_LOW: number;
  9292. /** Gets or sets the custom shader name to use */
  9293. customShaderOptions: ICustomShaderOptions;
  9294. /**
  9295. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  9296. */
  9297. onBeforeShadowMapRenderObservable: Observable<Effect>;
  9298. /**
  9299. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  9300. */
  9301. onAfterShadowMapRenderObservable: Observable<Effect>;
  9302. /**
  9303. * Observable triggered before a mesh is rendered in the shadow map.
  9304. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  9305. */
  9306. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  9307. /**
  9308. * Observable triggered after a mesh is rendered in the shadow map.
  9309. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  9310. */
  9311. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  9312. private _bias;
  9313. /**
  9314. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  9315. */
  9316. /**
  9317. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  9318. */
  9319. bias: number;
  9320. private _normalBias;
  9321. /**
  9322. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9323. */
  9324. /**
  9325. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9326. */
  9327. normalBias: number;
  9328. private _blurBoxOffset;
  9329. /**
  9330. * Gets the blur box offset: offset applied during the blur pass.
  9331. * Only useful if useKernelBlur = false
  9332. */
  9333. /**
  9334. * Sets the blur box offset: offset applied during the blur pass.
  9335. * Only useful if useKernelBlur = false
  9336. */
  9337. blurBoxOffset: number;
  9338. private _blurScale;
  9339. /**
  9340. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  9341. * 2 means half of the size.
  9342. */
  9343. /**
  9344. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  9345. * 2 means half of the size.
  9346. */
  9347. blurScale: number;
  9348. private _blurKernel;
  9349. /**
  9350. * Gets the blur kernel: kernel size of the blur pass.
  9351. * Only useful if useKernelBlur = true
  9352. */
  9353. /**
  9354. * Sets the blur kernel: kernel size of the blur pass.
  9355. * Only useful if useKernelBlur = true
  9356. */
  9357. blurKernel: number;
  9358. private _useKernelBlur;
  9359. /**
  9360. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  9361. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9362. */
  9363. /**
  9364. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  9365. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9366. */
  9367. useKernelBlur: boolean;
  9368. private _depthScale;
  9369. /**
  9370. * Gets the depth scale used in ESM mode.
  9371. */
  9372. /**
  9373. * Sets the depth scale used in ESM mode.
  9374. * This can override the scale stored on the light.
  9375. */
  9376. depthScale: number;
  9377. private _filter;
  9378. /**
  9379. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  9380. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9381. */
  9382. /**
  9383. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  9384. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9385. */
  9386. filter: number;
  9387. /**
  9388. * Gets if the current filter is set to Poisson Sampling.
  9389. */
  9390. /**
  9391. * Sets the current filter to Poisson Sampling.
  9392. */
  9393. usePoissonSampling: boolean;
  9394. /**
  9395. * Gets if the current filter is set to ESM.
  9396. */
  9397. /**
  9398. * Sets the current filter is to ESM.
  9399. */
  9400. useExponentialShadowMap: boolean;
  9401. /**
  9402. * Gets if the current filter is set to filtered ESM.
  9403. */
  9404. /**
  9405. * Gets if the current filter is set to filtered ESM.
  9406. */
  9407. useBlurExponentialShadowMap: boolean;
  9408. /**
  9409. * Gets if the current filter is set to "close ESM" (using the inverse of the
  9410. * exponential to prevent steep falloff artifacts).
  9411. */
  9412. /**
  9413. * Sets the current filter to "close ESM" (using the inverse of the
  9414. * exponential to prevent steep falloff artifacts).
  9415. */
  9416. useCloseExponentialShadowMap: boolean;
  9417. /**
  9418. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  9419. * exponential to prevent steep falloff artifacts).
  9420. */
  9421. /**
  9422. * Sets the current filter to filtered "close ESM" (using the inverse of the
  9423. * exponential to prevent steep falloff artifacts).
  9424. */
  9425. useBlurCloseExponentialShadowMap: boolean;
  9426. /**
  9427. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  9428. */
  9429. /**
  9430. * Sets the current filter to "PCF" (percentage closer filtering).
  9431. */
  9432. usePercentageCloserFiltering: boolean;
  9433. private _filteringQuality;
  9434. /**
  9435. * Gets the PCF or PCSS Quality.
  9436. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9437. */
  9438. /**
  9439. * Sets the PCF or PCSS Quality.
  9440. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9441. */
  9442. filteringQuality: number;
  9443. /**
  9444. * Gets if the current filter is set to "PCSS" (contact hardening).
  9445. */
  9446. /**
  9447. * Sets the current filter to "PCSS" (contact hardening).
  9448. */
  9449. useContactHardeningShadow: boolean;
  9450. private _contactHardeningLightSizeUVRatio;
  9451. /**
  9452. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9453. * Using a ratio helps keeping shape stability independently of the map size.
  9454. *
  9455. * It does not account for the light projection as it was having too much
  9456. * instability during the light setup or during light position changes.
  9457. *
  9458. * Only valid if useContactHardeningShadow is true.
  9459. */
  9460. /**
  9461. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9462. * Using a ratio helps keeping shape stability independently of the map size.
  9463. *
  9464. * It does not account for the light projection as it was having too much
  9465. * instability during the light setup or during light position changes.
  9466. *
  9467. * Only valid if useContactHardeningShadow is true.
  9468. */
  9469. contactHardeningLightSizeUVRatio: number;
  9470. private _darkness;
  9471. /** Gets or sets the actual darkness of a shadow */
  9472. darkness: number;
  9473. /**
  9474. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  9475. * 0 means strongest and 1 would means no shadow.
  9476. * @returns the darkness.
  9477. */
  9478. getDarkness(): number;
  9479. /**
  9480. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  9481. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  9482. * @returns the shadow generator allowing fluent coding.
  9483. */
  9484. setDarkness(darkness: number): ShadowGenerator;
  9485. private _transparencyShadow;
  9486. /** Gets or sets the ability to have transparent shadow */
  9487. transparencyShadow: boolean;
  9488. /**
  9489. * Sets the ability to have transparent shadow (boolean).
  9490. * @param transparent True if transparent else False
  9491. * @returns the shadow generator allowing fluent coding
  9492. */
  9493. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  9494. private _shadowMap;
  9495. private _shadowMap2;
  9496. /**
  9497. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9498. * @returns The render target texture if present otherwise, null
  9499. */
  9500. getShadowMap(): Nullable<RenderTargetTexture>;
  9501. /**
  9502. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9503. * @returns The render target texture if the shadow map is present otherwise, null
  9504. */
  9505. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9506. /**
  9507. * Gets the class name of that object
  9508. * @returns "ShadowGenerator"
  9509. */
  9510. getClassName(): string;
  9511. /**
  9512. * Helper function to add a mesh and its descendants to the list of shadow casters.
  9513. * @param mesh Mesh to add
  9514. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  9515. * @returns the Shadow Generator itself
  9516. */
  9517. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9518. /**
  9519. * Helper function to remove a mesh and its descendants from the list of shadow casters
  9520. * @param mesh Mesh to remove
  9521. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  9522. * @returns the Shadow Generator itself
  9523. */
  9524. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9525. /**
  9526. * Controls the extent to which the shadows fade out at the edge of the frustum
  9527. * Used only by directionals and spots
  9528. */
  9529. frustumEdgeFalloff: number;
  9530. private _light;
  9531. /**
  9532. * Returns the associated light object.
  9533. * @returns the light generating the shadow
  9534. */
  9535. getLight(): IShadowLight;
  9536. /**
  9537. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  9538. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  9539. * It might on the other hand introduce peter panning.
  9540. */
  9541. forceBackFacesOnly: boolean;
  9542. private _scene;
  9543. private _lightDirection;
  9544. private _effect;
  9545. private _viewMatrix;
  9546. private _projectionMatrix;
  9547. private _transformMatrix;
  9548. private _cachedPosition;
  9549. private _cachedDirection;
  9550. private _cachedDefines;
  9551. private _currentRenderID;
  9552. private _boxBlurPostprocess;
  9553. private _kernelBlurXPostprocess;
  9554. private _kernelBlurYPostprocess;
  9555. private _blurPostProcesses;
  9556. private _mapSize;
  9557. private _currentFaceIndex;
  9558. private _currentFaceIndexCache;
  9559. private _textureType;
  9560. private _defaultTextureMatrix;
  9561. private _storedUniqueId;
  9562. /** @hidden */
  9563. static _SceneComponentInitialization: (scene: Scene) => void;
  9564. /**
  9565. * Creates a ShadowGenerator object.
  9566. * A ShadowGenerator is the required tool to use the shadows.
  9567. * Each light casting shadows needs to use its own ShadowGenerator.
  9568. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  9569. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  9570. * @param light The light object generating the shadows.
  9571. * @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.
  9572. */
  9573. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  9574. private _initializeGenerator;
  9575. private _initializeShadowMap;
  9576. private _initializeBlurRTTAndPostProcesses;
  9577. private _renderForShadowMap;
  9578. private _renderSubMeshForShadowMap;
  9579. private _applyFilterValues;
  9580. /**
  9581. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9582. * @param onCompiled Callback triggered at the and of the effects compilation
  9583. * @param options Sets of optional options forcing the compilation with different modes
  9584. */
  9585. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9586. useInstances: boolean;
  9587. }>): void;
  9588. /**
  9589. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9590. * @param options Sets of optional options forcing the compilation with different modes
  9591. * @returns A promise that resolves when the compilation completes
  9592. */
  9593. forceCompilationAsync(options?: Partial<{
  9594. useInstances: boolean;
  9595. }>): Promise<void>;
  9596. /**
  9597. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9598. * @param subMesh The submesh we want to render in the shadow map
  9599. * @param useInstances Defines wether will draw in the map using instances
  9600. * @returns true if ready otherwise, false
  9601. */
  9602. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9603. /**
  9604. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9605. * @param defines Defines of the material we want to update
  9606. * @param lightIndex Index of the light in the enabled light list of the material
  9607. */
  9608. prepareDefines(defines: any, lightIndex: number): void;
  9609. /**
  9610. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9611. * defined in the generator but impacting the effect).
  9612. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9613. * @param effect The effect we are binfing the information for
  9614. */
  9615. bindShadowLight(lightIndex: string, effect: Effect): void;
  9616. /**
  9617. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9618. * (eq to shadow prjection matrix * light transform matrix)
  9619. * @returns The transform matrix used to create the shadow map
  9620. */
  9621. getTransformMatrix(): Matrix;
  9622. /**
  9623. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9624. * Cube and 2D textures for instance.
  9625. */
  9626. recreateShadowMap(): void;
  9627. private _disposeBlurPostProcesses;
  9628. private _disposeRTTandPostProcesses;
  9629. /**
  9630. * Disposes the ShadowGenerator.
  9631. * Returns nothing.
  9632. */
  9633. dispose(): void;
  9634. /**
  9635. * Serializes the shadow generator setup to a json object.
  9636. * @returns The serialized JSON object
  9637. */
  9638. serialize(): any;
  9639. /**
  9640. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  9641. * @param parsedShadowGenerator The JSON object to parse
  9642. * @param scene The scene to create the shadow map for
  9643. * @returns The parsed shadow generator
  9644. */
  9645. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  9646. }
  9647. }
  9648. declare module BABYLON {
  9649. /**
  9650. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  9651. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  9652. * 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.
  9653. */
  9654. export abstract class Light extends Node {
  9655. /**
  9656. * Falloff Default: light is falling off following the material specification:
  9657. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  9658. */
  9659. static readonly FALLOFF_DEFAULT: number;
  9660. /**
  9661. * Falloff Physical: light is falling off following the inverse squared distance law.
  9662. */
  9663. static readonly FALLOFF_PHYSICAL: number;
  9664. /**
  9665. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  9666. * to enhance interoperability with other engines.
  9667. */
  9668. static readonly FALLOFF_GLTF: number;
  9669. /**
  9670. * Falloff Standard: light is falling off like in the standard material
  9671. * to enhance interoperability with other materials.
  9672. */
  9673. static readonly FALLOFF_STANDARD: number;
  9674. /**
  9675. * If every light affecting the material is in this lightmapMode,
  9676. * material.lightmapTexture adds or multiplies
  9677. * (depends on material.useLightmapAsShadowmap)
  9678. * after every other light calculations.
  9679. */
  9680. static readonly LIGHTMAP_DEFAULT: number;
  9681. /**
  9682. * material.lightmapTexture as only diffuse lighting from this light
  9683. * adds only specular lighting from this light
  9684. * adds dynamic shadows
  9685. */
  9686. static readonly LIGHTMAP_SPECULAR: number;
  9687. /**
  9688. * material.lightmapTexture as only lighting
  9689. * no light calculation from this light
  9690. * only adds dynamic shadows from this light
  9691. */
  9692. static readonly LIGHTMAP_SHADOWSONLY: number;
  9693. /**
  9694. * Each light type uses the default quantity according to its type:
  9695. * point/spot lights use luminous intensity
  9696. * directional lights use illuminance
  9697. */
  9698. static readonly INTENSITYMODE_AUTOMATIC: number;
  9699. /**
  9700. * lumen (lm)
  9701. */
  9702. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  9703. /**
  9704. * candela (lm/sr)
  9705. */
  9706. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  9707. /**
  9708. * lux (lm/m^2)
  9709. */
  9710. static readonly INTENSITYMODE_ILLUMINANCE: number;
  9711. /**
  9712. * nit (cd/m^2)
  9713. */
  9714. static readonly INTENSITYMODE_LUMINANCE: number;
  9715. /**
  9716. * Light type const id of the point light.
  9717. */
  9718. static readonly LIGHTTYPEID_POINTLIGHT: number;
  9719. /**
  9720. * Light type const id of the directional light.
  9721. */
  9722. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  9723. /**
  9724. * Light type const id of the spot light.
  9725. */
  9726. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  9727. /**
  9728. * Light type const id of the hemispheric light.
  9729. */
  9730. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  9731. /**
  9732. * Diffuse gives the basic color to an object.
  9733. */
  9734. diffuse: Color3;
  9735. /**
  9736. * Specular produces a highlight color on an object.
  9737. * Note: This is note affecting PBR materials.
  9738. */
  9739. specular: Color3;
  9740. /**
  9741. * Defines the falloff type for this light. This lets overrriding how punctual light are
  9742. * falling off base on range or angle.
  9743. * This can be set to any values in Light.FALLOFF_x.
  9744. *
  9745. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  9746. * other types of materials.
  9747. */
  9748. falloffType: number;
  9749. /**
  9750. * Strength of the light.
  9751. * Note: By default it is define in the framework own unit.
  9752. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  9753. */
  9754. intensity: number;
  9755. private _range;
  9756. protected _inverseSquaredRange: number;
  9757. /**
  9758. * Defines how far from the source the light is impacting in scene units.
  9759. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  9760. */
  9761. /**
  9762. * Defines how far from the source the light is impacting in scene units.
  9763. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  9764. */
  9765. range: number;
  9766. /**
  9767. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  9768. * of light.
  9769. */
  9770. private _photometricScale;
  9771. private _intensityMode;
  9772. /**
  9773. * Gets the photometric scale used to interpret the intensity.
  9774. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  9775. */
  9776. /**
  9777. * Sets the photometric scale used to interpret the intensity.
  9778. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  9779. */
  9780. intensityMode: number;
  9781. private _radius;
  9782. /**
  9783. * Gets the light radius used by PBR Materials to simulate soft area lights.
  9784. */
  9785. /**
  9786. * sets the light radius used by PBR Materials to simulate soft area lights.
  9787. */
  9788. radius: number;
  9789. private _renderPriority;
  9790. /**
  9791. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  9792. * exceeding the number allowed of the materials.
  9793. */
  9794. renderPriority: number;
  9795. private _shadowEnabled;
  9796. /**
  9797. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  9798. * the current shadow generator.
  9799. */
  9800. /**
  9801. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  9802. * the current shadow generator.
  9803. */
  9804. shadowEnabled: boolean;
  9805. private _includedOnlyMeshes;
  9806. /**
  9807. * Gets the only meshes impacted by this light.
  9808. */
  9809. /**
  9810. * Sets the only meshes impacted by this light.
  9811. */
  9812. includedOnlyMeshes: AbstractMesh[];
  9813. private _excludedMeshes;
  9814. /**
  9815. * Gets the meshes not impacted by this light.
  9816. */
  9817. /**
  9818. * Sets the meshes not impacted by this light.
  9819. */
  9820. excludedMeshes: AbstractMesh[];
  9821. private _excludeWithLayerMask;
  9822. /**
  9823. * Gets the layer id use to find what meshes are not impacted by the light.
  9824. * Inactive if 0
  9825. */
  9826. /**
  9827. * Sets the layer id use to find what meshes are not impacted by the light.
  9828. * Inactive if 0
  9829. */
  9830. excludeWithLayerMask: number;
  9831. private _includeOnlyWithLayerMask;
  9832. /**
  9833. * Gets the layer id use to find what meshes are impacted by the light.
  9834. * Inactive if 0
  9835. */
  9836. /**
  9837. * Sets the layer id use to find what meshes are impacted by the light.
  9838. * Inactive if 0
  9839. */
  9840. includeOnlyWithLayerMask: number;
  9841. private _lightmapMode;
  9842. /**
  9843. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  9844. */
  9845. /**
  9846. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  9847. */
  9848. lightmapMode: number;
  9849. /**
  9850. * Shadow generator associted to the light.
  9851. * @hidden Internal use only.
  9852. */
  9853. _shadowGenerator: Nullable<IShadowGenerator>;
  9854. /**
  9855. * @hidden Internal use only.
  9856. */
  9857. _excludedMeshesIds: string[];
  9858. /**
  9859. * @hidden Internal use only.
  9860. */
  9861. _includedOnlyMeshesIds: string[];
  9862. /**
  9863. * The current light unifom buffer.
  9864. * @hidden Internal use only.
  9865. */
  9866. _uniformBuffer: UniformBuffer;
  9867. /**
  9868. * Creates a Light object in the scene.
  9869. * Documentation : https://doc.babylonjs.com/babylon101/lights
  9870. * @param name The firendly name of the light
  9871. * @param scene The scene the light belongs too
  9872. */
  9873. constructor(name: string, scene: Scene);
  9874. protected abstract _buildUniformLayout(): void;
  9875. /**
  9876. * Sets the passed Effect "effect" with the Light information.
  9877. * @param effect The effect to update
  9878. * @param lightIndex The index of the light in the effect to update
  9879. * @returns The light
  9880. */
  9881. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  9882. /**
  9883. * Sets the passed Effect "effect" with the Light information.
  9884. * @param effect The effect to update
  9885. * @param lightDataUniformName The uniform used to store light data (position or direction)
  9886. * @returns The light
  9887. */
  9888. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  9889. /**
  9890. * Returns the string "Light".
  9891. * @returns the class name
  9892. */
  9893. getClassName(): string;
  9894. /** @hidden */
  9895. readonly _isLight: boolean;
  9896. /**
  9897. * Converts the light information to a readable string for debug purpose.
  9898. * @param fullDetails Supports for multiple levels of logging within scene loading
  9899. * @returns the human readable light info
  9900. */
  9901. toString(fullDetails?: boolean): string;
  9902. /** @hidden */
  9903. protected _syncParentEnabledState(): void;
  9904. /**
  9905. * Set the enabled state of this node.
  9906. * @param value - the new enabled state
  9907. */
  9908. setEnabled(value: boolean): void;
  9909. /**
  9910. * Returns the Light associated shadow generator if any.
  9911. * @return the associated shadow generator.
  9912. */
  9913. getShadowGenerator(): Nullable<IShadowGenerator>;
  9914. /**
  9915. * Returns a Vector3, the absolute light position in the World.
  9916. * @returns the world space position of the light
  9917. */
  9918. getAbsolutePosition(): Vector3;
  9919. /**
  9920. * Specifies if the light will affect the passed mesh.
  9921. * @param mesh The mesh to test against the light
  9922. * @return true the mesh is affected otherwise, false.
  9923. */
  9924. canAffectMesh(mesh: AbstractMesh): boolean;
  9925. /**
  9926. * Sort function to order lights for rendering.
  9927. * @param a First Light object to compare to second.
  9928. * @param b Second Light object to compare first.
  9929. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  9930. */
  9931. static CompareLightsPriority(a: Light, b: Light): number;
  9932. /**
  9933. * Releases resources associated with this node.
  9934. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  9935. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  9936. */
  9937. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  9938. /**
  9939. * Returns the light type ID (integer).
  9940. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  9941. */
  9942. getTypeID(): number;
  9943. /**
  9944. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  9945. * @returns the scaled intensity in intensity mode unit
  9946. */
  9947. getScaledIntensity(): number;
  9948. /**
  9949. * Returns a new Light object, named "name", from the current one.
  9950. * @param name The name of the cloned light
  9951. * @returns the new created light
  9952. */
  9953. clone(name: string): Nullable<Light>;
  9954. /**
  9955. * Serializes the current light into a Serialization object.
  9956. * @returns the serialized object.
  9957. */
  9958. serialize(): any;
  9959. /**
  9960. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  9961. * This new light is named "name" and added to the passed scene.
  9962. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  9963. * @param name The friendly name of the light
  9964. * @param scene The scene the new light will belong to
  9965. * @returns the constructor function
  9966. */
  9967. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  9968. /**
  9969. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  9970. * @param parsedLight The JSON representation of the light
  9971. * @param scene The scene to create the parsed light in
  9972. * @returns the created light after parsing
  9973. */
  9974. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  9975. private _hookArrayForExcluded;
  9976. private _hookArrayForIncludedOnly;
  9977. private _resyncMeshes;
  9978. /**
  9979. * Forces the meshes to update their light related information in their rendering used effects
  9980. * @hidden Internal Use Only
  9981. */
  9982. _markMeshesAsLightDirty(): void;
  9983. /**
  9984. * Recomputes the cached photometric scale if needed.
  9985. */
  9986. private _computePhotometricScale;
  9987. /**
  9988. * Returns the Photometric Scale according to the light type and intensity mode.
  9989. */
  9990. private _getPhotometricScale;
  9991. /**
  9992. * Reorder the light in the scene according to their defined priority.
  9993. * @hidden Internal Use Only
  9994. */
  9995. _reorderLightsInScene(): void;
  9996. /**
  9997. * Prepares the list of defines specific to the light type.
  9998. * @param defines the list of defines
  9999. * @param lightIndex defines the index of the light for the effect
  10000. */
  10001. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  10002. }
  10003. }
  10004. declare module BABYLON {
  10005. /**
  10006. * Interface used to define Action
  10007. */
  10008. export interface IAction {
  10009. /**
  10010. * Trigger for the action
  10011. */
  10012. trigger: number;
  10013. /** Options of the trigger */
  10014. triggerOptions: any;
  10015. /**
  10016. * Gets the trigger parameters
  10017. * @returns the trigger parameters
  10018. */
  10019. getTriggerParameter(): any;
  10020. /**
  10021. * Internal only - executes current action event
  10022. * @hidden
  10023. */
  10024. _executeCurrent(evt?: ActionEvent): void;
  10025. /**
  10026. * Serialize placeholder for child classes
  10027. * @param parent of child
  10028. * @returns the serialized object
  10029. */
  10030. serialize(parent: any): any;
  10031. /**
  10032. * Internal only
  10033. * @hidden
  10034. */
  10035. _prepare(): void;
  10036. /**
  10037. * Internal only - manager for action
  10038. * @hidden
  10039. */
  10040. _actionManager: AbstractActionManager;
  10041. /**
  10042. * Adds action to chain of actions, may be a DoNothingAction
  10043. * @param action defines the next action to execute
  10044. * @returns The action passed in
  10045. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10046. */
  10047. then(action: IAction): IAction;
  10048. }
  10049. /**
  10050. * The action to be carried out following a trigger
  10051. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10052. */
  10053. export class Action implements IAction {
  10054. /** the trigger, with or without parameters, for the action */
  10055. triggerOptions: any;
  10056. /**
  10057. * Trigger for the action
  10058. */
  10059. trigger: number;
  10060. /**
  10061. * Internal only - manager for action
  10062. * @hidden
  10063. */
  10064. _actionManager: ActionManager;
  10065. private _nextActiveAction;
  10066. private _child;
  10067. private _condition?;
  10068. private _triggerParameter;
  10069. /**
  10070. * An event triggered prior to action being executed.
  10071. */
  10072. onBeforeExecuteObservable: Observable<Action>;
  10073. /**
  10074. * Creates a new Action
  10075. * @param triggerOptions the trigger, with or without parameters, for the action
  10076. * @param condition an optional determinant of action
  10077. */
  10078. constructor(
  10079. /** the trigger, with or without parameters, for the action */
  10080. triggerOptions: any, condition?: Condition);
  10081. /**
  10082. * Internal only
  10083. * @hidden
  10084. */
  10085. _prepare(): void;
  10086. /**
  10087. * Gets the trigger parameters
  10088. * @returns the trigger parameters
  10089. */
  10090. getTriggerParameter(): any;
  10091. /**
  10092. * Internal only - executes current action event
  10093. * @hidden
  10094. */
  10095. _executeCurrent(evt?: ActionEvent): void;
  10096. /**
  10097. * Execute placeholder for child classes
  10098. * @param evt optional action event
  10099. */
  10100. execute(evt?: ActionEvent): void;
  10101. /**
  10102. * Skips to next active action
  10103. */
  10104. skipToNextActiveAction(): void;
  10105. /**
  10106. * Adds action to chain of actions, may be a DoNothingAction
  10107. * @param action defines the next action to execute
  10108. * @returns The action passed in
  10109. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10110. */
  10111. then(action: Action): Action;
  10112. /**
  10113. * Internal only
  10114. * @hidden
  10115. */
  10116. _getProperty(propertyPath: string): string;
  10117. /**
  10118. * Internal only
  10119. * @hidden
  10120. */
  10121. _getEffectiveTarget(target: any, propertyPath: string): any;
  10122. /**
  10123. * Serialize placeholder for child classes
  10124. * @param parent of child
  10125. * @returns the serialized object
  10126. */
  10127. serialize(parent: any): any;
  10128. /**
  10129. * Internal only called by serialize
  10130. * @hidden
  10131. */
  10132. protected _serialize(serializedAction: any, parent?: any): any;
  10133. /**
  10134. * Internal only
  10135. * @hidden
  10136. */
  10137. static _SerializeValueAsString: (value: any) => string;
  10138. /**
  10139. * Internal only
  10140. * @hidden
  10141. */
  10142. static _GetTargetProperty: (target: Node | Scene) => {
  10143. name: string;
  10144. targetType: string;
  10145. value: string;
  10146. };
  10147. }
  10148. }
  10149. declare module BABYLON {
  10150. /**
  10151. * A Condition applied to an Action
  10152. */
  10153. export class Condition {
  10154. /**
  10155. * Internal only - manager for action
  10156. * @hidden
  10157. */
  10158. _actionManager: ActionManager;
  10159. /**
  10160. * Internal only
  10161. * @hidden
  10162. */
  10163. _evaluationId: number;
  10164. /**
  10165. * Internal only
  10166. * @hidden
  10167. */
  10168. _currentResult: boolean;
  10169. /**
  10170. * Creates a new Condition
  10171. * @param actionManager the manager of the action the condition is applied to
  10172. */
  10173. constructor(actionManager: ActionManager);
  10174. /**
  10175. * Check if the current condition is valid
  10176. * @returns a boolean
  10177. */
  10178. isValid(): boolean;
  10179. /**
  10180. * Internal only
  10181. * @hidden
  10182. */
  10183. _getProperty(propertyPath: string): string;
  10184. /**
  10185. * Internal only
  10186. * @hidden
  10187. */
  10188. _getEffectiveTarget(target: any, propertyPath: string): any;
  10189. /**
  10190. * Serialize placeholder for child classes
  10191. * @returns the serialized object
  10192. */
  10193. serialize(): any;
  10194. /**
  10195. * Internal only
  10196. * @hidden
  10197. */
  10198. protected _serialize(serializedCondition: any): any;
  10199. }
  10200. /**
  10201. * Defines specific conditional operators as extensions of Condition
  10202. */
  10203. export class ValueCondition extends Condition {
  10204. /** path to specify the property of the target the conditional operator uses */
  10205. propertyPath: string;
  10206. /** the value compared by the conditional operator against the current value of the property */
  10207. value: any;
  10208. /** the conditional operator, default ValueCondition.IsEqual */
  10209. operator: number;
  10210. /**
  10211. * Internal only
  10212. * @hidden
  10213. */
  10214. private static _IsEqual;
  10215. /**
  10216. * Internal only
  10217. * @hidden
  10218. */
  10219. private static _IsDifferent;
  10220. /**
  10221. * Internal only
  10222. * @hidden
  10223. */
  10224. private static _IsGreater;
  10225. /**
  10226. * Internal only
  10227. * @hidden
  10228. */
  10229. private static _IsLesser;
  10230. /**
  10231. * returns the number for IsEqual
  10232. */
  10233. static readonly IsEqual: number;
  10234. /**
  10235. * Returns the number for IsDifferent
  10236. */
  10237. static readonly IsDifferent: number;
  10238. /**
  10239. * Returns the number for IsGreater
  10240. */
  10241. static readonly IsGreater: number;
  10242. /**
  10243. * Returns the number for IsLesser
  10244. */
  10245. static readonly IsLesser: number;
  10246. /**
  10247. * Internal only The action manager for the condition
  10248. * @hidden
  10249. */
  10250. _actionManager: ActionManager;
  10251. /**
  10252. * Internal only
  10253. * @hidden
  10254. */
  10255. private _target;
  10256. /**
  10257. * Internal only
  10258. * @hidden
  10259. */
  10260. private _effectiveTarget;
  10261. /**
  10262. * Internal only
  10263. * @hidden
  10264. */
  10265. private _property;
  10266. /**
  10267. * Creates a new ValueCondition
  10268. * @param actionManager manager for the action the condition applies to
  10269. * @param target for the action
  10270. * @param propertyPath path to specify the property of the target the conditional operator uses
  10271. * @param value the value compared by the conditional operator against the current value of the property
  10272. * @param operator the conditional operator, default ValueCondition.IsEqual
  10273. */
  10274. constructor(actionManager: ActionManager, target: any,
  10275. /** path to specify the property of the target the conditional operator uses */
  10276. propertyPath: string,
  10277. /** the value compared by the conditional operator against the current value of the property */
  10278. value: any,
  10279. /** the conditional operator, default ValueCondition.IsEqual */
  10280. operator?: number);
  10281. /**
  10282. * Compares the given value with the property value for the specified conditional operator
  10283. * @returns the result of the comparison
  10284. */
  10285. isValid(): boolean;
  10286. /**
  10287. * Serialize the ValueCondition into a JSON compatible object
  10288. * @returns serialization object
  10289. */
  10290. serialize(): any;
  10291. /**
  10292. * Gets the name of the conditional operator for the ValueCondition
  10293. * @param operator the conditional operator
  10294. * @returns the name
  10295. */
  10296. static GetOperatorName(operator: number): string;
  10297. }
  10298. /**
  10299. * Defines a predicate condition as an extension of Condition
  10300. */
  10301. export class PredicateCondition extends Condition {
  10302. /** defines the predicate function used to validate the condition */
  10303. predicate: () => boolean;
  10304. /**
  10305. * Internal only - manager for action
  10306. * @hidden
  10307. */
  10308. _actionManager: ActionManager;
  10309. /**
  10310. * Creates a new PredicateCondition
  10311. * @param actionManager manager for the action the condition applies to
  10312. * @param predicate defines the predicate function used to validate the condition
  10313. */
  10314. constructor(actionManager: ActionManager,
  10315. /** defines the predicate function used to validate the condition */
  10316. predicate: () => boolean);
  10317. /**
  10318. * @returns the validity of the predicate condition
  10319. */
  10320. isValid(): boolean;
  10321. }
  10322. /**
  10323. * Defines a state condition as an extension of Condition
  10324. */
  10325. export class StateCondition extends Condition {
  10326. /** Value to compare with target state */
  10327. value: string;
  10328. /**
  10329. * Internal only - manager for action
  10330. * @hidden
  10331. */
  10332. _actionManager: ActionManager;
  10333. /**
  10334. * Internal only
  10335. * @hidden
  10336. */
  10337. private _target;
  10338. /**
  10339. * Creates a new StateCondition
  10340. * @param actionManager manager for the action the condition applies to
  10341. * @param target of the condition
  10342. * @param value to compare with target state
  10343. */
  10344. constructor(actionManager: ActionManager, target: any,
  10345. /** Value to compare with target state */
  10346. value: string);
  10347. /**
  10348. * Gets a boolean indicating if the current condition is met
  10349. * @returns the validity of the state
  10350. */
  10351. isValid(): boolean;
  10352. /**
  10353. * Serialize the StateCondition into a JSON compatible object
  10354. * @returns serialization object
  10355. */
  10356. serialize(): any;
  10357. }
  10358. }
  10359. declare module BABYLON {
  10360. /**
  10361. * This defines an action responsible to toggle a boolean once triggered.
  10362. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10363. */
  10364. export class SwitchBooleanAction extends Action {
  10365. /**
  10366. * The path to the boolean property in the target object
  10367. */
  10368. propertyPath: string;
  10369. private _target;
  10370. private _effectiveTarget;
  10371. private _property;
  10372. /**
  10373. * Instantiate the action
  10374. * @param triggerOptions defines the trigger options
  10375. * @param target defines the object containing the boolean
  10376. * @param propertyPath defines the path to the boolean property in the target object
  10377. * @param condition defines the trigger related conditions
  10378. */
  10379. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10380. /** @hidden */
  10381. _prepare(): void;
  10382. /**
  10383. * Execute the action toggle the boolean value.
  10384. */
  10385. execute(): void;
  10386. /**
  10387. * Serializes the actions and its related information.
  10388. * @param parent defines the object to serialize in
  10389. * @returns the serialized object
  10390. */
  10391. serialize(parent: any): any;
  10392. }
  10393. /**
  10394. * This defines an action responsible to set a the state field of the target
  10395. * to a desired value once triggered.
  10396. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10397. */
  10398. export class SetStateAction extends Action {
  10399. /**
  10400. * The value to store in the state field.
  10401. */
  10402. value: string;
  10403. private _target;
  10404. /**
  10405. * Instantiate the action
  10406. * @param triggerOptions defines the trigger options
  10407. * @param target defines the object containing the state property
  10408. * @param value defines the value to store in the state field
  10409. * @param condition defines the trigger related conditions
  10410. */
  10411. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10412. /**
  10413. * Execute the action and store the value on the target state property.
  10414. */
  10415. execute(): void;
  10416. /**
  10417. * Serializes the actions and its related information.
  10418. * @param parent defines the object to serialize in
  10419. * @returns the serialized object
  10420. */
  10421. serialize(parent: any): any;
  10422. }
  10423. /**
  10424. * This defines an action responsible to set a property of the target
  10425. * to a desired value once triggered.
  10426. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10427. */
  10428. export class SetValueAction extends Action {
  10429. /**
  10430. * The path of the property to set in the target.
  10431. */
  10432. propertyPath: string;
  10433. /**
  10434. * The value to set in the property
  10435. */
  10436. value: any;
  10437. private _target;
  10438. private _effectiveTarget;
  10439. private _property;
  10440. /**
  10441. * Instantiate the action
  10442. * @param triggerOptions defines the trigger options
  10443. * @param target defines the object containing the property
  10444. * @param propertyPath defines the path of the property to set in the target
  10445. * @param value defines the value to set in the property
  10446. * @param condition defines the trigger related conditions
  10447. */
  10448. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10449. /** @hidden */
  10450. _prepare(): void;
  10451. /**
  10452. * Execute the action and set the targetted property to the desired value.
  10453. */
  10454. execute(): void;
  10455. /**
  10456. * Serializes the actions and its related information.
  10457. * @param parent defines the object to serialize in
  10458. * @returns the serialized object
  10459. */
  10460. serialize(parent: any): any;
  10461. }
  10462. /**
  10463. * This defines an action responsible to increment the target value
  10464. * to a desired value once triggered.
  10465. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10466. */
  10467. export class IncrementValueAction extends Action {
  10468. /**
  10469. * The path of the property to increment in the target.
  10470. */
  10471. propertyPath: string;
  10472. /**
  10473. * The value we should increment the property by.
  10474. */
  10475. value: any;
  10476. private _target;
  10477. private _effectiveTarget;
  10478. private _property;
  10479. /**
  10480. * Instantiate the action
  10481. * @param triggerOptions defines the trigger options
  10482. * @param target defines the object containing the property
  10483. * @param propertyPath defines the path of the property to increment in the target
  10484. * @param value defines the value value we should increment the property by
  10485. * @param condition defines the trigger related conditions
  10486. */
  10487. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10488. /** @hidden */
  10489. _prepare(): void;
  10490. /**
  10491. * Execute the action and increment the target of the value amount.
  10492. */
  10493. execute(): void;
  10494. /**
  10495. * Serializes the actions and its related information.
  10496. * @param parent defines the object to serialize in
  10497. * @returns the serialized object
  10498. */
  10499. serialize(parent: any): any;
  10500. }
  10501. /**
  10502. * This defines an action responsible to start an animation once triggered.
  10503. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10504. */
  10505. export class PlayAnimationAction extends Action {
  10506. /**
  10507. * Where the animation should start (animation frame)
  10508. */
  10509. from: number;
  10510. /**
  10511. * Where the animation should stop (animation frame)
  10512. */
  10513. to: number;
  10514. /**
  10515. * Define if the animation should loop or stop after the first play.
  10516. */
  10517. loop?: boolean;
  10518. private _target;
  10519. /**
  10520. * Instantiate the action
  10521. * @param triggerOptions defines the trigger options
  10522. * @param target defines the target animation or animation name
  10523. * @param from defines from where the animation should start (animation frame)
  10524. * @param end defines where the animation should stop (animation frame)
  10525. * @param loop defines if the animation should loop or stop after the first play
  10526. * @param condition defines the trigger related conditions
  10527. */
  10528. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10529. /** @hidden */
  10530. _prepare(): void;
  10531. /**
  10532. * Execute the action and play the animation.
  10533. */
  10534. execute(): void;
  10535. /**
  10536. * Serializes the actions and its related information.
  10537. * @param parent defines the object to serialize in
  10538. * @returns the serialized object
  10539. */
  10540. serialize(parent: any): any;
  10541. }
  10542. /**
  10543. * This defines an action responsible to stop an animation once triggered.
  10544. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10545. */
  10546. export class StopAnimationAction extends Action {
  10547. private _target;
  10548. /**
  10549. * Instantiate the action
  10550. * @param triggerOptions defines the trigger options
  10551. * @param target defines the target animation or animation name
  10552. * @param condition defines the trigger related conditions
  10553. */
  10554. constructor(triggerOptions: any, target: any, condition?: Condition);
  10555. /** @hidden */
  10556. _prepare(): void;
  10557. /**
  10558. * Execute the action and stop the animation.
  10559. */
  10560. execute(): void;
  10561. /**
  10562. * Serializes the actions and its related information.
  10563. * @param parent defines the object to serialize in
  10564. * @returns the serialized object
  10565. */
  10566. serialize(parent: any): any;
  10567. }
  10568. /**
  10569. * This defines an action responsible that does nothing once triggered.
  10570. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10571. */
  10572. export class DoNothingAction extends Action {
  10573. /**
  10574. * Instantiate the action
  10575. * @param triggerOptions defines the trigger options
  10576. * @param condition defines the trigger related conditions
  10577. */
  10578. constructor(triggerOptions?: any, condition?: Condition);
  10579. /**
  10580. * Execute the action and do nothing.
  10581. */
  10582. execute(): void;
  10583. /**
  10584. * Serializes the actions and its related information.
  10585. * @param parent defines the object to serialize in
  10586. * @returns the serialized object
  10587. */
  10588. serialize(parent: any): any;
  10589. }
  10590. /**
  10591. * This defines an action responsible to trigger several actions once triggered.
  10592. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10593. */
  10594. export class CombineAction extends Action {
  10595. /**
  10596. * The list of aggregated animations to run.
  10597. */
  10598. children: Action[];
  10599. /**
  10600. * Instantiate the action
  10601. * @param triggerOptions defines the trigger options
  10602. * @param children defines the list of aggregated animations to run
  10603. * @param condition defines the trigger related conditions
  10604. */
  10605. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10606. /** @hidden */
  10607. _prepare(): void;
  10608. /**
  10609. * Execute the action and executes all the aggregated actions.
  10610. */
  10611. execute(evt: ActionEvent): void;
  10612. /**
  10613. * Serializes the actions and its related information.
  10614. * @param parent defines the object to serialize in
  10615. * @returns the serialized object
  10616. */
  10617. serialize(parent: any): any;
  10618. }
  10619. /**
  10620. * This defines an action responsible to run code (external event) once triggered.
  10621. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10622. */
  10623. export class ExecuteCodeAction extends Action {
  10624. /**
  10625. * The callback function to run.
  10626. */
  10627. func: (evt: ActionEvent) => void;
  10628. /**
  10629. * Instantiate the action
  10630. * @param triggerOptions defines the trigger options
  10631. * @param func defines the callback function to run
  10632. * @param condition defines the trigger related conditions
  10633. */
  10634. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10635. /**
  10636. * Execute the action and run the attached code.
  10637. */
  10638. execute(evt: ActionEvent): void;
  10639. }
  10640. /**
  10641. * This defines an action responsible to set the parent property of the target once triggered.
  10642. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10643. */
  10644. export class SetParentAction extends Action {
  10645. private _parent;
  10646. private _target;
  10647. /**
  10648. * Instantiate the action
  10649. * @param triggerOptions defines the trigger options
  10650. * @param target defines the target containing the parent property
  10651. * @param parent defines from where the animation should start (animation frame)
  10652. * @param condition defines the trigger related conditions
  10653. */
  10654. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10655. /** @hidden */
  10656. _prepare(): void;
  10657. /**
  10658. * Execute the action and set the parent property.
  10659. */
  10660. execute(): void;
  10661. /**
  10662. * Serializes the actions and its related information.
  10663. * @param parent defines the object to serialize in
  10664. * @returns the serialized object
  10665. */
  10666. serialize(parent: any): any;
  10667. }
  10668. }
  10669. declare module BABYLON {
  10670. /**
  10671. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10672. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10673. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10674. */
  10675. export class ActionManager extends AbstractActionManager {
  10676. /**
  10677. * Nothing
  10678. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10679. */
  10680. static readonly NothingTrigger: number;
  10681. /**
  10682. * On pick
  10683. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10684. */
  10685. static readonly OnPickTrigger: number;
  10686. /**
  10687. * On left pick
  10688. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10689. */
  10690. static readonly OnLeftPickTrigger: number;
  10691. /**
  10692. * On right pick
  10693. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10694. */
  10695. static readonly OnRightPickTrigger: number;
  10696. /**
  10697. * On center pick
  10698. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10699. */
  10700. static readonly OnCenterPickTrigger: number;
  10701. /**
  10702. * On pick down
  10703. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10704. */
  10705. static readonly OnPickDownTrigger: number;
  10706. /**
  10707. * On double pick
  10708. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10709. */
  10710. static readonly OnDoublePickTrigger: number;
  10711. /**
  10712. * On pick up
  10713. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10714. */
  10715. static readonly OnPickUpTrigger: number;
  10716. /**
  10717. * On pick out.
  10718. * This trigger will only be raised if you also declared a OnPickDown
  10719. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10720. */
  10721. static readonly OnPickOutTrigger: number;
  10722. /**
  10723. * On long press
  10724. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10725. */
  10726. static readonly OnLongPressTrigger: number;
  10727. /**
  10728. * On pointer over
  10729. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10730. */
  10731. static readonly OnPointerOverTrigger: number;
  10732. /**
  10733. * On pointer out
  10734. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10735. */
  10736. static readonly OnPointerOutTrigger: number;
  10737. /**
  10738. * On every frame
  10739. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10740. */
  10741. static readonly OnEveryFrameTrigger: number;
  10742. /**
  10743. * On intersection enter
  10744. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10745. */
  10746. static readonly OnIntersectionEnterTrigger: number;
  10747. /**
  10748. * On intersection exit
  10749. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10750. */
  10751. static readonly OnIntersectionExitTrigger: number;
  10752. /**
  10753. * On key down
  10754. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10755. */
  10756. static readonly OnKeyDownTrigger: number;
  10757. /**
  10758. * On key up
  10759. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10760. */
  10761. static readonly OnKeyUpTrigger: number;
  10762. private _scene;
  10763. /**
  10764. * Creates a new action manager
  10765. * @param scene defines the hosting scene
  10766. */
  10767. constructor(scene: Scene);
  10768. /**
  10769. * Releases all associated resources
  10770. */
  10771. dispose(): void;
  10772. /**
  10773. * Gets hosting scene
  10774. * @returns the hosting scene
  10775. */
  10776. getScene(): Scene;
  10777. /**
  10778. * Does this action manager handles actions of any of the given triggers
  10779. * @param triggers defines the triggers to be tested
  10780. * @return a boolean indicating whether one (or more) of the triggers is handled
  10781. */
  10782. hasSpecificTriggers(triggers: number[]): boolean;
  10783. /**
  10784. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  10785. * speed.
  10786. * @param triggerA defines the trigger to be tested
  10787. * @param triggerB defines the trigger to be tested
  10788. * @return a boolean indicating whether one (or more) of the triggers is handled
  10789. */
  10790. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  10791. /**
  10792. * Does this action manager handles actions of a given trigger
  10793. * @param trigger defines the trigger to be tested
  10794. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  10795. * @return whether the trigger is handled
  10796. */
  10797. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  10798. /**
  10799. * Does this action manager has pointer triggers
  10800. */
  10801. readonly hasPointerTriggers: boolean;
  10802. /**
  10803. * Does this action manager has pick triggers
  10804. */
  10805. readonly hasPickTriggers: boolean;
  10806. /**
  10807. * Registers an action to this action manager
  10808. * @param action defines the action to be registered
  10809. * @return the action amended (prepared) after registration
  10810. */
  10811. registerAction(action: IAction): Nullable<IAction>;
  10812. /**
  10813. * Unregisters an action to this action manager
  10814. * @param action defines the action to be unregistered
  10815. * @return a boolean indicating whether the action has been unregistered
  10816. */
  10817. unregisterAction(action: IAction): Boolean;
  10818. /**
  10819. * Process a specific trigger
  10820. * @param trigger defines the trigger to process
  10821. * @param evt defines the event details to be processed
  10822. */
  10823. processTrigger(trigger: number, evt?: IActionEvent): void;
  10824. /** @hidden */
  10825. _getEffectiveTarget(target: any, propertyPath: string): any;
  10826. /** @hidden */
  10827. _getProperty(propertyPath: string): string;
  10828. /**
  10829. * Serialize this manager to a JSON object
  10830. * @param name defines the property name to store this manager
  10831. * @returns a JSON representation of this manager
  10832. */
  10833. serialize(name: string): any;
  10834. /**
  10835. * Creates a new ActionManager from a JSON data
  10836. * @param parsedActions defines the JSON data to read from
  10837. * @param object defines the hosting mesh
  10838. * @param scene defines the hosting scene
  10839. */
  10840. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  10841. /**
  10842. * Get a trigger name by index
  10843. * @param trigger defines the trigger index
  10844. * @returns a trigger name
  10845. */
  10846. static GetTriggerName(trigger: number): string;
  10847. }
  10848. }
  10849. declare module BABYLON {
  10850. /**
  10851. * Class representing a ray with position and direction
  10852. */
  10853. export class Ray {
  10854. /** origin point */
  10855. origin: Vector3;
  10856. /** direction */
  10857. direction: Vector3;
  10858. /** length of the ray */
  10859. length: number;
  10860. private static readonly TmpVector3;
  10861. private _tmpRay;
  10862. /**
  10863. * Creates a new ray
  10864. * @param origin origin point
  10865. * @param direction direction
  10866. * @param length length of the ray
  10867. */
  10868. constructor(
  10869. /** origin point */
  10870. origin: Vector3,
  10871. /** direction */
  10872. direction: Vector3,
  10873. /** length of the ray */
  10874. length?: number);
  10875. /**
  10876. * Checks if the ray intersects a box
  10877. * @param minimum bound of the box
  10878. * @param maximum bound of the box
  10879. * @param intersectionTreshold extra extend to be added to the box in all direction
  10880. * @returns if the box was hit
  10881. */
  10882. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  10883. /**
  10884. * Checks if the ray intersects a box
  10885. * @param box the bounding box to check
  10886. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  10887. * @returns if the box was hit
  10888. */
  10889. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  10890. /**
  10891. * If the ray hits a sphere
  10892. * @param sphere the bounding sphere to check
  10893. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  10894. * @returns true if it hits the sphere
  10895. */
  10896. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  10897. /**
  10898. * If the ray hits a triange
  10899. * @param vertex0 triangle vertex
  10900. * @param vertex1 triangle vertex
  10901. * @param vertex2 triangle vertex
  10902. * @returns intersection information if hit
  10903. */
  10904. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  10905. /**
  10906. * Checks if ray intersects a plane
  10907. * @param plane the plane to check
  10908. * @returns the distance away it was hit
  10909. */
  10910. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  10911. /**
  10912. * Calculate the intercept of a ray on a given axis
  10913. * @param axis to check 'x' | 'y' | 'z'
  10914. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  10915. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  10916. */
  10917. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  10918. /**
  10919. * Checks if ray intersects a mesh
  10920. * @param mesh the mesh to check
  10921. * @param fastCheck if only the bounding box should checked
  10922. * @returns picking info of the intersecton
  10923. */
  10924. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  10925. /**
  10926. * Checks if ray intersects a mesh
  10927. * @param meshes the meshes to check
  10928. * @param fastCheck if only the bounding box should checked
  10929. * @param results array to store result in
  10930. * @returns Array of picking infos
  10931. */
  10932. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  10933. private _comparePickingInfo;
  10934. private static smallnum;
  10935. private static rayl;
  10936. /**
  10937. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  10938. * @param sega the first point of the segment to test the intersection against
  10939. * @param segb the second point of the segment to test the intersection against
  10940. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  10941. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  10942. */
  10943. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  10944. /**
  10945. * Update the ray from viewport position
  10946. * @param x position
  10947. * @param y y position
  10948. * @param viewportWidth viewport width
  10949. * @param viewportHeight viewport height
  10950. * @param world world matrix
  10951. * @param view view matrix
  10952. * @param projection projection matrix
  10953. * @returns this ray updated
  10954. */
  10955. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10956. /**
  10957. * Creates a ray with origin and direction of 0,0,0
  10958. * @returns the new ray
  10959. */
  10960. static Zero(): Ray;
  10961. /**
  10962. * Creates a new ray from screen space and viewport
  10963. * @param x position
  10964. * @param y y position
  10965. * @param viewportWidth viewport width
  10966. * @param viewportHeight viewport height
  10967. * @param world world matrix
  10968. * @param view view matrix
  10969. * @param projection projection matrix
  10970. * @returns new ray
  10971. */
  10972. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10973. /**
  10974. * 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
  10975. * transformed to the given world matrix.
  10976. * @param origin The origin point
  10977. * @param end The end point
  10978. * @param world a matrix to transform the ray to. Default is the identity matrix.
  10979. * @returns the new ray
  10980. */
  10981. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  10982. /**
  10983. * Transforms a ray by a matrix
  10984. * @param ray ray to transform
  10985. * @param matrix matrix to apply
  10986. * @returns the resulting new ray
  10987. */
  10988. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  10989. /**
  10990. * Transforms a ray by a matrix
  10991. * @param ray ray to transform
  10992. * @param matrix matrix to apply
  10993. * @param result ray to store result in
  10994. */
  10995. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  10996. /**
  10997. * Unproject a ray from screen space to object space
  10998. * @param sourceX defines the screen space x coordinate to use
  10999. * @param sourceY defines the screen space y coordinate to use
  11000. * @param viewportWidth defines the current width of the viewport
  11001. * @param viewportHeight defines the current height of the viewport
  11002. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  11003. * @param view defines the view matrix to use
  11004. * @param projection defines the projection matrix to use
  11005. */
  11006. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  11007. }
  11008. /**
  11009. * Type used to define predicate used to select faces when a mesh intersection is detected
  11010. */
  11011. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  11012. interface Scene {
  11013. /** @hidden */
  11014. _tempPickingRay: Nullable<Ray>;
  11015. /** @hidden */
  11016. _cachedRayForTransform: Ray;
  11017. /** @hidden */
  11018. _pickWithRayInverseMatrix: Matrix;
  11019. /** @hidden */
  11020. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  11021. /** @hidden */
  11022. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  11023. }
  11024. }
  11025. declare module BABYLON {
  11026. /**
  11027. * Groups all the scene component constants in one place to ease maintenance.
  11028. * @hidden
  11029. */
  11030. export class SceneComponentConstants {
  11031. static readonly NAME_EFFECTLAYER: string;
  11032. static readonly NAME_LAYER: string;
  11033. static readonly NAME_LENSFLARESYSTEM: string;
  11034. static readonly NAME_BOUNDINGBOXRENDERER: string;
  11035. static readonly NAME_PARTICLESYSTEM: string;
  11036. static readonly NAME_GAMEPAD: string;
  11037. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11038. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11039. static readonly NAME_DEPTHRENDERER: string;
  11040. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11041. static readonly NAME_SPRITE: string;
  11042. static readonly NAME_OUTLINERENDERER: string;
  11043. static readonly NAME_PROCEDURALTEXTURE: string;
  11044. static readonly NAME_SHADOWGENERATOR: string;
  11045. static readonly NAME_OCTREE: string;
  11046. static readonly NAME_PHYSICSENGINE: string;
  11047. static readonly NAME_AUDIO: string;
  11048. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11049. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11050. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11051. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11052. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11053. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11054. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11055. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11056. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11057. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11058. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11059. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11060. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11061. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11062. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11063. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11064. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11065. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11066. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11067. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11068. static readonly STEP_AFTERRENDER_AUDIO: number;
  11069. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11070. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11071. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11072. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11073. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11074. static readonly STEP_POINTERMOVE_SPRITE: number;
  11075. static readonly STEP_POINTERDOWN_SPRITE: number;
  11076. static readonly STEP_POINTERUP_SPRITE: number;
  11077. }
  11078. /**
  11079. * This represents a scene component.
  11080. *
  11081. * This is used to decouple the dependency the scene is having on the different workloads like
  11082. * layers, post processes...
  11083. */
  11084. export interface ISceneComponent {
  11085. /**
  11086. * The name of the component. Each component must have a unique name.
  11087. */
  11088. name: string;
  11089. /**
  11090. * The scene the component belongs to.
  11091. */
  11092. scene: Scene;
  11093. /**
  11094. * Register the component to one instance of a scene.
  11095. */
  11096. register(): void;
  11097. /**
  11098. * Rebuilds the elements related to this component in case of
  11099. * context lost for instance.
  11100. */
  11101. rebuild(): void;
  11102. /**
  11103. * Disposes the component and the associated ressources.
  11104. */
  11105. dispose(): void;
  11106. }
  11107. /**
  11108. * This represents a SERIALIZABLE scene component.
  11109. *
  11110. * This extends Scene Component to add Serialization methods on top.
  11111. */
  11112. export interface ISceneSerializableComponent extends ISceneComponent {
  11113. /**
  11114. * Adds all the elements from the container to the scene
  11115. * @param container the container holding the elements
  11116. */
  11117. addFromContainer(container: AbstractScene): void;
  11118. /**
  11119. * Removes all the elements in the container from the scene
  11120. * @param container contains the elements to remove
  11121. * @param dispose if the removed element should be disposed (default: false)
  11122. */
  11123. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  11124. /**
  11125. * Serializes the component data to the specified json object
  11126. * @param serializationObject The object to serialize to
  11127. */
  11128. serialize(serializationObject: any): void;
  11129. }
  11130. /**
  11131. * Strong typing of a Mesh related stage step action
  11132. */
  11133. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11134. /**
  11135. * Strong typing of a Evaluate Sub Mesh related stage step action
  11136. */
  11137. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11138. /**
  11139. * Strong typing of a Active Mesh related stage step action
  11140. */
  11141. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  11142. /**
  11143. * Strong typing of a Camera related stage step action
  11144. */
  11145. export type CameraStageAction = (camera: Camera) => void;
  11146. /**
  11147. * Strong typing of a Camera Frame buffer related stage step action
  11148. */
  11149. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  11150. /**
  11151. * Strong typing of a Render Target related stage step action
  11152. */
  11153. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11154. /**
  11155. * Strong typing of a RenderingGroup related stage step action
  11156. */
  11157. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11158. /**
  11159. * Strong typing of a Mesh Render related stage step action
  11160. */
  11161. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11162. /**
  11163. * Strong typing of a simple stage step action
  11164. */
  11165. export type SimpleStageAction = () => void;
  11166. /**
  11167. * Strong typing of a render target action.
  11168. */
  11169. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11170. /**
  11171. * Strong typing of a pointer move action.
  11172. */
  11173. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  11174. /**
  11175. * Strong typing of a pointer up/down action.
  11176. */
  11177. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11178. /**
  11179. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  11180. * @hidden
  11181. */
  11182. export class Stage<T extends Function> extends Array<{
  11183. index: number;
  11184. component: ISceneComponent;
  11185. action: T;
  11186. }> {
  11187. /**
  11188. * Hide ctor from the rest of the world.
  11189. * @param items The items to add.
  11190. */
  11191. private constructor();
  11192. /**
  11193. * Creates a new Stage.
  11194. * @returns A new instance of a Stage
  11195. */
  11196. static Create<T extends Function>(): Stage<T>;
  11197. /**
  11198. * Registers a step in an ordered way in the targeted stage.
  11199. * @param index Defines the position to register the step in
  11200. * @param component Defines the component attached to the step
  11201. * @param action Defines the action to launch during the step
  11202. */
  11203. registerStep(index: number, component: ISceneComponent, action: T): void;
  11204. /**
  11205. * Clears all the steps from the stage.
  11206. */
  11207. clear(): void;
  11208. }
  11209. }
  11210. declare module BABYLON {
  11211. interface Scene {
  11212. /** @hidden */
  11213. _pointerOverSprite: Nullable<Sprite>;
  11214. /** @hidden */
  11215. _pickedDownSprite: Nullable<Sprite>;
  11216. /** @hidden */
  11217. _tempSpritePickingRay: Nullable<Ray>;
  11218. /**
  11219. * All of the sprite managers added to this scene
  11220. * @see http://doc.babylonjs.com/babylon101/sprites
  11221. */
  11222. spriteManagers: Array<ISpriteManager>;
  11223. /**
  11224. * An event triggered when sprites rendering is about to start
  11225. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11226. */
  11227. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11228. /**
  11229. * An event triggered when sprites rendering is done
  11230. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11231. */
  11232. onAfterSpritesRenderingObservable: Observable<Scene>;
  11233. /** @hidden */
  11234. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11235. /** Launch a ray to try to pick a sprite in the scene
  11236. * @param x position on screen
  11237. * @param y position on screen
  11238. * @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
  11239. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11240. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11241. * @returns a PickingInfo
  11242. */
  11243. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11244. /** Use the given ray to pick a sprite in the scene
  11245. * @param ray The ray (in world space) to use to pick meshes
  11246. * @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
  11247. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11248. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11249. * @returns a PickingInfo
  11250. */
  11251. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11252. /** @hidden */
  11253. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11254. /** Launch a ray to try to pick sprites in the scene
  11255. * @param x position on screen
  11256. * @param y position on screen
  11257. * @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
  11258. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11259. * @returns a PickingInfo array
  11260. */
  11261. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11262. /** Use the given ray to pick sprites in the scene
  11263. * @param ray The ray (in world space) to use to pick meshes
  11264. * @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
  11265. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11266. * @returns a PickingInfo array
  11267. */
  11268. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11269. /**
  11270. * Force the sprite under the pointer
  11271. * @param sprite defines the sprite to use
  11272. */
  11273. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11274. /**
  11275. * Gets the sprite under the pointer
  11276. * @returns a Sprite or null if no sprite is under the pointer
  11277. */
  11278. getPointerOverSprite(): Nullable<Sprite>;
  11279. }
  11280. /**
  11281. * Defines the sprite scene component responsible to manage sprites
  11282. * in a given scene.
  11283. */
  11284. export class SpriteSceneComponent implements ISceneComponent {
  11285. /**
  11286. * The component name helpfull to identify the component in the list of scene components.
  11287. */
  11288. readonly name: string;
  11289. /**
  11290. * The scene the component belongs to.
  11291. */
  11292. scene: Scene;
  11293. /** @hidden */
  11294. private _spritePredicate;
  11295. /**
  11296. * Creates a new instance of the component for the given scene
  11297. * @param scene Defines the scene to register the component in
  11298. */
  11299. constructor(scene: Scene);
  11300. /**
  11301. * Registers the component in a given scene
  11302. */
  11303. register(): void;
  11304. /**
  11305. * Rebuilds the elements related to this component in case of
  11306. * context lost for instance.
  11307. */
  11308. rebuild(): void;
  11309. /**
  11310. * Disposes the component and the associated ressources.
  11311. */
  11312. dispose(): void;
  11313. private _pickSpriteButKeepRay;
  11314. private _pointerMove;
  11315. private _pointerDown;
  11316. private _pointerUp;
  11317. }
  11318. }
  11319. declare module BABYLON {
  11320. /** @hidden */
  11321. export var fogFragmentDeclaration: {
  11322. name: string;
  11323. shader: string;
  11324. };
  11325. }
  11326. declare module BABYLON {
  11327. /** @hidden */
  11328. export var fogFragment: {
  11329. name: string;
  11330. shader: string;
  11331. };
  11332. }
  11333. declare module BABYLON {
  11334. /** @hidden */
  11335. export var spritesPixelShader: {
  11336. name: string;
  11337. shader: string;
  11338. };
  11339. }
  11340. declare module BABYLON {
  11341. /** @hidden */
  11342. export var fogVertexDeclaration: {
  11343. name: string;
  11344. shader: string;
  11345. };
  11346. }
  11347. declare module BABYLON {
  11348. /** @hidden */
  11349. export var spritesVertexShader: {
  11350. name: string;
  11351. shader: string;
  11352. };
  11353. }
  11354. declare module BABYLON {
  11355. /**
  11356. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11357. */
  11358. export interface ISpriteManager extends IDisposable {
  11359. /**
  11360. * Restricts the camera to viewing objects with the same layerMask.
  11361. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11362. */
  11363. layerMask: number;
  11364. /**
  11365. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11366. */
  11367. isPickable: boolean;
  11368. /**
  11369. * Specifies the rendering group id for this mesh (0 by default)
  11370. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11371. */
  11372. renderingGroupId: number;
  11373. /**
  11374. * Defines the list of sprites managed by the manager.
  11375. */
  11376. sprites: Array<Sprite>;
  11377. /**
  11378. * Tests the intersection of a sprite with a specific ray.
  11379. * @param ray The ray we are sending to test the collision
  11380. * @param camera The camera space we are sending rays in
  11381. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11382. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  11383. * @returns picking info or null.
  11384. */
  11385. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11386. /**
  11387. * Intersects the sprites with a ray
  11388. * @param ray defines the ray to intersect with
  11389. * @param camera defines the current active camera
  11390. * @param predicate defines a predicate used to select candidate sprites
  11391. * @returns null if no hit or a PickingInfo array
  11392. */
  11393. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11394. /**
  11395. * Renders the list of sprites on screen.
  11396. */
  11397. render(): void;
  11398. }
  11399. /**
  11400. * Class used to manage multiple sprites on the same spritesheet
  11401. * @see http://doc.babylonjs.com/babylon101/sprites
  11402. */
  11403. export class SpriteManager implements ISpriteManager {
  11404. /** defines the manager's name */
  11405. name: string;
  11406. /** Gets the list of sprites */
  11407. sprites: Sprite[];
  11408. /** Gets or sets the rendering group id (0 by default) */
  11409. renderingGroupId: number;
  11410. /** Gets or sets camera layer mask */
  11411. layerMask: number;
  11412. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11413. fogEnabled: boolean;
  11414. /** Gets or sets a boolean indicating if the sprites are pickable */
  11415. isPickable: boolean;
  11416. /** Defines the default width of a cell in the spritesheet */
  11417. cellWidth: number;
  11418. /** Defines the default height of a cell in the spritesheet */
  11419. cellHeight: number;
  11420. /** Associative array from JSON sprite data file */
  11421. private _cellData;
  11422. /** Array of sprite names from JSON sprite data file */
  11423. private _spriteMap;
  11424. /** True when packed cell data from JSON file is ready*/
  11425. private _packedAndReady;
  11426. /**
  11427. * An event triggered when the manager is disposed.
  11428. */
  11429. onDisposeObservable: Observable<SpriteManager>;
  11430. private _onDisposeObserver;
  11431. /**
  11432. * Callback called when the manager is disposed
  11433. */
  11434. onDispose: () => void;
  11435. private _capacity;
  11436. private _fromPacked;
  11437. private _spriteTexture;
  11438. private _epsilon;
  11439. private _scene;
  11440. private _vertexData;
  11441. private _buffer;
  11442. private _vertexBuffers;
  11443. private _indexBuffer;
  11444. private _effectBase;
  11445. private _effectFog;
  11446. /**
  11447. * Gets or sets the spritesheet texture
  11448. */
  11449. texture: Texture;
  11450. /**
  11451. * Creates a new sprite manager
  11452. * @param name defines the manager's name
  11453. * @param imgUrl defines the sprite sheet url
  11454. * @param capacity defines the maximum allowed number of sprites
  11455. * @param cellSize defines the size of a sprite cell
  11456. * @param scene defines the hosting scene
  11457. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11458. * @param samplingMode defines the smapling mode to use with spritesheet
  11459. * @param fromPacked set to false; do not alter
  11460. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  11461. */
  11462. constructor(
  11463. /** defines the manager's name */
  11464. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: string | null);
  11465. private _makePacked;
  11466. private _appendSpriteVertex;
  11467. /**
  11468. * Intersects the sprites with a ray
  11469. * @param ray defines the ray to intersect with
  11470. * @param camera defines the current active camera
  11471. * @param predicate defines a predicate used to select candidate sprites
  11472. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11473. * @returns null if no hit or a PickingInfo
  11474. */
  11475. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11476. /**
  11477. * Intersects the sprites with a ray
  11478. * @param ray defines the ray to intersect with
  11479. * @param camera defines the current active camera
  11480. * @param predicate defines a predicate used to select candidate sprites
  11481. * @returns null if no hit or a PickingInfo array
  11482. */
  11483. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11484. /**
  11485. * Render all child sprites
  11486. */
  11487. render(): void;
  11488. /**
  11489. * Release associated resources
  11490. */
  11491. dispose(): void;
  11492. }
  11493. }
  11494. declare module BABYLON {
  11495. /**
  11496. * Class used to represent a sprite
  11497. * @see http://doc.babylonjs.com/babylon101/sprites
  11498. */
  11499. export class Sprite {
  11500. /** defines the name */
  11501. name: string;
  11502. /** Gets or sets the current world position */
  11503. position: Vector3;
  11504. /** Gets or sets the main color */
  11505. color: Color4;
  11506. /** Gets or sets the width */
  11507. width: number;
  11508. /** Gets or sets the height */
  11509. height: number;
  11510. /** Gets or sets rotation angle */
  11511. angle: number;
  11512. /** Gets or sets the cell index in the sprite sheet */
  11513. cellIndex: number;
  11514. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  11515. cellRef: string;
  11516. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  11517. invertU: number;
  11518. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  11519. invertV: number;
  11520. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  11521. disposeWhenFinishedAnimating: boolean;
  11522. /** Gets the list of attached animations */
  11523. animations: Animation[];
  11524. /** Gets or sets a boolean indicating if the sprite can be picked */
  11525. isPickable: boolean;
  11526. /**
  11527. * Gets or sets the associated action manager
  11528. */
  11529. actionManager: Nullable<ActionManager>;
  11530. private _animationStarted;
  11531. private _loopAnimation;
  11532. private _fromIndex;
  11533. private _toIndex;
  11534. private _delay;
  11535. private _direction;
  11536. private _manager;
  11537. private _time;
  11538. private _onAnimationEnd;
  11539. /**
  11540. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  11541. */
  11542. isVisible: boolean;
  11543. /**
  11544. * Gets or sets the sprite size
  11545. */
  11546. size: number;
  11547. /**
  11548. * Creates a new Sprite
  11549. * @param name defines the name
  11550. * @param manager defines the manager
  11551. */
  11552. constructor(
  11553. /** defines the name */
  11554. name: string, manager: ISpriteManager);
  11555. /**
  11556. * Starts an animation
  11557. * @param from defines the initial key
  11558. * @param to defines the end key
  11559. * @param loop defines if the animation must loop
  11560. * @param delay defines the start delay (in ms)
  11561. * @param onAnimationEnd defines a callback to call when animation ends
  11562. */
  11563. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  11564. /** Stops current animation (if any) */
  11565. stopAnimation(): void;
  11566. /** @hidden */
  11567. _animate(deltaTime: number): void;
  11568. /** Release associated resources */
  11569. dispose(): void;
  11570. }
  11571. }
  11572. declare module BABYLON {
  11573. /**
  11574. * Information about the result of picking within a scene
  11575. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  11576. */
  11577. export class PickingInfo {
  11578. /** @hidden */
  11579. _pickingUnavailable: boolean;
  11580. /**
  11581. * If the pick collided with an object
  11582. */
  11583. hit: boolean;
  11584. /**
  11585. * Distance away where the pick collided
  11586. */
  11587. distance: number;
  11588. /**
  11589. * The location of pick collision
  11590. */
  11591. pickedPoint: Nullable<Vector3>;
  11592. /**
  11593. * The mesh corresponding the the pick collision
  11594. */
  11595. pickedMesh: Nullable<AbstractMesh>;
  11596. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  11597. bu: number;
  11598. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  11599. bv: number;
  11600. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  11601. faceId: number;
  11602. /** Id of the the submesh that was picked */
  11603. subMeshId: number;
  11604. /** If a sprite was picked, this will be the sprite the pick collided with */
  11605. pickedSprite: Nullable<Sprite>;
  11606. /**
  11607. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  11608. */
  11609. originMesh: Nullable<AbstractMesh>;
  11610. /**
  11611. * The ray that was used to perform the picking.
  11612. */
  11613. ray: Nullable<Ray>;
  11614. /**
  11615. * Gets the normal correspodning to the face the pick collided with
  11616. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  11617. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  11618. * @returns The normal correspodning to the face the pick collided with
  11619. */
  11620. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  11621. /**
  11622. * Gets the texture coordinates of where the pick occured
  11623. * @returns the vector containing the coordnates of the texture
  11624. */
  11625. getTextureCoordinates(): Nullable<Vector2>;
  11626. }
  11627. }
  11628. declare module BABYLON {
  11629. /**
  11630. * Gather the list of pointer event types as constants.
  11631. */
  11632. export class PointerEventTypes {
  11633. /**
  11634. * 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.
  11635. */
  11636. static readonly POINTERDOWN: number;
  11637. /**
  11638. * The pointerup event is fired when a pointer is no longer active.
  11639. */
  11640. static readonly POINTERUP: number;
  11641. /**
  11642. * The pointermove event is fired when a pointer changes coordinates.
  11643. */
  11644. static readonly POINTERMOVE: number;
  11645. /**
  11646. * The pointerwheel event is fired when a mouse wheel has been rotated.
  11647. */
  11648. static readonly POINTERWHEEL: number;
  11649. /**
  11650. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  11651. */
  11652. static readonly POINTERPICK: number;
  11653. /**
  11654. * The pointertap event is fired when a the object has been touched and released without drag.
  11655. */
  11656. static readonly POINTERTAP: number;
  11657. /**
  11658. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  11659. */
  11660. static readonly POINTERDOUBLETAP: number;
  11661. }
  11662. /**
  11663. * Base class of pointer info types.
  11664. */
  11665. export class PointerInfoBase {
  11666. /**
  11667. * Defines the type of event (PointerEventTypes)
  11668. */
  11669. type: number;
  11670. /**
  11671. * Defines the related dom event
  11672. */
  11673. event: PointerEvent | MouseWheelEvent;
  11674. /**
  11675. * Instantiates the base class of pointers info.
  11676. * @param type Defines the type of event (PointerEventTypes)
  11677. * @param event Defines the related dom event
  11678. */
  11679. constructor(
  11680. /**
  11681. * Defines the type of event (PointerEventTypes)
  11682. */
  11683. type: number,
  11684. /**
  11685. * Defines the related dom event
  11686. */
  11687. event: PointerEvent | MouseWheelEvent);
  11688. }
  11689. /**
  11690. * This class is used to store pointer related info for the onPrePointerObservable event.
  11691. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  11692. */
  11693. export class PointerInfoPre extends PointerInfoBase {
  11694. /**
  11695. * Ray from a pointer if availible (eg. 6dof controller)
  11696. */
  11697. ray: Nullable<Ray>;
  11698. /**
  11699. * Defines the local position of the pointer on the canvas.
  11700. */
  11701. localPosition: Vector2;
  11702. /**
  11703. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  11704. */
  11705. skipOnPointerObservable: boolean;
  11706. /**
  11707. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  11708. * @param type Defines the type of event (PointerEventTypes)
  11709. * @param event Defines the related dom event
  11710. * @param localX Defines the local x coordinates of the pointer when the event occured
  11711. * @param localY Defines the local y coordinates of the pointer when the event occured
  11712. */
  11713. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  11714. }
  11715. /**
  11716. * This type contains all the data related to a pointer event in Babylon.js.
  11717. * 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.
  11718. */
  11719. export class PointerInfo extends PointerInfoBase {
  11720. /**
  11721. * Defines the picking info associated to the info (if any)\
  11722. */
  11723. pickInfo: Nullable<PickingInfo>;
  11724. /**
  11725. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  11726. * @param type Defines the type of event (PointerEventTypes)
  11727. * @param event Defines the related dom event
  11728. * @param pickInfo Defines the picking info associated to the info (if any)\
  11729. */
  11730. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  11731. /**
  11732. * Defines the picking info associated to the info (if any)\
  11733. */
  11734. pickInfo: Nullable<PickingInfo>);
  11735. }
  11736. /**
  11737. * Data relating to a touch event on the screen.
  11738. */
  11739. export interface PointerTouch {
  11740. /**
  11741. * X coordinate of touch.
  11742. */
  11743. x: number;
  11744. /**
  11745. * Y coordinate of touch.
  11746. */
  11747. y: number;
  11748. /**
  11749. * Id of touch. Unique for each finger.
  11750. */
  11751. pointerId: number;
  11752. /**
  11753. * Event type passed from DOM.
  11754. */
  11755. type: any;
  11756. }
  11757. }
  11758. declare module BABYLON {
  11759. /**
  11760. * Manage the mouse inputs to control the movement of a free camera.
  11761. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11762. */
  11763. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  11764. /**
  11765. * Define if touch is enabled in the mouse input
  11766. */
  11767. touchEnabled: boolean;
  11768. /**
  11769. * Defines the camera the input is attached to.
  11770. */
  11771. camera: FreeCamera;
  11772. /**
  11773. * Defines the buttons associated with the input to handle camera move.
  11774. */
  11775. buttons: number[];
  11776. /**
  11777. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  11778. */
  11779. angularSensibility: number;
  11780. private _pointerInput;
  11781. private _onMouseMove;
  11782. private _observer;
  11783. private previousPosition;
  11784. /**
  11785. * Observable for when a pointer move event occurs containing the move offset
  11786. */
  11787. onPointerMovedObservable: Observable<{
  11788. offsetX: number;
  11789. offsetY: number;
  11790. }>;
  11791. /**
  11792. * @hidden
  11793. * If the camera should be rotated automatically based on pointer movement
  11794. */
  11795. _allowCameraRotation: boolean;
  11796. /**
  11797. * Manage the mouse inputs to control the movement of a free camera.
  11798. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11799. * @param touchEnabled Defines if touch is enabled or not
  11800. */
  11801. constructor(
  11802. /**
  11803. * Define if touch is enabled in the mouse input
  11804. */
  11805. touchEnabled?: boolean);
  11806. /**
  11807. * Attach the input controls to a specific dom element to get the input from.
  11808. * @param element Defines the element the controls should be listened from
  11809. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  11810. */
  11811. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  11812. /**
  11813. * Called on JS contextmenu event.
  11814. * Override this method to provide functionality.
  11815. */
  11816. protected onContextMenu(evt: PointerEvent): void;
  11817. /**
  11818. * Detach the current controls from the specified dom element.
  11819. * @param element Defines the element to stop listening the inputs from
  11820. */
  11821. detachControl(element: Nullable<HTMLElement>): void;
  11822. /**
  11823. * Gets the class name of the current intput.
  11824. * @returns the class name
  11825. */
  11826. getClassName(): string;
  11827. /**
  11828. * Get the friendly name associated with the input class.
  11829. * @returns the input friendly name
  11830. */
  11831. getSimpleName(): string;
  11832. }
  11833. }
  11834. declare module BABYLON {
  11835. /**
  11836. * Manage the touch inputs to control the movement of a free camera.
  11837. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11838. */
  11839. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  11840. /**
  11841. * Defines the camera the input is attached to.
  11842. */
  11843. camera: FreeCamera;
  11844. /**
  11845. * Defines the touch sensibility for rotation.
  11846. * The higher the faster.
  11847. */
  11848. touchAngularSensibility: number;
  11849. /**
  11850. * Defines the touch sensibility for move.
  11851. * The higher the faster.
  11852. */
  11853. touchMoveSensibility: number;
  11854. private _offsetX;
  11855. private _offsetY;
  11856. private _pointerPressed;
  11857. private _pointerInput;
  11858. private _observer;
  11859. private _onLostFocus;
  11860. /**
  11861. * Attach the input controls to a specific dom element to get the input from.
  11862. * @param element Defines the element the controls should be listened from
  11863. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  11864. */
  11865. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  11866. /**
  11867. * Detach the current controls from the specified dom element.
  11868. * @param element Defines the element to stop listening the inputs from
  11869. */
  11870. detachControl(element: Nullable<HTMLElement>): void;
  11871. /**
  11872. * Update the current camera state depending on the inputs that have been used this frame.
  11873. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  11874. */
  11875. checkInputs(): void;
  11876. /**
  11877. * Gets the class name of the current intput.
  11878. * @returns the class name
  11879. */
  11880. getClassName(): string;
  11881. /**
  11882. * Get the friendly name associated with the input class.
  11883. * @returns the input friendly name
  11884. */
  11885. getSimpleName(): string;
  11886. }
  11887. }
  11888. declare module BABYLON {
  11889. /**
  11890. * Default Inputs manager for the FreeCamera.
  11891. * It groups all the default supported inputs for ease of use.
  11892. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11893. */
  11894. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  11895. /**
  11896. * @hidden
  11897. */
  11898. _mouseInput: Nullable<FreeCameraMouseInput>;
  11899. /**
  11900. * Instantiates a new FreeCameraInputsManager.
  11901. * @param camera Defines the camera the inputs belong to
  11902. */
  11903. constructor(camera: FreeCamera);
  11904. /**
  11905. * Add keyboard input support to the input manager.
  11906. * @returns the current input manager
  11907. */
  11908. addKeyboard(): FreeCameraInputsManager;
  11909. /**
  11910. * Add mouse input support to the input manager.
  11911. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  11912. * @returns the current input manager
  11913. */
  11914. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  11915. /**
  11916. * Removes the mouse input support from the manager
  11917. * @returns the current input manager
  11918. */
  11919. removeMouse(): FreeCameraInputsManager;
  11920. /**
  11921. * Add touch input support to the input manager.
  11922. * @returns the current input manager
  11923. */
  11924. addTouch(): FreeCameraInputsManager;
  11925. /**
  11926. * Remove all attached input methods from a camera
  11927. */
  11928. clear(): void;
  11929. }
  11930. }
  11931. declare module BABYLON {
  11932. /**
  11933. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  11934. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  11935. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  11936. */
  11937. export class FreeCamera extends TargetCamera {
  11938. /**
  11939. * Define the collision ellipsoid of the camera.
  11940. * This is helpful to simulate a camera body like the player body around the camera
  11941. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  11942. */
  11943. ellipsoid: Vector3;
  11944. /**
  11945. * Define an offset for the position of the ellipsoid around the camera.
  11946. * This can be helpful to determine the center of the body near the gravity center of the body
  11947. * instead of its head.
  11948. */
  11949. ellipsoidOffset: Vector3;
  11950. /**
  11951. * Enable or disable collisions of the camera with the rest of the scene objects.
  11952. */
  11953. checkCollisions: boolean;
  11954. /**
  11955. * Enable or disable gravity on the camera.
  11956. */
  11957. applyGravity: boolean;
  11958. /**
  11959. * Define the input manager associated to the camera.
  11960. */
  11961. inputs: FreeCameraInputsManager;
  11962. /**
  11963. * Gets the input sensibility for a mouse input. (default is 2000.0)
  11964. * Higher values reduce sensitivity.
  11965. */
  11966. /**
  11967. * Sets the input sensibility for a mouse input. (default is 2000.0)
  11968. * Higher values reduce sensitivity.
  11969. */
  11970. angularSensibility: number;
  11971. /**
  11972. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  11973. */
  11974. keysUp: number[];
  11975. /**
  11976. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  11977. */
  11978. keysDown: number[];
  11979. /**
  11980. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  11981. */
  11982. keysLeft: number[];
  11983. /**
  11984. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  11985. */
  11986. keysRight: number[];
  11987. /**
  11988. * Event raised when the camera collide with a mesh in the scene.
  11989. */
  11990. onCollide: (collidedMesh: AbstractMesh) => void;
  11991. private _collider;
  11992. private _needMoveForGravity;
  11993. private _oldPosition;
  11994. private _diffPosition;
  11995. private _newPosition;
  11996. /** @hidden */
  11997. _localDirection: Vector3;
  11998. /** @hidden */
  11999. _transformedDirection: Vector3;
  12000. /**
  12001. * Instantiates a Free Camera.
  12002. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12003. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  12004. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12005. * @param name Define the name of the camera in the scene
  12006. * @param position Define the start position of the camera in the scene
  12007. * @param scene Define the scene the camera belongs to
  12008. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  12009. */
  12010. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  12011. /**
  12012. * Attached controls to the current camera.
  12013. * @param element Defines the element the controls should be listened from
  12014. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12015. */
  12016. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12017. /**
  12018. * Detach the current controls from the camera.
  12019. * The camera will stop reacting to inputs.
  12020. * @param element Defines the element to stop listening the inputs from
  12021. */
  12022. detachControl(element: HTMLElement): void;
  12023. private _collisionMask;
  12024. /**
  12025. * Define a collision mask to limit the list of object the camera can collide with
  12026. */
  12027. collisionMask: number;
  12028. /** @hidden */
  12029. _collideWithWorld(displacement: Vector3): void;
  12030. private _onCollisionPositionChange;
  12031. /** @hidden */
  12032. _checkInputs(): void;
  12033. /** @hidden */
  12034. _decideIfNeedsToMove(): boolean;
  12035. /** @hidden */
  12036. _updatePosition(): void;
  12037. /**
  12038. * Destroy the camera and release the current resources hold by it.
  12039. */
  12040. dispose(): void;
  12041. /**
  12042. * Gets the current object class name.
  12043. * @return the class name
  12044. */
  12045. getClassName(): string;
  12046. }
  12047. }
  12048. declare module BABYLON {
  12049. /**
  12050. * Represents a gamepad control stick position
  12051. */
  12052. export class StickValues {
  12053. /**
  12054. * The x component of the control stick
  12055. */
  12056. x: number;
  12057. /**
  12058. * The y component of the control stick
  12059. */
  12060. y: number;
  12061. /**
  12062. * Initializes the gamepad x and y control stick values
  12063. * @param x The x component of the gamepad control stick value
  12064. * @param y The y component of the gamepad control stick value
  12065. */
  12066. constructor(
  12067. /**
  12068. * The x component of the control stick
  12069. */
  12070. x: number,
  12071. /**
  12072. * The y component of the control stick
  12073. */
  12074. y: number);
  12075. }
  12076. /**
  12077. * An interface which manages callbacks for gamepad button changes
  12078. */
  12079. export interface GamepadButtonChanges {
  12080. /**
  12081. * Called when a gamepad has been changed
  12082. */
  12083. changed: boolean;
  12084. /**
  12085. * Called when a gamepad press event has been triggered
  12086. */
  12087. pressChanged: boolean;
  12088. /**
  12089. * Called when a touch event has been triggered
  12090. */
  12091. touchChanged: boolean;
  12092. /**
  12093. * Called when a value has changed
  12094. */
  12095. valueChanged: boolean;
  12096. }
  12097. /**
  12098. * Represents a gamepad
  12099. */
  12100. export class Gamepad {
  12101. /**
  12102. * The id of the gamepad
  12103. */
  12104. id: string;
  12105. /**
  12106. * The index of the gamepad
  12107. */
  12108. index: number;
  12109. /**
  12110. * The browser gamepad
  12111. */
  12112. browserGamepad: any;
  12113. /**
  12114. * Specifies what type of gamepad this represents
  12115. */
  12116. type: number;
  12117. private _leftStick;
  12118. private _rightStick;
  12119. /** @hidden */
  12120. _isConnected: boolean;
  12121. private _leftStickAxisX;
  12122. private _leftStickAxisY;
  12123. private _rightStickAxisX;
  12124. private _rightStickAxisY;
  12125. /**
  12126. * Triggered when the left control stick has been changed
  12127. */
  12128. private _onleftstickchanged;
  12129. /**
  12130. * Triggered when the right control stick has been changed
  12131. */
  12132. private _onrightstickchanged;
  12133. /**
  12134. * Represents a gamepad controller
  12135. */
  12136. static GAMEPAD: number;
  12137. /**
  12138. * Represents a generic controller
  12139. */
  12140. static GENERIC: number;
  12141. /**
  12142. * Represents an XBox controller
  12143. */
  12144. static XBOX: number;
  12145. /**
  12146. * Represents a pose-enabled controller
  12147. */
  12148. static POSE_ENABLED: number;
  12149. /**
  12150. * Represents an Dual Shock controller
  12151. */
  12152. static DUALSHOCK: number;
  12153. /**
  12154. * Specifies whether the left control stick should be Y-inverted
  12155. */
  12156. protected _invertLeftStickY: boolean;
  12157. /**
  12158. * Specifies if the gamepad has been connected
  12159. */
  12160. readonly isConnected: boolean;
  12161. /**
  12162. * Initializes the gamepad
  12163. * @param id The id of the gamepad
  12164. * @param index The index of the gamepad
  12165. * @param browserGamepad The browser gamepad
  12166. * @param leftStickX The x component of the left joystick
  12167. * @param leftStickY The y component of the left joystick
  12168. * @param rightStickX The x component of the right joystick
  12169. * @param rightStickY The y component of the right joystick
  12170. */
  12171. constructor(
  12172. /**
  12173. * The id of the gamepad
  12174. */
  12175. id: string,
  12176. /**
  12177. * The index of the gamepad
  12178. */
  12179. index: number,
  12180. /**
  12181. * The browser gamepad
  12182. */
  12183. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12184. /**
  12185. * Callback triggered when the left joystick has changed
  12186. * @param callback
  12187. */
  12188. onleftstickchanged(callback: (values: StickValues) => void): void;
  12189. /**
  12190. * Callback triggered when the right joystick has changed
  12191. * @param callback
  12192. */
  12193. onrightstickchanged(callback: (values: StickValues) => void): void;
  12194. /**
  12195. * Gets the left joystick
  12196. */
  12197. /**
  12198. * Sets the left joystick values
  12199. */
  12200. leftStick: StickValues;
  12201. /**
  12202. * Gets the right joystick
  12203. */
  12204. /**
  12205. * Sets the right joystick value
  12206. */
  12207. rightStick: StickValues;
  12208. /**
  12209. * Updates the gamepad joystick positions
  12210. */
  12211. update(): void;
  12212. /**
  12213. * Disposes the gamepad
  12214. */
  12215. dispose(): void;
  12216. }
  12217. /**
  12218. * Represents a generic gamepad
  12219. */
  12220. export class GenericPad extends Gamepad {
  12221. private _buttons;
  12222. private _onbuttondown;
  12223. private _onbuttonup;
  12224. /**
  12225. * Observable triggered when a button has been pressed
  12226. */
  12227. onButtonDownObservable: Observable<number>;
  12228. /**
  12229. * Observable triggered when a button has been released
  12230. */
  12231. onButtonUpObservable: Observable<number>;
  12232. /**
  12233. * Callback triggered when a button has been pressed
  12234. * @param callback Called when a button has been pressed
  12235. */
  12236. onbuttondown(callback: (buttonPressed: number) => void): void;
  12237. /**
  12238. * Callback triggered when a button has been released
  12239. * @param callback Called when a button has been released
  12240. */
  12241. onbuttonup(callback: (buttonReleased: number) => void): void;
  12242. /**
  12243. * Initializes the generic gamepad
  12244. * @param id The id of the generic gamepad
  12245. * @param index The index of the generic gamepad
  12246. * @param browserGamepad The browser gamepad
  12247. */
  12248. constructor(id: string, index: number, browserGamepad: any);
  12249. private _setButtonValue;
  12250. /**
  12251. * Updates the generic gamepad
  12252. */
  12253. update(): void;
  12254. /**
  12255. * Disposes the generic gamepad
  12256. */
  12257. dispose(): void;
  12258. }
  12259. }
  12260. declare module BABYLON {
  12261. interface Engine {
  12262. /**
  12263. * Creates a raw texture
  12264. * @param data defines the data to store in the texture
  12265. * @param width defines the width of the texture
  12266. * @param height defines the height of the texture
  12267. * @param format defines the format of the data
  12268. * @param generateMipMaps defines if the engine should generate the mip levels
  12269. * @param invertY defines if data must be stored with Y axis inverted
  12270. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  12271. * @param compression defines the compression used (null by default)
  12272. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12273. * @returns the raw texture inside an InternalTexture
  12274. */
  12275. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  12276. /**
  12277. * Update a raw texture
  12278. * @param texture defines the texture to update
  12279. * @param data defines the data to store in the texture
  12280. * @param format defines the format of the data
  12281. * @param invertY defines if data must be stored with Y axis inverted
  12282. */
  12283. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12284. /**
  12285. * Update a raw texture
  12286. * @param texture defines the texture to update
  12287. * @param data defines the data to store in the texture
  12288. * @param format defines the format of the data
  12289. * @param invertY defines if data must be stored with Y axis inverted
  12290. * @param compression defines the compression used (null by default)
  12291. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12292. */
  12293. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  12294. /**
  12295. * Creates a new raw cube texture
  12296. * @param data defines the array of data to use to create each face
  12297. * @param size defines the size of the textures
  12298. * @param format defines the format of the data
  12299. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12300. * @param generateMipMaps defines if the engine should generate the mip levels
  12301. * @param invertY defines if data must be stored with Y axis inverted
  12302. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12303. * @param compression defines the compression used (null by default)
  12304. * @returns the cube texture as an InternalTexture
  12305. */
  12306. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  12307. /**
  12308. * Update a raw cube texture
  12309. * @param texture defines the texture to udpdate
  12310. * @param data defines the data to store
  12311. * @param format defines the data format
  12312. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12313. * @param invertY defines if data must be stored with Y axis inverted
  12314. */
  12315. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  12316. /**
  12317. * Update a raw cube texture
  12318. * @param texture defines the texture to udpdate
  12319. * @param data defines the data to store
  12320. * @param format defines the data format
  12321. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12322. * @param invertY defines if data must be stored with Y axis inverted
  12323. * @param compression defines the compression used (null by default)
  12324. */
  12325. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  12326. /**
  12327. * Update a raw cube texture
  12328. * @param texture defines the texture to udpdate
  12329. * @param data defines the data to store
  12330. * @param format defines the data format
  12331. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12332. * @param invertY defines if data must be stored with Y axis inverted
  12333. * @param compression defines the compression used (null by default)
  12334. * @param level defines which level of the texture to update
  12335. */
  12336. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  12337. /**
  12338. * Creates a new raw cube texture from a specified url
  12339. * @param url defines the url where the data is located
  12340. * @param scene defines the current scene
  12341. * @param size defines the size of the textures
  12342. * @param format defines the format of the data
  12343. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12344. * @param noMipmap defines if the engine should avoid generating the mip levels
  12345. * @param callback defines a callback used to extract texture data from loaded data
  12346. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12347. * @param onLoad defines a callback called when texture is loaded
  12348. * @param onError defines a callback called if there is an error
  12349. * @returns the cube texture as an InternalTexture
  12350. */
  12351. 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;
  12352. /**
  12353. * Creates a new raw cube texture from a specified url
  12354. * @param url defines the url where the data is located
  12355. * @param scene defines the current scene
  12356. * @param size defines the size of the textures
  12357. * @param format defines the format of the data
  12358. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12359. * @param noMipmap defines if the engine should avoid generating the mip levels
  12360. * @param callback defines a callback used to extract texture data from loaded data
  12361. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12362. * @param onLoad defines a callback called when texture is loaded
  12363. * @param onError defines a callback called if there is an error
  12364. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12365. * @param invertY defines if data must be stored with Y axis inverted
  12366. * @returns the cube texture as an InternalTexture
  12367. */
  12368. 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;
  12369. /**
  12370. * Creates a new raw 3D texture
  12371. * @param data defines the data used to create the texture
  12372. * @param width defines the width of the texture
  12373. * @param height defines the height of the texture
  12374. * @param depth defines the depth of the texture
  12375. * @param format defines the format of the texture
  12376. * @param generateMipMaps defines if the engine must generate mip levels
  12377. * @param invertY defines if data must be stored with Y axis inverted
  12378. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12379. * @param compression defines the compressed used (can be null)
  12380. * @param textureType defines the compressed used (can be null)
  12381. * @returns a new raw 3D texture (stored in an InternalTexture)
  12382. */
  12383. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  12384. /**
  12385. * Update a raw 3D texture
  12386. * @param texture defines the texture to update
  12387. * @param data defines the data to store
  12388. * @param format defines the data format
  12389. * @param invertY defines if data must be stored with Y axis inverted
  12390. */
  12391. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12392. /**
  12393. * Update a raw 3D texture
  12394. * @param texture defines the texture to update
  12395. * @param data defines the data to store
  12396. * @param format defines the data format
  12397. * @param invertY defines if data must be stored with Y axis inverted
  12398. * @param compression defines the used compression (can be null)
  12399. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  12400. */
  12401. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  12402. }
  12403. }
  12404. declare module BABYLON {
  12405. /**
  12406. * Raw texture can help creating a texture directly from an array of data.
  12407. * This can be super useful if you either get the data from an uncompressed source or
  12408. * if you wish to create your texture pixel by pixel.
  12409. */
  12410. export class RawTexture extends Texture {
  12411. /**
  12412. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12413. */
  12414. format: number;
  12415. private _engine;
  12416. /**
  12417. * Instantiates a new RawTexture.
  12418. * Raw texture can help creating a texture directly from an array of data.
  12419. * This can be super useful if you either get the data from an uncompressed source or
  12420. * if you wish to create your texture pixel by pixel.
  12421. * @param data define the array of data to use to create the texture
  12422. * @param width define the width of the texture
  12423. * @param height define the height of the texture
  12424. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12425. * @param scene define the scene the texture belongs to
  12426. * @param generateMipMaps define whether mip maps should be generated or not
  12427. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12428. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12429. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12430. */
  12431. constructor(data: ArrayBufferView, width: number, height: number,
  12432. /**
  12433. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12434. */
  12435. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  12436. /**
  12437. * Updates the texture underlying data.
  12438. * @param data Define the new data of the texture
  12439. */
  12440. update(data: ArrayBufferView): void;
  12441. /**
  12442. * Creates a luminance texture from some data.
  12443. * @param data Define the texture data
  12444. * @param width Define the width of the texture
  12445. * @param height Define the height of the texture
  12446. * @param scene Define the scene the texture belongs to
  12447. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12448. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12449. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12450. * @returns the luminance texture
  12451. */
  12452. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12453. /**
  12454. * Creates a luminance alpha texture from some data.
  12455. * @param data Define the texture data
  12456. * @param width Define the width of the texture
  12457. * @param height Define the height of the texture
  12458. * @param scene Define the scene the texture belongs to
  12459. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12460. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12461. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12462. * @returns the luminance alpha texture
  12463. */
  12464. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12465. /**
  12466. * Creates an alpha texture from some data.
  12467. * @param data Define the texture data
  12468. * @param width Define the width of the texture
  12469. * @param height Define the height of the texture
  12470. * @param scene Define the scene the texture belongs to
  12471. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12472. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12473. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12474. * @returns the alpha texture
  12475. */
  12476. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12477. /**
  12478. * Creates a RGB texture from some data.
  12479. * @param data Define the texture data
  12480. * @param width Define the width of the texture
  12481. * @param height Define the height of the texture
  12482. * @param scene Define the scene the texture belongs to
  12483. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12484. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12485. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12486. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12487. * @returns the RGB alpha texture
  12488. */
  12489. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12490. /**
  12491. * Creates a RGBA texture from some data.
  12492. * @param data Define the texture data
  12493. * @param width Define the width of the texture
  12494. * @param height Define the height of the texture
  12495. * @param scene Define the scene the texture belongs to
  12496. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12497. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12498. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12499. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12500. * @returns the RGBA texture
  12501. */
  12502. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12503. /**
  12504. * Creates a R texture from some data.
  12505. * @param data Define the texture data
  12506. * @param width Define the width of the texture
  12507. * @param height Define the height of the texture
  12508. * @param scene Define the scene the texture belongs to
  12509. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12510. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12511. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12512. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12513. * @returns the R texture
  12514. */
  12515. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12516. }
  12517. }
  12518. declare module BABYLON {
  12519. /**
  12520. * Interface for the size containing width and height
  12521. */
  12522. export interface ISize {
  12523. /**
  12524. * Width
  12525. */
  12526. width: number;
  12527. /**
  12528. * Heighht
  12529. */
  12530. height: number;
  12531. }
  12532. /**
  12533. * Size containing widht and height
  12534. */
  12535. export class Size implements ISize {
  12536. /**
  12537. * Width
  12538. */
  12539. width: number;
  12540. /**
  12541. * Height
  12542. */
  12543. height: number;
  12544. /**
  12545. * Creates a Size object from the given width and height (floats).
  12546. * @param width width of the new size
  12547. * @param height height of the new size
  12548. */
  12549. constructor(width: number, height: number);
  12550. /**
  12551. * Returns a string with the Size width and height
  12552. * @returns a string with the Size width and height
  12553. */
  12554. toString(): string;
  12555. /**
  12556. * "Size"
  12557. * @returns the string "Size"
  12558. */
  12559. getClassName(): string;
  12560. /**
  12561. * Returns the Size hash code.
  12562. * @returns a hash code for a unique width and height
  12563. */
  12564. getHashCode(): number;
  12565. /**
  12566. * Updates the current size from the given one.
  12567. * @param src the given size
  12568. */
  12569. copyFrom(src: Size): void;
  12570. /**
  12571. * Updates in place the current Size from the given floats.
  12572. * @param width width of the new size
  12573. * @param height height of the new size
  12574. * @returns the updated Size.
  12575. */
  12576. copyFromFloats(width: number, height: number): Size;
  12577. /**
  12578. * Updates in place the current Size from the given floats.
  12579. * @param width width to set
  12580. * @param height height to set
  12581. * @returns the updated Size.
  12582. */
  12583. set(width: number, height: number): Size;
  12584. /**
  12585. * Multiplies the width and height by numbers
  12586. * @param w factor to multiple the width by
  12587. * @param h factor to multiple the height by
  12588. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  12589. */
  12590. multiplyByFloats(w: number, h: number): Size;
  12591. /**
  12592. * Clones the size
  12593. * @returns a new Size copied from the given one.
  12594. */
  12595. clone(): Size;
  12596. /**
  12597. * True if the current Size and the given one width and height are strictly equal.
  12598. * @param other the other size to compare against
  12599. * @returns True if the current Size and the given one width and height are strictly equal.
  12600. */
  12601. equals(other: Size): boolean;
  12602. /**
  12603. * The surface of the Size : width * height (float).
  12604. */
  12605. readonly surface: number;
  12606. /**
  12607. * Create a new size of zero
  12608. * @returns a new Size set to (0.0, 0.0)
  12609. */
  12610. static Zero(): Size;
  12611. /**
  12612. * Sums the width and height of two sizes
  12613. * @param otherSize size to add to this size
  12614. * @returns a new Size set as the addition result of the current Size and the given one.
  12615. */
  12616. add(otherSize: Size): Size;
  12617. /**
  12618. * Subtracts the width and height of two
  12619. * @param otherSize size to subtract to this size
  12620. * @returns a new Size set as the subtraction result of the given one from the current Size.
  12621. */
  12622. subtract(otherSize: Size): Size;
  12623. /**
  12624. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  12625. * @param start starting size to lerp between
  12626. * @param end end size to lerp between
  12627. * @param amount amount to lerp between the start and end values
  12628. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  12629. */
  12630. static Lerp(start: Size, end: Size, amount: number): Size;
  12631. }
  12632. }
  12633. declare module BABYLON {
  12634. /**
  12635. * Defines a runtime animation
  12636. */
  12637. export class RuntimeAnimation {
  12638. private _events;
  12639. /**
  12640. * The current frame of the runtime animation
  12641. */
  12642. private _currentFrame;
  12643. /**
  12644. * The animation used by the runtime animation
  12645. */
  12646. private _animation;
  12647. /**
  12648. * The target of the runtime animation
  12649. */
  12650. private _target;
  12651. /**
  12652. * The initiating animatable
  12653. */
  12654. private _host;
  12655. /**
  12656. * The original value of the runtime animation
  12657. */
  12658. private _originalValue;
  12659. /**
  12660. * The original blend value of the runtime animation
  12661. */
  12662. private _originalBlendValue;
  12663. /**
  12664. * The offsets cache of the runtime animation
  12665. */
  12666. private _offsetsCache;
  12667. /**
  12668. * The high limits cache of the runtime animation
  12669. */
  12670. private _highLimitsCache;
  12671. /**
  12672. * Specifies if the runtime animation has been stopped
  12673. */
  12674. private _stopped;
  12675. /**
  12676. * The blending factor of the runtime animation
  12677. */
  12678. private _blendingFactor;
  12679. /**
  12680. * The BabylonJS scene
  12681. */
  12682. private _scene;
  12683. /**
  12684. * The current value of the runtime animation
  12685. */
  12686. private _currentValue;
  12687. /** @hidden */
  12688. _animationState: _IAnimationState;
  12689. /**
  12690. * The active target of the runtime animation
  12691. */
  12692. private _activeTargets;
  12693. private _currentActiveTarget;
  12694. private _directTarget;
  12695. /**
  12696. * The target path of the runtime animation
  12697. */
  12698. private _targetPath;
  12699. /**
  12700. * The weight of the runtime animation
  12701. */
  12702. private _weight;
  12703. /**
  12704. * The ratio offset of the runtime animation
  12705. */
  12706. private _ratioOffset;
  12707. /**
  12708. * The previous delay of the runtime animation
  12709. */
  12710. private _previousDelay;
  12711. /**
  12712. * The previous ratio of the runtime animation
  12713. */
  12714. private _previousRatio;
  12715. private _enableBlending;
  12716. private _keys;
  12717. private _minFrame;
  12718. private _maxFrame;
  12719. private _minValue;
  12720. private _maxValue;
  12721. private _targetIsArray;
  12722. /**
  12723. * Gets the current frame of the runtime animation
  12724. */
  12725. readonly currentFrame: number;
  12726. /**
  12727. * Gets the weight of the runtime animation
  12728. */
  12729. readonly weight: number;
  12730. /**
  12731. * Gets the current value of the runtime animation
  12732. */
  12733. readonly currentValue: any;
  12734. /**
  12735. * Gets the target path of the runtime animation
  12736. */
  12737. readonly targetPath: string;
  12738. /**
  12739. * Gets the actual target of the runtime animation
  12740. */
  12741. readonly target: any;
  12742. /** @hidden */
  12743. _onLoop: () => void;
  12744. /**
  12745. * Create a new RuntimeAnimation object
  12746. * @param target defines the target of the animation
  12747. * @param animation defines the source animation object
  12748. * @param scene defines the hosting scene
  12749. * @param host defines the initiating Animatable
  12750. */
  12751. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  12752. private _preparePath;
  12753. /**
  12754. * Gets the animation from the runtime animation
  12755. */
  12756. readonly animation: Animation;
  12757. /**
  12758. * Resets the runtime animation to the beginning
  12759. * @param restoreOriginal defines whether to restore the target property to the original value
  12760. */
  12761. reset(restoreOriginal?: boolean): void;
  12762. /**
  12763. * Specifies if the runtime animation is stopped
  12764. * @returns Boolean specifying if the runtime animation is stopped
  12765. */
  12766. isStopped(): boolean;
  12767. /**
  12768. * Disposes of the runtime animation
  12769. */
  12770. dispose(): void;
  12771. /**
  12772. * Apply the interpolated value to the target
  12773. * @param currentValue defines the value computed by the animation
  12774. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  12775. */
  12776. setValue(currentValue: any, weight: number): void;
  12777. private _getOriginalValues;
  12778. private _setValue;
  12779. /**
  12780. * Gets the loop pmode of the runtime animation
  12781. * @returns Loop Mode
  12782. */
  12783. private _getCorrectLoopMode;
  12784. /**
  12785. * Move the current animation to a given frame
  12786. * @param frame defines the frame to move to
  12787. */
  12788. goToFrame(frame: number): void;
  12789. /**
  12790. * @hidden Internal use only
  12791. */
  12792. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  12793. /**
  12794. * Execute the current animation
  12795. * @param delay defines the delay to add to the current frame
  12796. * @param from defines the lower bound of the animation range
  12797. * @param to defines the upper bound of the animation range
  12798. * @param loop defines if the current animation must loop
  12799. * @param speedRatio defines the current speed ratio
  12800. * @param weight defines the weight of the animation (default is -1 so no weight)
  12801. * @param onLoop optional callback called when animation loops
  12802. * @returns a boolean indicating if the animation is running
  12803. */
  12804. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  12805. }
  12806. }
  12807. declare module BABYLON {
  12808. /**
  12809. * Class used to store an actual running animation
  12810. */
  12811. export class Animatable {
  12812. /** defines the target object */
  12813. target: any;
  12814. /** defines the starting frame number (default is 0) */
  12815. fromFrame: number;
  12816. /** defines the ending frame number (default is 100) */
  12817. toFrame: number;
  12818. /** defines if the animation must loop (default is false) */
  12819. loopAnimation: boolean;
  12820. /** defines a callback to call when animation ends if it is not looping */
  12821. onAnimationEnd?: (() => void) | null | undefined;
  12822. /** defines a callback to call when animation loops */
  12823. onAnimationLoop?: (() => void) | null | undefined;
  12824. private _localDelayOffset;
  12825. private _pausedDelay;
  12826. private _runtimeAnimations;
  12827. private _paused;
  12828. private _scene;
  12829. private _speedRatio;
  12830. private _weight;
  12831. private _syncRoot;
  12832. /**
  12833. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  12834. * This will only apply for non looping animation (default is true)
  12835. */
  12836. disposeOnEnd: boolean;
  12837. /**
  12838. * Gets a boolean indicating if the animation has started
  12839. */
  12840. animationStarted: boolean;
  12841. /**
  12842. * Observer raised when the animation ends
  12843. */
  12844. onAnimationEndObservable: Observable<Animatable>;
  12845. /**
  12846. * Observer raised when the animation loops
  12847. */
  12848. onAnimationLoopObservable: Observable<Animatable>;
  12849. /**
  12850. * Gets the root Animatable used to synchronize and normalize animations
  12851. */
  12852. readonly syncRoot: Nullable<Animatable>;
  12853. /**
  12854. * Gets the current frame of the first RuntimeAnimation
  12855. * Used to synchronize Animatables
  12856. */
  12857. readonly masterFrame: number;
  12858. /**
  12859. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  12860. */
  12861. weight: number;
  12862. /**
  12863. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  12864. */
  12865. speedRatio: number;
  12866. /**
  12867. * Creates a new Animatable
  12868. * @param scene defines the hosting scene
  12869. * @param target defines the target object
  12870. * @param fromFrame defines the starting frame number (default is 0)
  12871. * @param toFrame defines the ending frame number (default is 100)
  12872. * @param loopAnimation defines if the animation must loop (default is false)
  12873. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  12874. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  12875. * @param animations defines a group of animation to add to the new Animatable
  12876. * @param onAnimationLoop defines a callback to call when animation loops
  12877. */
  12878. constructor(scene: Scene,
  12879. /** defines the target object */
  12880. target: any,
  12881. /** defines the starting frame number (default is 0) */
  12882. fromFrame?: number,
  12883. /** defines the ending frame number (default is 100) */
  12884. toFrame?: number,
  12885. /** defines if the animation must loop (default is false) */
  12886. loopAnimation?: boolean, speedRatio?: number,
  12887. /** defines a callback to call when animation ends if it is not looping */
  12888. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  12889. /** defines a callback to call when animation loops */
  12890. onAnimationLoop?: (() => void) | null | undefined);
  12891. /**
  12892. * Synchronize and normalize current Animatable with a source Animatable
  12893. * This is useful when using animation weights and when animations are not of the same length
  12894. * @param root defines the root Animatable to synchronize with
  12895. * @returns the current Animatable
  12896. */
  12897. syncWith(root: Animatable): Animatable;
  12898. /**
  12899. * Gets the list of runtime animations
  12900. * @returns an array of RuntimeAnimation
  12901. */
  12902. getAnimations(): RuntimeAnimation[];
  12903. /**
  12904. * Adds more animations to the current animatable
  12905. * @param target defines the target of the animations
  12906. * @param animations defines the new animations to add
  12907. */
  12908. appendAnimations(target: any, animations: Animation[]): void;
  12909. /**
  12910. * Gets the source animation for a specific property
  12911. * @param property defines the propertyu to look for
  12912. * @returns null or the source animation for the given property
  12913. */
  12914. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  12915. /**
  12916. * Gets the runtime animation for a specific property
  12917. * @param property defines the propertyu to look for
  12918. * @returns null or the runtime animation for the given property
  12919. */
  12920. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  12921. /**
  12922. * Resets the animatable to its original state
  12923. */
  12924. reset(): void;
  12925. /**
  12926. * Allows the animatable to blend with current running animations
  12927. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  12928. * @param blendingSpeed defines the blending speed to use
  12929. */
  12930. enableBlending(blendingSpeed: number): void;
  12931. /**
  12932. * Disable animation blending
  12933. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  12934. */
  12935. disableBlending(): void;
  12936. /**
  12937. * Jump directly to a given frame
  12938. * @param frame defines the frame to jump to
  12939. */
  12940. goToFrame(frame: number): void;
  12941. /**
  12942. * Pause the animation
  12943. */
  12944. pause(): void;
  12945. /**
  12946. * Restart the animation
  12947. */
  12948. restart(): void;
  12949. private _raiseOnAnimationEnd;
  12950. /**
  12951. * Stop and delete the current animation
  12952. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  12953. * @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)
  12954. */
  12955. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  12956. /**
  12957. * Wait asynchronously for the animation to end
  12958. * @returns a promise which will be fullfilled when the animation ends
  12959. */
  12960. waitAsync(): Promise<Animatable>;
  12961. /** @hidden */
  12962. _animate(delay: number): boolean;
  12963. }
  12964. interface Scene {
  12965. /** @hidden */
  12966. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  12967. /** @hidden */
  12968. _processLateAnimationBindingsForMatrices(holder: {
  12969. totalWeight: number;
  12970. animations: RuntimeAnimation[];
  12971. originalValue: Matrix;
  12972. }): any;
  12973. /** @hidden */
  12974. _processLateAnimationBindingsForQuaternions(holder: {
  12975. totalWeight: number;
  12976. animations: RuntimeAnimation[];
  12977. originalValue: Quaternion;
  12978. }, refQuaternion: Quaternion): Quaternion;
  12979. /** @hidden */
  12980. _processLateAnimationBindings(): void;
  12981. /**
  12982. * Will start the animation sequence of a given target
  12983. * @param target defines the target
  12984. * @param from defines from which frame should animation start
  12985. * @param to defines until which frame should animation run.
  12986. * @param weight defines the weight to apply to the animation (1.0 by default)
  12987. * @param loop defines if the animation loops
  12988. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  12989. * @param onAnimationEnd defines the function to be executed when the animation ends
  12990. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  12991. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  12992. * @param onAnimationLoop defines the callback to call when an animation loops
  12993. * @returns the animatable object created for this animation
  12994. */
  12995. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  12996. /**
  12997. * Will start the animation sequence of a given target
  12998. * @param target defines the target
  12999. * @param from defines from which frame should animation start
  13000. * @param to defines until which frame should animation run.
  13001. * @param loop defines if the animation loops
  13002. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13003. * @param onAnimationEnd defines the function to be executed when the animation ends
  13004. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13005. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13006. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  13007. * @param onAnimationLoop defines the callback to call when an animation loops
  13008. * @returns the animatable object created for this animation
  13009. */
  13010. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13011. /**
  13012. * Will start the animation sequence of a given target and its hierarchy
  13013. * @param target defines the target
  13014. * @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.
  13015. * @param from defines from which frame should animation start
  13016. * @param to defines until which frame should animation run.
  13017. * @param loop defines if the animation loops
  13018. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13019. * @param onAnimationEnd defines the function to be executed when the animation ends
  13020. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13021. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13022. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13023. * @param onAnimationLoop defines the callback to call when an animation loops
  13024. * @returns the list of created animatables
  13025. */
  13026. 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[];
  13027. /**
  13028. * Begin a new animation on a given node
  13029. * @param target defines the target where the animation will take place
  13030. * @param animations defines the list of animations to start
  13031. * @param from defines the initial value
  13032. * @param to defines the final value
  13033. * @param loop defines if you want animation to loop (off by default)
  13034. * @param speedRatio defines the speed ratio to apply to all animations
  13035. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13036. * @param onAnimationLoop defines the callback to call when an animation loops
  13037. * @returns the list of created animatables
  13038. */
  13039. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  13040. /**
  13041. * Begin a new animation on a given node and its hierarchy
  13042. * @param target defines the root node where the animation will take place
  13043. * @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.
  13044. * @param animations defines the list of animations to start
  13045. * @param from defines the initial value
  13046. * @param to defines the final value
  13047. * @param loop defines if you want animation to loop (off by default)
  13048. * @param speedRatio defines the speed ratio to apply to all animations
  13049. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13050. * @param onAnimationLoop defines the callback to call when an animation loops
  13051. * @returns the list of animatables created for all nodes
  13052. */
  13053. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  13054. /**
  13055. * Gets the animatable associated with a specific target
  13056. * @param target defines the target of the animatable
  13057. * @returns the required animatable if found
  13058. */
  13059. getAnimatableByTarget(target: any): Nullable<Animatable>;
  13060. /**
  13061. * Gets all animatables associated with a given target
  13062. * @param target defines the target to look animatables for
  13063. * @returns an array of Animatables
  13064. */
  13065. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  13066. /**
  13067. * Stops and removes all animations that have been applied to the scene
  13068. */
  13069. stopAllAnimations(): void;
  13070. /**
  13071. * Gets the current delta time used by animation engine
  13072. */
  13073. deltaTime: number;
  13074. }
  13075. interface Bone {
  13076. /**
  13077. * Copy an animation range from another bone
  13078. * @param source defines the source bone
  13079. * @param rangeName defines the range name to copy
  13080. * @param frameOffset defines the frame offset
  13081. * @param rescaleAsRequired defines if rescaling must be applied if required
  13082. * @param skelDimensionsRatio defines the scaling ratio
  13083. * @returns true if operation was successful
  13084. */
  13085. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  13086. }
  13087. }
  13088. declare module BABYLON {
  13089. /**
  13090. * Class used to override all child animations of a given target
  13091. */
  13092. export class AnimationPropertiesOverride {
  13093. /**
  13094. * Gets or sets a value indicating if animation blending must be used
  13095. */
  13096. enableBlending: boolean;
  13097. /**
  13098. * Gets or sets the blending speed to use when enableBlending is true
  13099. */
  13100. blendingSpeed: number;
  13101. /**
  13102. * Gets or sets the default loop mode to use
  13103. */
  13104. loopMode: number;
  13105. }
  13106. }
  13107. declare module BABYLON {
  13108. /**
  13109. * Class used to handle skinning animations
  13110. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13111. */
  13112. export class Skeleton implements IAnimatable {
  13113. /** defines the skeleton name */
  13114. name: string;
  13115. /** defines the skeleton Id */
  13116. id: string;
  13117. /**
  13118. * Defines the list of child bones
  13119. */
  13120. bones: Bone[];
  13121. /**
  13122. * Defines an estimate of the dimension of the skeleton at rest
  13123. */
  13124. dimensionsAtRest: Vector3;
  13125. /**
  13126. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  13127. */
  13128. needInitialSkinMatrix: boolean;
  13129. /**
  13130. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  13131. */
  13132. overrideMesh: Nullable<AbstractMesh>;
  13133. /**
  13134. * Gets the list of animations attached to this skeleton
  13135. */
  13136. animations: Array<Animation>;
  13137. private _scene;
  13138. private _isDirty;
  13139. private _transformMatrices;
  13140. private _transformMatrixTexture;
  13141. private _meshesWithPoseMatrix;
  13142. private _animatables;
  13143. private _identity;
  13144. private _synchronizedWithMesh;
  13145. private _ranges;
  13146. private _lastAbsoluteTransformsUpdateId;
  13147. private _canUseTextureForBones;
  13148. private _uniqueId;
  13149. /** @hidden */
  13150. _numBonesWithLinkedTransformNode: number;
  13151. /** @hidden */
  13152. _hasWaitingData: Nullable<boolean>;
  13153. /**
  13154. * Specifies if the skeleton should be serialized
  13155. */
  13156. doNotSerialize: boolean;
  13157. private _useTextureToStoreBoneMatrices;
  13158. /**
  13159. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  13160. * Please note that this option is not available if the hardware does not support it
  13161. */
  13162. useTextureToStoreBoneMatrices: boolean;
  13163. private _animationPropertiesOverride;
  13164. /**
  13165. * Gets or sets the animation properties override
  13166. */
  13167. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  13168. /**
  13169. * List of inspectable custom properties (used by the Inspector)
  13170. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  13171. */
  13172. inspectableCustomProperties: IInspectable[];
  13173. /**
  13174. * An observable triggered before computing the skeleton's matrices
  13175. */
  13176. onBeforeComputeObservable: Observable<Skeleton>;
  13177. /**
  13178. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  13179. */
  13180. readonly isUsingTextureForMatrices: boolean;
  13181. /**
  13182. * Gets the unique ID of this skeleton
  13183. */
  13184. readonly uniqueId: number;
  13185. /**
  13186. * Creates a new skeleton
  13187. * @param name defines the skeleton name
  13188. * @param id defines the skeleton Id
  13189. * @param scene defines the hosting scene
  13190. */
  13191. constructor(
  13192. /** defines the skeleton name */
  13193. name: string,
  13194. /** defines the skeleton Id */
  13195. id: string, scene: Scene);
  13196. /**
  13197. * Gets the current object class name.
  13198. * @return the class name
  13199. */
  13200. getClassName(): string;
  13201. /**
  13202. * Returns an array containing the root bones
  13203. * @returns an array containing the root bones
  13204. */
  13205. getChildren(): Array<Bone>;
  13206. /**
  13207. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  13208. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13209. * @returns a Float32Array containing matrices data
  13210. */
  13211. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  13212. /**
  13213. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  13214. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13215. * @returns a raw texture containing the data
  13216. */
  13217. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  13218. /**
  13219. * Gets the current hosting scene
  13220. * @returns a scene object
  13221. */
  13222. getScene(): Scene;
  13223. /**
  13224. * Gets a string representing the current skeleton data
  13225. * @param fullDetails defines a boolean indicating if we want a verbose version
  13226. * @returns a string representing the current skeleton data
  13227. */
  13228. toString(fullDetails?: boolean): string;
  13229. /**
  13230. * Get bone's index searching by name
  13231. * @param name defines bone's name to search for
  13232. * @return the indice of the bone. Returns -1 if not found
  13233. */
  13234. getBoneIndexByName(name: string): number;
  13235. /**
  13236. * Creater a new animation range
  13237. * @param name defines the name of the range
  13238. * @param from defines the start key
  13239. * @param to defines the end key
  13240. */
  13241. createAnimationRange(name: string, from: number, to: number): void;
  13242. /**
  13243. * Delete a specific animation range
  13244. * @param name defines the name of the range
  13245. * @param deleteFrames defines if frames must be removed as well
  13246. */
  13247. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  13248. /**
  13249. * Gets a specific animation range
  13250. * @param name defines the name of the range to look for
  13251. * @returns the requested animation range or null if not found
  13252. */
  13253. getAnimationRange(name: string): Nullable<AnimationRange>;
  13254. /**
  13255. * Gets the list of all animation ranges defined on this skeleton
  13256. * @returns an array
  13257. */
  13258. getAnimationRanges(): Nullable<AnimationRange>[];
  13259. /**
  13260. * Copy animation range from a source skeleton.
  13261. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  13262. * @param source defines the source skeleton
  13263. * @param name defines the name of the range to copy
  13264. * @param rescaleAsRequired defines if rescaling must be applied if required
  13265. * @returns true if operation was successful
  13266. */
  13267. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  13268. /**
  13269. * Forces the skeleton to go to rest pose
  13270. */
  13271. returnToRest(): void;
  13272. private _getHighestAnimationFrame;
  13273. /**
  13274. * Begin a specific animation range
  13275. * @param name defines the name of the range to start
  13276. * @param loop defines if looping must be turned on (false by default)
  13277. * @param speedRatio defines the speed ratio to apply (1 by default)
  13278. * @param onAnimationEnd defines a callback which will be called when animation will end
  13279. * @returns a new animatable
  13280. */
  13281. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  13282. /** @hidden */
  13283. _markAsDirty(): void;
  13284. /** @hidden */
  13285. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13286. /** @hidden */
  13287. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13288. private _computeTransformMatrices;
  13289. /**
  13290. * Build all resources required to render a skeleton
  13291. */
  13292. prepare(): void;
  13293. /**
  13294. * Gets the list of animatables currently running for this skeleton
  13295. * @returns an array of animatables
  13296. */
  13297. getAnimatables(): IAnimatable[];
  13298. /**
  13299. * Clone the current skeleton
  13300. * @param name defines the name of the new skeleton
  13301. * @param id defines the id of the new skeleton
  13302. * @returns the new skeleton
  13303. */
  13304. clone(name: string, id: string): Skeleton;
  13305. /**
  13306. * Enable animation blending for this skeleton
  13307. * @param blendingSpeed defines the blending speed to apply
  13308. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13309. */
  13310. enableBlending(blendingSpeed?: number): void;
  13311. /**
  13312. * Releases all resources associated with the current skeleton
  13313. */
  13314. dispose(): void;
  13315. /**
  13316. * Serialize the skeleton in a JSON object
  13317. * @returns a JSON object
  13318. */
  13319. serialize(): any;
  13320. /**
  13321. * Creates a new skeleton from serialized data
  13322. * @param parsedSkeleton defines the serialized data
  13323. * @param scene defines the hosting scene
  13324. * @returns a new skeleton
  13325. */
  13326. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  13327. /**
  13328. * Compute all node absolute transforms
  13329. * @param forceUpdate defines if computation must be done even if cache is up to date
  13330. */
  13331. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  13332. /**
  13333. * Gets the root pose matrix
  13334. * @returns a matrix
  13335. */
  13336. getPoseMatrix(): Nullable<Matrix>;
  13337. /**
  13338. * Sorts bones per internal index
  13339. */
  13340. sortBones(): void;
  13341. private _sortBones;
  13342. }
  13343. }
  13344. declare module BABYLON {
  13345. /**
  13346. * Class used to store bone information
  13347. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13348. */
  13349. export class Bone extends Node {
  13350. /**
  13351. * defines the bone name
  13352. */
  13353. name: string;
  13354. private static _tmpVecs;
  13355. private static _tmpQuat;
  13356. private static _tmpMats;
  13357. /**
  13358. * Gets the list of child bones
  13359. */
  13360. children: Bone[];
  13361. /** Gets the animations associated with this bone */
  13362. animations: Animation[];
  13363. /**
  13364. * Gets or sets bone length
  13365. */
  13366. length: number;
  13367. /**
  13368. * @hidden Internal only
  13369. * Set this value to map this bone to a different index in the transform matrices
  13370. * Set this value to -1 to exclude the bone from the transform matrices
  13371. */
  13372. _index: Nullable<number>;
  13373. private _skeleton;
  13374. private _localMatrix;
  13375. private _restPose;
  13376. private _baseMatrix;
  13377. private _absoluteTransform;
  13378. private _invertedAbsoluteTransform;
  13379. private _parent;
  13380. private _scalingDeterminant;
  13381. private _worldTransform;
  13382. private _localScaling;
  13383. private _localRotation;
  13384. private _localPosition;
  13385. private _needToDecompose;
  13386. private _needToCompose;
  13387. /** @hidden */
  13388. _linkedTransformNode: Nullable<TransformNode>;
  13389. /** @hidden */
  13390. _waitingTransformNodeId: Nullable<string>;
  13391. /** @hidden */
  13392. /** @hidden */
  13393. _matrix: Matrix;
  13394. /**
  13395. * Create a new bone
  13396. * @param name defines the bone name
  13397. * @param skeleton defines the parent skeleton
  13398. * @param parentBone defines the parent (can be null if the bone is the root)
  13399. * @param localMatrix defines the local matrix
  13400. * @param restPose defines the rest pose matrix
  13401. * @param baseMatrix defines the base matrix
  13402. * @param index defines index of the bone in the hiearchy
  13403. */
  13404. constructor(
  13405. /**
  13406. * defines the bone name
  13407. */
  13408. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  13409. /**
  13410. * Gets the current object class name.
  13411. * @return the class name
  13412. */
  13413. getClassName(): string;
  13414. /**
  13415. * Gets the parent skeleton
  13416. * @returns a skeleton
  13417. */
  13418. getSkeleton(): Skeleton;
  13419. /**
  13420. * Gets parent bone
  13421. * @returns a bone or null if the bone is the root of the bone hierarchy
  13422. */
  13423. getParent(): Nullable<Bone>;
  13424. /**
  13425. * Returns an array containing the root bones
  13426. * @returns an array containing the root bones
  13427. */
  13428. getChildren(): Array<Bone>;
  13429. /**
  13430. * Sets the parent bone
  13431. * @param parent defines the parent (can be null if the bone is the root)
  13432. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13433. */
  13434. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  13435. /**
  13436. * Gets the local matrix
  13437. * @returns a matrix
  13438. */
  13439. getLocalMatrix(): Matrix;
  13440. /**
  13441. * Gets the base matrix (initial matrix which remains unchanged)
  13442. * @returns a matrix
  13443. */
  13444. getBaseMatrix(): Matrix;
  13445. /**
  13446. * Gets the rest pose matrix
  13447. * @returns a matrix
  13448. */
  13449. getRestPose(): Matrix;
  13450. /**
  13451. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  13452. */
  13453. getWorldMatrix(): Matrix;
  13454. /**
  13455. * Sets the local matrix to rest pose matrix
  13456. */
  13457. returnToRest(): void;
  13458. /**
  13459. * Gets the inverse of the absolute transform matrix.
  13460. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  13461. * @returns a matrix
  13462. */
  13463. getInvertedAbsoluteTransform(): Matrix;
  13464. /**
  13465. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  13466. * @returns a matrix
  13467. */
  13468. getAbsoluteTransform(): Matrix;
  13469. /**
  13470. * Links with the given transform node.
  13471. * The local matrix of this bone is copied from the transform node every frame.
  13472. * @param transformNode defines the transform node to link to
  13473. */
  13474. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  13475. /**
  13476. * Gets the node used to drive the bone's transformation
  13477. * @returns a transform node or null
  13478. */
  13479. getTransformNode(): Nullable<TransformNode>;
  13480. /** Gets or sets current position (in local space) */
  13481. position: Vector3;
  13482. /** Gets or sets current rotation (in local space) */
  13483. rotation: Vector3;
  13484. /** Gets or sets current rotation quaternion (in local space) */
  13485. rotationQuaternion: Quaternion;
  13486. /** Gets or sets current scaling (in local space) */
  13487. scaling: Vector3;
  13488. /**
  13489. * Gets the animation properties override
  13490. */
  13491. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  13492. private _decompose;
  13493. private _compose;
  13494. /**
  13495. * Update the base and local matrices
  13496. * @param matrix defines the new base or local matrix
  13497. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13498. * @param updateLocalMatrix defines if the local matrix should be updated
  13499. */
  13500. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  13501. /** @hidden */
  13502. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  13503. /**
  13504. * Flag the bone as dirty (Forcing it to update everything)
  13505. */
  13506. markAsDirty(): void;
  13507. /** @hidden */
  13508. _markAsDirtyAndCompose(): void;
  13509. private _markAsDirtyAndDecompose;
  13510. /**
  13511. * Translate the bone in local or world space
  13512. * @param vec The amount to translate the bone
  13513. * @param space The space that the translation is in
  13514. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13515. */
  13516. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13517. /**
  13518. * Set the postion of the bone in local or world space
  13519. * @param position The position to set the bone
  13520. * @param space The space that the position is in
  13521. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13522. */
  13523. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13524. /**
  13525. * Set the absolute position of the bone (world space)
  13526. * @param position The position to set the bone
  13527. * @param mesh The mesh that this bone is attached to
  13528. */
  13529. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  13530. /**
  13531. * Scale the bone on the x, y and z axes (in local space)
  13532. * @param x The amount to scale the bone on the x axis
  13533. * @param y The amount to scale the bone on the y axis
  13534. * @param z The amount to scale the bone on the z axis
  13535. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  13536. */
  13537. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  13538. /**
  13539. * Set the bone scaling in local space
  13540. * @param scale defines the scaling vector
  13541. */
  13542. setScale(scale: Vector3): void;
  13543. /**
  13544. * Gets the current scaling in local space
  13545. * @returns the current scaling vector
  13546. */
  13547. getScale(): Vector3;
  13548. /**
  13549. * Gets the current scaling in local space and stores it in a target vector
  13550. * @param result defines the target vector
  13551. */
  13552. getScaleToRef(result: Vector3): void;
  13553. /**
  13554. * Set the yaw, pitch, and roll of the bone in local or world space
  13555. * @param yaw The rotation of the bone on the y axis
  13556. * @param pitch The rotation of the bone on the x axis
  13557. * @param roll The rotation of the bone on the z axis
  13558. * @param space The space that the axes of rotation are in
  13559. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13560. */
  13561. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  13562. /**
  13563. * Add a rotation to the bone on an axis in local or world space
  13564. * @param axis The axis to rotate the bone on
  13565. * @param amount The amount to rotate the bone
  13566. * @param space The space that the axis is in
  13567. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13568. */
  13569. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  13570. /**
  13571. * Set the rotation of the bone to a particular axis angle in local or world space
  13572. * @param axis The axis to rotate the bone on
  13573. * @param angle The angle that the bone should be rotated to
  13574. * @param space The space that the axis is in
  13575. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13576. */
  13577. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  13578. /**
  13579. * Set the euler rotation of the bone in local of world space
  13580. * @param rotation The euler rotation that the bone should be set to
  13581. * @param space The space that the rotation is in
  13582. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13583. */
  13584. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13585. /**
  13586. * Set the quaternion rotation of the bone in local of world space
  13587. * @param quat The quaternion rotation that the bone should be set to
  13588. * @param space The space that the rotation is in
  13589. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13590. */
  13591. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  13592. /**
  13593. * Set the rotation matrix of the bone in local of world space
  13594. * @param rotMat The rotation matrix that the bone should be set to
  13595. * @param space The space that the rotation is in
  13596. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13597. */
  13598. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  13599. private _rotateWithMatrix;
  13600. private _getNegativeRotationToRef;
  13601. /**
  13602. * Get the position of the bone in local or world space
  13603. * @param space The space that the returned position is in
  13604. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13605. * @returns The position of the bone
  13606. */
  13607. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  13608. /**
  13609. * Copy the position of the bone to a vector3 in local or world space
  13610. * @param space The space that the returned position is in
  13611. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13612. * @param result The vector3 to copy the position to
  13613. */
  13614. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  13615. /**
  13616. * Get the absolute position of the bone (world space)
  13617. * @param mesh The mesh that this bone is attached to
  13618. * @returns The absolute position of the bone
  13619. */
  13620. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  13621. /**
  13622. * Copy the absolute position of the bone (world space) to the result param
  13623. * @param mesh The mesh that this bone is attached to
  13624. * @param result The vector3 to copy the absolute position to
  13625. */
  13626. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  13627. /**
  13628. * Compute the absolute transforms of this bone and its children
  13629. */
  13630. computeAbsoluteTransforms(): void;
  13631. /**
  13632. * Get the world direction from an axis that is in the local space of the bone
  13633. * @param localAxis The local direction that is used to compute the world direction
  13634. * @param mesh The mesh that this bone is attached to
  13635. * @returns The world direction
  13636. */
  13637. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13638. /**
  13639. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  13640. * @param localAxis The local direction that is used to compute the world direction
  13641. * @param mesh The mesh that this bone is attached to
  13642. * @param result The vector3 that the world direction will be copied to
  13643. */
  13644. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13645. /**
  13646. * Get the euler rotation of the bone in local or world space
  13647. * @param space The space that the rotation should be in
  13648. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13649. * @returns The euler rotation
  13650. */
  13651. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  13652. /**
  13653. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  13654. * @param space The space that the rotation should be in
  13655. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13656. * @param result The vector3 that the rotation should be copied to
  13657. */
  13658. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13659. /**
  13660. * Get the quaternion rotation of the bone in either local or world space
  13661. * @param space The space that the rotation should be in
  13662. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13663. * @returns The quaternion rotation
  13664. */
  13665. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  13666. /**
  13667. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  13668. * @param space The space that the rotation should be in
  13669. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13670. * @param result The quaternion that the rotation should be copied to
  13671. */
  13672. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  13673. /**
  13674. * Get the rotation matrix of the bone in local or world space
  13675. * @param space The space that the rotation should be in
  13676. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13677. * @returns The rotation matrix
  13678. */
  13679. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  13680. /**
  13681. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  13682. * @param space The space that the rotation should be in
  13683. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13684. * @param result The quaternion that the rotation should be copied to
  13685. */
  13686. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  13687. /**
  13688. * Get the world position of a point that is in the local space of the bone
  13689. * @param position The local position
  13690. * @param mesh The mesh that this bone is attached to
  13691. * @returns The world position
  13692. */
  13693. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13694. /**
  13695. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  13696. * @param position The local position
  13697. * @param mesh The mesh that this bone is attached to
  13698. * @param result The vector3 that the world position should be copied to
  13699. */
  13700. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13701. /**
  13702. * Get the local position of a point that is in world space
  13703. * @param position The world position
  13704. * @param mesh The mesh that this bone is attached to
  13705. * @returns The local position
  13706. */
  13707. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13708. /**
  13709. * Get the local position of a point that is in world space and copy it to the result param
  13710. * @param position The world position
  13711. * @param mesh The mesh that this bone is attached to
  13712. * @param result The vector3 that the local position should be copied to
  13713. */
  13714. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13715. }
  13716. }
  13717. declare module BABYLON {
  13718. /**
  13719. * 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.
  13720. * @see https://doc.babylonjs.com/how_to/transformnode
  13721. */
  13722. export class TransformNode extends Node {
  13723. /**
  13724. * Object will not rotate to face the camera
  13725. */
  13726. static BILLBOARDMODE_NONE: number;
  13727. /**
  13728. * Object will rotate to face the camera but only on the x axis
  13729. */
  13730. static BILLBOARDMODE_X: number;
  13731. /**
  13732. * Object will rotate to face the camera but only on the y axis
  13733. */
  13734. static BILLBOARDMODE_Y: number;
  13735. /**
  13736. * Object will rotate to face the camera but only on the z axis
  13737. */
  13738. static BILLBOARDMODE_Z: number;
  13739. /**
  13740. * Object will rotate to face the camera
  13741. */
  13742. static BILLBOARDMODE_ALL: number;
  13743. /**
  13744. * Object will rotate to face the camera's position instead of orientation
  13745. */
  13746. static BILLBOARDMODE_USE_POSITION: number;
  13747. private _forward;
  13748. private _forwardInverted;
  13749. private _up;
  13750. private _right;
  13751. private _rightInverted;
  13752. private _position;
  13753. private _rotation;
  13754. private _rotationQuaternion;
  13755. protected _scaling: Vector3;
  13756. protected _isDirty: boolean;
  13757. private _transformToBoneReferal;
  13758. private _isAbsoluteSynced;
  13759. private _billboardMode;
  13760. /**
  13761. * Gets or sets the billboard mode. Default is 0.
  13762. *
  13763. * | Value | Type | Description |
  13764. * | --- | --- | --- |
  13765. * | 0 | BILLBOARDMODE_NONE | |
  13766. * | 1 | BILLBOARDMODE_X | |
  13767. * | 2 | BILLBOARDMODE_Y | |
  13768. * | 4 | BILLBOARDMODE_Z | |
  13769. * | 7 | BILLBOARDMODE_ALL | |
  13770. *
  13771. */
  13772. billboardMode: number;
  13773. private _preserveParentRotationForBillboard;
  13774. /**
  13775. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  13776. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  13777. */
  13778. preserveParentRotationForBillboard: boolean;
  13779. /**
  13780. * 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
  13781. */
  13782. scalingDeterminant: number;
  13783. private _infiniteDistance;
  13784. /**
  13785. * Gets or sets the distance of the object to max, often used by skybox
  13786. */
  13787. infiniteDistance: boolean;
  13788. /**
  13789. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  13790. * By default the system will update normals to compensate
  13791. */
  13792. ignoreNonUniformScaling: boolean;
  13793. /**
  13794. * 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
  13795. */
  13796. reIntegrateRotationIntoRotationQuaternion: boolean;
  13797. /** @hidden */
  13798. _poseMatrix: Nullable<Matrix>;
  13799. /** @hidden */
  13800. _localMatrix: Matrix;
  13801. private _usePivotMatrix;
  13802. private _absolutePosition;
  13803. private _absoluteScaling;
  13804. private _absoluteRotationQuaternion;
  13805. private _pivotMatrix;
  13806. private _pivotMatrixInverse;
  13807. protected _postMultiplyPivotMatrix: boolean;
  13808. protected _isWorldMatrixFrozen: boolean;
  13809. /** @hidden */
  13810. _indexInSceneTransformNodesArray: number;
  13811. /**
  13812. * An event triggered after the world matrix is updated
  13813. */
  13814. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  13815. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  13816. /**
  13817. * Gets a string identifying the name of the class
  13818. * @returns "TransformNode" string
  13819. */
  13820. getClassName(): string;
  13821. /**
  13822. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  13823. */
  13824. position: Vector3;
  13825. /**
  13826. * 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)).
  13827. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  13828. */
  13829. rotation: Vector3;
  13830. /**
  13831. * 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)).
  13832. */
  13833. scaling: Vector3;
  13834. /**
  13835. * 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).
  13836. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  13837. */
  13838. rotationQuaternion: Nullable<Quaternion>;
  13839. /**
  13840. * The forward direction of that transform in world space.
  13841. */
  13842. readonly forward: Vector3;
  13843. /**
  13844. * The up direction of that transform in world space.
  13845. */
  13846. readonly up: Vector3;
  13847. /**
  13848. * The right direction of that transform in world space.
  13849. */
  13850. readonly right: Vector3;
  13851. /**
  13852. * Copies the parameter passed Matrix into the mesh Pose matrix.
  13853. * @param matrix the matrix to copy the pose from
  13854. * @returns this TransformNode.
  13855. */
  13856. updatePoseMatrix(matrix: Matrix): TransformNode;
  13857. /**
  13858. * Returns the mesh Pose matrix.
  13859. * @returns the pose matrix
  13860. */
  13861. getPoseMatrix(): Matrix;
  13862. /** @hidden */
  13863. _isSynchronized(): boolean;
  13864. /** @hidden */
  13865. _initCache(): void;
  13866. /**
  13867. * Flag the transform node as dirty (Forcing it to update everything)
  13868. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  13869. * @returns this transform node
  13870. */
  13871. markAsDirty(property: string): TransformNode;
  13872. /**
  13873. * Returns the current mesh absolute position.
  13874. * Returns a Vector3.
  13875. */
  13876. readonly absolutePosition: Vector3;
  13877. /**
  13878. * Returns the current mesh absolute scaling.
  13879. * Returns a Vector3.
  13880. */
  13881. readonly absoluteScaling: Vector3;
  13882. /**
  13883. * Returns the current mesh absolute rotation.
  13884. * Returns a Quaternion.
  13885. */
  13886. readonly absoluteRotationQuaternion: Quaternion;
  13887. /**
  13888. * Sets a new matrix to apply before all other transformation
  13889. * @param matrix defines the transform matrix
  13890. * @returns the current TransformNode
  13891. */
  13892. setPreTransformMatrix(matrix: Matrix): TransformNode;
  13893. /**
  13894. * Sets a new pivot matrix to the current node
  13895. * @param matrix defines the new pivot matrix to use
  13896. * @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
  13897. * @returns the current TransformNode
  13898. */
  13899. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  13900. /**
  13901. * Returns the mesh pivot matrix.
  13902. * Default : Identity.
  13903. * @returns the matrix
  13904. */
  13905. getPivotMatrix(): Matrix;
  13906. /**
  13907. * Instantiate (when possible) or clone that node with its hierarchy
  13908. * @param newParent defines the new parent to use for the instance (or clone)
  13909. * @returns an instance (or a clone) of the current node with its hiearchy
  13910. */
  13911. instantiateHierarchy(newParent?: Nullable<TransformNode>): Nullable<TransformNode>;
  13912. /**
  13913. * Prevents the World matrix to be computed any longer
  13914. * @param newWorldMatrix defines an optional matrix to use as world matrix
  13915. * @returns the TransformNode.
  13916. */
  13917. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  13918. /**
  13919. * Allows back the World matrix computation.
  13920. * @returns the TransformNode.
  13921. */
  13922. unfreezeWorldMatrix(): this;
  13923. /**
  13924. * True if the World matrix has been frozen.
  13925. */
  13926. readonly isWorldMatrixFrozen: boolean;
  13927. /**
  13928. * Retuns the mesh absolute position in the World.
  13929. * @returns a Vector3.
  13930. */
  13931. getAbsolutePosition(): Vector3;
  13932. /**
  13933. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  13934. * @param absolutePosition the absolute position to set
  13935. * @returns the TransformNode.
  13936. */
  13937. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  13938. /**
  13939. * Sets the mesh position in its local space.
  13940. * @param vector3 the position to set in localspace
  13941. * @returns the TransformNode.
  13942. */
  13943. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  13944. /**
  13945. * Returns the mesh position in the local space from the current World matrix values.
  13946. * @returns a new Vector3.
  13947. */
  13948. getPositionExpressedInLocalSpace(): Vector3;
  13949. /**
  13950. * Translates the mesh along the passed Vector3 in its local space.
  13951. * @param vector3 the distance to translate in localspace
  13952. * @returns the TransformNode.
  13953. */
  13954. locallyTranslate(vector3: Vector3): TransformNode;
  13955. private static _lookAtVectorCache;
  13956. /**
  13957. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  13958. * @param targetPoint the position (must be in same space as current mesh) to look at
  13959. * @param yawCor optional yaw (y-axis) correction in radians
  13960. * @param pitchCor optional pitch (x-axis) correction in radians
  13961. * @param rollCor optional roll (z-axis) correction in radians
  13962. * @param space the choosen space of the target
  13963. * @returns the TransformNode.
  13964. */
  13965. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  13966. /**
  13967. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  13968. * This Vector3 is expressed in the World space.
  13969. * @param localAxis axis to rotate
  13970. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  13971. */
  13972. getDirection(localAxis: Vector3): Vector3;
  13973. /**
  13974. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  13975. * localAxis is expressed in the mesh local space.
  13976. * result is computed in the Wordl space from the mesh World matrix.
  13977. * @param localAxis axis to rotate
  13978. * @param result the resulting transformnode
  13979. * @returns this TransformNode.
  13980. */
  13981. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  13982. /**
  13983. * Sets this transform node rotation to the given local axis.
  13984. * @param localAxis the axis in local space
  13985. * @param yawCor optional yaw (y-axis) correction in radians
  13986. * @param pitchCor optional pitch (x-axis) correction in radians
  13987. * @param rollCor optional roll (z-axis) correction in radians
  13988. * @returns this TransformNode
  13989. */
  13990. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  13991. /**
  13992. * Sets a new pivot point to the current node
  13993. * @param point defines the new pivot point to use
  13994. * @param space defines if the point is in world or local space (local by default)
  13995. * @returns the current TransformNode
  13996. */
  13997. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  13998. /**
  13999. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  14000. * @returns the pivot point
  14001. */
  14002. getPivotPoint(): Vector3;
  14003. /**
  14004. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  14005. * @param result the vector3 to store the result
  14006. * @returns this TransformNode.
  14007. */
  14008. getPivotPointToRef(result: Vector3): TransformNode;
  14009. /**
  14010. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  14011. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  14012. */
  14013. getAbsolutePivotPoint(): Vector3;
  14014. /**
  14015. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  14016. * @param result vector3 to store the result
  14017. * @returns this TransformNode.
  14018. */
  14019. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  14020. /**
  14021. * Defines the passed node as the parent of the current node.
  14022. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  14023. * @see https://doc.babylonjs.com/how_to/parenting
  14024. * @param node the node ot set as the parent
  14025. * @returns this TransformNode.
  14026. */
  14027. setParent(node: Nullable<Node>): TransformNode;
  14028. private _nonUniformScaling;
  14029. /**
  14030. * True if the scaling property of this object is non uniform eg. (1,2,1)
  14031. */
  14032. readonly nonUniformScaling: boolean;
  14033. /** @hidden */
  14034. _updateNonUniformScalingState(value: boolean): boolean;
  14035. /**
  14036. * Attach the current TransformNode to another TransformNode associated with a bone
  14037. * @param bone Bone affecting the TransformNode
  14038. * @param affectedTransformNode TransformNode associated with the bone
  14039. * @returns this object
  14040. */
  14041. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  14042. /**
  14043. * Detach the transform node if its associated with a bone
  14044. * @returns this object
  14045. */
  14046. detachFromBone(): TransformNode;
  14047. private static _rotationAxisCache;
  14048. /**
  14049. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  14050. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14051. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14052. * The passed axis is also normalized.
  14053. * @param axis the axis to rotate around
  14054. * @param amount the amount to rotate in radians
  14055. * @param space Space to rotate in (Default: local)
  14056. * @returns the TransformNode.
  14057. */
  14058. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  14059. /**
  14060. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  14061. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14062. * The passed axis is also normalized. .
  14063. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  14064. * @param point the point to rotate around
  14065. * @param axis the axis to rotate around
  14066. * @param amount the amount to rotate in radians
  14067. * @returns the TransformNode
  14068. */
  14069. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  14070. /**
  14071. * Translates the mesh along the axis vector for the passed distance in the given space.
  14072. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14073. * @param axis the axis to translate in
  14074. * @param distance the distance to translate
  14075. * @param space Space to rotate in (Default: local)
  14076. * @returns the TransformNode.
  14077. */
  14078. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  14079. /**
  14080. * Adds a rotation step to the mesh current rotation.
  14081. * x, y, z are Euler angles expressed in radians.
  14082. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  14083. * This means this rotation is made in the mesh local space only.
  14084. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  14085. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  14086. * ```javascript
  14087. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  14088. * ```
  14089. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  14090. * 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.
  14091. * @param x Rotation to add
  14092. * @param y Rotation to add
  14093. * @param z Rotation to add
  14094. * @returns the TransformNode.
  14095. */
  14096. addRotation(x: number, y: number, z: number): TransformNode;
  14097. /**
  14098. * @hidden
  14099. */
  14100. protected _getEffectiveParent(): Nullable<Node>;
  14101. /**
  14102. * Computes the world matrix of the node
  14103. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14104. * @returns the world matrix
  14105. */
  14106. computeWorldMatrix(force?: boolean): Matrix;
  14107. protected _afterComputeWorldMatrix(): void;
  14108. /**
  14109. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  14110. * @param func callback function to add
  14111. *
  14112. * @returns the TransformNode.
  14113. */
  14114. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14115. /**
  14116. * Removes a registered callback function.
  14117. * @param func callback function to remove
  14118. * @returns the TransformNode.
  14119. */
  14120. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14121. /**
  14122. * Gets the position of the current mesh in camera space
  14123. * @param camera defines the camera to use
  14124. * @returns a position
  14125. */
  14126. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  14127. /**
  14128. * Returns the distance from the mesh to the active camera
  14129. * @param camera defines the camera to use
  14130. * @returns the distance
  14131. */
  14132. getDistanceToCamera(camera?: Nullable<Camera>): number;
  14133. /**
  14134. * Clone the current transform node
  14135. * @param name Name of the new clone
  14136. * @param newParent New parent for the clone
  14137. * @param doNotCloneChildren Do not clone children hierarchy
  14138. * @returns the new transform node
  14139. */
  14140. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  14141. /**
  14142. * Serializes the objects information.
  14143. * @param currentSerializationObject defines the object to serialize in
  14144. * @returns the serialized object
  14145. */
  14146. serialize(currentSerializationObject?: any): any;
  14147. /**
  14148. * Returns a new TransformNode object parsed from the source provided.
  14149. * @param parsedTransformNode is the source.
  14150. * @param scene the scne the object belongs to
  14151. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  14152. * @returns a new TransformNode object parsed from the source provided.
  14153. */
  14154. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  14155. /**
  14156. * Get all child-transformNodes of this node
  14157. * @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
  14158. * @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
  14159. * @returns an array of TransformNode
  14160. */
  14161. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  14162. /**
  14163. * Releases resources associated with this transform node.
  14164. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14165. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14166. */
  14167. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14168. /**
  14169. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  14170. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  14171. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  14172. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  14173. * @returns the current mesh
  14174. */
  14175. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  14176. private _syncAbsoluteScalingAndRotation;
  14177. }
  14178. }
  14179. declare module BABYLON {
  14180. /**
  14181. * Defines the types of pose enabled controllers that are supported
  14182. */
  14183. export enum PoseEnabledControllerType {
  14184. /**
  14185. * HTC Vive
  14186. */
  14187. VIVE = 0,
  14188. /**
  14189. * Oculus Rift
  14190. */
  14191. OCULUS = 1,
  14192. /**
  14193. * Windows mixed reality
  14194. */
  14195. WINDOWS = 2,
  14196. /**
  14197. * Samsung gear VR
  14198. */
  14199. GEAR_VR = 3,
  14200. /**
  14201. * Google Daydream
  14202. */
  14203. DAYDREAM = 4,
  14204. /**
  14205. * Generic
  14206. */
  14207. GENERIC = 5
  14208. }
  14209. /**
  14210. * Defines the MutableGamepadButton interface for the state of a gamepad button
  14211. */
  14212. export interface MutableGamepadButton {
  14213. /**
  14214. * Value of the button/trigger
  14215. */
  14216. value: number;
  14217. /**
  14218. * If the button/trigger is currently touched
  14219. */
  14220. touched: boolean;
  14221. /**
  14222. * If the button/trigger is currently pressed
  14223. */
  14224. pressed: boolean;
  14225. }
  14226. /**
  14227. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  14228. * @hidden
  14229. */
  14230. export interface ExtendedGamepadButton extends GamepadButton {
  14231. /**
  14232. * If the button/trigger is currently pressed
  14233. */
  14234. readonly pressed: boolean;
  14235. /**
  14236. * If the button/trigger is currently touched
  14237. */
  14238. readonly touched: boolean;
  14239. /**
  14240. * Value of the button/trigger
  14241. */
  14242. readonly value: number;
  14243. }
  14244. /** @hidden */
  14245. export interface _GamePadFactory {
  14246. /**
  14247. * Returns wether or not the current gamepad can be created for this type of controller.
  14248. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14249. * @returns true if it can be created, otherwise false
  14250. */
  14251. canCreate(gamepadInfo: any): boolean;
  14252. /**
  14253. * Creates a new instance of the Gamepad.
  14254. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14255. * @returns the new gamepad instance
  14256. */
  14257. create(gamepadInfo: any): Gamepad;
  14258. }
  14259. /**
  14260. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14261. */
  14262. export class PoseEnabledControllerHelper {
  14263. /** @hidden */
  14264. static _ControllerFactories: _GamePadFactory[];
  14265. /** @hidden */
  14266. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  14267. /**
  14268. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14269. * @param vrGamepad the gamepad to initialized
  14270. * @returns a vr controller of the type the gamepad identified as
  14271. */
  14272. static InitiateController(vrGamepad: any): Gamepad;
  14273. }
  14274. /**
  14275. * Defines the PoseEnabledController object that contains state of a vr capable controller
  14276. */
  14277. export class PoseEnabledController extends Gamepad implements PoseControlled {
  14278. /**
  14279. * If the controller is used in a webXR session
  14280. */
  14281. isXR: boolean;
  14282. private _deviceRoomPosition;
  14283. private _deviceRoomRotationQuaternion;
  14284. /**
  14285. * The device position in babylon space
  14286. */
  14287. devicePosition: Vector3;
  14288. /**
  14289. * The device rotation in babylon space
  14290. */
  14291. deviceRotationQuaternion: Quaternion;
  14292. /**
  14293. * The scale factor of the device in babylon space
  14294. */
  14295. deviceScaleFactor: number;
  14296. /**
  14297. * (Likely devicePosition should be used instead) The device position in its room space
  14298. */
  14299. position: Vector3;
  14300. /**
  14301. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  14302. */
  14303. rotationQuaternion: Quaternion;
  14304. /**
  14305. * The type of controller (Eg. Windows mixed reality)
  14306. */
  14307. controllerType: PoseEnabledControllerType;
  14308. protected _calculatedPosition: Vector3;
  14309. private _calculatedRotation;
  14310. /**
  14311. * The raw pose from the device
  14312. */
  14313. rawPose: DevicePose;
  14314. private _trackPosition;
  14315. private _maxRotationDistFromHeadset;
  14316. private _draggedRoomRotation;
  14317. /**
  14318. * @hidden
  14319. */
  14320. _disableTrackPosition(fixedPosition: Vector3): void;
  14321. /**
  14322. * Internal, the mesh attached to the controller
  14323. * @hidden
  14324. */
  14325. _mesh: Nullable<AbstractMesh>;
  14326. private _poseControlledCamera;
  14327. private _leftHandSystemQuaternion;
  14328. /**
  14329. * Internal, matrix used to convert room space to babylon space
  14330. * @hidden
  14331. */
  14332. _deviceToWorld: Matrix;
  14333. /**
  14334. * Node to be used when casting a ray from the controller
  14335. * @hidden
  14336. */
  14337. _pointingPoseNode: Nullable<TransformNode>;
  14338. /**
  14339. * Name of the child mesh that can be used to cast a ray from the controller
  14340. */
  14341. static readonly POINTING_POSE: string;
  14342. /**
  14343. * Creates a new PoseEnabledController from a gamepad
  14344. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  14345. */
  14346. constructor(browserGamepad: any);
  14347. private _workingMatrix;
  14348. /**
  14349. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  14350. */
  14351. update(): void;
  14352. /**
  14353. * Updates only the pose device and mesh without doing any button event checking
  14354. */
  14355. protected _updatePoseAndMesh(): void;
  14356. /**
  14357. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  14358. * @param poseData raw pose fromthe device
  14359. */
  14360. updateFromDevice(poseData: DevicePose): void;
  14361. /**
  14362. * @hidden
  14363. */
  14364. _meshAttachedObservable: Observable<AbstractMesh>;
  14365. /**
  14366. * Attaches a mesh to the controller
  14367. * @param mesh the mesh to be attached
  14368. */
  14369. attachToMesh(mesh: AbstractMesh): void;
  14370. /**
  14371. * Attaches the controllers mesh to a camera
  14372. * @param camera the camera the mesh should be attached to
  14373. */
  14374. attachToPoseControlledCamera(camera: TargetCamera): void;
  14375. /**
  14376. * Disposes of the controller
  14377. */
  14378. dispose(): void;
  14379. /**
  14380. * The mesh that is attached to the controller
  14381. */
  14382. readonly mesh: Nullable<AbstractMesh>;
  14383. /**
  14384. * Gets the ray of the controller in the direction the controller is pointing
  14385. * @param length the length the resulting ray should be
  14386. * @returns a ray in the direction the controller is pointing
  14387. */
  14388. getForwardRay(length?: number): Ray;
  14389. }
  14390. }
  14391. declare module BABYLON {
  14392. /**
  14393. * Defines the WebVRController object that represents controllers tracked in 3D space
  14394. */
  14395. export abstract class WebVRController extends PoseEnabledController {
  14396. /**
  14397. * Internal, the default controller model for the controller
  14398. */
  14399. protected _defaultModel: Nullable<AbstractMesh>;
  14400. /**
  14401. * Fired when the trigger state has changed
  14402. */
  14403. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  14404. /**
  14405. * Fired when the main button state has changed
  14406. */
  14407. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14408. /**
  14409. * Fired when the secondary button state has changed
  14410. */
  14411. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14412. /**
  14413. * Fired when the pad state has changed
  14414. */
  14415. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  14416. /**
  14417. * Fired when controllers stick values have changed
  14418. */
  14419. onPadValuesChangedObservable: Observable<StickValues>;
  14420. /**
  14421. * Array of button availible on the controller
  14422. */
  14423. protected _buttons: Array<MutableGamepadButton>;
  14424. private _onButtonStateChange;
  14425. /**
  14426. * Fired when a controller button's state has changed
  14427. * @param callback the callback containing the button that was modified
  14428. */
  14429. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  14430. /**
  14431. * X and Y axis corresponding to the controllers joystick
  14432. */
  14433. pad: StickValues;
  14434. /**
  14435. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  14436. */
  14437. hand: string;
  14438. /**
  14439. * The default controller model for the controller
  14440. */
  14441. readonly defaultModel: Nullable<AbstractMesh>;
  14442. /**
  14443. * Creates a new WebVRController from a gamepad
  14444. * @param vrGamepad the gamepad that the WebVRController should be created from
  14445. */
  14446. constructor(vrGamepad: any);
  14447. /**
  14448. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  14449. */
  14450. update(): void;
  14451. /**
  14452. * Function to be called when a button is modified
  14453. */
  14454. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  14455. /**
  14456. * Loads a mesh and attaches it to the controller
  14457. * @param scene the scene the mesh should be added to
  14458. * @param meshLoaded callback for when the mesh has been loaded
  14459. */
  14460. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  14461. private _setButtonValue;
  14462. private _changes;
  14463. private _checkChanges;
  14464. /**
  14465. * Disposes of th webVRCOntroller
  14466. */
  14467. dispose(): void;
  14468. }
  14469. }
  14470. declare module BABYLON {
  14471. /**
  14472. * The HemisphericLight simulates the ambient environment light,
  14473. * so the passed direction is the light reflection direction, not the incoming direction.
  14474. */
  14475. export class HemisphericLight extends Light {
  14476. /**
  14477. * The groundColor is the light in the opposite direction to the one specified during creation.
  14478. * 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.
  14479. */
  14480. groundColor: Color3;
  14481. /**
  14482. * The light reflection direction, not the incoming direction.
  14483. */
  14484. direction: Vector3;
  14485. /**
  14486. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  14487. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  14488. * The HemisphericLight can't cast shadows.
  14489. * Documentation : https://doc.babylonjs.com/babylon101/lights
  14490. * @param name The friendly name of the light
  14491. * @param direction The direction of the light reflection
  14492. * @param scene The scene the light belongs to
  14493. */
  14494. constructor(name: string, direction: Vector3, scene: Scene);
  14495. protected _buildUniformLayout(): void;
  14496. /**
  14497. * Returns the string "HemisphericLight".
  14498. * @return The class name
  14499. */
  14500. getClassName(): string;
  14501. /**
  14502. * Sets the HemisphericLight direction towards the passed target (Vector3).
  14503. * Returns the updated direction.
  14504. * @param target The target the direction should point to
  14505. * @return The computed direction
  14506. */
  14507. setDirectionToTarget(target: Vector3): Vector3;
  14508. /**
  14509. * Returns the shadow generator associated to the light.
  14510. * @returns Always null for hemispheric lights because it does not support shadows.
  14511. */
  14512. getShadowGenerator(): Nullable<IShadowGenerator>;
  14513. /**
  14514. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  14515. * @param effect The effect to update
  14516. * @param lightIndex The index of the light in the effect to update
  14517. * @returns The hemispheric light
  14518. */
  14519. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  14520. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  14521. /**
  14522. * Computes the world matrix of the node
  14523. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14524. * @param useWasUpdatedFlag defines a reserved property
  14525. * @returns the world matrix
  14526. */
  14527. computeWorldMatrix(): Matrix;
  14528. /**
  14529. * Returns the integer 3.
  14530. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  14531. */
  14532. getTypeID(): number;
  14533. /**
  14534. * Prepares the list of defines specific to the light type.
  14535. * @param defines the list of defines
  14536. * @param lightIndex defines the index of the light for the effect
  14537. */
  14538. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  14539. }
  14540. }
  14541. declare module BABYLON {
  14542. /** @hidden */
  14543. export var vrMultiviewToSingleviewPixelShader: {
  14544. name: string;
  14545. shader: string;
  14546. };
  14547. }
  14548. declare module BABYLON {
  14549. /**
  14550. * Renders to multiple views with a single draw call
  14551. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  14552. */
  14553. export class MultiviewRenderTarget extends RenderTargetTexture {
  14554. /**
  14555. * Creates a multiview render target
  14556. * @param scene scene used with the render target
  14557. * @param size the size of the render target (used for each view)
  14558. */
  14559. constructor(scene: Scene, size?: number | {
  14560. width: number;
  14561. height: number;
  14562. } | {
  14563. ratio: number;
  14564. });
  14565. /**
  14566. * @hidden
  14567. * @param faceIndex the face index, if its a cube texture
  14568. */
  14569. _bindFrameBuffer(faceIndex?: number): void;
  14570. /**
  14571. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  14572. * @returns the view count
  14573. */
  14574. getViewCount(): number;
  14575. }
  14576. }
  14577. declare module BABYLON {
  14578. /**
  14579. * Represents a camera frustum
  14580. */
  14581. export class Frustum {
  14582. /**
  14583. * Gets the planes representing the frustum
  14584. * @param transform matrix to be applied to the returned planes
  14585. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  14586. */
  14587. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  14588. /**
  14589. * Gets the near frustum plane transformed by the transform matrix
  14590. * @param transform transformation matrix to be applied to the resulting frustum plane
  14591. * @param frustumPlane the resuling frustum plane
  14592. */
  14593. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14594. /**
  14595. * Gets the far frustum plane transformed by the transform matrix
  14596. * @param transform transformation matrix to be applied to the resulting frustum plane
  14597. * @param frustumPlane the resuling frustum plane
  14598. */
  14599. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14600. /**
  14601. * Gets the left frustum plane transformed by the transform matrix
  14602. * @param transform transformation matrix to be applied to the resulting frustum plane
  14603. * @param frustumPlane the resuling frustum plane
  14604. */
  14605. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14606. /**
  14607. * Gets the right frustum plane transformed by the transform matrix
  14608. * @param transform transformation matrix to be applied to the resulting frustum plane
  14609. * @param frustumPlane the resuling frustum plane
  14610. */
  14611. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14612. /**
  14613. * Gets the top frustum plane transformed by the transform matrix
  14614. * @param transform transformation matrix to be applied to the resulting frustum plane
  14615. * @param frustumPlane the resuling frustum plane
  14616. */
  14617. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14618. /**
  14619. * Gets the bottom frustum plane transformed by the transform matrix
  14620. * @param transform transformation matrix to be applied to the resulting frustum plane
  14621. * @param frustumPlane the resuling frustum plane
  14622. */
  14623. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14624. /**
  14625. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  14626. * @param transform transformation matrix to be applied to the resulting frustum planes
  14627. * @param frustumPlanes the resuling frustum planes
  14628. */
  14629. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  14630. }
  14631. }
  14632. declare module BABYLON {
  14633. interface Engine {
  14634. /**
  14635. * Creates a new multiview render target
  14636. * @param width defines the width of the texture
  14637. * @param height defines the height of the texture
  14638. * @returns the created multiview texture
  14639. */
  14640. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  14641. /**
  14642. * Binds a multiview framebuffer to be drawn to
  14643. * @param multiviewTexture texture to bind
  14644. */
  14645. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  14646. }
  14647. interface Camera {
  14648. /**
  14649. * @hidden
  14650. * 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)
  14651. */
  14652. _useMultiviewToSingleView: boolean;
  14653. /**
  14654. * @hidden
  14655. * 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)
  14656. */
  14657. _multiviewTexture: Nullable<RenderTargetTexture>;
  14658. /**
  14659. * @hidden
  14660. * ensures the multiview texture of the camera exists and has the specified width/height
  14661. * @param width height to set on the multiview texture
  14662. * @param height width to set on the multiview texture
  14663. */
  14664. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  14665. }
  14666. interface Scene {
  14667. /** @hidden */
  14668. _transformMatrixR: Matrix;
  14669. /** @hidden */
  14670. _multiviewSceneUbo: Nullable<UniformBuffer>;
  14671. /** @hidden */
  14672. _createMultiviewUbo(): void;
  14673. /** @hidden */
  14674. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  14675. /** @hidden */
  14676. _renderMultiviewToSingleView(camera: Camera): void;
  14677. }
  14678. }
  14679. declare module BABYLON {
  14680. /**
  14681. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  14682. * This will not be used for webXR as it supports displaying texture arrays directly
  14683. */
  14684. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  14685. /**
  14686. * Initializes a VRMultiviewToSingleview
  14687. * @param name name of the post process
  14688. * @param camera camera to be applied to
  14689. * @param scaleFactor scaling factor to the size of the output texture
  14690. */
  14691. constructor(name: string, camera: Camera, scaleFactor: number);
  14692. }
  14693. }
  14694. declare module BABYLON {
  14695. interface Engine {
  14696. /** @hidden */
  14697. _vrDisplay: any;
  14698. /** @hidden */
  14699. _vrSupported: boolean;
  14700. /** @hidden */
  14701. _oldSize: Size;
  14702. /** @hidden */
  14703. _oldHardwareScaleFactor: number;
  14704. /** @hidden */
  14705. _vrExclusivePointerMode: boolean;
  14706. /** @hidden */
  14707. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  14708. /** @hidden */
  14709. _onVRDisplayPointerRestricted: () => void;
  14710. /** @hidden */
  14711. _onVRDisplayPointerUnrestricted: () => void;
  14712. /** @hidden */
  14713. _onVrDisplayConnect: Nullable<(display: any) => void>;
  14714. /** @hidden */
  14715. _onVrDisplayDisconnect: Nullable<() => void>;
  14716. /** @hidden */
  14717. _onVrDisplayPresentChange: Nullable<() => void>;
  14718. /**
  14719. * Observable signaled when VR display mode changes
  14720. */
  14721. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  14722. /**
  14723. * Observable signaled when VR request present is complete
  14724. */
  14725. onVRRequestPresentComplete: Observable<boolean>;
  14726. /**
  14727. * Observable signaled when VR request present starts
  14728. */
  14729. onVRRequestPresentStart: Observable<Engine>;
  14730. /**
  14731. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  14732. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  14733. */
  14734. isInVRExclusivePointerMode: boolean;
  14735. /**
  14736. * Gets a boolean indicating if a webVR device was detected
  14737. * @returns true if a webVR device was detected
  14738. */
  14739. isVRDevicePresent(): boolean;
  14740. /**
  14741. * Gets the current webVR device
  14742. * @returns the current webVR device (or null)
  14743. */
  14744. getVRDevice(): any;
  14745. /**
  14746. * Initializes a webVR display and starts listening to display change events
  14747. * The onVRDisplayChangedObservable will be notified upon these changes
  14748. * @returns A promise containing a VRDisplay and if vr is supported
  14749. */
  14750. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  14751. /** @hidden */
  14752. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  14753. /**
  14754. * Call this function to switch to webVR mode
  14755. * Will do nothing if webVR is not supported or if there is no webVR device
  14756. * @see http://doc.babylonjs.com/how_to/webvr_camera
  14757. */
  14758. enableVR(): void;
  14759. /** @hidden */
  14760. _onVRFullScreenTriggered(): void;
  14761. }
  14762. }
  14763. declare module BABYLON {
  14764. /**
  14765. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  14766. * IMPORTANT!! The data is right-hand data.
  14767. * @export
  14768. * @interface DevicePose
  14769. */
  14770. export interface DevicePose {
  14771. /**
  14772. * The position of the device, values in array are [x,y,z].
  14773. */
  14774. readonly position: Nullable<Float32Array>;
  14775. /**
  14776. * The linearVelocity of the device, values in array are [x,y,z].
  14777. */
  14778. readonly linearVelocity: Nullable<Float32Array>;
  14779. /**
  14780. * The linearAcceleration of the device, values in array are [x,y,z].
  14781. */
  14782. readonly linearAcceleration: Nullable<Float32Array>;
  14783. /**
  14784. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  14785. */
  14786. readonly orientation: Nullable<Float32Array>;
  14787. /**
  14788. * The angularVelocity of the device, values in array are [x,y,z].
  14789. */
  14790. readonly angularVelocity: Nullable<Float32Array>;
  14791. /**
  14792. * The angularAcceleration of the device, values in array are [x,y,z].
  14793. */
  14794. readonly angularAcceleration: Nullable<Float32Array>;
  14795. }
  14796. /**
  14797. * Interface representing a pose controlled object in Babylon.
  14798. * A pose controlled object has both regular pose values as well as pose values
  14799. * from an external device such as a VR head mounted display
  14800. */
  14801. export interface PoseControlled {
  14802. /**
  14803. * The position of the object in babylon space.
  14804. */
  14805. position: Vector3;
  14806. /**
  14807. * The rotation quaternion of the object in babylon space.
  14808. */
  14809. rotationQuaternion: Quaternion;
  14810. /**
  14811. * The position of the device in babylon space.
  14812. */
  14813. devicePosition?: Vector3;
  14814. /**
  14815. * The rotation quaternion of the device in babylon space.
  14816. */
  14817. deviceRotationQuaternion: Quaternion;
  14818. /**
  14819. * The raw pose coming from the device.
  14820. */
  14821. rawPose: Nullable<DevicePose>;
  14822. /**
  14823. * The scale of the device to be used when translating from device space to babylon space.
  14824. */
  14825. deviceScaleFactor: number;
  14826. /**
  14827. * Updates the poseControlled values based on the input device pose.
  14828. * @param poseData the pose data to update the object with
  14829. */
  14830. updateFromDevice(poseData: DevicePose): void;
  14831. }
  14832. /**
  14833. * Set of options to customize the webVRCamera
  14834. */
  14835. export interface WebVROptions {
  14836. /**
  14837. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  14838. */
  14839. trackPosition?: boolean;
  14840. /**
  14841. * Sets the scale of the vrDevice in babylon space. (default: 1)
  14842. */
  14843. positionScale?: number;
  14844. /**
  14845. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  14846. */
  14847. displayName?: string;
  14848. /**
  14849. * Should the native controller meshes be initialized. (default: true)
  14850. */
  14851. controllerMeshes?: boolean;
  14852. /**
  14853. * Creating a default HemiLight only on controllers. (default: true)
  14854. */
  14855. defaultLightingOnControllers?: boolean;
  14856. /**
  14857. * If you don't want to use the default VR button of the helper. (default: false)
  14858. */
  14859. useCustomVRButton?: boolean;
  14860. /**
  14861. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  14862. */
  14863. customVRButton?: HTMLButtonElement;
  14864. /**
  14865. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  14866. */
  14867. rayLength?: number;
  14868. /**
  14869. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  14870. */
  14871. defaultHeight?: number;
  14872. /**
  14873. * If multiview should be used if availible (default: false)
  14874. */
  14875. useMultiview?: boolean;
  14876. }
  14877. /**
  14878. * This represents a WebVR camera.
  14879. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  14880. * @example http://doc.babylonjs.com/how_to/webvr_camera
  14881. */
  14882. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  14883. private webVROptions;
  14884. /**
  14885. * @hidden
  14886. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  14887. */
  14888. _vrDevice: any;
  14889. /**
  14890. * The rawPose of the vrDevice.
  14891. */
  14892. rawPose: Nullable<DevicePose>;
  14893. private _onVREnabled;
  14894. private _specsVersion;
  14895. private _attached;
  14896. private _frameData;
  14897. protected _descendants: Array<Node>;
  14898. private _deviceRoomPosition;
  14899. /** @hidden */
  14900. _deviceRoomRotationQuaternion: Quaternion;
  14901. private _standingMatrix;
  14902. /**
  14903. * Represents device position in babylon space.
  14904. */
  14905. devicePosition: Vector3;
  14906. /**
  14907. * Represents device rotation in babylon space.
  14908. */
  14909. deviceRotationQuaternion: Quaternion;
  14910. /**
  14911. * The scale of the device to be used when translating from device space to babylon space.
  14912. */
  14913. deviceScaleFactor: number;
  14914. private _deviceToWorld;
  14915. private _worldToDevice;
  14916. /**
  14917. * References to the webVR controllers for the vrDevice.
  14918. */
  14919. controllers: Array<WebVRController>;
  14920. /**
  14921. * Emits an event when a controller is attached.
  14922. */
  14923. onControllersAttachedObservable: Observable<WebVRController[]>;
  14924. /**
  14925. * Emits an event when a controller's mesh has been loaded;
  14926. */
  14927. onControllerMeshLoadedObservable: Observable<WebVRController>;
  14928. /**
  14929. * Emits an event when the HMD's pose has been updated.
  14930. */
  14931. onPoseUpdatedFromDeviceObservable: Observable<any>;
  14932. private _poseSet;
  14933. /**
  14934. * If the rig cameras be used as parent instead of this camera.
  14935. */
  14936. rigParenting: boolean;
  14937. private _lightOnControllers;
  14938. private _defaultHeight?;
  14939. /**
  14940. * Instantiates a WebVRFreeCamera.
  14941. * @param name The name of the WebVRFreeCamera
  14942. * @param position The starting anchor position for the camera
  14943. * @param scene The scene the camera belongs to
  14944. * @param webVROptions a set of customizable options for the webVRCamera
  14945. */
  14946. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  14947. /**
  14948. * Gets the device distance from the ground in meters.
  14949. * @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.
  14950. */
  14951. deviceDistanceToRoomGround(): number;
  14952. /**
  14953. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  14954. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  14955. */
  14956. useStandingMatrix(callback?: (bool: boolean) => void): void;
  14957. /**
  14958. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  14959. * @returns A promise with a boolean set to if the standing matrix is supported.
  14960. */
  14961. useStandingMatrixAsync(): Promise<boolean>;
  14962. /**
  14963. * Disposes the camera
  14964. */
  14965. dispose(): void;
  14966. /**
  14967. * Gets a vrController by name.
  14968. * @param name The name of the controller to retreive
  14969. * @returns the controller matching the name specified or null if not found
  14970. */
  14971. getControllerByName(name: string): Nullable<WebVRController>;
  14972. private _leftController;
  14973. /**
  14974. * The controller corresponding to the users left hand.
  14975. */
  14976. readonly leftController: Nullable<WebVRController>;
  14977. private _rightController;
  14978. /**
  14979. * The controller corresponding to the users right hand.
  14980. */
  14981. readonly rightController: Nullable<WebVRController>;
  14982. /**
  14983. * Casts a ray forward from the vrCamera's gaze.
  14984. * @param length Length of the ray (default: 100)
  14985. * @returns the ray corresponding to the gaze
  14986. */
  14987. getForwardRay(length?: number): Ray;
  14988. /**
  14989. * @hidden
  14990. * Updates the camera based on device's frame data
  14991. */
  14992. _checkInputs(): void;
  14993. /**
  14994. * Updates the poseControlled values based on the input device pose.
  14995. * @param poseData Pose coming from the device
  14996. */
  14997. updateFromDevice(poseData: DevicePose): void;
  14998. private _htmlElementAttached;
  14999. private _detachIfAttached;
  15000. /**
  15001. * WebVR's attach control will start broadcasting frames to the device.
  15002. * Note that in certain browsers (chrome for example) this function must be called
  15003. * within a user-interaction callback. Example:
  15004. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  15005. *
  15006. * @param element html element to attach the vrDevice to
  15007. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  15008. */
  15009. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  15010. /**
  15011. * Detaches the camera from the html element and disables VR
  15012. *
  15013. * @param element html element to detach from
  15014. */
  15015. detachControl(element: HTMLElement): void;
  15016. /**
  15017. * @returns the name of this class
  15018. */
  15019. getClassName(): string;
  15020. /**
  15021. * Calls resetPose on the vrDisplay
  15022. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  15023. */
  15024. resetToCurrentRotation(): void;
  15025. /**
  15026. * @hidden
  15027. * Updates the rig cameras (left and right eye)
  15028. */
  15029. _updateRigCameras(): void;
  15030. private _workingVector;
  15031. private _oneVector;
  15032. private _workingMatrix;
  15033. private updateCacheCalled;
  15034. private _correctPositionIfNotTrackPosition;
  15035. /**
  15036. * @hidden
  15037. * Updates the cached values of the camera
  15038. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  15039. */
  15040. _updateCache(ignoreParentClass?: boolean): void;
  15041. /**
  15042. * @hidden
  15043. * Get current device position in babylon world
  15044. */
  15045. _computeDevicePosition(): void;
  15046. /**
  15047. * Updates the current device position and rotation in the babylon world
  15048. */
  15049. update(): void;
  15050. /**
  15051. * @hidden
  15052. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  15053. * @returns an identity matrix
  15054. */
  15055. _getViewMatrix(): Matrix;
  15056. private _tmpMatrix;
  15057. /**
  15058. * This function is called by the two RIG cameras.
  15059. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  15060. * @hidden
  15061. */
  15062. _getWebVRViewMatrix(): Matrix;
  15063. /** @hidden */
  15064. _getWebVRProjectionMatrix(): Matrix;
  15065. private _onGamepadConnectedObserver;
  15066. private _onGamepadDisconnectedObserver;
  15067. private _updateCacheWhenTrackingDisabledObserver;
  15068. /**
  15069. * Initializes the controllers and their meshes
  15070. */
  15071. initControllers(): void;
  15072. }
  15073. }
  15074. declare module BABYLON {
  15075. /**
  15076. * Size options for a post process
  15077. */
  15078. export type PostProcessOptions = {
  15079. width: number;
  15080. height: number;
  15081. };
  15082. /**
  15083. * PostProcess can be used to apply a shader to a texture after it has been rendered
  15084. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  15085. */
  15086. export class PostProcess {
  15087. /** Name of the PostProcess. */
  15088. name: string;
  15089. /**
  15090. * Gets or sets the unique id of the post process
  15091. */
  15092. uniqueId: number;
  15093. /**
  15094. * Width of the texture to apply the post process on
  15095. */
  15096. width: number;
  15097. /**
  15098. * Height of the texture to apply the post process on
  15099. */
  15100. height: number;
  15101. /**
  15102. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  15103. * @hidden
  15104. */
  15105. _outputTexture: Nullable<InternalTexture>;
  15106. /**
  15107. * Sampling mode used by the shader
  15108. * See https://doc.babylonjs.com/classes/3.1/texture
  15109. */
  15110. renderTargetSamplingMode: number;
  15111. /**
  15112. * Clear color to use when screen clearing
  15113. */
  15114. clearColor: Color4;
  15115. /**
  15116. * If the buffer needs to be cleared before applying the post process. (default: true)
  15117. * Should be set to false if shader will overwrite all previous pixels.
  15118. */
  15119. autoClear: boolean;
  15120. /**
  15121. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  15122. */
  15123. alphaMode: number;
  15124. /**
  15125. * Sets the setAlphaBlendConstants of the babylon engine
  15126. */
  15127. alphaConstants: Color4;
  15128. /**
  15129. * Animations to be used for the post processing
  15130. */
  15131. animations: Animation[];
  15132. /**
  15133. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  15134. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  15135. */
  15136. enablePixelPerfectMode: boolean;
  15137. /**
  15138. * Force the postprocess to be applied without taking in account viewport
  15139. */
  15140. forceFullscreenViewport: boolean;
  15141. /**
  15142. * List of inspectable custom properties (used by the Inspector)
  15143. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15144. */
  15145. inspectableCustomProperties: IInspectable[];
  15146. /**
  15147. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  15148. *
  15149. * | Value | Type | Description |
  15150. * | ----- | ----------------------------------- | ----------- |
  15151. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  15152. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  15153. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  15154. *
  15155. */
  15156. scaleMode: number;
  15157. /**
  15158. * Force textures to be a power of two (default: false)
  15159. */
  15160. alwaysForcePOT: boolean;
  15161. private _samples;
  15162. /**
  15163. * Number of sample textures (default: 1)
  15164. */
  15165. samples: number;
  15166. /**
  15167. * Modify the scale of the post process to be the same as the viewport (default: false)
  15168. */
  15169. adaptScaleToCurrentViewport: boolean;
  15170. private _camera;
  15171. private _scene;
  15172. private _engine;
  15173. private _options;
  15174. private _reusable;
  15175. private _textureType;
  15176. /**
  15177. * Smart array of input and output textures for the post process.
  15178. * @hidden
  15179. */
  15180. _textures: SmartArray<InternalTexture>;
  15181. /**
  15182. * The index in _textures that corresponds to the output texture.
  15183. * @hidden
  15184. */
  15185. _currentRenderTextureInd: number;
  15186. private _effect;
  15187. private _samplers;
  15188. private _fragmentUrl;
  15189. private _vertexUrl;
  15190. private _parameters;
  15191. private _scaleRatio;
  15192. protected _indexParameters: any;
  15193. private _shareOutputWithPostProcess;
  15194. private _texelSize;
  15195. private _forcedOutputTexture;
  15196. /**
  15197. * Returns the fragment url or shader name used in the post process.
  15198. * @returns the fragment url or name in the shader store.
  15199. */
  15200. getEffectName(): string;
  15201. /**
  15202. * An event triggered when the postprocess is activated.
  15203. */
  15204. onActivateObservable: Observable<Camera>;
  15205. private _onActivateObserver;
  15206. /**
  15207. * A function that is added to the onActivateObservable
  15208. */
  15209. onActivate: Nullable<(camera: Camera) => void>;
  15210. /**
  15211. * An event triggered when the postprocess changes its size.
  15212. */
  15213. onSizeChangedObservable: Observable<PostProcess>;
  15214. private _onSizeChangedObserver;
  15215. /**
  15216. * A function that is added to the onSizeChangedObservable
  15217. */
  15218. onSizeChanged: (postProcess: PostProcess) => void;
  15219. /**
  15220. * An event triggered when the postprocess applies its effect.
  15221. */
  15222. onApplyObservable: Observable<Effect>;
  15223. private _onApplyObserver;
  15224. /**
  15225. * A function that is added to the onApplyObservable
  15226. */
  15227. onApply: (effect: Effect) => void;
  15228. /**
  15229. * An event triggered before rendering the postprocess
  15230. */
  15231. onBeforeRenderObservable: Observable<Effect>;
  15232. private _onBeforeRenderObserver;
  15233. /**
  15234. * A function that is added to the onBeforeRenderObservable
  15235. */
  15236. onBeforeRender: (effect: Effect) => void;
  15237. /**
  15238. * An event triggered after rendering the postprocess
  15239. */
  15240. onAfterRenderObservable: Observable<Effect>;
  15241. private _onAfterRenderObserver;
  15242. /**
  15243. * A function that is added to the onAfterRenderObservable
  15244. */
  15245. onAfterRender: (efect: Effect) => void;
  15246. /**
  15247. * 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
  15248. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  15249. */
  15250. inputTexture: InternalTexture;
  15251. /**
  15252. * Gets the camera which post process is applied to.
  15253. * @returns The camera the post process is applied to.
  15254. */
  15255. getCamera(): Camera;
  15256. /**
  15257. * Gets the texel size of the postprocess.
  15258. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  15259. */
  15260. readonly texelSize: Vector2;
  15261. /**
  15262. * Creates a new instance PostProcess
  15263. * @param name The name of the PostProcess.
  15264. * @param fragmentUrl The url of the fragment shader to be used.
  15265. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  15266. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  15267. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15268. * @param camera The camera to apply the render pass to.
  15269. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15270. * @param engine The engine which the post process will be applied. (default: current engine)
  15271. * @param reusable If the post process can be reused on the same frame. (default: false)
  15272. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  15273. * @param textureType Type of textures used when performing the post process. (default: 0)
  15274. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  15275. * @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
  15276. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  15277. */
  15278. constructor(
  15279. /** Name of the PostProcess. */
  15280. 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);
  15281. /**
  15282. * Gets a string idenfifying the name of the class
  15283. * @returns "PostProcess" string
  15284. */
  15285. getClassName(): string;
  15286. /**
  15287. * Gets the engine which this post process belongs to.
  15288. * @returns The engine the post process was enabled with.
  15289. */
  15290. getEngine(): Engine;
  15291. /**
  15292. * The effect that is created when initializing the post process.
  15293. * @returns The created effect corresponding the the postprocess.
  15294. */
  15295. getEffect(): Effect;
  15296. /**
  15297. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  15298. * @param postProcess The post process to share the output with.
  15299. * @returns This post process.
  15300. */
  15301. shareOutputWith(postProcess: PostProcess): PostProcess;
  15302. /**
  15303. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  15304. * This should be called if the post process that shares output with this post process is disabled/disposed.
  15305. */
  15306. useOwnOutput(): void;
  15307. /**
  15308. * Updates the effect with the current post process compile time values and recompiles the shader.
  15309. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15310. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15311. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15312. * @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
  15313. * @param onCompiled Called when the shader has been compiled.
  15314. * @param onError Called if there is an error when compiling a shader.
  15315. */
  15316. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15317. /**
  15318. * The post process is reusable if it can be used multiple times within one frame.
  15319. * @returns If the post process is reusable
  15320. */
  15321. isReusable(): boolean;
  15322. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  15323. markTextureDirty(): void;
  15324. /**
  15325. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  15326. * 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.
  15327. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  15328. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  15329. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  15330. * @returns The target texture that was bound to be written to.
  15331. */
  15332. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  15333. /**
  15334. * If the post process is supported.
  15335. */
  15336. readonly isSupported: boolean;
  15337. /**
  15338. * The aspect ratio of the output texture.
  15339. */
  15340. readonly aspectRatio: number;
  15341. /**
  15342. * Get a value indicating if the post-process is ready to be used
  15343. * @returns true if the post-process is ready (shader is compiled)
  15344. */
  15345. isReady(): boolean;
  15346. /**
  15347. * Binds all textures and uniforms to the shader, this will be run on every pass.
  15348. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  15349. */
  15350. apply(): Nullable<Effect>;
  15351. private _disposeTextures;
  15352. /**
  15353. * Disposes the post process.
  15354. * @param camera The camera to dispose the post process on.
  15355. */
  15356. dispose(camera?: Camera): void;
  15357. }
  15358. }
  15359. declare module BABYLON {
  15360. /** @hidden */
  15361. export var kernelBlurVaryingDeclaration: {
  15362. name: string;
  15363. shader: string;
  15364. };
  15365. }
  15366. declare module BABYLON {
  15367. /** @hidden */
  15368. export var kernelBlurFragment: {
  15369. name: string;
  15370. shader: string;
  15371. };
  15372. }
  15373. declare module BABYLON {
  15374. /** @hidden */
  15375. export var kernelBlurFragment2: {
  15376. name: string;
  15377. shader: string;
  15378. };
  15379. }
  15380. declare module BABYLON {
  15381. /** @hidden */
  15382. export var kernelBlurPixelShader: {
  15383. name: string;
  15384. shader: string;
  15385. };
  15386. }
  15387. declare module BABYLON {
  15388. /** @hidden */
  15389. export var kernelBlurVertex: {
  15390. name: string;
  15391. shader: string;
  15392. };
  15393. }
  15394. declare module BABYLON {
  15395. /** @hidden */
  15396. export var kernelBlurVertexShader: {
  15397. name: string;
  15398. shader: string;
  15399. };
  15400. }
  15401. declare module BABYLON {
  15402. /**
  15403. * The Blur Post Process which blurs an image based on a kernel and direction.
  15404. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  15405. */
  15406. export class BlurPostProcess extends PostProcess {
  15407. /** The direction in which to blur the image. */
  15408. direction: Vector2;
  15409. private blockCompilation;
  15410. protected _kernel: number;
  15411. protected _idealKernel: number;
  15412. protected _packedFloat: boolean;
  15413. private _staticDefines;
  15414. /**
  15415. * Sets the length in pixels of the blur sample region
  15416. */
  15417. /**
  15418. * Gets the length in pixels of the blur sample region
  15419. */
  15420. kernel: number;
  15421. /**
  15422. * Sets wether or not the blur needs to unpack/repack floats
  15423. */
  15424. /**
  15425. * Gets wether or not the blur is unpacking/repacking floats
  15426. */
  15427. packedFloat: boolean;
  15428. /**
  15429. * Creates a new instance BlurPostProcess
  15430. * @param name The name of the effect.
  15431. * @param direction The direction in which to blur the image.
  15432. * @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.
  15433. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15434. * @param camera The camera to apply the render pass to.
  15435. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15436. * @param engine The engine which the post process will be applied. (default: current engine)
  15437. * @param reusable If the post process can be reused on the same frame. (default: false)
  15438. * @param textureType Type of textures used when performing the post process. (default: 0)
  15439. * @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)
  15440. */
  15441. constructor(name: string,
  15442. /** The direction in which to blur the image. */
  15443. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  15444. /**
  15445. * Updates the effect with the current post process compile time values and recompiles the shader.
  15446. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15447. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15448. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15449. * @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
  15450. * @param onCompiled Called when the shader has been compiled.
  15451. * @param onError Called if there is an error when compiling a shader.
  15452. */
  15453. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15454. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15455. /**
  15456. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  15457. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  15458. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  15459. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  15460. * The gaps between physical kernels are compensated for in the weighting of the samples
  15461. * @param idealKernel Ideal blur kernel.
  15462. * @return Nearest best kernel.
  15463. */
  15464. protected _nearestBestKernel(idealKernel: number): number;
  15465. /**
  15466. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  15467. * @param x The point on the Gaussian distribution to sample.
  15468. * @return the value of the Gaussian function at x.
  15469. */
  15470. protected _gaussianWeight(x: number): number;
  15471. /**
  15472. * Generates a string that can be used as a floating point number in GLSL.
  15473. * @param x Value to print.
  15474. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  15475. * @return GLSL float string.
  15476. */
  15477. protected _glslFloat(x: number, decimalFigures?: number): string;
  15478. }
  15479. }
  15480. declare module BABYLON {
  15481. /**
  15482. * Mirror texture can be used to simulate the view from a mirror in a scene.
  15483. * It will dynamically be rendered every frame to adapt to the camera point of view.
  15484. * You can then easily use it as a reflectionTexture on a flat surface.
  15485. * In case the surface is not a plane, please consider relying on reflection probes.
  15486. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15487. */
  15488. export class MirrorTexture extends RenderTargetTexture {
  15489. private scene;
  15490. /**
  15491. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  15492. * 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.
  15493. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15494. */
  15495. mirrorPlane: Plane;
  15496. /**
  15497. * Define the blur ratio used to blur the reflection if needed.
  15498. */
  15499. blurRatio: number;
  15500. /**
  15501. * Define the adaptive blur kernel used to blur the reflection if needed.
  15502. * This will autocompute the closest best match for the `blurKernel`
  15503. */
  15504. adaptiveBlurKernel: number;
  15505. /**
  15506. * Define the blur kernel used to blur the reflection if needed.
  15507. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15508. */
  15509. blurKernel: number;
  15510. /**
  15511. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  15512. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15513. */
  15514. blurKernelX: number;
  15515. /**
  15516. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  15517. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15518. */
  15519. blurKernelY: number;
  15520. private _autoComputeBlurKernel;
  15521. protected _onRatioRescale(): void;
  15522. private _updateGammaSpace;
  15523. private _imageProcessingConfigChangeObserver;
  15524. private _transformMatrix;
  15525. private _mirrorMatrix;
  15526. private _savedViewMatrix;
  15527. private _blurX;
  15528. private _blurY;
  15529. private _adaptiveBlurKernel;
  15530. private _blurKernelX;
  15531. private _blurKernelY;
  15532. private _blurRatio;
  15533. /**
  15534. * Instantiates a Mirror Texture.
  15535. * Mirror texture can be used to simulate the view from a mirror in a scene.
  15536. * It will dynamically be rendered every frame to adapt to the camera point of view.
  15537. * You can then easily use it as a reflectionTexture on a flat surface.
  15538. * In case the surface is not a plane, please consider relying on reflection probes.
  15539. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15540. * @param name
  15541. * @param size
  15542. * @param scene
  15543. * @param generateMipMaps
  15544. * @param type
  15545. * @param samplingMode
  15546. * @param generateDepthBuffer
  15547. */
  15548. constructor(name: string, size: number | {
  15549. width: number;
  15550. height: number;
  15551. } | {
  15552. ratio: number;
  15553. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  15554. private _preparePostProcesses;
  15555. /**
  15556. * Clone the mirror texture.
  15557. * @returns the cloned texture
  15558. */
  15559. clone(): MirrorTexture;
  15560. /**
  15561. * Serialize the texture to a JSON representation you could use in Parse later on
  15562. * @returns the serialized JSON representation
  15563. */
  15564. serialize(): any;
  15565. /**
  15566. * Dispose the texture and release its associated resources.
  15567. */
  15568. dispose(): void;
  15569. }
  15570. }
  15571. declare module BABYLON {
  15572. /**
  15573. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  15574. * @see http://doc.babylonjs.com/babylon101/materials#texture
  15575. */
  15576. export class Texture extends BaseTexture {
  15577. /**
  15578. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  15579. */
  15580. static SerializeBuffers: boolean;
  15581. /** @hidden */
  15582. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  15583. /** @hidden */
  15584. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  15585. /** @hidden */
  15586. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  15587. /** nearest is mag = nearest and min = nearest and mip = linear */
  15588. static readonly NEAREST_SAMPLINGMODE: number;
  15589. /** nearest is mag = nearest and min = nearest and mip = linear */
  15590. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  15591. /** Bilinear is mag = linear and min = linear and mip = nearest */
  15592. static readonly BILINEAR_SAMPLINGMODE: number;
  15593. /** Bilinear is mag = linear and min = linear and mip = nearest */
  15594. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  15595. /** Trilinear is mag = linear and min = linear and mip = linear */
  15596. static readonly TRILINEAR_SAMPLINGMODE: number;
  15597. /** Trilinear is mag = linear and min = linear and mip = linear */
  15598. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  15599. /** mag = nearest and min = nearest and mip = nearest */
  15600. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  15601. /** mag = nearest and min = linear and mip = nearest */
  15602. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  15603. /** mag = nearest and min = linear and mip = linear */
  15604. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  15605. /** mag = nearest and min = linear and mip = none */
  15606. static readonly NEAREST_LINEAR: number;
  15607. /** mag = nearest and min = nearest and mip = none */
  15608. static readonly NEAREST_NEAREST: number;
  15609. /** mag = linear and min = nearest and mip = nearest */
  15610. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  15611. /** mag = linear and min = nearest and mip = linear */
  15612. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  15613. /** mag = linear and min = linear and mip = none */
  15614. static readonly LINEAR_LINEAR: number;
  15615. /** mag = linear and min = nearest and mip = none */
  15616. static readonly LINEAR_NEAREST: number;
  15617. /** Explicit coordinates mode */
  15618. static readonly EXPLICIT_MODE: number;
  15619. /** Spherical coordinates mode */
  15620. static readonly SPHERICAL_MODE: number;
  15621. /** Planar coordinates mode */
  15622. static readonly PLANAR_MODE: number;
  15623. /** Cubic coordinates mode */
  15624. static readonly CUBIC_MODE: number;
  15625. /** Projection coordinates mode */
  15626. static readonly PROJECTION_MODE: number;
  15627. /** Inverse Cubic coordinates mode */
  15628. static readonly SKYBOX_MODE: number;
  15629. /** Inverse Cubic coordinates mode */
  15630. static readonly INVCUBIC_MODE: number;
  15631. /** Equirectangular coordinates mode */
  15632. static readonly EQUIRECTANGULAR_MODE: number;
  15633. /** Equirectangular Fixed coordinates mode */
  15634. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  15635. /** Equirectangular Fixed Mirrored coordinates mode */
  15636. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  15637. /** Texture is not repeating outside of 0..1 UVs */
  15638. static readonly CLAMP_ADDRESSMODE: number;
  15639. /** Texture is repeating outside of 0..1 UVs */
  15640. static readonly WRAP_ADDRESSMODE: number;
  15641. /** Texture is repeating and mirrored */
  15642. static readonly MIRROR_ADDRESSMODE: number;
  15643. /**
  15644. * 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
  15645. */
  15646. static UseSerializedUrlIfAny: boolean;
  15647. /**
  15648. * Define the url of the texture.
  15649. */
  15650. url: Nullable<string>;
  15651. /**
  15652. * Define an offset on the texture to offset the u coordinates of the UVs
  15653. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  15654. */
  15655. uOffset: number;
  15656. /**
  15657. * Define an offset on the texture to offset the v coordinates of the UVs
  15658. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  15659. */
  15660. vOffset: number;
  15661. /**
  15662. * Define an offset on the texture to scale the u coordinates of the UVs
  15663. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  15664. */
  15665. uScale: number;
  15666. /**
  15667. * Define an offset on the texture to scale the v coordinates of the UVs
  15668. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  15669. */
  15670. vScale: number;
  15671. /**
  15672. * Define an offset on the texture to rotate around the u coordinates of the UVs
  15673. * @see http://doc.babylonjs.com/how_to/more_materials
  15674. */
  15675. uAng: number;
  15676. /**
  15677. * Define an offset on the texture to rotate around the v coordinates of the UVs
  15678. * @see http://doc.babylonjs.com/how_to/more_materials
  15679. */
  15680. vAng: number;
  15681. /**
  15682. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  15683. * @see http://doc.babylonjs.com/how_to/more_materials
  15684. */
  15685. wAng: number;
  15686. /**
  15687. * Defines the center of rotation (U)
  15688. */
  15689. uRotationCenter: number;
  15690. /**
  15691. * Defines the center of rotation (V)
  15692. */
  15693. vRotationCenter: number;
  15694. /**
  15695. * Defines the center of rotation (W)
  15696. */
  15697. wRotationCenter: number;
  15698. /**
  15699. * Are mip maps generated for this texture or not.
  15700. */
  15701. readonly noMipmap: boolean;
  15702. /**
  15703. * List of inspectable custom properties (used by the Inspector)
  15704. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15705. */
  15706. inspectableCustomProperties: Nullable<IInspectable[]>;
  15707. private _noMipmap;
  15708. /** @hidden */
  15709. _invertY: boolean;
  15710. private _rowGenerationMatrix;
  15711. private _cachedTextureMatrix;
  15712. private _projectionModeMatrix;
  15713. private _t0;
  15714. private _t1;
  15715. private _t2;
  15716. private _cachedUOffset;
  15717. private _cachedVOffset;
  15718. private _cachedUScale;
  15719. private _cachedVScale;
  15720. private _cachedUAng;
  15721. private _cachedVAng;
  15722. private _cachedWAng;
  15723. private _cachedProjectionMatrixId;
  15724. private _cachedCoordinatesMode;
  15725. /** @hidden */
  15726. protected _initialSamplingMode: number;
  15727. /** @hidden */
  15728. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>;
  15729. private _deleteBuffer;
  15730. protected _format: Nullable<number>;
  15731. private _delayedOnLoad;
  15732. private _delayedOnError;
  15733. /**
  15734. * Observable triggered once the texture has been loaded.
  15735. */
  15736. onLoadObservable: Observable<Texture>;
  15737. protected _isBlocking: boolean;
  15738. /**
  15739. * Is the texture preventing material to render while loading.
  15740. * If false, a default texture will be used instead of the loading one during the preparation step.
  15741. */
  15742. isBlocking: boolean;
  15743. /**
  15744. * Get the current sampling mode associated with the texture.
  15745. */
  15746. readonly samplingMode: number;
  15747. /**
  15748. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  15749. */
  15750. readonly invertY: boolean;
  15751. /**
  15752. * Instantiates a new texture.
  15753. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  15754. * @see http://doc.babylonjs.com/babylon101/materials#texture
  15755. * @param url define the url of the picture to load as a texture
  15756. * @param scene define the scene or engine the texture will belong to
  15757. * @param noMipmap define if the texture will require mip maps or not
  15758. * @param invertY define if the texture needs to be inverted on the y axis during loading
  15759. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  15760. * @param onLoad define a callback triggered when the texture has been loaded
  15761. * @param onError define a callback triggered when an error occurred during the loading session
  15762. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  15763. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  15764. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  15765. */
  15766. constructor(url: Nullable<string>, sceneOrEngine: Nullable<Scene | ThinEngine>, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, deleteBuffer?: boolean, format?: number);
  15767. /**
  15768. * Update the url (and optional buffer) of this texture if url was null during construction.
  15769. * @param url the url of the texture
  15770. * @param buffer the buffer of the texture (defaults to null)
  15771. * @param onLoad callback called when the texture is loaded (defaults to null)
  15772. */
  15773. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  15774. /**
  15775. * Finish the loading sequence of a texture flagged as delayed load.
  15776. * @hidden
  15777. */
  15778. delayLoad(): void;
  15779. private _prepareRowForTextureGeneration;
  15780. /**
  15781. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  15782. * @returns the transform matrix of the texture.
  15783. */
  15784. getTextureMatrix(): Matrix;
  15785. /**
  15786. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  15787. * @returns The reflection texture transform
  15788. */
  15789. getReflectionTextureMatrix(): Matrix;
  15790. /**
  15791. * Clones the texture.
  15792. * @returns the cloned texture
  15793. */
  15794. clone(): Texture;
  15795. /**
  15796. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  15797. * @returns The JSON representation of the texture
  15798. */
  15799. serialize(): any;
  15800. /**
  15801. * Get the current class name of the texture useful for serialization or dynamic coding.
  15802. * @returns "Texture"
  15803. */
  15804. getClassName(): string;
  15805. /**
  15806. * Dispose the texture and release its associated resources.
  15807. */
  15808. dispose(): void;
  15809. /**
  15810. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  15811. * @param parsedTexture Define the JSON representation of the texture
  15812. * @param scene Define the scene the parsed texture should be instantiated in
  15813. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  15814. * @returns The parsed texture if successful
  15815. */
  15816. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  15817. /**
  15818. * Creates a texture from its base 64 representation.
  15819. * @param data Define the base64 payload without the data: prefix
  15820. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  15821. * @param scene Define the scene the texture should belong to
  15822. * @param noMipmap Forces the texture to not create mip map information if true
  15823. * @param invertY define if the texture needs to be inverted on the y axis during loading
  15824. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  15825. * @param onLoad define a callback triggered when the texture has been loaded
  15826. * @param onError define a callback triggered when an error occurred during the loading session
  15827. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  15828. * @returns the created texture
  15829. */
  15830. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  15831. /**
  15832. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  15833. * @param data Define the base64 payload without the data: prefix
  15834. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  15835. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  15836. * @param scene Define the scene the texture should belong to
  15837. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  15838. * @param noMipmap Forces the texture to not create mip map information if true
  15839. * @param invertY define if the texture needs to be inverted on the y axis during loading
  15840. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  15841. * @param onLoad define a callback triggered when the texture has been loaded
  15842. * @param onError define a callback triggered when an error occurred during the loading session
  15843. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  15844. * @returns the created texture
  15845. */
  15846. 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;
  15847. }
  15848. }
  15849. declare module BABYLON {
  15850. /**
  15851. * PostProcessManager is used to manage one or more post processes or post process pipelines
  15852. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  15853. */
  15854. export class PostProcessManager {
  15855. private _scene;
  15856. private _indexBuffer;
  15857. private _vertexBuffers;
  15858. /**
  15859. * Creates a new instance PostProcess
  15860. * @param scene The scene that the post process is associated with.
  15861. */
  15862. constructor(scene: Scene);
  15863. private _prepareBuffers;
  15864. private _buildIndexBuffer;
  15865. /**
  15866. * Rebuilds the vertex buffers of the manager.
  15867. * @hidden
  15868. */
  15869. _rebuild(): void;
  15870. /**
  15871. * Prepares a frame to be run through a post process.
  15872. * @param sourceTexture The input texture to the post procesess. (default: null)
  15873. * @param postProcesses An array of post processes to be run. (default: null)
  15874. * @returns True if the post processes were able to be run.
  15875. * @hidden
  15876. */
  15877. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  15878. /**
  15879. * Manually render a set of post processes to a texture.
  15880. * @param postProcesses An array of post processes to be run.
  15881. * @param targetTexture The target texture to render to.
  15882. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  15883. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  15884. * @param lodLevel defines which lod of the texture to render to
  15885. */
  15886. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  15887. /**
  15888. * Finalize the result of the output of the postprocesses.
  15889. * @param doNotPresent If true the result will not be displayed to the screen.
  15890. * @param targetTexture The target texture to render to.
  15891. * @param faceIndex The index of the face to bind the target texture to.
  15892. * @param postProcesses The array of post processes to render.
  15893. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  15894. * @hidden
  15895. */
  15896. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  15897. /**
  15898. * Disposes of the post process manager.
  15899. */
  15900. dispose(): void;
  15901. }
  15902. }
  15903. declare module BABYLON {
  15904. /** Interface used by value gradients (color, factor, ...) */
  15905. export interface IValueGradient {
  15906. /**
  15907. * Gets or sets the gradient value (between 0 and 1)
  15908. */
  15909. gradient: number;
  15910. }
  15911. /** Class used to store color4 gradient */
  15912. export class ColorGradient implements IValueGradient {
  15913. /**
  15914. * Gets or sets the gradient value (between 0 and 1)
  15915. */
  15916. gradient: number;
  15917. /**
  15918. * Gets or sets first associated color
  15919. */
  15920. color1: Color4;
  15921. /**
  15922. * Gets or sets second associated color
  15923. */
  15924. color2?: Color4;
  15925. /**
  15926. * Will get a color picked randomly between color1 and color2.
  15927. * If color2 is undefined then color1 will be used
  15928. * @param result defines the target Color4 to store the result in
  15929. */
  15930. getColorToRef(result: Color4): void;
  15931. }
  15932. /** Class used to store color 3 gradient */
  15933. export class Color3Gradient implements IValueGradient {
  15934. /**
  15935. * Gets or sets the gradient value (between 0 and 1)
  15936. */
  15937. gradient: number;
  15938. /**
  15939. * Gets or sets the associated color
  15940. */
  15941. color: Color3;
  15942. }
  15943. /** Class used to store factor gradient */
  15944. export class FactorGradient implements IValueGradient {
  15945. /**
  15946. * Gets or sets the gradient value (between 0 and 1)
  15947. */
  15948. gradient: number;
  15949. /**
  15950. * Gets or sets first associated factor
  15951. */
  15952. factor1: number;
  15953. /**
  15954. * Gets or sets second associated factor
  15955. */
  15956. factor2?: number;
  15957. /**
  15958. * Will get a number picked randomly between factor1 and factor2.
  15959. * If factor2 is undefined then factor1 will be used
  15960. * @returns the picked number
  15961. */
  15962. getFactor(): number;
  15963. }
  15964. /**
  15965. * Helper used to simplify some generic gradient tasks
  15966. */
  15967. export class GradientHelper {
  15968. /**
  15969. * Gets the current gradient from an array of IValueGradient
  15970. * @param ratio defines the current ratio to get
  15971. * @param gradients defines the array of IValueGradient
  15972. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  15973. */
  15974. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  15975. }
  15976. }
  15977. declare module BABYLON {
  15978. interface ThinEngine {
  15979. /**
  15980. * Creates a dynamic texture
  15981. * @param width defines the width of the texture
  15982. * @param height defines the height of the texture
  15983. * @param generateMipMaps defines if the engine should generate the mip levels
  15984. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  15985. * @returns the dynamic texture inside an InternalTexture
  15986. */
  15987. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  15988. /**
  15989. * Update the content of a dynamic texture
  15990. * @param texture defines the texture to update
  15991. * @param canvas defines the canvas containing the source
  15992. * @param invertY defines if data must be stored with Y axis inverted
  15993. * @param premulAlpha defines if alpha is stored as premultiplied
  15994. * @param format defines the format of the data
  15995. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  15996. */
  15997. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  15998. }
  15999. }
  16000. declare module BABYLON {
  16001. /**
  16002. * A class extending Texture allowing drawing on a texture
  16003. * @see http://doc.babylonjs.com/how_to/dynamictexture
  16004. */
  16005. export class DynamicTexture extends Texture {
  16006. private _generateMipMaps;
  16007. private _canvas;
  16008. private _context;
  16009. private _engine;
  16010. /**
  16011. * Creates a DynamicTexture
  16012. * @param name defines the name of the texture
  16013. * @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
  16014. * @param scene defines the scene where you want the texture
  16015. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  16016. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  16017. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  16018. */
  16019. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  16020. /**
  16021. * Get the current class name of the texture useful for serialization or dynamic coding.
  16022. * @returns "DynamicTexture"
  16023. */
  16024. getClassName(): string;
  16025. /**
  16026. * Gets the current state of canRescale
  16027. */
  16028. readonly canRescale: boolean;
  16029. private _recreate;
  16030. /**
  16031. * Scales the texture
  16032. * @param ratio the scale factor to apply to both width and height
  16033. */
  16034. scale(ratio: number): void;
  16035. /**
  16036. * Resizes the texture
  16037. * @param width the new width
  16038. * @param height the new height
  16039. */
  16040. scaleTo(width: number, height: number): void;
  16041. /**
  16042. * Gets the context of the canvas used by the texture
  16043. * @returns the canvas context of the dynamic texture
  16044. */
  16045. getContext(): CanvasRenderingContext2D;
  16046. /**
  16047. * Clears the texture
  16048. */
  16049. clear(): void;
  16050. /**
  16051. * Updates the texture
  16052. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  16053. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  16054. */
  16055. update(invertY?: boolean, premulAlpha?: boolean): void;
  16056. /**
  16057. * Draws text onto the texture
  16058. * @param text defines the text to be drawn
  16059. * @param x defines the placement of the text from the left
  16060. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  16061. * @param font defines the font to be used with font-style, font-size, font-name
  16062. * @param color defines the color used for the text
  16063. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  16064. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  16065. * @param update defines whether texture is immediately update (default is true)
  16066. */
  16067. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  16068. /**
  16069. * Clones the texture
  16070. * @returns the clone of the texture.
  16071. */
  16072. clone(): DynamicTexture;
  16073. /**
  16074. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  16075. * @returns a serialized dynamic texture object
  16076. */
  16077. serialize(): any;
  16078. /** @hidden */
  16079. _rebuild(): void;
  16080. }
  16081. }
  16082. declare module BABYLON {
  16083. interface AbstractScene {
  16084. /**
  16085. * The list of procedural textures added to the scene
  16086. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16087. */
  16088. proceduralTextures: Array<ProceduralTexture>;
  16089. }
  16090. /**
  16091. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  16092. * in a given scene.
  16093. */
  16094. export class ProceduralTextureSceneComponent implements ISceneComponent {
  16095. /**
  16096. * The component name helpfull to identify the component in the list of scene components.
  16097. */
  16098. readonly name: string;
  16099. /**
  16100. * The scene the component belongs to.
  16101. */
  16102. scene: Scene;
  16103. /**
  16104. * Creates a new instance of the component for the given scene
  16105. * @param scene Defines the scene to register the component in
  16106. */
  16107. constructor(scene: Scene);
  16108. /**
  16109. * Registers the component in a given scene
  16110. */
  16111. register(): void;
  16112. /**
  16113. * Rebuilds the elements related to this component in case of
  16114. * context lost for instance.
  16115. */
  16116. rebuild(): void;
  16117. /**
  16118. * Disposes the component and the associated ressources.
  16119. */
  16120. dispose(): void;
  16121. private _beforeClear;
  16122. }
  16123. }
  16124. declare module BABYLON {
  16125. interface ThinEngine {
  16126. /**
  16127. * Creates a new render target cube texture
  16128. * @param size defines the size of the texture
  16129. * @param options defines the options used to create the texture
  16130. * @returns a new render target cube texture stored in an InternalTexture
  16131. */
  16132. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  16133. }
  16134. }
  16135. declare module BABYLON {
  16136. /** @hidden */
  16137. export var proceduralVertexShader: {
  16138. name: string;
  16139. shader: string;
  16140. };
  16141. }
  16142. declare module BABYLON {
  16143. /**
  16144. * 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.
  16145. * This is the base class of any Procedural texture and contains most of the shareable code.
  16146. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16147. */
  16148. export class ProceduralTexture extends Texture {
  16149. isCube: boolean;
  16150. /**
  16151. * Define if the texture is enabled or not (disabled texture will not render)
  16152. */
  16153. isEnabled: boolean;
  16154. /**
  16155. * Define if the texture must be cleared before rendering (default is true)
  16156. */
  16157. autoClear: boolean;
  16158. /**
  16159. * Callback called when the texture is generated
  16160. */
  16161. onGenerated: () => void;
  16162. /**
  16163. * Event raised when the texture is generated
  16164. */
  16165. onGeneratedObservable: Observable<ProceduralTexture>;
  16166. /** @hidden */
  16167. _generateMipMaps: boolean;
  16168. /** @hidden **/
  16169. _effect: Effect;
  16170. /** @hidden */
  16171. _textures: {
  16172. [key: string]: Texture;
  16173. };
  16174. private _size;
  16175. private _currentRefreshId;
  16176. private _refreshRate;
  16177. private _vertexBuffers;
  16178. private _indexBuffer;
  16179. private _uniforms;
  16180. private _samplers;
  16181. private _fragment;
  16182. private _floats;
  16183. private _ints;
  16184. private _floatsArrays;
  16185. private _colors3;
  16186. private _colors4;
  16187. private _vectors2;
  16188. private _vectors3;
  16189. private _matrices;
  16190. private _fallbackTexture;
  16191. private _fallbackTextureUsed;
  16192. private _engine;
  16193. private _cachedDefines;
  16194. private _contentUpdateId;
  16195. private _contentData;
  16196. /**
  16197. * Instantiates a new procedural texture.
  16198. * 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.
  16199. * This is the base class of any Procedural texture and contains most of the shareable code.
  16200. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16201. * @param name Define the name of the texture
  16202. * @param size Define the size of the texture to create
  16203. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  16204. * @param scene Define the scene the texture belongs to
  16205. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  16206. * @param generateMipMaps Define if the texture should creates mip maps or not
  16207. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  16208. */
  16209. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  16210. /**
  16211. * The effect that is created when initializing the post process.
  16212. * @returns The created effect corresponding the the postprocess.
  16213. */
  16214. getEffect(): Effect;
  16215. /**
  16216. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  16217. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  16218. */
  16219. getContent(): Nullable<ArrayBufferView>;
  16220. private _createIndexBuffer;
  16221. /** @hidden */
  16222. _rebuild(): void;
  16223. /**
  16224. * Resets the texture in order to recreate its associated resources.
  16225. * This can be called in case of context loss
  16226. */
  16227. reset(): void;
  16228. protected _getDefines(): string;
  16229. /**
  16230. * Is the texture ready to be used ? (rendered at least once)
  16231. * @returns true if ready, otherwise, false.
  16232. */
  16233. isReady(): boolean;
  16234. /**
  16235. * Resets the refresh counter of the texture and start bak from scratch.
  16236. * Could be useful to regenerate the texture if it is setup to render only once.
  16237. */
  16238. resetRefreshCounter(): void;
  16239. /**
  16240. * Set the fragment shader to use in order to render the texture.
  16241. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  16242. */
  16243. setFragment(fragment: any): void;
  16244. /**
  16245. * Define the refresh rate of the texture or the rendering frequency.
  16246. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  16247. */
  16248. refreshRate: number;
  16249. /** @hidden */
  16250. _shouldRender(): boolean;
  16251. /**
  16252. * Get the size the texture is rendering at.
  16253. * @returns the size (texture is always squared)
  16254. */
  16255. getRenderSize(): number;
  16256. /**
  16257. * Resize the texture to new value.
  16258. * @param size Define the new size the texture should have
  16259. * @param generateMipMaps Define whether the new texture should create mip maps
  16260. */
  16261. resize(size: number, generateMipMaps: boolean): void;
  16262. private _checkUniform;
  16263. /**
  16264. * Set a texture in the shader program used to render.
  16265. * @param name Define the name of the uniform samplers as defined in the shader
  16266. * @param texture Define the texture to bind to this sampler
  16267. * @return the texture itself allowing "fluent" like uniform updates
  16268. */
  16269. setTexture(name: string, texture: Texture): ProceduralTexture;
  16270. /**
  16271. * Set a float in the shader.
  16272. * @param name Define the name of the uniform as defined in the shader
  16273. * @param value Define the value to give to the uniform
  16274. * @return the texture itself allowing "fluent" like uniform updates
  16275. */
  16276. setFloat(name: string, value: number): ProceduralTexture;
  16277. /**
  16278. * Set a int in the shader.
  16279. * @param name Define the name of the uniform as defined in the shader
  16280. * @param value Define the value to give to the uniform
  16281. * @return the texture itself allowing "fluent" like uniform updates
  16282. */
  16283. setInt(name: string, value: number): ProceduralTexture;
  16284. /**
  16285. * Set an array of floats in the shader.
  16286. * @param name Define the name of the uniform as defined in the shader
  16287. * @param value Define the value to give to the uniform
  16288. * @return the texture itself allowing "fluent" like uniform updates
  16289. */
  16290. setFloats(name: string, value: number[]): ProceduralTexture;
  16291. /**
  16292. * Set a vec3 in the shader from a Color3.
  16293. * @param name Define the name of the uniform as defined in the shader
  16294. * @param value Define the value to give to the uniform
  16295. * @return the texture itself allowing "fluent" like uniform updates
  16296. */
  16297. setColor3(name: string, value: Color3): ProceduralTexture;
  16298. /**
  16299. * Set a vec4 in the shader from a Color4.
  16300. * @param name Define the name of the uniform as defined in the shader
  16301. * @param value Define the value to give to the uniform
  16302. * @return the texture itself allowing "fluent" like uniform updates
  16303. */
  16304. setColor4(name: string, value: Color4): ProceduralTexture;
  16305. /**
  16306. * Set a vec2 in the shader from a Vector2.
  16307. * @param name Define the name of the uniform as defined in the shader
  16308. * @param value Define the value to give to the uniform
  16309. * @return the texture itself allowing "fluent" like uniform updates
  16310. */
  16311. setVector2(name: string, value: Vector2): ProceduralTexture;
  16312. /**
  16313. * Set a vec3 in the shader from a Vector3.
  16314. * @param name Define the name of the uniform as defined in the shader
  16315. * @param value Define the value to give to the uniform
  16316. * @return the texture itself allowing "fluent" like uniform updates
  16317. */
  16318. setVector3(name: string, value: Vector3): ProceduralTexture;
  16319. /**
  16320. * Set a mat4 in the shader from a MAtrix.
  16321. * @param name Define the name of the uniform as defined in the shader
  16322. * @param value Define the value to give to the uniform
  16323. * @return the texture itself allowing "fluent" like uniform updates
  16324. */
  16325. setMatrix(name: string, value: Matrix): ProceduralTexture;
  16326. /**
  16327. * Render the texture to its associated render target.
  16328. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  16329. */
  16330. render(useCameraPostProcess?: boolean): void;
  16331. /**
  16332. * Clone the texture.
  16333. * @returns the cloned texture
  16334. */
  16335. clone(): ProceduralTexture;
  16336. /**
  16337. * Dispose the texture and release its asoociated resources.
  16338. */
  16339. dispose(): void;
  16340. }
  16341. }
  16342. declare module BABYLON {
  16343. /**
  16344. * This represents the base class for particle system in Babylon.
  16345. * 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.
  16346. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  16347. * @example https://doc.babylonjs.com/babylon101/particles
  16348. */
  16349. export class BaseParticleSystem {
  16350. /**
  16351. * Source color is added to the destination color without alpha affecting the result
  16352. */
  16353. static BLENDMODE_ONEONE: number;
  16354. /**
  16355. * Blend current color and particle color using particle’s alpha
  16356. */
  16357. static BLENDMODE_STANDARD: number;
  16358. /**
  16359. * Add current color and particle color multiplied by particle’s alpha
  16360. */
  16361. static BLENDMODE_ADD: number;
  16362. /**
  16363. * Multiply current color with particle color
  16364. */
  16365. static BLENDMODE_MULTIPLY: number;
  16366. /**
  16367. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  16368. */
  16369. static BLENDMODE_MULTIPLYADD: number;
  16370. /**
  16371. * List of animations used by the particle system.
  16372. */
  16373. animations: Animation[];
  16374. /**
  16375. * The id of the Particle system.
  16376. */
  16377. id: string;
  16378. /**
  16379. * The friendly name of the Particle system.
  16380. */
  16381. name: string;
  16382. /**
  16383. * The rendering group used by the Particle system to chose when to render.
  16384. */
  16385. renderingGroupId: number;
  16386. /**
  16387. * The emitter represents the Mesh or position we are attaching the particle system to.
  16388. */
  16389. emitter: Nullable<AbstractMesh | Vector3>;
  16390. /**
  16391. * The maximum number of particles to emit per frame
  16392. */
  16393. emitRate: number;
  16394. /**
  16395. * If you want to launch only a few particles at once, that can be done, as well.
  16396. */
  16397. manualEmitCount: number;
  16398. /**
  16399. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  16400. */
  16401. updateSpeed: number;
  16402. /**
  16403. * The amount of time the particle system is running (depends of the overall update speed).
  16404. */
  16405. targetStopDuration: number;
  16406. /**
  16407. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  16408. */
  16409. disposeOnStop: boolean;
  16410. /**
  16411. * Minimum power of emitting particles.
  16412. */
  16413. minEmitPower: number;
  16414. /**
  16415. * Maximum power of emitting particles.
  16416. */
  16417. maxEmitPower: number;
  16418. /**
  16419. * Minimum life time of emitting particles.
  16420. */
  16421. minLifeTime: number;
  16422. /**
  16423. * Maximum life time of emitting particles.
  16424. */
  16425. maxLifeTime: number;
  16426. /**
  16427. * Minimum Size of emitting particles.
  16428. */
  16429. minSize: number;
  16430. /**
  16431. * Maximum Size of emitting particles.
  16432. */
  16433. maxSize: number;
  16434. /**
  16435. * Minimum scale of emitting particles on X axis.
  16436. */
  16437. minScaleX: number;
  16438. /**
  16439. * Maximum scale of emitting particles on X axis.
  16440. */
  16441. maxScaleX: number;
  16442. /**
  16443. * Minimum scale of emitting particles on Y axis.
  16444. */
  16445. minScaleY: number;
  16446. /**
  16447. * Maximum scale of emitting particles on Y axis.
  16448. */
  16449. maxScaleY: number;
  16450. /**
  16451. * Gets or sets the minimal initial rotation in radians.
  16452. */
  16453. minInitialRotation: number;
  16454. /**
  16455. * Gets or sets the maximal initial rotation in radians.
  16456. */
  16457. maxInitialRotation: number;
  16458. /**
  16459. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  16460. */
  16461. minAngularSpeed: number;
  16462. /**
  16463. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  16464. */
  16465. maxAngularSpeed: number;
  16466. /**
  16467. * The texture used to render each particle. (this can be a spritesheet)
  16468. */
  16469. particleTexture: Nullable<Texture>;
  16470. /**
  16471. * The layer mask we are rendering the particles through.
  16472. */
  16473. layerMask: number;
  16474. /**
  16475. * This can help using your own shader to render the particle system.
  16476. * The according effect will be created
  16477. */
  16478. customShader: any;
  16479. /**
  16480. * By default particle system starts as soon as they are created. This prevents the
  16481. * automatic start to happen and let you decide when to start emitting particles.
  16482. */
  16483. preventAutoStart: boolean;
  16484. private _noiseTexture;
  16485. /**
  16486. * Gets or sets a texture used to add random noise to particle positions
  16487. */
  16488. noiseTexture: Nullable<ProceduralTexture>;
  16489. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  16490. noiseStrength: Vector3;
  16491. /**
  16492. * Callback triggered when the particle animation is ending.
  16493. */
  16494. onAnimationEnd: Nullable<() => void>;
  16495. /**
  16496. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  16497. */
  16498. blendMode: number;
  16499. /**
  16500. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  16501. * to override the particles.
  16502. */
  16503. forceDepthWrite: boolean;
  16504. /** 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 */
  16505. preWarmCycles: number;
  16506. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  16507. preWarmStepOffset: number;
  16508. /**
  16509. * 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)
  16510. */
  16511. spriteCellChangeSpeed: number;
  16512. /**
  16513. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  16514. */
  16515. startSpriteCellID: number;
  16516. /**
  16517. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  16518. */
  16519. endSpriteCellID: number;
  16520. /**
  16521. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  16522. */
  16523. spriteCellWidth: number;
  16524. /**
  16525. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  16526. */
  16527. spriteCellHeight: number;
  16528. /**
  16529. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  16530. */
  16531. spriteRandomStartCell: boolean;
  16532. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  16533. translationPivot: Vector2;
  16534. /** @hidden */
  16535. protected _isAnimationSheetEnabled: boolean;
  16536. /**
  16537. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  16538. */
  16539. beginAnimationOnStart: boolean;
  16540. /**
  16541. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  16542. */
  16543. beginAnimationFrom: number;
  16544. /**
  16545. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  16546. */
  16547. beginAnimationTo: number;
  16548. /**
  16549. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  16550. */
  16551. beginAnimationLoop: boolean;
  16552. /**
  16553. * Gets or sets a world offset applied to all particles
  16554. */
  16555. worldOffset: Vector3;
  16556. /**
  16557. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  16558. */
  16559. isAnimationSheetEnabled: boolean;
  16560. /**
  16561. * Get hosting scene
  16562. * @returns the scene
  16563. */
  16564. getScene(): Scene;
  16565. /**
  16566. * You can use gravity if you want to give an orientation to your particles.
  16567. */
  16568. gravity: Vector3;
  16569. protected _colorGradients: Nullable<Array<ColorGradient>>;
  16570. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  16571. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  16572. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  16573. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  16574. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  16575. protected _dragGradients: Nullable<Array<FactorGradient>>;
  16576. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  16577. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  16578. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  16579. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  16580. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  16581. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  16582. /**
  16583. * Defines the delay in milliseconds before starting the system (0 by default)
  16584. */
  16585. startDelay: number;
  16586. /**
  16587. * Gets the current list of drag gradients.
  16588. * You must use addDragGradient and removeDragGradient to udpate this list
  16589. * @returns the list of drag gradients
  16590. */
  16591. getDragGradients(): Nullable<Array<FactorGradient>>;
  16592. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  16593. limitVelocityDamping: number;
  16594. /**
  16595. * Gets the current list of limit velocity gradients.
  16596. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  16597. * @returns the list of limit velocity gradients
  16598. */
  16599. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  16600. /**
  16601. * Gets the current list of color gradients.
  16602. * You must use addColorGradient and removeColorGradient to udpate this list
  16603. * @returns the list of color gradients
  16604. */
  16605. getColorGradients(): Nullable<Array<ColorGradient>>;
  16606. /**
  16607. * Gets the current list of size gradients.
  16608. * You must use addSizeGradient and removeSizeGradient to udpate this list
  16609. * @returns the list of size gradients
  16610. */
  16611. getSizeGradients(): Nullable<Array<FactorGradient>>;
  16612. /**
  16613. * Gets the current list of color remap gradients.
  16614. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  16615. * @returns the list of color remap gradients
  16616. */
  16617. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  16618. /**
  16619. * Gets the current list of alpha remap gradients.
  16620. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  16621. * @returns the list of alpha remap gradients
  16622. */
  16623. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  16624. /**
  16625. * Gets the current list of life time gradients.
  16626. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  16627. * @returns the list of life time gradients
  16628. */
  16629. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  16630. /**
  16631. * Gets the current list of angular speed gradients.
  16632. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  16633. * @returns the list of angular speed gradients
  16634. */
  16635. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  16636. /**
  16637. * Gets the current list of velocity gradients.
  16638. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  16639. * @returns the list of velocity gradients
  16640. */
  16641. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  16642. /**
  16643. * Gets the current list of start size gradients.
  16644. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  16645. * @returns the list of start size gradients
  16646. */
  16647. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  16648. /**
  16649. * Gets the current list of emit rate gradients.
  16650. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  16651. * @returns the list of emit rate gradients
  16652. */
  16653. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  16654. /**
  16655. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16656. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16657. */
  16658. direction1: Vector3;
  16659. /**
  16660. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16661. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16662. */
  16663. direction2: Vector3;
  16664. /**
  16665. * 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.
  16666. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16667. */
  16668. minEmitBox: Vector3;
  16669. /**
  16670. * 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.
  16671. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16672. */
  16673. maxEmitBox: Vector3;
  16674. /**
  16675. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  16676. */
  16677. color1: Color4;
  16678. /**
  16679. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  16680. */
  16681. color2: Color4;
  16682. /**
  16683. * Color the particle will have at the end of its lifetime
  16684. */
  16685. colorDead: Color4;
  16686. /**
  16687. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  16688. */
  16689. textureMask: Color4;
  16690. /**
  16691. * The particle emitter type defines the emitter used by the particle system.
  16692. * It can be for example box, sphere, or cone...
  16693. */
  16694. particleEmitterType: IParticleEmitterType;
  16695. /** @hidden */
  16696. _isSubEmitter: boolean;
  16697. /**
  16698. * Gets or sets the billboard mode to use when isBillboardBased = true.
  16699. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  16700. */
  16701. billboardMode: number;
  16702. protected _isBillboardBased: boolean;
  16703. /**
  16704. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  16705. */
  16706. isBillboardBased: boolean;
  16707. /**
  16708. * The scene the particle system belongs to.
  16709. */
  16710. protected _scene: Scene;
  16711. /**
  16712. * Local cache of defines for image processing.
  16713. */
  16714. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  16715. /**
  16716. * Default configuration related to image processing available in the standard Material.
  16717. */
  16718. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  16719. /**
  16720. * Gets the image processing configuration used either in this material.
  16721. */
  16722. /**
  16723. * Sets the Default image processing configuration used either in the this material.
  16724. *
  16725. * If sets to null, the scene one is in use.
  16726. */
  16727. imageProcessingConfiguration: ImageProcessingConfiguration;
  16728. /**
  16729. * Attaches a new image processing configuration to the Standard Material.
  16730. * @param configuration
  16731. */
  16732. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  16733. /** @hidden */
  16734. protected _reset(): void;
  16735. /** @hidden */
  16736. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  16737. /**
  16738. * Instantiates a particle system.
  16739. * 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.
  16740. * @param name The name of the particle system
  16741. */
  16742. constructor(name: string);
  16743. /**
  16744. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  16745. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16746. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16747. * @returns the emitter
  16748. */
  16749. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  16750. /**
  16751. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  16752. * @param radius The radius of the hemisphere to emit from
  16753. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16754. * @returns the emitter
  16755. */
  16756. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  16757. /**
  16758. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  16759. * @param radius The radius of the sphere to emit from
  16760. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16761. * @returns the emitter
  16762. */
  16763. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  16764. /**
  16765. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  16766. * @param radius The radius of the sphere to emit from
  16767. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  16768. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  16769. * @returns the emitter
  16770. */
  16771. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  16772. /**
  16773. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  16774. * @param radius The radius of the emission cylinder
  16775. * @param height The height of the emission cylinder
  16776. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  16777. * @param directionRandomizer How much to randomize the particle direction [0-1]
  16778. * @returns the emitter
  16779. */
  16780. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  16781. /**
  16782. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  16783. * @param radius The radius of the cylinder to emit from
  16784. * @param height The height of the emission cylinder
  16785. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16786. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  16787. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  16788. * @returns the emitter
  16789. */
  16790. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  16791. /**
  16792. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  16793. * @param radius The radius of the cone to emit from
  16794. * @param angle The base angle of the cone
  16795. * @returns the emitter
  16796. */
  16797. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  16798. /**
  16799. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  16800. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16801. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16802. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16803. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16804. * @returns the emitter
  16805. */
  16806. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  16807. }
  16808. }
  16809. declare module BABYLON {
  16810. /**
  16811. * Type of sub emitter
  16812. */
  16813. export enum SubEmitterType {
  16814. /**
  16815. * Attached to the particle over it's lifetime
  16816. */
  16817. ATTACHED = 0,
  16818. /**
  16819. * Created when the particle dies
  16820. */
  16821. END = 1
  16822. }
  16823. /**
  16824. * Sub emitter class used to emit particles from an existing particle
  16825. */
  16826. export class SubEmitter {
  16827. /**
  16828. * the particle system to be used by the sub emitter
  16829. */
  16830. particleSystem: ParticleSystem;
  16831. /**
  16832. * Type of the submitter (Default: END)
  16833. */
  16834. type: SubEmitterType;
  16835. /**
  16836. * 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)
  16837. * Note: This only is supported when using an emitter of type Mesh
  16838. */
  16839. inheritDirection: boolean;
  16840. /**
  16841. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  16842. */
  16843. inheritedVelocityAmount: number;
  16844. /**
  16845. * Creates a sub emitter
  16846. * @param particleSystem the particle system to be used by the sub emitter
  16847. */
  16848. constructor(
  16849. /**
  16850. * the particle system to be used by the sub emitter
  16851. */
  16852. particleSystem: ParticleSystem);
  16853. /**
  16854. * Clones the sub emitter
  16855. * @returns the cloned sub emitter
  16856. */
  16857. clone(): SubEmitter;
  16858. /**
  16859. * Serialize current object to a JSON object
  16860. * @returns the serialized object
  16861. */
  16862. serialize(): any;
  16863. /** @hidden */
  16864. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  16865. /**
  16866. * Creates a new SubEmitter from a serialized JSON version
  16867. * @param serializationObject defines the JSON object to read from
  16868. * @param scene defines the hosting scene
  16869. * @param rootUrl defines the rootUrl for data loading
  16870. * @returns a new SubEmitter
  16871. */
  16872. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  16873. /** Release associated resources */
  16874. dispose(): void;
  16875. }
  16876. }
  16877. declare module BABYLON {
  16878. /** @hidden */
  16879. export var clipPlaneFragmentDeclaration: {
  16880. name: string;
  16881. shader: string;
  16882. };
  16883. }
  16884. declare module BABYLON {
  16885. /** @hidden */
  16886. export var imageProcessingDeclaration: {
  16887. name: string;
  16888. shader: string;
  16889. };
  16890. }
  16891. declare module BABYLON {
  16892. /** @hidden */
  16893. export var imageProcessingFunctions: {
  16894. name: string;
  16895. shader: string;
  16896. };
  16897. }
  16898. declare module BABYLON {
  16899. /** @hidden */
  16900. export var clipPlaneFragment: {
  16901. name: string;
  16902. shader: string;
  16903. };
  16904. }
  16905. declare module BABYLON {
  16906. /** @hidden */
  16907. export var particlesPixelShader: {
  16908. name: string;
  16909. shader: string;
  16910. };
  16911. }
  16912. declare module BABYLON {
  16913. /** @hidden */
  16914. export var clipPlaneVertexDeclaration: {
  16915. name: string;
  16916. shader: string;
  16917. };
  16918. }
  16919. declare module BABYLON {
  16920. /** @hidden */
  16921. export var clipPlaneVertex: {
  16922. name: string;
  16923. shader: string;
  16924. };
  16925. }
  16926. declare module BABYLON {
  16927. /** @hidden */
  16928. export var particlesVertexShader: {
  16929. name: string;
  16930. shader: string;
  16931. };
  16932. }
  16933. declare module BABYLON {
  16934. /**
  16935. * This represents a particle system in Babylon.
  16936. * 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.
  16937. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  16938. * @example https://doc.babylonjs.com/babylon101/particles
  16939. */
  16940. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  16941. /**
  16942. * Billboard mode will only apply to Y axis
  16943. */
  16944. static readonly BILLBOARDMODE_Y: number;
  16945. /**
  16946. * Billboard mode will apply to all axes
  16947. */
  16948. static readonly BILLBOARDMODE_ALL: number;
  16949. /**
  16950. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  16951. */
  16952. static readonly BILLBOARDMODE_STRETCHED: number;
  16953. /**
  16954. * This function can be defined to provide custom update for active particles.
  16955. * This function will be called instead of regular update (age, position, color, etc.).
  16956. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  16957. */
  16958. updateFunction: (particles: Particle[]) => void;
  16959. private _emitterWorldMatrix;
  16960. /**
  16961. * This function can be defined to specify initial direction for every new particle.
  16962. * It by default use the emitterType defined function
  16963. */
  16964. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  16965. /**
  16966. * This function can be defined to specify initial position for every new particle.
  16967. * It by default use the emitterType defined function
  16968. */
  16969. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  16970. /**
  16971. * @hidden
  16972. */
  16973. _inheritedVelocityOffset: Vector3;
  16974. /**
  16975. * An event triggered when the system is disposed
  16976. */
  16977. onDisposeObservable: Observable<ParticleSystem>;
  16978. private _onDisposeObserver;
  16979. /**
  16980. * Sets a callback that will be triggered when the system is disposed
  16981. */
  16982. onDispose: () => void;
  16983. private _particles;
  16984. private _epsilon;
  16985. private _capacity;
  16986. private _stockParticles;
  16987. private _newPartsExcess;
  16988. private _vertexData;
  16989. private _vertexBuffer;
  16990. private _vertexBuffers;
  16991. private _spriteBuffer;
  16992. private _indexBuffer;
  16993. private _effect;
  16994. private _customEffect;
  16995. private _cachedDefines;
  16996. private _scaledColorStep;
  16997. private _colorDiff;
  16998. private _scaledDirection;
  16999. private _scaledGravity;
  17000. private _currentRenderId;
  17001. private _alive;
  17002. private _useInstancing;
  17003. private _started;
  17004. private _stopped;
  17005. private _actualFrame;
  17006. private _scaledUpdateSpeed;
  17007. private _vertexBufferSize;
  17008. /** @hidden */
  17009. _currentEmitRateGradient: Nullable<FactorGradient>;
  17010. /** @hidden */
  17011. _currentEmitRate1: number;
  17012. /** @hidden */
  17013. _currentEmitRate2: number;
  17014. /** @hidden */
  17015. _currentStartSizeGradient: Nullable<FactorGradient>;
  17016. /** @hidden */
  17017. _currentStartSize1: number;
  17018. /** @hidden */
  17019. _currentStartSize2: number;
  17020. private readonly _rawTextureWidth;
  17021. private _rampGradientsTexture;
  17022. private _useRampGradients;
  17023. /** Gets or sets a boolean indicating that ramp gradients must be used
  17024. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  17025. */
  17026. useRampGradients: boolean;
  17027. /**
  17028. * 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.
  17029. * 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: [])
  17030. */
  17031. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  17032. private _subEmitters;
  17033. /**
  17034. * @hidden
  17035. * If the particle systems emitter should be disposed when the particle system is disposed
  17036. */
  17037. _disposeEmitterOnDispose: boolean;
  17038. /**
  17039. * The current active Sub-systems, this property is used by the root particle system only.
  17040. */
  17041. activeSubSystems: Array<ParticleSystem>;
  17042. private _rootParticleSystem;
  17043. /**
  17044. * Gets the current list of active particles
  17045. */
  17046. readonly particles: Particle[];
  17047. /**
  17048. * Returns the string "ParticleSystem"
  17049. * @returns a string containing the class name
  17050. */
  17051. getClassName(): string;
  17052. /**
  17053. * Instantiates a particle system.
  17054. * 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.
  17055. * @param name The name of the particle system
  17056. * @param capacity The max number of particles alive at the same time
  17057. * @param scene The scene the particle system belongs to
  17058. * @param customEffect a custom effect used to change the way particles are rendered by default
  17059. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  17060. * @param epsilon Offset used to render the particles
  17061. */
  17062. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  17063. private _addFactorGradient;
  17064. private _removeFactorGradient;
  17065. /**
  17066. * Adds a new life time gradient
  17067. * @param gradient defines the gradient to use (between 0 and 1)
  17068. * @param factor defines the life time factor to affect to the specified gradient
  17069. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17070. * @returns the current particle system
  17071. */
  17072. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17073. /**
  17074. * Remove a specific life time gradient
  17075. * @param gradient defines the gradient to remove
  17076. * @returns the current particle system
  17077. */
  17078. removeLifeTimeGradient(gradient: number): IParticleSystem;
  17079. /**
  17080. * Adds a new size gradient
  17081. * @param gradient defines the gradient to use (between 0 and 1)
  17082. * @param factor defines the size factor to affect to the specified gradient
  17083. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17084. * @returns the current particle system
  17085. */
  17086. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17087. /**
  17088. * Remove a specific size gradient
  17089. * @param gradient defines the gradient to remove
  17090. * @returns the current particle system
  17091. */
  17092. removeSizeGradient(gradient: number): IParticleSystem;
  17093. /**
  17094. * Adds a new color remap gradient
  17095. * @param gradient defines the gradient to use (between 0 and 1)
  17096. * @param min defines the color remap minimal range
  17097. * @param max defines the color remap maximal range
  17098. * @returns the current particle system
  17099. */
  17100. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17101. /**
  17102. * Remove a specific color remap gradient
  17103. * @param gradient defines the gradient to remove
  17104. * @returns the current particle system
  17105. */
  17106. removeColorRemapGradient(gradient: number): IParticleSystem;
  17107. /**
  17108. * Adds a new alpha remap gradient
  17109. * @param gradient defines the gradient to use (between 0 and 1)
  17110. * @param min defines the alpha remap minimal range
  17111. * @param max defines the alpha remap maximal range
  17112. * @returns the current particle system
  17113. */
  17114. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17115. /**
  17116. * Remove a specific alpha remap gradient
  17117. * @param gradient defines the gradient to remove
  17118. * @returns the current particle system
  17119. */
  17120. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  17121. /**
  17122. * Adds a new angular speed gradient
  17123. * @param gradient defines the gradient to use (between 0 and 1)
  17124. * @param factor defines the angular speed to affect to the specified gradient
  17125. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17126. * @returns the current particle system
  17127. */
  17128. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17129. /**
  17130. * Remove a specific angular speed gradient
  17131. * @param gradient defines the gradient to remove
  17132. * @returns the current particle system
  17133. */
  17134. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  17135. /**
  17136. * Adds a new velocity gradient
  17137. * @param gradient defines the gradient to use (between 0 and 1)
  17138. * @param factor defines the velocity to affect to the specified gradient
  17139. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17140. * @returns the current particle system
  17141. */
  17142. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17143. /**
  17144. * Remove a specific velocity gradient
  17145. * @param gradient defines the gradient to remove
  17146. * @returns the current particle system
  17147. */
  17148. removeVelocityGradient(gradient: number): IParticleSystem;
  17149. /**
  17150. * Adds a new limit velocity gradient
  17151. * @param gradient defines the gradient to use (between 0 and 1)
  17152. * @param factor defines the limit velocity value to affect to the specified gradient
  17153. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17154. * @returns the current particle system
  17155. */
  17156. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17157. /**
  17158. * Remove a specific limit velocity gradient
  17159. * @param gradient defines the gradient to remove
  17160. * @returns the current particle system
  17161. */
  17162. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  17163. /**
  17164. * Adds a new drag gradient
  17165. * @param gradient defines the gradient to use (between 0 and 1)
  17166. * @param factor defines the drag value to affect to the specified gradient
  17167. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17168. * @returns the current particle system
  17169. */
  17170. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17171. /**
  17172. * Remove a specific drag gradient
  17173. * @param gradient defines the gradient to remove
  17174. * @returns the current particle system
  17175. */
  17176. removeDragGradient(gradient: number): IParticleSystem;
  17177. /**
  17178. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  17179. * @param gradient defines the gradient to use (between 0 and 1)
  17180. * @param factor defines the emit rate value to affect to the specified gradient
  17181. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17182. * @returns the current particle system
  17183. */
  17184. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17185. /**
  17186. * Remove a specific emit rate gradient
  17187. * @param gradient defines the gradient to remove
  17188. * @returns the current particle system
  17189. */
  17190. removeEmitRateGradient(gradient: number): IParticleSystem;
  17191. /**
  17192. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  17193. * @param gradient defines the gradient to use (between 0 and 1)
  17194. * @param factor defines the start size value to affect to the specified gradient
  17195. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17196. * @returns the current particle system
  17197. */
  17198. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17199. /**
  17200. * Remove a specific start size gradient
  17201. * @param gradient defines the gradient to remove
  17202. * @returns the current particle system
  17203. */
  17204. removeStartSizeGradient(gradient: number): IParticleSystem;
  17205. private _createRampGradientTexture;
  17206. /**
  17207. * Gets the current list of ramp gradients.
  17208. * You must use addRampGradient and removeRampGradient to udpate this list
  17209. * @returns the list of ramp gradients
  17210. */
  17211. getRampGradients(): Nullable<Array<Color3Gradient>>;
  17212. /**
  17213. * Adds a new ramp gradient used to remap particle colors
  17214. * @param gradient defines the gradient to use (between 0 and 1)
  17215. * @param color defines the color to affect to the specified gradient
  17216. * @returns the current particle system
  17217. */
  17218. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  17219. /**
  17220. * Remove a specific ramp gradient
  17221. * @param gradient defines the gradient to remove
  17222. * @returns the current particle system
  17223. */
  17224. removeRampGradient(gradient: number): ParticleSystem;
  17225. /**
  17226. * Adds a new color gradient
  17227. * @param gradient defines the gradient to use (between 0 and 1)
  17228. * @param color1 defines the color to affect to the specified gradient
  17229. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  17230. * @returns this particle system
  17231. */
  17232. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  17233. /**
  17234. * Remove a specific color gradient
  17235. * @param gradient defines the gradient to remove
  17236. * @returns this particle system
  17237. */
  17238. removeColorGradient(gradient: number): IParticleSystem;
  17239. private _fetchR;
  17240. protected _reset(): void;
  17241. private _resetEffect;
  17242. private _createVertexBuffers;
  17243. private _createIndexBuffer;
  17244. /**
  17245. * Gets the maximum number of particles active at the same time.
  17246. * @returns The max number of active particles.
  17247. */
  17248. getCapacity(): number;
  17249. /**
  17250. * Gets whether there are still active particles in the system.
  17251. * @returns True if it is alive, otherwise false.
  17252. */
  17253. isAlive(): boolean;
  17254. /**
  17255. * Gets if the system has been started. (Note: this will still be true after stop is called)
  17256. * @returns True if it has been started, otherwise false.
  17257. */
  17258. isStarted(): boolean;
  17259. private _prepareSubEmitterInternalArray;
  17260. /**
  17261. * Starts the particle system and begins to emit
  17262. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  17263. */
  17264. start(delay?: number): void;
  17265. /**
  17266. * Stops the particle system.
  17267. * @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.
  17268. */
  17269. stop(stopSubEmitters?: boolean): void;
  17270. /**
  17271. * Remove all active particles
  17272. */
  17273. reset(): void;
  17274. /**
  17275. * @hidden (for internal use only)
  17276. */
  17277. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  17278. /**
  17279. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  17280. * Its lifetime will start back at 0.
  17281. */
  17282. recycleParticle: (particle: Particle) => void;
  17283. private _stopSubEmitters;
  17284. private _createParticle;
  17285. private _removeFromRoot;
  17286. private _emitFromParticle;
  17287. private _update;
  17288. /** @hidden */
  17289. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  17290. /** @hidden */
  17291. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  17292. /** @hidden */
  17293. private _getEffect;
  17294. /**
  17295. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  17296. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  17297. */
  17298. animate(preWarmOnly?: boolean): void;
  17299. private _appendParticleVertices;
  17300. /**
  17301. * Rebuilds the particle system.
  17302. */
  17303. rebuild(): void;
  17304. /**
  17305. * Is this system ready to be used/rendered
  17306. * @return true if the system is ready
  17307. */
  17308. isReady(): boolean;
  17309. private _render;
  17310. /**
  17311. * Renders the particle system in its current state.
  17312. * @returns the current number of particles
  17313. */
  17314. render(): number;
  17315. /**
  17316. * Disposes the particle system and free the associated resources
  17317. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  17318. */
  17319. dispose(disposeTexture?: boolean): void;
  17320. /**
  17321. * Clones the particle system.
  17322. * @param name The name of the cloned object
  17323. * @param newEmitter The new emitter to use
  17324. * @returns the cloned particle system
  17325. */
  17326. clone(name: string, newEmitter: any): ParticleSystem;
  17327. /**
  17328. * Serializes the particle system to a JSON object.
  17329. * @returns the JSON object
  17330. */
  17331. serialize(): any;
  17332. /** @hidden */
  17333. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  17334. /** @hidden */
  17335. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  17336. /**
  17337. * Parses a JSON object to create a particle system.
  17338. * @param parsedParticleSystem The JSON object to parse
  17339. * @param scene The scene to create the particle system in
  17340. * @param rootUrl The root url to use to load external dependencies like texture
  17341. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  17342. * @returns the Parsed particle system
  17343. */
  17344. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  17345. }
  17346. }
  17347. declare module BABYLON {
  17348. /**
  17349. * A particle represents one of the element emitted by a particle system.
  17350. * This is mainly define by its coordinates, direction, velocity and age.
  17351. */
  17352. export class Particle {
  17353. /**
  17354. * The particle system the particle belongs to.
  17355. */
  17356. particleSystem: ParticleSystem;
  17357. private static _Count;
  17358. /**
  17359. * Unique ID of the particle
  17360. */
  17361. id: number;
  17362. /**
  17363. * The world position of the particle in the scene.
  17364. */
  17365. position: Vector3;
  17366. /**
  17367. * The world direction of the particle in the scene.
  17368. */
  17369. direction: Vector3;
  17370. /**
  17371. * The color of the particle.
  17372. */
  17373. color: Color4;
  17374. /**
  17375. * The color change of the particle per step.
  17376. */
  17377. colorStep: Color4;
  17378. /**
  17379. * Defines how long will the life of the particle be.
  17380. */
  17381. lifeTime: number;
  17382. /**
  17383. * The current age of the particle.
  17384. */
  17385. age: number;
  17386. /**
  17387. * The current size of the particle.
  17388. */
  17389. size: number;
  17390. /**
  17391. * The current scale of the particle.
  17392. */
  17393. scale: Vector2;
  17394. /**
  17395. * The current angle of the particle.
  17396. */
  17397. angle: number;
  17398. /**
  17399. * Defines how fast is the angle changing.
  17400. */
  17401. angularSpeed: number;
  17402. /**
  17403. * Defines the cell index used by the particle to be rendered from a sprite.
  17404. */
  17405. cellIndex: number;
  17406. /**
  17407. * The information required to support color remapping
  17408. */
  17409. remapData: Vector4;
  17410. /** @hidden */
  17411. _randomCellOffset?: number;
  17412. /** @hidden */
  17413. _initialDirection: Nullable<Vector3>;
  17414. /** @hidden */
  17415. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  17416. /** @hidden */
  17417. _initialStartSpriteCellID: number;
  17418. /** @hidden */
  17419. _initialEndSpriteCellID: number;
  17420. /** @hidden */
  17421. _currentColorGradient: Nullable<ColorGradient>;
  17422. /** @hidden */
  17423. _currentColor1: Color4;
  17424. /** @hidden */
  17425. _currentColor2: Color4;
  17426. /** @hidden */
  17427. _currentSizeGradient: Nullable<FactorGradient>;
  17428. /** @hidden */
  17429. _currentSize1: number;
  17430. /** @hidden */
  17431. _currentSize2: number;
  17432. /** @hidden */
  17433. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  17434. /** @hidden */
  17435. _currentAngularSpeed1: number;
  17436. /** @hidden */
  17437. _currentAngularSpeed2: number;
  17438. /** @hidden */
  17439. _currentVelocityGradient: Nullable<FactorGradient>;
  17440. /** @hidden */
  17441. _currentVelocity1: number;
  17442. /** @hidden */
  17443. _currentVelocity2: number;
  17444. /** @hidden */
  17445. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  17446. /** @hidden */
  17447. _currentLimitVelocity1: number;
  17448. /** @hidden */
  17449. _currentLimitVelocity2: number;
  17450. /** @hidden */
  17451. _currentDragGradient: Nullable<FactorGradient>;
  17452. /** @hidden */
  17453. _currentDrag1: number;
  17454. /** @hidden */
  17455. _currentDrag2: number;
  17456. /** @hidden */
  17457. _randomNoiseCoordinates1: Vector3;
  17458. /** @hidden */
  17459. _randomNoiseCoordinates2: Vector3;
  17460. /**
  17461. * Creates a new instance Particle
  17462. * @param particleSystem the particle system the particle belongs to
  17463. */
  17464. constructor(
  17465. /**
  17466. * The particle system the particle belongs to.
  17467. */
  17468. particleSystem: ParticleSystem);
  17469. private updateCellInfoFromSystem;
  17470. /**
  17471. * Defines how the sprite cell index is updated for the particle
  17472. */
  17473. updateCellIndex(): void;
  17474. /** @hidden */
  17475. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  17476. /** @hidden */
  17477. _inheritParticleInfoToSubEmitters(): void;
  17478. /** @hidden */
  17479. _reset(): void;
  17480. /**
  17481. * Copy the properties of particle to another one.
  17482. * @param other the particle to copy the information to.
  17483. */
  17484. copyTo(other: Particle): void;
  17485. }
  17486. }
  17487. declare module BABYLON {
  17488. /**
  17489. * Particle emitter represents a volume emitting particles.
  17490. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  17491. */
  17492. export interface IParticleEmitterType {
  17493. /**
  17494. * Called by the particle System when the direction is computed for the created particle.
  17495. * @param worldMatrix is the world matrix of the particle system
  17496. * @param directionToUpdate is the direction vector to update with the result
  17497. * @param particle is the particle we are computed the direction for
  17498. */
  17499. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17500. /**
  17501. * Called by the particle System when the position is computed for the created particle.
  17502. * @param worldMatrix is the world matrix of the particle system
  17503. * @param positionToUpdate is the position vector to update with the result
  17504. * @param particle is the particle we are computed the position for
  17505. */
  17506. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17507. /**
  17508. * Clones the current emitter and returns a copy of it
  17509. * @returns the new emitter
  17510. */
  17511. clone(): IParticleEmitterType;
  17512. /**
  17513. * Called by the GPUParticleSystem to setup the update shader
  17514. * @param effect defines the update shader
  17515. */
  17516. applyToShader(effect: Effect): void;
  17517. /**
  17518. * Returns a string to use to update the GPU particles update shader
  17519. * @returns the effect defines string
  17520. */
  17521. getEffectDefines(): string;
  17522. /**
  17523. * Returns a string representing the class name
  17524. * @returns a string containing the class name
  17525. */
  17526. getClassName(): string;
  17527. /**
  17528. * Serializes the particle system to a JSON object.
  17529. * @returns the JSON object
  17530. */
  17531. serialize(): any;
  17532. /**
  17533. * Parse properties from a JSON object
  17534. * @param serializationObject defines the JSON object
  17535. */
  17536. parse(serializationObject: any): void;
  17537. }
  17538. }
  17539. declare module BABYLON {
  17540. /**
  17541. * Particle emitter emitting particles from the inside of a box.
  17542. * It emits the particles randomly between 2 given directions.
  17543. */
  17544. export class BoxParticleEmitter implements IParticleEmitterType {
  17545. /**
  17546. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17547. */
  17548. direction1: Vector3;
  17549. /**
  17550. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17551. */
  17552. direction2: Vector3;
  17553. /**
  17554. * 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.
  17555. */
  17556. minEmitBox: Vector3;
  17557. /**
  17558. * 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.
  17559. */
  17560. maxEmitBox: Vector3;
  17561. /**
  17562. * Creates a new instance BoxParticleEmitter
  17563. */
  17564. constructor();
  17565. /**
  17566. * Called by the particle System when the direction is computed for the created particle.
  17567. * @param worldMatrix is the world matrix of the particle system
  17568. * @param directionToUpdate is the direction vector to update with the result
  17569. * @param particle is the particle we are computed the direction for
  17570. */
  17571. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17572. /**
  17573. * Called by the particle System when the position is computed for the created particle.
  17574. * @param worldMatrix is the world matrix of the particle system
  17575. * @param positionToUpdate is the position vector to update with the result
  17576. * @param particle is the particle we are computed the position for
  17577. */
  17578. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17579. /**
  17580. * Clones the current emitter and returns a copy of it
  17581. * @returns the new emitter
  17582. */
  17583. clone(): BoxParticleEmitter;
  17584. /**
  17585. * Called by the GPUParticleSystem to setup the update shader
  17586. * @param effect defines the update shader
  17587. */
  17588. applyToShader(effect: Effect): void;
  17589. /**
  17590. * Returns a string to use to update the GPU particles update shader
  17591. * @returns a string containng the defines string
  17592. */
  17593. getEffectDefines(): string;
  17594. /**
  17595. * Returns the string "BoxParticleEmitter"
  17596. * @returns a string containing the class name
  17597. */
  17598. getClassName(): string;
  17599. /**
  17600. * Serializes the particle system to a JSON object.
  17601. * @returns the JSON object
  17602. */
  17603. serialize(): any;
  17604. /**
  17605. * Parse properties from a JSON object
  17606. * @param serializationObject defines the JSON object
  17607. */
  17608. parse(serializationObject: any): void;
  17609. }
  17610. }
  17611. declare module BABYLON {
  17612. /**
  17613. * Particle emitter emitting particles from the inside of a cone.
  17614. * It emits the particles alongside the cone volume from the base to the particle.
  17615. * The emission direction might be randomized.
  17616. */
  17617. export class ConeParticleEmitter implements IParticleEmitterType {
  17618. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  17619. directionRandomizer: number;
  17620. private _radius;
  17621. private _angle;
  17622. private _height;
  17623. /**
  17624. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  17625. */
  17626. radiusRange: number;
  17627. /**
  17628. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  17629. */
  17630. heightRange: number;
  17631. /**
  17632. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  17633. */
  17634. emitFromSpawnPointOnly: boolean;
  17635. /**
  17636. * Gets or sets the radius of the emission cone
  17637. */
  17638. radius: number;
  17639. /**
  17640. * Gets or sets the angle of the emission cone
  17641. */
  17642. angle: number;
  17643. private _buildHeight;
  17644. /**
  17645. * Creates a new instance ConeParticleEmitter
  17646. * @param radius the radius of the emission cone (1 by default)
  17647. * @param angle the cone base angle (PI by default)
  17648. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  17649. */
  17650. constructor(radius?: number, angle?: number,
  17651. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  17652. directionRandomizer?: number);
  17653. /**
  17654. * Called by the particle System when the direction is computed for the created particle.
  17655. * @param worldMatrix is the world matrix of the particle system
  17656. * @param directionToUpdate is the direction vector to update with the result
  17657. * @param particle is the particle we are computed the direction for
  17658. */
  17659. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17660. /**
  17661. * Called by the particle System when the position is computed for the created particle.
  17662. * @param worldMatrix is the world matrix of the particle system
  17663. * @param positionToUpdate is the position vector to update with the result
  17664. * @param particle is the particle we are computed the position for
  17665. */
  17666. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17667. /**
  17668. * Clones the current emitter and returns a copy of it
  17669. * @returns the new emitter
  17670. */
  17671. clone(): ConeParticleEmitter;
  17672. /**
  17673. * Called by the GPUParticleSystem to setup the update shader
  17674. * @param effect defines the update shader
  17675. */
  17676. applyToShader(effect: Effect): void;
  17677. /**
  17678. * Returns a string to use to update the GPU particles update shader
  17679. * @returns a string containng the defines string
  17680. */
  17681. getEffectDefines(): string;
  17682. /**
  17683. * Returns the string "ConeParticleEmitter"
  17684. * @returns a string containing the class name
  17685. */
  17686. getClassName(): string;
  17687. /**
  17688. * Serializes the particle system to a JSON object.
  17689. * @returns the JSON object
  17690. */
  17691. serialize(): any;
  17692. /**
  17693. * Parse properties from a JSON object
  17694. * @param serializationObject defines the JSON object
  17695. */
  17696. parse(serializationObject: any): void;
  17697. }
  17698. }
  17699. declare module BABYLON {
  17700. /**
  17701. * Particle emitter emitting particles from the inside of a cylinder.
  17702. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  17703. */
  17704. export class CylinderParticleEmitter implements IParticleEmitterType {
  17705. /**
  17706. * The radius of the emission cylinder.
  17707. */
  17708. radius: number;
  17709. /**
  17710. * The height of the emission cylinder.
  17711. */
  17712. height: number;
  17713. /**
  17714. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17715. */
  17716. radiusRange: number;
  17717. /**
  17718. * How much to randomize the particle direction [0-1].
  17719. */
  17720. directionRandomizer: number;
  17721. /**
  17722. * Creates a new instance CylinderParticleEmitter
  17723. * @param radius the radius of the emission cylinder (1 by default)
  17724. * @param height the height of the emission cylinder (1 by default)
  17725. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17726. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  17727. */
  17728. constructor(
  17729. /**
  17730. * The radius of the emission cylinder.
  17731. */
  17732. radius?: number,
  17733. /**
  17734. * The height of the emission cylinder.
  17735. */
  17736. height?: number,
  17737. /**
  17738. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17739. */
  17740. radiusRange?: number,
  17741. /**
  17742. * How much to randomize the particle direction [0-1].
  17743. */
  17744. directionRandomizer?: number);
  17745. /**
  17746. * Called by the particle System when the direction is computed for the created particle.
  17747. * @param worldMatrix is the world matrix of the particle system
  17748. * @param directionToUpdate is the direction vector to update with the result
  17749. * @param particle is the particle we are computed the direction for
  17750. */
  17751. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17752. /**
  17753. * Called by the particle System when the position is computed for the created particle.
  17754. * @param worldMatrix is the world matrix of the particle system
  17755. * @param positionToUpdate is the position vector to update with the result
  17756. * @param particle is the particle we are computed the position for
  17757. */
  17758. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17759. /**
  17760. * Clones the current emitter and returns a copy of it
  17761. * @returns the new emitter
  17762. */
  17763. clone(): CylinderParticleEmitter;
  17764. /**
  17765. * Called by the GPUParticleSystem to setup the update shader
  17766. * @param effect defines the update shader
  17767. */
  17768. applyToShader(effect: Effect): void;
  17769. /**
  17770. * Returns a string to use to update the GPU particles update shader
  17771. * @returns a string containng the defines string
  17772. */
  17773. getEffectDefines(): string;
  17774. /**
  17775. * Returns the string "CylinderParticleEmitter"
  17776. * @returns a string containing the class name
  17777. */
  17778. getClassName(): string;
  17779. /**
  17780. * Serializes the particle system to a JSON object.
  17781. * @returns the JSON object
  17782. */
  17783. serialize(): any;
  17784. /**
  17785. * Parse properties from a JSON object
  17786. * @param serializationObject defines the JSON object
  17787. */
  17788. parse(serializationObject: any): void;
  17789. }
  17790. /**
  17791. * Particle emitter emitting particles from the inside of a cylinder.
  17792. * It emits the particles randomly between two vectors.
  17793. */
  17794. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  17795. /**
  17796. * The min limit of the emission direction.
  17797. */
  17798. direction1: Vector3;
  17799. /**
  17800. * The max limit of the emission direction.
  17801. */
  17802. direction2: Vector3;
  17803. /**
  17804. * Creates a new instance CylinderDirectedParticleEmitter
  17805. * @param radius the radius of the emission cylinder (1 by default)
  17806. * @param height the height of the emission cylinder (1 by default)
  17807. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17808. * @param direction1 the min limit of the emission direction (up vector by default)
  17809. * @param direction2 the max limit of the emission direction (up vector by default)
  17810. */
  17811. constructor(radius?: number, height?: number, radiusRange?: number,
  17812. /**
  17813. * The min limit of the emission direction.
  17814. */
  17815. direction1?: Vector3,
  17816. /**
  17817. * The max limit of the emission direction.
  17818. */
  17819. direction2?: Vector3);
  17820. /**
  17821. * Called by the particle System when the direction is computed for the created particle.
  17822. * @param worldMatrix is the world matrix of the particle system
  17823. * @param directionToUpdate is the direction vector to update with the result
  17824. * @param particle is the particle we are computed the direction for
  17825. */
  17826. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17827. /**
  17828. * Clones the current emitter and returns a copy of it
  17829. * @returns the new emitter
  17830. */
  17831. clone(): CylinderDirectedParticleEmitter;
  17832. /**
  17833. * Called by the GPUParticleSystem to setup the update shader
  17834. * @param effect defines the update shader
  17835. */
  17836. applyToShader(effect: Effect): void;
  17837. /**
  17838. * Returns a string to use to update the GPU particles update shader
  17839. * @returns a string containng the defines string
  17840. */
  17841. getEffectDefines(): string;
  17842. /**
  17843. * Returns the string "CylinderDirectedParticleEmitter"
  17844. * @returns a string containing the class name
  17845. */
  17846. getClassName(): string;
  17847. /**
  17848. * Serializes the particle system to a JSON object.
  17849. * @returns the JSON object
  17850. */
  17851. serialize(): any;
  17852. /**
  17853. * Parse properties from a JSON object
  17854. * @param serializationObject defines the JSON object
  17855. */
  17856. parse(serializationObject: any): void;
  17857. }
  17858. }
  17859. declare module BABYLON {
  17860. /**
  17861. * Particle emitter emitting particles from the inside of a hemisphere.
  17862. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  17863. */
  17864. export class HemisphericParticleEmitter implements IParticleEmitterType {
  17865. /**
  17866. * The radius of the emission hemisphere.
  17867. */
  17868. radius: number;
  17869. /**
  17870. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17871. */
  17872. radiusRange: number;
  17873. /**
  17874. * How much to randomize the particle direction [0-1].
  17875. */
  17876. directionRandomizer: number;
  17877. /**
  17878. * Creates a new instance HemisphericParticleEmitter
  17879. * @param radius the radius of the emission hemisphere (1 by default)
  17880. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17881. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  17882. */
  17883. constructor(
  17884. /**
  17885. * The radius of the emission hemisphere.
  17886. */
  17887. radius?: number,
  17888. /**
  17889. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17890. */
  17891. radiusRange?: number,
  17892. /**
  17893. * How much to randomize the particle direction [0-1].
  17894. */
  17895. directionRandomizer?: number);
  17896. /**
  17897. * Called by the particle System when the direction is computed for the created particle.
  17898. * @param worldMatrix is the world matrix of the particle system
  17899. * @param directionToUpdate is the direction vector to update with the result
  17900. * @param particle is the particle we are computed the direction for
  17901. */
  17902. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17903. /**
  17904. * Called by the particle System when the position is computed for the created particle.
  17905. * @param worldMatrix is the world matrix of the particle system
  17906. * @param positionToUpdate is the position vector to update with the result
  17907. * @param particle is the particle we are computed the position for
  17908. */
  17909. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17910. /**
  17911. * Clones the current emitter and returns a copy of it
  17912. * @returns the new emitter
  17913. */
  17914. clone(): HemisphericParticleEmitter;
  17915. /**
  17916. * Called by the GPUParticleSystem to setup the update shader
  17917. * @param effect defines the update shader
  17918. */
  17919. applyToShader(effect: Effect): void;
  17920. /**
  17921. * Returns a string to use to update the GPU particles update shader
  17922. * @returns a string containng the defines string
  17923. */
  17924. getEffectDefines(): string;
  17925. /**
  17926. * Returns the string "HemisphericParticleEmitter"
  17927. * @returns a string containing the class name
  17928. */
  17929. getClassName(): string;
  17930. /**
  17931. * Serializes the particle system to a JSON object.
  17932. * @returns the JSON object
  17933. */
  17934. serialize(): any;
  17935. /**
  17936. * Parse properties from a JSON object
  17937. * @param serializationObject defines the JSON object
  17938. */
  17939. parse(serializationObject: any): void;
  17940. }
  17941. }
  17942. declare module BABYLON {
  17943. /**
  17944. * Particle emitter emitting particles from a point.
  17945. * It emits the particles randomly between 2 given directions.
  17946. */
  17947. export class PointParticleEmitter implements IParticleEmitterType {
  17948. /**
  17949. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17950. */
  17951. direction1: Vector3;
  17952. /**
  17953. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17954. */
  17955. direction2: Vector3;
  17956. /**
  17957. * Creates a new instance PointParticleEmitter
  17958. */
  17959. constructor();
  17960. /**
  17961. * Called by the particle System when the direction is computed for the created particle.
  17962. * @param worldMatrix is the world matrix of the particle system
  17963. * @param directionToUpdate is the direction vector to update with the result
  17964. * @param particle is the particle we are computed the direction for
  17965. */
  17966. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17967. /**
  17968. * Called by the particle System when the position is computed for the created particle.
  17969. * @param worldMatrix is the world matrix of the particle system
  17970. * @param positionToUpdate is the position vector to update with the result
  17971. * @param particle is the particle we are computed the position for
  17972. */
  17973. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17974. /**
  17975. * Clones the current emitter and returns a copy of it
  17976. * @returns the new emitter
  17977. */
  17978. clone(): PointParticleEmitter;
  17979. /**
  17980. * Called by the GPUParticleSystem to setup the update shader
  17981. * @param effect defines the update shader
  17982. */
  17983. applyToShader(effect: Effect): void;
  17984. /**
  17985. * Returns a string to use to update the GPU particles update shader
  17986. * @returns a string containng the defines string
  17987. */
  17988. getEffectDefines(): string;
  17989. /**
  17990. * Returns the string "PointParticleEmitter"
  17991. * @returns a string containing the class name
  17992. */
  17993. getClassName(): string;
  17994. /**
  17995. * Serializes the particle system to a JSON object.
  17996. * @returns the JSON object
  17997. */
  17998. serialize(): any;
  17999. /**
  18000. * Parse properties from a JSON object
  18001. * @param serializationObject defines the JSON object
  18002. */
  18003. parse(serializationObject: any): void;
  18004. }
  18005. }
  18006. declare module BABYLON {
  18007. /**
  18008. * Particle emitter emitting particles from the inside of a sphere.
  18009. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  18010. */
  18011. export class SphereParticleEmitter implements IParticleEmitterType {
  18012. /**
  18013. * The radius of the emission sphere.
  18014. */
  18015. radius: number;
  18016. /**
  18017. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18018. */
  18019. radiusRange: number;
  18020. /**
  18021. * How much to randomize the particle direction [0-1].
  18022. */
  18023. directionRandomizer: number;
  18024. /**
  18025. * Creates a new instance SphereParticleEmitter
  18026. * @param radius the radius of the emission sphere (1 by default)
  18027. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18028. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18029. */
  18030. constructor(
  18031. /**
  18032. * The radius of the emission sphere.
  18033. */
  18034. radius?: number,
  18035. /**
  18036. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18037. */
  18038. radiusRange?: number,
  18039. /**
  18040. * How much to randomize the particle direction [0-1].
  18041. */
  18042. directionRandomizer?: number);
  18043. /**
  18044. * Called by the particle System when the direction is computed for the created particle.
  18045. * @param worldMatrix is the world matrix of the particle system
  18046. * @param directionToUpdate is the direction vector to update with the result
  18047. * @param particle is the particle we are computed the direction for
  18048. */
  18049. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18050. /**
  18051. * Called by the particle System when the position is computed for the created particle.
  18052. * @param worldMatrix is the world matrix of the particle system
  18053. * @param positionToUpdate is the position vector to update with the result
  18054. * @param particle is the particle we are computed the position for
  18055. */
  18056. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18057. /**
  18058. * Clones the current emitter and returns a copy of it
  18059. * @returns the new emitter
  18060. */
  18061. clone(): SphereParticleEmitter;
  18062. /**
  18063. * Called by the GPUParticleSystem to setup the update shader
  18064. * @param effect defines the update shader
  18065. */
  18066. applyToShader(effect: Effect): void;
  18067. /**
  18068. * Returns a string to use to update the GPU particles update shader
  18069. * @returns a string containng the defines string
  18070. */
  18071. getEffectDefines(): string;
  18072. /**
  18073. * Returns the string "SphereParticleEmitter"
  18074. * @returns a string containing the class name
  18075. */
  18076. getClassName(): string;
  18077. /**
  18078. * Serializes the particle system to a JSON object.
  18079. * @returns the JSON object
  18080. */
  18081. serialize(): any;
  18082. /**
  18083. * Parse properties from a JSON object
  18084. * @param serializationObject defines the JSON object
  18085. */
  18086. parse(serializationObject: any): void;
  18087. }
  18088. /**
  18089. * Particle emitter emitting particles from the inside of a sphere.
  18090. * It emits the particles randomly between two vectors.
  18091. */
  18092. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  18093. /**
  18094. * The min limit of the emission direction.
  18095. */
  18096. direction1: Vector3;
  18097. /**
  18098. * The max limit of the emission direction.
  18099. */
  18100. direction2: Vector3;
  18101. /**
  18102. * Creates a new instance SphereDirectedParticleEmitter
  18103. * @param radius the radius of the emission sphere (1 by default)
  18104. * @param direction1 the min limit of the emission direction (up vector by default)
  18105. * @param direction2 the max limit of the emission direction (up vector by default)
  18106. */
  18107. constructor(radius?: number,
  18108. /**
  18109. * The min limit of the emission direction.
  18110. */
  18111. direction1?: Vector3,
  18112. /**
  18113. * The max limit of the emission direction.
  18114. */
  18115. direction2?: Vector3);
  18116. /**
  18117. * Called by the particle System when the direction is computed for the created particle.
  18118. * @param worldMatrix is the world matrix of the particle system
  18119. * @param directionToUpdate is the direction vector to update with the result
  18120. * @param particle is the particle we are computed the direction for
  18121. */
  18122. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18123. /**
  18124. * Clones the current emitter and returns a copy of it
  18125. * @returns the new emitter
  18126. */
  18127. clone(): SphereDirectedParticleEmitter;
  18128. /**
  18129. * Called by the GPUParticleSystem to setup the update shader
  18130. * @param effect defines the update shader
  18131. */
  18132. applyToShader(effect: Effect): void;
  18133. /**
  18134. * Returns a string to use to update the GPU particles update shader
  18135. * @returns a string containng the defines string
  18136. */
  18137. getEffectDefines(): string;
  18138. /**
  18139. * Returns the string "SphereDirectedParticleEmitter"
  18140. * @returns a string containing the class name
  18141. */
  18142. getClassName(): string;
  18143. /**
  18144. * Serializes the particle system to a JSON object.
  18145. * @returns the JSON object
  18146. */
  18147. serialize(): any;
  18148. /**
  18149. * Parse properties from a JSON object
  18150. * @param serializationObject defines the JSON object
  18151. */
  18152. parse(serializationObject: any): void;
  18153. }
  18154. }
  18155. declare module BABYLON {
  18156. /**
  18157. * Interface representing a particle system in Babylon.js.
  18158. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  18159. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  18160. */
  18161. export interface IParticleSystem {
  18162. /**
  18163. * List of animations used by the particle system.
  18164. */
  18165. animations: Animation[];
  18166. /**
  18167. * The id of the Particle system.
  18168. */
  18169. id: string;
  18170. /**
  18171. * The name of the Particle system.
  18172. */
  18173. name: string;
  18174. /**
  18175. * The emitter represents the Mesh or position we are attaching the particle system to.
  18176. */
  18177. emitter: Nullable<AbstractMesh | Vector3>;
  18178. /**
  18179. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  18180. */
  18181. isBillboardBased: boolean;
  18182. /**
  18183. * The rendering group used by the Particle system to chose when to render.
  18184. */
  18185. renderingGroupId: number;
  18186. /**
  18187. * The layer mask we are rendering the particles through.
  18188. */
  18189. layerMask: number;
  18190. /**
  18191. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  18192. */
  18193. updateSpeed: number;
  18194. /**
  18195. * The amount of time the particle system is running (depends of the overall update speed).
  18196. */
  18197. targetStopDuration: number;
  18198. /**
  18199. * The texture used to render each particle. (this can be a spritesheet)
  18200. */
  18201. particleTexture: Nullable<Texture>;
  18202. /**
  18203. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  18204. */
  18205. blendMode: number;
  18206. /**
  18207. * Minimum life time of emitting particles.
  18208. */
  18209. minLifeTime: number;
  18210. /**
  18211. * Maximum life time of emitting particles.
  18212. */
  18213. maxLifeTime: number;
  18214. /**
  18215. * Minimum Size of emitting particles.
  18216. */
  18217. minSize: number;
  18218. /**
  18219. * Maximum Size of emitting particles.
  18220. */
  18221. maxSize: number;
  18222. /**
  18223. * Minimum scale of emitting particles on X axis.
  18224. */
  18225. minScaleX: number;
  18226. /**
  18227. * Maximum scale of emitting particles on X axis.
  18228. */
  18229. maxScaleX: number;
  18230. /**
  18231. * Minimum scale of emitting particles on Y axis.
  18232. */
  18233. minScaleY: number;
  18234. /**
  18235. * Maximum scale of emitting particles on Y axis.
  18236. */
  18237. maxScaleY: number;
  18238. /**
  18239. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18240. */
  18241. color1: Color4;
  18242. /**
  18243. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18244. */
  18245. color2: Color4;
  18246. /**
  18247. * Color the particle will have at the end of its lifetime.
  18248. */
  18249. colorDead: Color4;
  18250. /**
  18251. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  18252. */
  18253. emitRate: number;
  18254. /**
  18255. * You can use gravity if you want to give an orientation to your particles.
  18256. */
  18257. gravity: Vector3;
  18258. /**
  18259. * Minimum power of emitting particles.
  18260. */
  18261. minEmitPower: number;
  18262. /**
  18263. * Maximum power of emitting particles.
  18264. */
  18265. maxEmitPower: number;
  18266. /**
  18267. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  18268. */
  18269. minAngularSpeed: number;
  18270. /**
  18271. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  18272. */
  18273. maxAngularSpeed: number;
  18274. /**
  18275. * Gets or sets the minimal initial rotation in radians.
  18276. */
  18277. minInitialRotation: number;
  18278. /**
  18279. * Gets or sets the maximal initial rotation in radians.
  18280. */
  18281. maxInitialRotation: number;
  18282. /**
  18283. * The particle emitter type defines the emitter used by the particle system.
  18284. * It can be for example box, sphere, or cone...
  18285. */
  18286. particleEmitterType: Nullable<IParticleEmitterType>;
  18287. /**
  18288. * Defines the delay in milliseconds before starting the system (0 by default)
  18289. */
  18290. startDelay: number;
  18291. /**
  18292. * 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
  18293. */
  18294. preWarmCycles: number;
  18295. /**
  18296. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  18297. */
  18298. preWarmStepOffset: number;
  18299. /**
  18300. * 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)
  18301. */
  18302. spriteCellChangeSpeed: number;
  18303. /**
  18304. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  18305. */
  18306. startSpriteCellID: number;
  18307. /**
  18308. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  18309. */
  18310. endSpriteCellID: number;
  18311. /**
  18312. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  18313. */
  18314. spriteCellWidth: number;
  18315. /**
  18316. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  18317. */
  18318. spriteCellHeight: number;
  18319. /**
  18320. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  18321. */
  18322. spriteRandomStartCell: boolean;
  18323. /**
  18324. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  18325. */
  18326. isAnimationSheetEnabled: boolean;
  18327. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  18328. translationPivot: Vector2;
  18329. /**
  18330. * Gets or sets a texture used to add random noise to particle positions
  18331. */
  18332. noiseTexture: Nullable<BaseTexture>;
  18333. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  18334. noiseStrength: Vector3;
  18335. /**
  18336. * Gets or sets the billboard mode to use when isBillboardBased = true.
  18337. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  18338. */
  18339. billboardMode: number;
  18340. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  18341. limitVelocityDamping: number;
  18342. /**
  18343. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  18344. */
  18345. beginAnimationOnStart: boolean;
  18346. /**
  18347. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  18348. */
  18349. beginAnimationFrom: number;
  18350. /**
  18351. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  18352. */
  18353. beginAnimationTo: number;
  18354. /**
  18355. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  18356. */
  18357. beginAnimationLoop: boolean;
  18358. /**
  18359. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  18360. */
  18361. disposeOnStop: boolean;
  18362. /**
  18363. * Gets the maximum number of particles active at the same time.
  18364. * @returns The max number of active particles.
  18365. */
  18366. getCapacity(): number;
  18367. /**
  18368. * Gets if the system has been started. (Note: this will still be true after stop is called)
  18369. * @returns True if it has been started, otherwise false.
  18370. */
  18371. isStarted(): boolean;
  18372. /**
  18373. * Animates the particle system for this frame.
  18374. */
  18375. animate(): void;
  18376. /**
  18377. * Renders the particle system in its current state.
  18378. * @returns the current number of particles
  18379. */
  18380. render(): number;
  18381. /**
  18382. * Dispose the particle system and frees its associated resources.
  18383. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  18384. */
  18385. dispose(disposeTexture?: boolean): void;
  18386. /**
  18387. * Clones the particle system.
  18388. * @param name The name of the cloned object
  18389. * @param newEmitter The new emitter to use
  18390. * @returns the cloned particle system
  18391. */
  18392. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  18393. /**
  18394. * Serializes the particle system to a JSON object.
  18395. * @returns the JSON object
  18396. */
  18397. serialize(): any;
  18398. /**
  18399. * Rebuild the particle system
  18400. */
  18401. rebuild(): void;
  18402. /**
  18403. * Starts the particle system and begins to emit
  18404. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  18405. */
  18406. start(delay?: number): void;
  18407. /**
  18408. * Stops the particle system.
  18409. */
  18410. stop(): void;
  18411. /**
  18412. * Remove all active particles
  18413. */
  18414. reset(): void;
  18415. /**
  18416. * Is this system ready to be used/rendered
  18417. * @return true if the system is ready
  18418. */
  18419. isReady(): boolean;
  18420. /**
  18421. * Adds a new color gradient
  18422. * @param gradient defines the gradient to use (between 0 and 1)
  18423. * @param color1 defines the color to affect to the specified gradient
  18424. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  18425. * @returns the current particle system
  18426. */
  18427. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  18428. /**
  18429. * Remove a specific color gradient
  18430. * @param gradient defines the gradient to remove
  18431. * @returns the current particle system
  18432. */
  18433. removeColorGradient(gradient: number): IParticleSystem;
  18434. /**
  18435. * Adds a new size gradient
  18436. * @param gradient defines the gradient to use (between 0 and 1)
  18437. * @param factor defines the size factor to affect to the specified gradient
  18438. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18439. * @returns the current particle system
  18440. */
  18441. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18442. /**
  18443. * Remove a specific size gradient
  18444. * @param gradient defines the gradient to remove
  18445. * @returns the current particle system
  18446. */
  18447. removeSizeGradient(gradient: number): IParticleSystem;
  18448. /**
  18449. * Gets the current list of color gradients.
  18450. * You must use addColorGradient and removeColorGradient to udpate this list
  18451. * @returns the list of color gradients
  18452. */
  18453. getColorGradients(): Nullable<Array<ColorGradient>>;
  18454. /**
  18455. * Gets the current list of size gradients.
  18456. * You must use addSizeGradient and removeSizeGradient to udpate this list
  18457. * @returns the list of size gradients
  18458. */
  18459. getSizeGradients(): Nullable<Array<FactorGradient>>;
  18460. /**
  18461. * Gets the current list of angular speed gradients.
  18462. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  18463. * @returns the list of angular speed gradients
  18464. */
  18465. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  18466. /**
  18467. * Adds a new angular speed gradient
  18468. * @param gradient defines the gradient to use (between 0 and 1)
  18469. * @param factor defines the angular speed to affect to the specified gradient
  18470. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18471. * @returns the current particle system
  18472. */
  18473. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18474. /**
  18475. * Remove a specific angular speed gradient
  18476. * @param gradient defines the gradient to remove
  18477. * @returns the current particle system
  18478. */
  18479. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  18480. /**
  18481. * Gets the current list of velocity gradients.
  18482. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  18483. * @returns the list of velocity gradients
  18484. */
  18485. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  18486. /**
  18487. * Adds a new velocity gradient
  18488. * @param gradient defines the gradient to use (between 0 and 1)
  18489. * @param factor defines the velocity to affect to the specified gradient
  18490. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18491. * @returns the current particle system
  18492. */
  18493. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18494. /**
  18495. * Remove a specific velocity gradient
  18496. * @param gradient defines the gradient to remove
  18497. * @returns the current particle system
  18498. */
  18499. removeVelocityGradient(gradient: number): IParticleSystem;
  18500. /**
  18501. * Gets the current list of limit velocity gradients.
  18502. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  18503. * @returns the list of limit velocity gradients
  18504. */
  18505. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  18506. /**
  18507. * Adds a new limit velocity gradient
  18508. * @param gradient defines the gradient to use (between 0 and 1)
  18509. * @param factor defines the limit velocity to affect to the specified gradient
  18510. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18511. * @returns the current particle system
  18512. */
  18513. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18514. /**
  18515. * Remove a specific limit velocity gradient
  18516. * @param gradient defines the gradient to remove
  18517. * @returns the current particle system
  18518. */
  18519. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  18520. /**
  18521. * Adds a new drag gradient
  18522. * @param gradient defines the gradient to use (between 0 and 1)
  18523. * @param factor defines the drag to affect to the specified gradient
  18524. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18525. * @returns the current particle system
  18526. */
  18527. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18528. /**
  18529. * Remove a specific drag gradient
  18530. * @param gradient defines the gradient to remove
  18531. * @returns the current particle system
  18532. */
  18533. removeDragGradient(gradient: number): IParticleSystem;
  18534. /**
  18535. * Gets the current list of drag gradients.
  18536. * You must use addDragGradient and removeDragGradient to udpate this list
  18537. * @returns the list of drag gradients
  18538. */
  18539. getDragGradients(): Nullable<Array<FactorGradient>>;
  18540. /**
  18541. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  18542. * @param gradient defines the gradient to use (between 0 and 1)
  18543. * @param factor defines the emit rate to affect to the specified gradient
  18544. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18545. * @returns the current particle system
  18546. */
  18547. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18548. /**
  18549. * Remove a specific emit rate gradient
  18550. * @param gradient defines the gradient to remove
  18551. * @returns the current particle system
  18552. */
  18553. removeEmitRateGradient(gradient: number): IParticleSystem;
  18554. /**
  18555. * Gets the current list of emit rate gradients.
  18556. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  18557. * @returns the list of emit rate gradients
  18558. */
  18559. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  18560. /**
  18561. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  18562. * @param gradient defines the gradient to use (between 0 and 1)
  18563. * @param factor defines the start size to affect to the specified gradient
  18564. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18565. * @returns the current particle system
  18566. */
  18567. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18568. /**
  18569. * Remove a specific start size gradient
  18570. * @param gradient defines the gradient to remove
  18571. * @returns the current particle system
  18572. */
  18573. removeStartSizeGradient(gradient: number): IParticleSystem;
  18574. /**
  18575. * Gets the current list of start size gradients.
  18576. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  18577. * @returns the list of start size gradients
  18578. */
  18579. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  18580. /**
  18581. * Adds a new life time gradient
  18582. * @param gradient defines the gradient to use (between 0 and 1)
  18583. * @param factor defines the life time factor to affect to the specified gradient
  18584. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18585. * @returns the current particle system
  18586. */
  18587. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18588. /**
  18589. * Remove a specific life time gradient
  18590. * @param gradient defines the gradient to remove
  18591. * @returns the current particle system
  18592. */
  18593. removeLifeTimeGradient(gradient: number): IParticleSystem;
  18594. /**
  18595. * Gets the current list of life time gradients.
  18596. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  18597. * @returns the list of life time gradients
  18598. */
  18599. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  18600. /**
  18601. * Gets the current list of color gradients.
  18602. * You must use addColorGradient and removeColorGradient to udpate this list
  18603. * @returns the list of color gradients
  18604. */
  18605. getColorGradients(): Nullable<Array<ColorGradient>>;
  18606. /**
  18607. * Adds a new ramp gradient used to remap particle colors
  18608. * @param gradient defines the gradient to use (between 0 and 1)
  18609. * @param color defines the color to affect to the specified gradient
  18610. * @returns the current particle system
  18611. */
  18612. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  18613. /**
  18614. * Gets the current list of ramp gradients.
  18615. * You must use addRampGradient and removeRampGradient to udpate this list
  18616. * @returns the list of ramp gradients
  18617. */
  18618. getRampGradients(): Nullable<Array<Color3Gradient>>;
  18619. /** Gets or sets a boolean indicating that ramp gradients must be used
  18620. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  18621. */
  18622. useRampGradients: boolean;
  18623. /**
  18624. * Adds a new color remap gradient
  18625. * @param gradient defines the gradient to use (between 0 and 1)
  18626. * @param min defines the color remap minimal range
  18627. * @param max defines the color remap maximal range
  18628. * @returns the current particle system
  18629. */
  18630. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  18631. /**
  18632. * Gets the current list of color remap gradients.
  18633. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  18634. * @returns the list of color remap gradients
  18635. */
  18636. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  18637. /**
  18638. * Adds a new alpha remap gradient
  18639. * @param gradient defines the gradient to use (between 0 and 1)
  18640. * @param min defines the alpha remap minimal range
  18641. * @param max defines the alpha remap maximal range
  18642. * @returns the current particle system
  18643. */
  18644. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  18645. /**
  18646. * Gets the current list of alpha remap gradients.
  18647. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  18648. * @returns the list of alpha remap gradients
  18649. */
  18650. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  18651. /**
  18652. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  18653. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  18654. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  18655. * @returns the emitter
  18656. */
  18657. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  18658. /**
  18659. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  18660. * @param radius The radius of the hemisphere to emit from
  18661. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  18662. * @returns the emitter
  18663. */
  18664. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  18665. /**
  18666. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  18667. * @param radius The radius of the sphere to emit from
  18668. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  18669. * @returns the emitter
  18670. */
  18671. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  18672. /**
  18673. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  18674. * @param radius The radius of the sphere to emit from
  18675. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  18676. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  18677. * @returns the emitter
  18678. */
  18679. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  18680. /**
  18681. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  18682. * @param radius The radius of the emission cylinder
  18683. * @param height The height of the emission cylinder
  18684. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  18685. * @param directionRandomizer How much to randomize the particle direction [0-1]
  18686. * @returns the emitter
  18687. */
  18688. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  18689. /**
  18690. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  18691. * @param radius The radius of the cylinder to emit from
  18692. * @param height The height of the emission cylinder
  18693. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18694. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  18695. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  18696. * @returns the emitter
  18697. */
  18698. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  18699. /**
  18700. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  18701. * @param radius The radius of the cone to emit from
  18702. * @param angle The base angle of the cone
  18703. * @returns the emitter
  18704. */
  18705. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  18706. /**
  18707. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  18708. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  18709. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  18710. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  18711. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  18712. * @returns the emitter
  18713. */
  18714. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  18715. /**
  18716. * Get hosting scene
  18717. * @returns the scene
  18718. */
  18719. getScene(): Scene;
  18720. }
  18721. }
  18722. declare module BABYLON {
  18723. /**
  18724. * Defines the options associated with the creation of a shader material.
  18725. */
  18726. export interface IShaderMaterialOptions {
  18727. /**
  18728. * Does the material work in alpha blend mode
  18729. */
  18730. needAlphaBlending: boolean;
  18731. /**
  18732. * Does the material work in alpha test mode
  18733. */
  18734. needAlphaTesting: boolean;
  18735. /**
  18736. * The list of attribute names used in the shader
  18737. */
  18738. attributes: string[];
  18739. /**
  18740. * The list of unifrom names used in the shader
  18741. */
  18742. uniforms: string[];
  18743. /**
  18744. * The list of UBO names used in the shader
  18745. */
  18746. uniformBuffers: string[];
  18747. /**
  18748. * The list of sampler names used in the shader
  18749. */
  18750. samplers: string[];
  18751. /**
  18752. * The list of defines used in the shader
  18753. */
  18754. defines: string[];
  18755. }
  18756. /**
  18757. * 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.
  18758. *
  18759. * This returned material effects how the mesh will look based on the code in the shaders.
  18760. *
  18761. * @see http://doc.babylonjs.com/how_to/shader_material
  18762. */
  18763. export class ShaderMaterial extends Material {
  18764. private _shaderPath;
  18765. private _options;
  18766. private _textures;
  18767. private _textureArrays;
  18768. private _floats;
  18769. private _ints;
  18770. private _floatsArrays;
  18771. private _colors3;
  18772. private _colors3Arrays;
  18773. private _colors4;
  18774. private _colors4Arrays;
  18775. private _vectors2;
  18776. private _vectors3;
  18777. private _vectors4;
  18778. private _matrices;
  18779. private _matrices3x3;
  18780. private _matrices2x2;
  18781. private _vectors2Arrays;
  18782. private _vectors3Arrays;
  18783. private _vectors4Arrays;
  18784. private _cachedWorldViewMatrix;
  18785. private _cachedWorldViewProjectionMatrix;
  18786. private _renderId;
  18787. /**
  18788. * Instantiate a new shader material.
  18789. * 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.
  18790. * This returned material effects how the mesh will look based on the code in the shaders.
  18791. * @see http://doc.babylonjs.com/how_to/shader_material
  18792. * @param name Define the name of the material in the scene
  18793. * @param scene Define the scene the material belongs to
  18794. * @param shaderPath Defines the route to the shader code in one of three ways:
  18795. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  18796. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  18797. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  18798. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  18799. * @param options Define the options used to create the shader
  18800. */
  18801. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  18802. /**
  18803. * Gets the options used to compile the shader.
  18804. * They can be modified to trigger a new compilation
  18805. */
  18806. readonly options: IShaderMaterialOptions;
  18807. /**
  18808. * Gets the current class name of the material e.g. "ShaderMaterial"
  18809. * Mainly use in serialization.
  18810. * @returns the class name
  18811. */
  18812. getClassName(): string;
  18813. /**
  18814. * Specifies if the material will require alpha blending
  18815. * @returns a boolean specifying if alpha blending is needed
  18816. */
  18817. needAlphaBlending(): boolean;
  18818. /**
  18819. * Specifies if this material should be rendered in alpha test mode
  18820. * @returns a boolean specifying if an alpha test is needed.
  18821. */
  18822. needAlphaTesting(): boolean;
  18823. private _checkUniform;
  18824. /**
  18825. * Set a texture in the shader.
  18826. * @param name Define the name of the uniform samplers as defined in the shader
  18827. * @param texture Define the texture to bind to this sampler
  18828. * @return the material itself allowing "fluent" like uniform updates
  18829. */
  18830. setTexture(name: string, texture: Texture): ShaderMaterial;
  18831. /**
  18832. * Set a texture array in the shader.
  18833. * @param name Define the name of the uniform sampler array as defined in the shader
  18834. * @param textures Define the list of textures to bind to this sampler
  18835. * @return the material itself allowing "fluent" like uniform updates
  18836. */
  18837. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  18838. /**
  18839. * Set a float in the shader.
  18840. * @param name Define the name of the uniform as defined in the shader
  18841. * @param value Define the value to give to the uniform
  18842. * @return the material itself allowing "fluent" like uniform updates
  18843. */
  18844. setFloat(name: string, value: number): ShaderMaterial;
  18845. /**
  18846. * Set a int in the shader.
  18847. * @param name Define the name of the uniform as defined in the shader
  18848. * @param value Define the value to give to the uniform
  18849. * @return the material itself allowing "fluent" like uniform updates
  18850. */
  18851. setInt(name: string, value: number): ShaderMaterial;
  18852. /**
  18853. * Set an array of floats in the shader.
  18854. * @param name Define the name of the uniform as defined in the shader
  18855. * @param value Define the value to give to the uniform
  18856. * @return the material itself allowing "fluent" like uniform updates
  18857. */
  18858. setFloats(name: string, value: number[]): ShaderMaterial;
  18859. /**
  18860. * Set a vec3 in the shader from a Color3.
  18861. * @param name Define the name of the uniform as defined in the shader
  18862. * @param value Define the value to give to the uniform
  18863. * @return the material itself allowing "fluent" like uniform updates
  18864. */
  18865. setColor3(name: string, value: Color3): ShaderMaterial;
  18866. /**
  18867. * Set a vec3 array in the shader from a Color3 array.
  18868. * @param name Define the name of the uniform as defined in the shader
  18869. * @param value Define the value to give to the uniform
  18870. * @return the material itself allowing "fluent" like uniform updates
  18871. */
  18872. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  18873. /**
  18874. * Set a vec4 in the shader from a Color4.
  18875. * @param name Define the name of the uniform as defined in the shader
  18876. * @param value Define the value to give to the uniform
  18877. * @return the material itself allowing "fluent" like uniform updates
  18878. */
  18879. setColor4(name: string, value: Color4): ShaderMaterial;
  18880. /**
  18881. * Set a vec4 array in the shader from a Color4 array.
  18882. * @param name Define the name of the uniform as defined in the shader
  18883. * @param value Define the value to give to the uniform
  18884. * @return the material itself allowing "fluent" like uniform updates
  18885. */
  18886. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  18887. /**
  18888. * Set a vec2 in the shader from a Vector2.
  18889. * @param name Define the name of the uniform as defined in the shader
  18890. * @param value Define the value to give to the uniform
  18891. * @return the material itself allowing "fluent" like uniform updates
  18892. */
  18893. setVector2(name: string, value: Vector2): ShaderMaterial;
  18894. /**
  18895. * Set a vec3 in the shader from a Vector3.
  18896. * @param name Define the name of the uniform as defined in the shader
  18897. * @param value Define the value to give to the uniform
  18898. * @return the material itself allowing "fluent" like uniform updates
  18899. */
  18900. setVector3(name: string, value: Vector3): ShaderMaterial;
  18901. /**
  18902. * Set a vec4 in the shader from a Vector4.
  18903. * @param name Define the name of the uniform as defined in the shader
  18904. * @param value Define the value to give to the uniform
  18905. * @return the material itself allowing "fluent" like uniform updates
  18906. */
  18907. setVector4(name: string, value: Vector4): ShaderMaterial;
  18908. /**
  18909. * Set a mat4 in the shader from a Matrix.
  18910. * @param name Define the name of the uniform as defined in the shader
  18911. * @param value Define the value to give to the uniform
  18912. * @return the material itself allowing "fluent" like uniform updates
  18913. */
  18914. setMatrix(name: string, value: Matrix): ShaderMaterial;
  18915. /**
  18916. * Set a mat3 in the shader from a Float32Array.
  18917. * @param name Define the name of the uniform as defined in the shader
  18918. * @param value Define the value to give to the uniform
  18919. * @return the material itself allowing "fluent" like uniform updates
  18920. */
  18921. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  18922. /**
  18923. * Set a mat2 in the shader from a Float32Array.
  18924. * @param name Define the name of the uniform as defined in the shader
  18925. * @param value Define the value to give to the uniform
  18926. * @return the material itself allowing "fluent" like uniform updates
  18927. */
  18928. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  18929. /**
  18930. * Set a vec2 array in the shader from a number array.
  18931. * @param name Define the name of the uniform as defined in the shader
  18932. * @param value Define the value to give to the uniform
  18933. * @return the material itself allowing "fluent" like uniform updates
  18934. */
  18935. setArray2(name: string, value: number[]): ShaderMaterial;
  18936. /**
  18937. * Set a vec3 array in the shader from a number array.
  18938. * @param name Define the name of the uniform as defined in the shader
  18939. * @param value Define the value to give to the uniform
  18940. * @return the material itself allowing "fluent" like uniform updates
  18941. */
  18942. setArray3(name: string, value: number[]): ShaderMaterial;
  18943. /**
  18944. * Set a vec4 array in the shader from a number array.
  18945. * @param name Define the name of the uniform as defined in the shader
  18946. * @param value Define the value to give to the uniform
  18947. * @return the material itself allowing "fluent" like uniform updates
  18948. */
  18949. setArray4(name: string, value: number[]): ShaderMaterial;
  18950. private _checkCache;
  18951. /**
  18952. * Specifies that the submesh is ready to be used
  18953. * @param mesh defines the mesh to check
  18954. * @param subMesh defines which submesh to check
  18955. * @param useInstances specifies that instances should be used
  18956. * @returns a boolean indicating that the submesh is ready or not
  18957. */
  18958. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  18959. /**
  18960. * Checks if the material is ready to render the requested mesh
  18961. * @param mesh Define the mesh to render
  18962. * @param useInstances Define whether or not the material is used with instances
  18963. * @returns true if ready, otherwise false
  18964. */
  18965. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  18966. /**
  18967. * Binds the world matrix to the material
  18968. * @param world defines the world transformation matrix
  18969. */
  18970. bindOnlyWorldMatrix(world: Matrix): void;
  18971. /**
  18972. * Binds the material to the mesh
  18973. * @param world defines the world transformation matrix
  18974. * @param mesh defines the mesh to bind the material to
  18975. */
  18976. bind(world: Matrix, mesh?: Mesh): void;
  18977. /**
  18978. * Gets the active textures from the material
  18979. * @returns an array of textures
  18980. */
  18981. getActiveTextures(): BaseTexture[];
  18982. /**
  18983. * Specifies if the material uses a texture
  18984. * @param texture defines the texture to check against the material
  18985. * @returns a boolean specifying if the material uses the texture
  18986. */
  18987. hasTexture(texture: BaseTexture): boolean;
  18988. /**
  18989. * Makes a duplicate of the material, and gives it a new name
  18990. * @param name defines the new name for the duplicated material
  18991. * @returns the cloned material
  18992. */
  18993. clone(name: string): ShaderMaterial;
  18994. /**
  18995. * Disposes the material
  18996. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  18997. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  18998. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  18999. */
  19000. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  19001. /**
  19002. * Serializes this material in a JSON representation
  19003. * @returns the serialized material object
  19004. */
  19005. serialize(): any;
  19006. /**
  19007. * Creates a shader material from parsed shader material data
  19008. * @param source defines the JSON represnetation of the material
  19009. * @param scene defines the hosting scene
  19010. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  19011. * @returns a new material
  19012. */
  19013. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  19014. }
  19015. }
  19016. declare module BABYLON {
  19017. /** @hidden */
  19018. export var colorPixelShader: {
  19019. name: string;
  19020. shader: string;
  19021. };
  19022. }
  19023. declare module BABYLON {
  19024. /** @hidden */
  19025. export var colorVertexShader: {
  19026. name: string;
  19027. shader: string;
  19028. };
  19029. }
  19030. declare module BABYLON {
  19031. /**
  19032. * Line mesh
  19033. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  19034. */
  19035. export class LinesMesh extends Mesh {
  19036. /**
  19037. * If vertex color should be applied to the mesh
  19038. */
  19039. readonly useVertexColor?: boolean | undefined;
  19040. /**
  19041. * If vertex alpha should be applied to the mesh
  19042. */
  19043. readonly useVertexAlpha?: boolean | undefined;
  19044. /**
  19045. * Color of the line (Default: White)
  19046. */
  19047. color: Color3;
  19048. /**
  19049. * Alpha of the line (Default: 1)
  19050. */
  19051. alpha: number;
  19052. /**
  19053. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  19054. * This margin is expressed in world space coordinates, so its value may vary.
  19055. * Default value is 0.1
  19056. */
  19057. intersectionThreshold: number;
  19058. private _colorShader;
  19059. private color4;
  19060. /**
  19061. * Creates a new LinesMesh
  19062. * @param name defines the name
  19063. * @param scene defines the hosting scene
  19064. * @param parent defines the parent mesh if any
  19065. * @param source defines the optional source LinesMesh used to clone data from
  19066. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  19067. * When false, achieved by calling a clone(), also passing False.
  19068. * This will make creation of children, recursive.
  19069. * @param useVertexColor defines if this LinesMesh supports vertex color
  19070. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  19071. */
  19072. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  19073. /**
  19074. * If vertex color should be applied to the mesh
  19075. */
  19076. useVertexColor?: boolean | undefined,
  19077. /**
  19078. * If vertex alpha should be applied to the mesh
  19079. */
  19080. useVertexAlpha?: boolean | undefined);
  19081. private _addClipPlaneDefine;
  19082. private _removeClipPlaneDefine;
  19083. isReady(): boolean;
  19084. /**
  19085. * Returns the string "LineMesh"
  19086. */
  19087. getClassName(): string;
  19088. /**
  19089. * @hidden
  19090. */
  19091. /**
  19092. * @hidden
  19093. */
  19094. material: Material;
  19095. /**
  19096. * @hidden
  19097. */
  19098. readonly checkCollisions: boolean;
  19099. /** @hidden */
  19100. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  19101. /** @hidden */
  19102. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  19103. /**
  19104. * Disposes of the line mesh
  19105. * @param doNotRecurse If children should be disposed
  19106. */
  19107. dispose(doNotRecurse?: boolean): void;
  19108. /**
  19109. * Returns a new LineMesh object cloned from the current one.
  19110. */
  19111. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  19112. /**
  19113. * Creates a new InstancedLinesMesh object from the mesh model.
  19114. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  19115. * @param name defines the name of the new instance
  19116. * @returns a new InstancedLinesMesh
  19117. */
  19118. createInstance(name: string): InstancedLinesMesh;
  19119. }
  19120. /**
  19121. * Creates an instance based on a source LinesMesh
  19122. */
  19123. export class InstancedLinesMesh extends InstancedMesh {
  19124. /**
  19125. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  19126. * This margin is expressed in world space coordinates, so its value may vary.
  19127. * Initilized with the intersectionThreshold value of the source LinesMesh
  19128. */
  19129. intersectionThreshold: number;
  19130. constructor(name: string, source: LinesMesh);
  19131. /**
  19132. * Returns the string "InstancedLinesMesh".
  19133. */
  19134. getClassName(): string;
  19135. }
  19136. }
  19137. declare module BABYLON {
  19138. /** @hidden */
  19139. export var linePixelShader: {
  19140. name: string;
  19141. shader: string;
  19142. };
  19143. }
  19144. declare module BABYLON {
  19145. /** @hidden */
  19146. export var lineVertexShader: {
  19147. name: string;
  19148. shader: string;
  19149. };
  19150. }
  19151. declare module BABYLON {
  19152. interface AbstractMesh {
  19153. /**
  19154. * Gets the edgesRenderer associated with the mesh
  19155. */
  19156. edgesRenderer: Nullable<EdgesRenderer>;
  19157. }
  19158. interface LinesMesh {
  19159. /**
  19160. * Enables the edge rendering mode on the mesh.
  19161. * This mode makes the mesh edges visible
  19162. * @param epsilon defines the maximal distance between two angles to detect a face
  19163. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  19164. * @returns the currentAbstractMesh
  19165. * @see https://www.babylonjs-playground.com/#19O9TU#0
  19166. */
  19167. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  19168. }
  19169. interface InstancedLinesMesh {
  19170. /**
  19171. * Enables the edge rendering mode on the mesh.
  19172. * This mode makes the mesh edges visible
  19173. * @param epsilon defines the maximal distance between two angles to detect a face
  19174. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  19175. * @returns the current InstancedLinesMesh
  19176. * @see https://www.babylonjs-playground.com/#19O9TU#0
  19177. */
  19178. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  19179. }
  19180. /**
  19181. * Defines the minimum contract an Edges renderer should follow.
  19182. */
  19183. export interface IEdgesRenderer extends IDisposable {
  19184. /**
  19185. * Gets or sets a boolean indicating if the edgesRenderer is active
  19186. */
  19187. isEnabled: boolean;
  19188. /**
  19189. * Renders the edges of the attached mesh,
  19190. */
  19191. render(): void;
  19192. /**
  19193. * Checks wether or not the edges renderer is ready to render.
  19194. * @return true if ready, otherwise false.
  19195. */
  19196. isReady(): boolean;
  19197. }
  19198. /**
  19199. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  19200. */
  19201. export class EdgesRenderer implements IEdgesRenderer {
  19202. /**
  19203. * Define the size of the edges with an orthographic camera
  19204. */
  19205. edgesWidthScalerForOrthographic: number;
  19206. /**
  19207. * Define the size of the edges with a perspective camera
  19208. */
  19209. edgesWidthScalerForPerspective: number;
  19210. protected _source: AbstractMesh;
  19211. protected _linesPositions: number[];
  19212. protected _linesNormals: number[];
  19213. protected _linesIndices: number[];
  19214. protected _epsilon: number;
  19215. protected _indicesCount: number;
  19216. protected _lineShader: ShaderMaterial;
  19217. protected _ib: DataBuffer;
  19218. protected _buffers: {
  19219. [key: string]: Nullable<VertexBuffer>;
  19220. };
  19221. protected _checkVerticesInsteadOfIndices: boolean;
  19222. private _meshRebuildObserver;
  19223. private _meshDisposeObserver;
  19224. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  19225. isEnabled: boolean;
  19226. /**
  19227. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  19228. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  19229. * @param source Mesh used to create edges
  19230. * @param epsilon sum of angles in adjacency to check for edge
  19231. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  19232. * @param generateEdgesLines - should generate Lines or only prepare resources.
  19233. */
  19234. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  19235. protected _prepareRessources(): void;
  19236. /** @hidden */
  19237. _rebuild(): void;
  19238. /**
  19239. * Releases the required resources for the edges renderer
  19240. */
  19241. dispose(): void;
  19242. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  19243. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  19244. /**
  19245. * Checks if the pair of p0 and p1 is en edge
  19246. * @param faceIndex
  19247. * @param edge
  19248. * @param faceNormals
  19249. * @param p0
  19250. * @param p1
  19251. * @private
  19252. */
  19253. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  19254. /**
  19255. * push line into the position, normal and index buffer
  19256. * @protected
  19257. */
  19258. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  19259. /**
  19260. * Generates lines edges from adjacencjes
  19261. * @private
  19262. */
  19263. _generateEdgesLines(): void;
  19264. /**
  19265. * Checks wether or not the edges renderer is ready to render.
  19266. * @return true if ready, otherwise false.
  19267. */
  19268. isReady(): boolean;
  19269. /**
  19270. * Renders the edges of the attached mesh,
  19271. */
  19272. render(): void;
  19273. }
  19274. /**
  19275. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  19276. */
  19277. export class LineEdgesRenderer extends EdgesRenderer {
  19278. /**
  19279. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  19280. * @param source LineMesh used to generate edges
  19281. * @param epsilon not important (specified angle for edge detection)
  19282. * @param checkVerticesInsteadOfIndices not important for LineMesh
  19283. */
  19284. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  19285. /**
  19286. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  19287. */
  19288. _generateEdgesLines(): void;
  19289. }
  19290. }
  19291. declare module BABYLON {
  19292. /**
  19293. * This represents the object necessary to create a rendering group.
  19294. * This is exclusively used and created by the rendering manager.
  19295. * To modify the behavior, you use the available helpers in your scene or meshes.
  19296. * @hidden
  19297. */
  19298. export class RenderingGroup {
  19299. index: number;
  19300. private static _zeroVector;
  19301. private _scene;
  19302. private _opaqueSubMeshes;
  19303. private _transparentSubMeshes;
  19304. private _alphaTestSubMeshes;
  19305. private _depthOnlySubMeshes;
  19306. private _particleSystems;
  19307. private _spriteManagers;
  19308. private _opaqueSortCompareFn;
  19309. private _alphaTestSortCompareFn;
  19310. private _transparentSortCompareFn;
  19311. private _renderOpaque;
  19312. private _renderAlphaTest;
  19313. private _renderTransparent;
  19314. /** @hidden */
  19315. _edgesRenderers: SmartArray<IEdgesRenderer>;
  19316. onBeforeTransparentRendering: () => void;
  19317. /**
  19318. * Set the opaque sort comparison function.
  19319. * If null the sub meshes will be render in the order they were created
  19320. */
  19321. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19322. /**
  19323. * Set the alpha test sort comparison function.
  19324. * If null the sub meshes will be render in the order they were created
  19325. */
  19326. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19327. /**
  19328. * Set the transparent sort comparison function.
  19329. * If null the sub meshes will be render in the order they were created
  19330. */
  19331. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19332. /**
  19333. * Creates a new rendering group.
  19334. * @param index The rendering group index
  19335. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  19336. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  19337. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  19338. */
  19339. 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>);
  19340. /**
  19341. * Render all the sub meshes contained in the group.
  19342. * @param customRenderFunction Used to override the default render behaviour of the group.
  19343. * @returns true if rendered some submeshes.
  19344. */
  19345. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  19346. /**
  19347. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  19348. * @param subMeshes The submeshes to render
  19349. */
  19350. private renderOpaqueSorted;
  19351. /**
  19352. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  19353. * @param subMeshes The submeshes to render
  19354. */
  19355. private renderAlphaTestSorted;
  19356. /**
  19357. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  19358. * @param subMeshes The submeshes to render
  19359. */
  19360. private renderTransparentSorted;
  19361. /**
  19362. * Renders the submeshes in a specified order.
  19363. * @param subMeshes The submeshes to sort before render
  19364. * @param sortCompareFn The comparison function use to sort
  19365. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  19366. * @param transparent Specifies to activate blending if true
  19367. */
  19368. private static renderSorted;
  19369. /**
  19370. * Renders the submeshes in the order they were dispatched (no sort applied).
  19371. * @param subMeshes The submeshes to render
  19372. */
  19373. private static renderUnsorted;
  19374. /**
  19375. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19376. * are rendered back to front if in the same alpha index.
  19377. *
  19378. * @param a The first submesh
  19379. * @param b The second submesh
  19380. * @returns The result of the comparison
  19381. */
  19382. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  19383. /**
  19384. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19385. * are rendered back to front.
  19386. *
  19387. * @param a The first submesh
  19388. * @param b The second submesh
  19389. * @returns The result of the comparison
  19390. */
  19391. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  19392. /**
  19393. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19394. * are rendered front to back (prevent overdraw).
  19395. *
  19396. * @param a The first submesh
  19397. * @param b The second submesh
  19398. * @returns The result of the comparison
  19399. */
  19400. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  19401. /**
  19402. * Resets the different lists of submeshes to prepare a new frame.
  19403. */
  19404. prepare(): void;
  19405. dispose(): void;
  19406. /**
  19407. * Inserts the submesh in its correct queue depending on its material.
  19408. * @param subMesh The submesh to dispatch
  19409. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  19410. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  19411. */
  19412. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  19413. dispatchSprites(spriteManager: ISpriteManager): void;
  19414. dispatchParticles(particleSystem: IParticleSystem): void;
  19415. private _renderParticles;
  19416. private _renderSprites;
  19417. }
  19418. }
  19419. declare module BABYLON {
  19420. /**
  19421. * Interface describing the different options available in the rendering manager
  19422. * regarding Auto Clear between groups.
  19423. */
  19424. export interface IRenderingManagerAutoClearSetup {
  19425. /**
  19426. * Defines whether or not autoclear is enable.
  19427. */
  19428. autoClear: boolean;
  19429. /**
  19430. * Defines whether or not to autoclear the depth buffer.
  19431. */
  19432. depth: boolean;
  19433. /**
  19434. * Defines whether or not to autoclear the stencil buffer.
  19435. */
  19436. stencil: boolean;
  19437. }
  19438. /**
  19439. * This class is used by the onRenderingGroupObservable
  19440. */
  19441. export class RenderingGroupInfo {
  19442. /**
  19443. * The Scene that being rendered
  19444. */
  19445. scene: Scene;
  19446. /**
  19447. * The camera currently used for the rendering pass
  19448. */
  19449. camera: Nullable<Camera>;
  19450. /**
  19451. * The ID of the renderingGroup being processed
  19452. */
  19453. renderingGroupId: number;
  19454. }
  19455. /**
  19456. * This is the manager responsible of all the rendering for meshes sprites and particles.
  19457. * It is enable to manage the different groups as well as the different necessary sort functions.
  19458. * This should not be used directly aside of the few static configurations
  19459. */
  19460. export class RenderingManager {
  19461. /**
  19462. * The max id used for rendering groups (not included)
  19463. */
  19464. static MAX_RENDERINGGROUPS: number;
  19465. /**
  19466. * The min id used for rendering groups (included)
  19467. */
  19468. static MIN_RENDERINGGROUPS: number;
  19469. /**
  19470. * Used to globally prevent autoclearing scenes.
  19471. */
  19472. static AUTOCLEAR: boolean;
  19473. /**
  19474. * @hidden
  19475. */
  19476. _useSceneAutoClearSetup: boolean;
  19477. private _scene;
  19478. private _renderingGroups;
  19479. private _depthStencilBufferAlreadyCleaned;
  19480. private _autoClearDepthStencil;
  19481. private _customOpaqueSortCompareFn;
  19482. private _customAlphaTestSortCompareFn;
  19483. private _customTransparentSortCompareFn;
  19484. private _renderingGroupInfo;
  19485. /**
  19486. * Instantiates a new rendering group for a particular scene
  19487. * @param scene Defines the scene the groups belongs to
  19488. */
  19489. constructor(scene: Scene);
  19490. private _clearDepthStencilBuffer;
  19491. /**
  19492. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  19493. * @hidden
  19494. */
  19495. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  19496. /**
  19497. * Resets the different information of the group to prepare a new frame
  19498. * @hidden
  19499. */
  19500. reset(): void;
  19501. /**
  19502. * Dispose and release the group and its associated resources.
  19503. * @hidden
  19504. */
  19505. dispose(): void;
  19506. /**
  19507. * Clear the info related to rendering groups preventing retention points during dispose.
  19508. */
  19509. freeRenderingGroups(): void;
  19510. private _prepareRenderingGroup;
  19511. /**
  19512. * Add a sprite manager to the rendering manager in order to render it this frame.
  19513. * @param spriteManager Define the sprite manager to render
  19514. */
  19515. dispatchSprites(spriteManager: ISpriteManager): void;
  19516. /**
  19517. * Add a particle system to the rendering manager in order to render it this frame.
  19518. * @param particleSystem Define the particle system to render
  19519. */
  19520. dispatchParticles(particleSystem: IParticleSystem): void;
  19521. /**
  19522. * Add a submesh to the manager in order to render it this frame
  19523. * @param subMesh The submesh to dispatch
  19524. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  19525. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  19526. */
  19527. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  19528. /**
  19529. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  19530. * This allowed control for front to back rendering or reversly depending of the special needs.
  19531. *
  19532. * @param renderingGroupId The rendering group id corresponding to its index
  19533. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  19534. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  19535. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  19536. */
  19537. 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;
  19538. /**
  19539. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  19540. *
  19541. * @param renderingGroupId The rendering group id corresponding to its index
  19542. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  19543. * @param depth Automatically clears depth between groups if true and autoClear is true.
  19544. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  19545. */
  19546. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  19547. /**
  19548. * Gets the current auto clear configuration for one rendering group of the rendering
  19549. * manager.
  19550. * @param index the rendering group index to get the information for
  19551. * @returns The auto clear setup for the requested rendering group
  19552. */
  19553. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  19554. }
  19555. }
  19556. declare module BABYLON {
  19557. /**
  19558. * This Helps creating a texture that will be created from a camera in your scene.
  19559. * It is basically a dynamic texture that could be used to create special effects for instance.
  19560. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  19561. */
  19562. export class RenderTargetTexture extends Texture {
  19563. isCube: boolean;
  19564. /**
  19565. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  19566. */
  19567. static readonly REFRESHRATE_RENDER_ONCE: number;
  19568. /**
  19569. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  19570. */
  19571. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  19572. /**
  19573. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  19574. * the central point of your effect and can save a lot of performances.
  19575. */
  19576. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  19577. /**
  19578. * Use this predicate to dynamically define the list of mesh you want to render.
  19579. * If set, the renderList property will be overwritten.
  19580. */
  19581. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  19582. private _renderList;
  19583. /**
  19584. * Use this list to define the list of mesh you want to render.
  19585. */
  19586. renderList: Nullable<Array<AbstractMesh>>;
  19587. private _hookArray;
  19588. /**
  19589. * Define if particles should be rendered in your texture.
  19590. */
  19591. renderParticles: boolean;
  19592. /**
  19593. * Define if sprites should be rendered in your texture.
  19594. */
  19595. renderSprites: boolean;
  19596. /**
  19597. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  19598. */
  19599. coordinatesMode: number;
  19600. /**
  19601. * Define the camera used to render the texture.
  19602. */
  19603. activeCamera: Nullable<Camera>;
  19604. /**
  19605. * Override the render function of the texture with your own one.
  19606. */
  19607. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  19608. /**
  19609. * Define if camera post processes should be use while rendering the texture.
  19610. */
  19611. useCameraPostProcesses: boolean;
  19612. /**
  19613. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  19614. */
  19615. ignoreCameraViewport: boolean;
  19616. private _postProcessManager;
  19617. private _postProcesses;
  19618. private _resizeObserver;
  19619. /**
  19620. * An event triggered when the texture is unbind.
  19621. */
  19622. onBeforeBindObservable: Observable<RenderTargetTexture>;
  19623. /**
  19624. * An event triggered when the texture is unbind.
  19625. */
  19626. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  19627. private _onAfterUnbindObserver;
  19628. /**
  19629. * Set a after unbind callback in the texture.
  19630. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  19631. */
  19632. onAfterUnbind: () => void;
  19633. /**
  19634. * An event triggered before rendering the texture
  19635. */
  19636. onBeforeRenderObservable: Observable<number>;
  19637. private _onBeforeRenderObserver;
  19638. /**
  19639. * Set a before render callback in the texture.
  19640. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  19641. */
  19642. onBeforeRender: (faceIndex: number) => void;
  19643. /**
  19644. * An event triggered after rendering the texture
  19645. */
  19646. onAfterRenderObservable: Observable<number>;
  19647. private _onAfterRenderObserver;
  19648. /**
  19649. * Set a after render callback in the texture.
  19650. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  19651. */
  19652. onAfterRender: (faceIndex: number) => void;
  19653. /**
  19654. * An event triggered after the texture clear
  19655. */
  19656. onClearObservable: Observable<Engine>;
  19657. private _onClearObserver;
  19658. /**
  19659. * Set a clear callback in the texture.
  19660. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  19661. */
  19662. onClear: (Engine: Engine) => void;
  19663. /**
  19664. * An event triggered when the texture is resized.
  19665. */
  19666. onResizeObservable: Observable<RenderTargetTexture>;
  19667. /**
  19668. * Define the clear color of the Render Target if it should be different from the scene.
  19669. */
  19670. clearColor: Color4;
  19671. protected _size: number | {
  19672. width: number;
  19673. height: number;
  19674. };
  19675. protected _initialSizeParameter: number | {
  19676. width: number;
  19677. height: number;
  19678. } | {
  19679. ratio: number;
  19680. };
  19681. protected _sizeRatio: Nullable<number>;
  19682. /** @hidden */
  19683. _generateMipMaps: boolean;
  19684. protected _renderingManager: RenderingManager;
  19685. /** @hidden */
  19686. _waitingRenderList: string[];
  19687. protected _doNotChangeAspectRatio: boolean;
  19688. protected _currentRefreshId: number;
  19689. protected _refreshRate: number;
  19690. protected _textureMatrix: Matrix;
  19691. protected _samples: number;
  19692. protected _renderTargetOptions: RenderTargetCreationOptions;
  19693. /**
  19694. * Gets render target creation options that were used.
  19695. */
  19696. readonly renderTargetOptions: RenderTargetCreationOptions;
  19697. protected _engine: Engine;
  19698. protected _onRatioRescale(): void;
  19699. /**
  19700. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  19701. * It must define where the camera used to render the texture is set
  19702. */
  19703. boundingBoxPosition: Vector3;
  19704. private _boundingBoxSize;
  19705. /**
  19706. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  19707. * When defined, the cubemap will switch to local mode
  19708. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  19709. * @example https://www.babylonjs-playground.com/#RNASML
  19710. */
  19711. boundingBoxSize: Vector3;
  19712. /**
  19713. * In case the RTT has been created with a depth texture, get the associated
  19714. * depth texture.
  19715. * Otherwise, return null.
  19716. */
  19717. depthStencilTexture: Nullable<InternalTexture>;
  19718. /**
  19719. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  19720. * or used a shadow, depth texture...
  19721. * @param name The friendly name of the texture
  19722. * @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)
  19723. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  19724. * @param generateMipMaps True if mip maps need to be generated after render.
  19725. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  19726. * @param type The type of the buffer in the RTT (int, half float, float...)
  19727. * @param isCube True if a cube texture needs to be created
  19728. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  19729. * @param generateDepthBuffer True to generate a depth buffer
  19730. * @param generateStencilBuffer True to generate a stencil buffer
  19731. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  19732. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  19733. * @param delayAllocation if the texture allocation should be delayed (default: false)
  19734. */
  19735. constructor(name: string, size: number | {
  19736. width: number;
  19737. height: number;
  19738. } | {
  19739. ratio: number;
  19740. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  19741. /**
  19742. * Creates a depth stencil texture.
  19743. * This is only available in WebGL 2 or with the depth texture extension available.
  19744. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  19745. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  19746. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  19747. */
  19748. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  19749. private _processSizeParameter;
  19750. /**
  19751. * Define the number of samples to use in case of MSAA.
  19752. * It defaults to one meaning no MSAA has been enabled.
  19753. */
  19754. samples: number;
  19755. /**
  19756. * Resets the refresh counter of the texture and start bak from scratch.
  19757. * Could be useful to regenerate the texture if it is setup to render only once.
  19758. */
  19759. resetRefreshCounter(): void;
  19760. /**
  19761. * Define the refresh rate of the texture or the rendering frequency.
  19762. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  19763. */
  19764. refreshRate: number;
  19765. /**
  19766. * Adds a post process to the render target rendering passes.
  19767. * @param postProcess define the post process to add
  19768. */
  19769. addPostProcess(postProcess: PostProcess): void;
  19770. /**
  19771. * Clear all the post processes attached to the render target
  19772. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  19773. */
  19774. clearPostProcesses(dispose?: boolean): void;
  19775. /**
  19776. * Remove one of the post process from the list of attached post processes to the texture
  19777. * @param postProcess define the post process to remove from the list
  19778. */
  19779. removePostProcess(postProcess: PostProcess): void;
  19780. /** @hidden */
  19781. _shouldRender(): boolean;
  19782. /**
  19783. * Gets the actual render size of the texture.
  19784. * @returns the width of the render size
  19785. */
  19786. getRenderSize(): number;
  19787. /**
  19788. * Gets the actual render width of the texture.
  19789. * @returns the width of the render size
  19790. */
  19791. getRenderWidth(): number;
  19792. /**
  19793. * Gets the actual render height of the texture.
  19794. * @returns the height of the render size
  19795. */
  19796. getRenderHeight(): number;
  19797. /**
  19798. * Get if the texture can be rescaled or not.
  19799. */
  19800. readonly canRescale: boolean;
  19801. /**
  19802. * Resize the texture using a ratio.
  19803. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  19804. */
  19805. scale(ratio: number): void;
  19806. /**
  19807. * Get the texture reflection matrix used to rotate/transform the reflection.
  19808. * @returns the reflection matrix
  19809. */
  19810. getReflectionTextureMatrix(): Matrix;
  19811. /**
  19812. * Resize the texture to a new desired size.
  19813. * Be carrefull as it will recreate all the data in the new texture.
  19814. * @param size Define the new size. It can be:
  19815. * - a number for squared texture,
  19816. * - an object containing { width: number, height: number }
  19817. * - or an object containing a ratio { ratio: number }
  19818. */
  19819. resize(size: number | {
  19820. width: number;
  19821. height: number;
  19822. } | {
  19823. ratio: number;
  19824. }): void;
  19825. /**
  19826. * Renders all the objects from the render list into the texture.
  19827. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  19828. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  19829. */
  19830. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  19831. private _bestReflectionRenderTargetDimension;
  19832. /**
  19833. * @hidden
  19834. * @param faceIndex face index to bind to if this is a cubetexture
  19835. */
  19836. _bindFrameBuffer(faceIndex?: number): void;
  19837. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  19838. private renderToTarget;
  19839. /**
  19840. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  19841. * This allowed control for front to back rendering or reversly depending of the special needs.
  19842. *
  19843. * @param renderingGroupId The rendering group id corresponding to its index
  19844. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  19845. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  19846. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  19847. */
  19848. 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;
  19849. /**
  19850. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  19851. *
  19852. * @param renderingGroupId The rendering group id corresponding to its index
  19853. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  19854. */
  19855. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  19856. /**
  19857. * Clones the texture.
  19858. * @returns the cloned texture
  19859. */
  19860. clone(): RenderTargetTexture;
  19861. /**
  19862. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  19863. * @returns The JSON representation of the texture
  19864. */
  19865. serialize(): any;
  19866. /**
  19867. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  19868. */
  19869. disposeFramebufferObjects(): void;
  19870. /**
  19871. * Dispose the texture and release its associated resources.
  19872. */
  19873. dispose(): void;
  19874. /** @hidden */
  19875. _rebuild(): void;
  19876. /**
  19877. * Clear the info related to rendering groups preventing retention point in material dispose.
  19878. */
  19879. freeRenderingGroups(): void;
  19880. /**
  19881. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  19882. * @returns the view count
  19883. */
  19884. getViewCount(): number;
  19885. }
  19886. }
  19887. declare module BABYLON {
  19888. /**
  19889. * Base class for the main features of a material in Babylon.js
  19890. */
  19891. export class Material implements IAnimatable {
  19892. /**
  19893. * Returns the triangle fill mode
  19894. */
  19895. static readonly TriangleFillMode: number;
  19896. /**
  19897. * Returns the wireframe mode
  19898. */
  19899. static readonly WireFrameFillMode: number;
  19900. /**
  19901. * Returns the point fill mode
  19902. */
  19903. static readonly PointFillMode: number;
  19904. /**
  19905. * Returns the point list draw mode
  19906. */
  19907. static readonly PointListDrawMode: number;
  19908. /**
  19909. * Returns the line list draw mode
  19910. */
  19911. static readonly LineListDrawMode: number;
  19912. /**
  19913. * Returns the line loop draw mode
  19914. */
  19915. static readonly LineLoopDrawMode: number;
  19916. /**
  19917. * Returns the line strip draw mode
  19918. */
  19919. static readonly LineStripDrawMode: number;
  19920. /**
  19921. * Returns the triangle strip draw mode
  19922. */
  19923. static readonly TriangleStripDrawMode: number;
  19924. /**
  19925. * Returns the triangle fan draw mode
  19926. */
  19927. static readonly TriangleFanDrawMode: number;
  19928. /**
  19929. * Stores the clock-wise side orientation
  19930. */
  19931. static readonly ClockWiseSideOrientation: number;
  19932. /**
  19933. * Stores the counter clock-wise side orientation
  19934. */
  19935. static readonly CounterClockWiseSideOrientation: number;
  19936. /**
  19937. * The dirty texture flag value
  19938. */
  19939. static readonly TextureDirtyFlag: number;
  19940. /**
  19941. * The dirty light flag value
  19942. */
  19943. static readonly LightDirtyFlag: number;
  19944. /**
  19945. * The dirty fresnel flag value
  19946. */
  19947. static readonly FresnelDirtyFlag: number;
  19948. /**
  19949. * The dirty attribute flag value
  19950. */
  19951. static readonly AttributesDirtyFlag: number;
  19952. /**
  19953. * The dirty misc flag value
  19954. */
  19955. static readonly MiscDirtyFlag: number;
  19956. /**
  19957. * The all dirty flag value
  19958. */
  19959. static readonly AllDirtyFlag: number;
  19960. /**
  19961. * The ID of the material
  19962. */
  19963. id: string;
  19964. /**
  19965. * Gets or sets the unique id of the material
  19966. */
  19967. uniqueId: number;
  19968. /**
  19969. * The name of the material
  19970. */
  19971. name: string;
  19972. /**
  19973. * Gets or sets user defined metadata
  19974. */
  19975. metadata: any;
  19976. /**
  19977. * For internal use only. Please do not use.
  19978. */
  19979. reservedDataStore: any;
  19980. /**
  19981. * Specifies if the ready state should be checked on each call
  19982. */
  19983. checkReadyOnEveryCall: boolean;
  19984. /**
  19985. * Specifies if the ready state should be checked once
  19986. */
  19987. checkReadyOnlyOnce: boolean;
  19988. /**
  19989. * The state of the material
  19990. */
  19991. state: string;
  19992. /**
  19993. * The alpha value of the material
  19994. */
  19995. protected _alpha: number;
  19996. /**
  19997. * List of inspectable custom properties (used by the Inspector)
  19998. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  19999. */
  20000. inspectableCustomProperties: IInspectable[];
  20001. /**
  20002. * Sets the alpha value of the material
  20003. */
  20004. /**
  20005. * Gets the alpha value of the material
  20006. */
  20007. alpha: number;
  20008. /**
  20009. * Specifies if back face culling is enabled
  20010. */
  20011. protected _backFaceCulling: boolean;
  20012. /**
  20013. * Sets the back-face culling state
  20014. */
  20015. /**
  20016. * Gets the back-face culling state
  20017. */
  20018. backFaceCulling: boolean;
  20019. /**
  20020. * Stores the value for side orientation
  20021. */
  20022. sideOrientation: number;
  20023. /**
  20024. * Callback triggered when the material is compiled
  20025. */
  20026. onCompiled: Nullable<(effect: Effect) => void>;
  20027. /**
  20028. * Callback triggered when an error occurs
  20029. */
  20030. onError: Nullable<(effect: Effect, errors: string) => void>;
  20031. /**
  20032. * Callback triggered to get the render target textures
  20033. */
  20034. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  20035. /**
  20036. * Gets a boolean indicating that current material needs to register RTT
  20037. */
  20038. readonly hasRenderTargetTextures: boolean;
  20039. /**
  20040. * Specifies if the material should be serialized
  20041. */
  20042. doNotSerialize: boolean;
  20043. /**
  20044. * @hidden
  20045. */
  20046. _storeEffectOnSubMeshes: boolean;
  20047. /**
  20048. * Stores the animations for the material
  20049. */
  20050. animations: Nullable<Array<Animation>>;
  20051. /**
  20052. * An event triggered when the material is disposed
  20053. */
  20054. onDisposeObservable: Observable<Material>;
  20055. /**
  20056. * An observer which watches for dispose events
  20057. */
  20058. private _onDisposeObserver;
  20059. private _onUnBindObservable;
  20060. /**
  20061. * Called during a dispose event
  20062. */
  20063. onDispose: () => void;
  20064. private _onBindObservable;
  20065. /**
  20066. * An event triggered when the material is bound
  20067. */
  20068. readonly onBindObservable: Observable<AbstractMesh>;
  20069. /**
  20070. * An observer which watches for bind events
  20071. */
  20072. private _onBindObserver;
  20073. /**
  20074. * Called during a bind event
  20075. */
  20076. onBind: (Mesh: AbstractMesh) => void;
  20077. /**
  20078. * An event triggered when the material is unbound
  20079. */
  20080. readonly onUnBindObservable: Observable<Material>;
  20081. /**
  20082. * Stores the value of the alpha mode
  20083. */
  20084. private _alphaMode;
  20085. /**
  20086. * Sets the value of the alpha mode.
  20087. *
  20088. * | Value | Type | Description |
  20089. * | --- | --- | --- |
  20090. * | 0 | ALPHA_DISABLE | |
  20091. * | 1 | ALPHA_ADD | |
  20092. * | 2 | ALPHA_COMBINE | |
  20093. * | 3 | ALPHA_SUBTRACT | |
  20094. * | 4 | ALPHA_MULTIPLY | |
  20095. * | 5 | ALPHA_MAXIMIZED | |
  20096. * | 6 | ALPHA_ONEONE | |
  20097. * | 7 | ALPHA_PREMULTIPLIED | |
  20098. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  20099. * | 9 | ALPHA_INTERPOLATE | |
  20100. * | 10 | ALPHA_SCREENMODE | |
  20101. *
  20102. */
  20103. /**
  20104. * Gets the value of the alpha mode
  20105. */
  20106. alphaMode: number;
  20107. /**
  20108. * Stores the state of the need depth pre-pass value
  20109. */
  20110. private _needDepthPrePass;
  20111. /**
  20112. * Sets the need depth pre-pass value
  20113. */
  20114. /**
  20115. * Gets the depth pre-pass value
  20116. */
  20117. needDepthPrePass: boolean;
  20118. /**
  20119. * Specifies if depth writing should be disabled
  20120. */
  20121. disableDepthWrite: boolean;
  20122. /**
  20123. * Specifies if depth writing should be forced
  20124. */
  20125. forceDepthWrite: boolean;
  20126. /**
  20127. * Specifies if there should be a separate pass for culling
  20128. */
  20129. separateCullingPass: boolean;
  20130. /**
  20131. * Stores the state specifing if fog should be enabled
  20132. */
  20133. private _fogEnabled;
  20134. /**
  20135. * Sets the state for enabling fog
  20136. */
  20137. /**
  20138. * Gets the value of the fog enabled state
  20139. */
  20140. fogEnabled: boolean;
  20141. /**
  20142. * Stores the size of points
  20143. */
  20144. pointSize: number;
  20145. /**
  20146. * Stores the z offset value
  20147. */
  20148. zOffset: number;
  20149. /**
  20150. * Gets a value specifying if wireframe mode is enabled
  20151. */
  20152. /**
  20153. * Sets the state of wireframe mode
  20154. */
  20155. wireframe: boolean;
  20156. /**
  20157. * Gets the value specifying if point clouds are enabled
  20158. */
  20159. /**
  20160. * Sets the state of point cloud mode
  20161. */
  20162. pointsCloud: boolean;
  20163. /**
  20164. * Gets the material fill mode
  20165. */
  20166. /**
  20167. * Sets the material fill mode
  20168. */
  20169. fillMode: number;
  20170. /**
  20171. * @hidden
  20172. * Stores the effects for the material
  20173. */
  20174. _effect: Nullable<Effect>;
  20175. /**
  20176. * @hidden
  20177. * Specifies if the material was previously ready
  20178. */
  20179. _wasPreviouslyReady: boolean;
  20180. /**
  20181. * Specifies if uniform buffers should be used
  20182. */
  20183. private _useUBO;
  20184. /**
  20185. * Stores a reference to the scene
  20186. */
  20187. private _scene;
  20188. /**
  20189. * Stores the fill mode state
  20190. */
  20191. private _fillMode;
  20192. /**
  20193. * Specifies if the depth write state should be cached
  20194. */
  20195. private _cachedDepthWriteState;
  20196. /**
  20197. * Stores the uniform buffer
  20198. */
  20199. protected _uniformBuffer: UniformBuffer;
  20200. /** @hidden */
  20201. _indexInSceneMaterialArray: number;
  20202. /** @hidden */
  20203. meshMap: Nullable<{
  20204. [id: string]: AbstractMesh | undefined;
  20205. }>;
  20206. /**
  20207. * Creates a material instance
  20208. * @param name defines the name of the material
  20209. * @param scene defines the scene to reference
  20210. * @param doNotAdd specifies if the material should be added to the scene
  20211. */
  20212. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  20213. /**
  20214. * Returns a string representation of the current material
  20215. * @param fullDetails defines a boolean indicating which levels of logging is desired
  20216. * @returns a string with material information
  20217. */
  20218. toString(fullDetails?: boolean): string;
  20219. /**
  20220. * Gets the class name of the material
  20221. * @returns a string with the class name of the material
  20222. */
  20223. getClassName(): string;
  20224. /**
  20225. * Specifies if updates for the material been locked
  20226. */
  20227. readonly isFrozen: boolean;
  20228. /**
  20229. * Locks updates for the material
  20230. */
  20231. freeze(): void;
  20232. /**
  20233. * Unlocks updates for the material
  20234. */
  20235. unfreeze(): void;
  20236. /**
  20237. * Specifies if the material is ready to be used
  20238. * @param mesh defines the mesh to check
  20239. * @param useInstances specifies if instances should be used
  20240. * @returns a boolean indicating if the material is ready to be used
  20241. */
  20242. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  20243. /**
  20244. * Specifies that the submesh is ready to be used
  20245. * @param mesh defines the mesh to check
  20246. * @param subMesh defines which submesh to check
  20247. * @param useInstances specifies that instances should be used
  20248. * @returns a boolean indicating that the submesh is ready or not
  20249. */
  20250. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  20251. /**
  20252. * Returns the material effect
  20253. * @returns the effect associated with the material
  20254. */
  20255. getEffect(): Nullable<Effect>;
  20256. /**
  20257. * Returns the current scene
  20258. * @returns a Scene
  20259. */
  20260. getScene(): Scene;
  20261. /**
  20262. * Specifies if the material will require alpha blending
  20263. * @returns a boolean specifying if alpha blending is needed
  20264. */
  20265. needAlphaBlending(): boolean;
  20266. /**
  20267. * Specifies if the mesh will require alpha blending
  20268. * @param mesh defines the mesh to check
  20269. * @returns a boolean specifying if alpha blending is needed for the mesh
  20270. */
  20271. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  20272. /**
  20273. * Specifies if this material should be rendered in alpha test mode
  20274. * @returns a boolean specifying if an alpha test is needed.
  20275. */
  20276. needAlphaTesting(): boolean;
  20277. /**
  20278. * Gets the texture used for the alpha test
  20279. * @returns the texture to use for alpha testing
  20280. */
  20281. getAlphaTestTexture(): Nullable<BaseTexture>;
  20282. /**
  20283. * Marks the material to indicate that it needs to be re-calculated
  20284. */
  20285. markDirty(): void;
  20286. /** @hidden */
  20287. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  20288. /**
  20289. * Binds the material to the mesh
  20290. * @param world defines the world transformation matrix
  20291. * @param mesh defines the mesh to bind the material to
  20292. */
  20293. bind(world: Matrix, mesh?: Mesh): void;
  20294. /**
  20295. * Binds the submesh to the material
  20296. * @param world defines the world transformation matrix
  20297. * @param mesh defines the mesh containing the submesh
  20298. * @param subMesh defines the submesh to bind the material to
  20299. */
  20300. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  20301. /**
  20302. * Binds the world matrix to the material
  20303. * @param world defines the world transformation matrix
  20304. */
  20305. bindOnlyWorldMatrix(world: Matrix): void;
  20306. /**
  20307. * Binds the scene's uniform buffer to the effect.
  20308. * @param effect defines the effect to bind to the scene uniform buffer
  20309. * @param sceneUbo defines the uniform buffer storing scene data
  20310. */
  20311. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  20312. /**
  20313. * Binds the view matrix to the effect
  20314. * @param effect defines the effect to bind the view matrix to
  20315. */
  20316. bindView(effect: Effect): void;
  20317. /**
  20318. * Binds the view projection matrix to the effect
  20319. * @param effect defines the effect to bind the view projection matrix to
  20320. */
  20321. bindViewProjection(effect: Effect): void;
  20322. /**
  20323. * Specifies if material alpha testing should be turned on for the mesh
  20324. * @param mesh defines the mesh to check
  20325. */
  20326. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  20327. /**
  20328. * Processes to execute after binding the material to a mesh
  20329. * @param mesh defines the rendered mesh
  20330. */
  20331. protected _afterBind(mesh?: Mesh): void;
  20332. /**
  20333. * Unbinds the material from the mesh
  20334. */
  20335. unbind(): void;
  20336. /**
  20337. * Gets the active textures from the material
  20338. * @returns an array of textures
  20339. */
  20340. getActiveTextures(): BaseTexture[];
  20341. /**
  20342. * Specifies if the material uses a texture
  20343. * @param texture defines the texture to check against the material
  20344. * @returns a boolean specifying if the material uses the texture
  20345. */
  20346. hasTexture(texture: BaseTexture): boolean;
  20347. /**
  20348. * Makes a duplicate of the material, and gives it a new name
  20349. * @param name defines the new name for the duplicated material
  20350. * @returns the cloned material
  20351. */
  20352. clone(name: string): Nullable<Material>;
  20353. /**
  20354. * Gets the meshes bound to the material
  20355. * @returns an array of meshes bound to the material
  20356. */
  20357. getBindedMeshes(): AbstractMesh[];
  20358. /**
  20359. * Force shader compilation
  20360. * @param mesh defines the mesh associated with this material
  20361. * @param onCompiled defines a function to execute once the material is compiled
  20362. * @param options defines the options to configure the compilation
  20363. * @param onError defines a function to execute if the material fails compiling
  20364. */
  20365. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  20366. clipPlane: boolean;
  20367. }>, onError?: (reason: string) => void): void;
  20368. /**
  20369. * Force shader compilation
  20370. * @param mesh defines the mesh that will use this material
  20371. * @param options defines additional options for compiling the shaders
  20372. * @returns a promise that resolves when the compilation completes
  20373. */
  20374. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  20375. clipPlane: boolean;
  20376. }>): Promise<void>;
  20377. private static readonly _AllDirtyCallBack;
  20378. private static readonly _ImageProcessingDirtyCallBack;
  20379. private static readonly _TextureDirtyCallBack;
  20380. private static readonly _FresnelDirtyCallBack;
  20381. private static readonly _MiscDirtyCallBack;
  20382. private static readonly _LightsDirtyCallBack;
  20383. private static readonly _AttributeDirtyCallBack;
  20384. private static _FresnelAndMiscDirtyCallBack;
  20385. private static _TextureAndMiscDirtyCallBack;
  20386. private static readonly _DirtyCallbackArray;
  20387. private static readonly _RunDirtyCallBacks;
  20388. /**
  20389. * Marks a define in the material to indicate that it needs to be re-computed
  20390. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  20391. */
  20392. markAsDirty(flag: number): void;
  20393. /**
  20394. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  20395. * @param func defines a function which checks material defines against the submeshes
  20396. */
  20397. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  20398. /**
  20399. * Indicates that we need to re-calculated for all submeshes
  20400. */
  20401. protected _markAllSubMeshesAsAllDirty(): void;
  20402. /**
  20403. * Indicates that image processing needs to be re-calculated for all submeshes
  20404. */
  20405. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  20406. /**
  20407. * Indicates that textures need to be re-calculated for all submeshes
  20408. */
  20409. protected _markAllSubMeshesAsTexturesDirty(): void;
  20410. /**
  20411. * Indicates that fresnel needs to be re-calculated for all submeshes
  20412. */
  20413. protected _markAllSubMeshesAsFresnelDirty(): void;
  20414. /**
  20415. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  20416. */
  20417. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  20418. /**
  20419. * Indicates that lights need to be re-calculated for all submeshes
  20420. */
  20421. protected _markAllSubMeshesAsLightsDirty(): void;
  20422. /**
  20423. * Indicates that attributes need to be re-calculated for all submeshes
  20424. */
  20425. protected _markAllSubMeshesAsAttributesDirty(): void;
  20426. /**
  20427. * Indicates that misc needs to be re-calculated for all submeshes
  20428. */
  20429. protected _markAllSubMeshesAsMiscDirty(): void;
  20430. /**
  20431. * Indicates that textures and misc need to be re-calculated for all submeshes
  20432. */
  20433. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  20434. /**
  20435. * Disposes the material
  20436. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  20437. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  20438. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  20439. */
  20440. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  20441. /** @hidden */
  20442. private releaseVertexArrayObject;
  20443. /**
  20444. * Serializes this material
  20445. * @returns the serialized material object
  20446. */
  20447. serialize(): any;
  20448. /**
  20449. * Creates a material from parsed material data
  20450. * @param parsedMaterial defines parsed material data
  20451. * @param scene defines the hosting scene
  20452. * @param rootUrl defines the root URL to use to load textures
  20453. * @returns a new material
  20454. */
  20455. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  20456. }
  20457. }
  20458. declare module BABYLON {
  20459. /**
  20460. * Creates an instance based on a source mesh.
  20461. */
  20462. export class InstancedMesh extends AbstractMesh {
  20463. private _sourceMesh;
  20464. private _currentLOD;
  20465. /** @hidden */
  20466. _actAsRegularMesh: boolean;
  20467. /** @hidden */
  20468. _indexInSourceMeshInstanceArray: number;
  20469. constructor(name: string, source: Mesh);
  20470. /**
  20471. * Returns the string "InstancedMesh".
  20472. */
  20473. getClassName(): string;
  20474. /** Gets the list of lights affecting that mesh */
  20475. readonly lightSources: Light[];
  20476. _resyncLightSources(): void;
  20477. _resyncLighSource(light: Light): void;
  20478. _removeLightSource(light: Light, dispose: boolean): void;
  20479. /**
  20480. * If the source mesh receives shadows
  20481. */
  20482. readonly receiveShadows: boolean;
  20483. /**
  20484. * The material of the source mesh
  20485. */
  20486. readonly material: Nullable<Material>;
  20487. /**
  20488. * Visibility of the source mesh
  20489. */
  20490. readonly visibility: number;
  20491. /**
  20492. * Skeleton of the source mesh
  20493. */
  20494. readonly skeleton: Nullable<Skeleton>;
  20495. /**
  20496. * Rendering ground id of the source mesh
  20497. */
  20498. renderingGroupId: number;
  20499. /**
  20500. * Returns the total number of vertices (integer).
  20501. */
  20502. getTotalVertices(): number;
  20503. /**
  20504. * Returns a positive integer : the total number of indices in this mesh geometry.
  20505. * @returns the numner of indices or zero if the mesh has no geometry.
  20506. */
  20507. getTotalIndices(): number;
  20508. /**
  20509. * The source mesh of the instance
  20510. */
  20511. readonly sourceMesh: Mesh;
  20512. /**
  20513. * Is this node ready to be used/rendered
  20514. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  20515. * @return {boolean} is it ready
  20516. */
  20517. isReady(completeCheck?: boolean): boolean;
  20518. /**
  20519. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  20520. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  20521. * @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.
  20522. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  20523. */
  20524. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  20525. /**
  20526. * Sets the vertex data of the mesh geometry for the requested `kind`.
  20527. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  20528. * The `data` are either a numeric array either a Float32Array.
  20529. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  20530. * 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).
  20531. * Note that a new underlying VertexBuffer object is created each call.
  20532. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  20533. *
  20534. * Possible `kind` values :
  20535. * - VertexBuffer.PositionKind
  20536. * - VertexBuffer.UVKind
  20537. * - VertexBuffer.UV2Kind
  20538. * - VertexBuffer.UV3Kind
  20539. * - VertexBuffer.UV4Kind
  20540. * - VertexBuffer.UV5Kind
  20541. * - VertexBuffer.UV6Kind
  20542. * - VertexBuffer.ColorKind
  20543. * - VertexBuffer.MatricesIndicesKind
  20544. * - VertexBuffer.MatricesIndicesExtraKind
  20545. * - VertexBuffer.MatricesWeightsKind
  20546. * - VertexBuffer.MatricesWeightsExtraKind
  20547. *
  20548. * Returns the Mesh.
  20549. */
  20550. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  20551. /**
  20552. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  20553. * If the mesh has no geometry, it is simply returned as it is.
  20554. * The `data` are either a numeric array either a Float32Array.
  20555. * No new underlying VertexBuffer object is created.
  20556. * 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.
  20557. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  20558. *
  20559. * Possible `kind` values :
  20560. * - VertexBuffer.PositionKind
  20561. * - VertexBuffer.UVKind
  20562. * - VertexBuffer.UV2Kind
  20563. * - VertexBuffer.UV3Kind
  20564. * - VertexBuffer.UV4Kind
  20565. * - VertexBuffer.UV5Kind
  20566. * - VertexBuffer.UV6Kind
  20567. * - VertexBuffer.ColorKind
  20568. * - VertexBuffer.MatricesIndicesKind
  20569. * - VertexBuffer.MatricesIndicesExtraKind
  20570. * - VertexBuffer.MatricesWeightsKind
  20571. * - VertexBuffer.MatricesWeightsExtraKind
  20572. *
  20573. * Returns the Mesh.
  20574. */
  20575. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  20576. /**
  20577. * Sets the mesh indices.
  20578. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  20579. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  20580. * This method creates a new index buffer each call.
  20581. * Returns the Mesh.
  20582. */
  20583. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  20584. /**
  20585. * Boolean : True if the mesh owns the requested kind of data.
  20586. */
  20587. isVerticesDataPresent(kind: string): boolean;
  20588. /**
  20589. * Returns an array of indices (IndicesArray).
  20590. */
  20591. getIndices(): Nullable<IndicesArray>;
  20592. readonly _positions: Nullable<Vector3[]>;
  20593. /**
  20594. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  20595. * This means the mesh underlying bounding box and sphere are recomputed.
  20596. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  20597. * @returns the current mesh
  20598. */
  20599. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  20600. /** @hidden */
  20601. _preActivate(): InstancedMesh;
  20602. /** @hidden */
  20603. _activate(renderId: number, intermediateRendering: boolean): boolean;
  20604. /** @hidden */
  20605. _postActivate(): void;
  20606. getWorldMatrix(): Matrix;
  20607. readonly isAnInstance: boolean;
  20608. /**
  20609. * Returns the current associated LOD AbstractMesh.
  20610. */
  20611. getLOD(camera: Camera): AbstractMesh;
  20612. /** @hidden */
  20613. _syncSubMeshes(): InstancedMesh;
  20614. /** @hidden */
  20615. _generatePointsArray(): boolean;
  20616. /**
  20617. * Creates a new InstancedMesh from the current mesh.
  20618. * - name (string) : the cloned mesh name
  20619. * - newParent (optional Node) : the optional Node to parent the clone to.
  20620. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  20621. *
  20622. * Returns the clone.
  20623. */
  20624. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  20625. /**
  20626. * Disposes the InstancedMesh.
  20627. * Returns nothing.
  20628. */
  20629. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  20630. }
  20631. }
  20632. declare module BABYLON {
  20633. /**
  20634. * A multi-material is used to apply different materials to different parts of the same object without the need of
  20635. * separate meshes. This can be use to improve performances.
  20636. * @see http://doc.babylonjs.com/how_to/multi_materials
  20637. */
  20638. export class MultiMaterial extends Material {
  20639. private _subMaterials;
  20640. /**
  20641. * Gets or Sets the list of Materials used within the multi material.
  20642. * They need to be ordered according to the submeshes order in the associated mesh
  20643. */
  20644. subMaterials: Nullable<Material>[];
  20645. /**
  20646. * Function used to align with Node.getChildren()
  20647. * @returns the list of Materials used within the multi material
  20648. */
  20649. getChildren(): Nullable<Material>[];
  20650. /**
  20651. * Instantiates a new Multi Material
  20652. * A multi-material is used to apply different materials to different parts of the same object without the need of
  20653. * separate meshes. This can be use to improve performances.
  20654. * @see http://doc.babylonjs.com/how_to/multi_materials
  20655. * @param name Define the name in the scene
  20656. * @param scene Define the scene the material belongs to
  20657. */
  20658. constructor(name: string, scene: Scene);
  20659. private _hookArray;
  20660. /**
  20661. * Get one of the submaterial by its index in the submaterials array
  20662. * @param index The index to look the sub material at
  20663. * @returns The Material if the index has been defined
  20664. */
  20665. getSubMaterial(index: number): Nullable<Material>;
  20666. /**
  20667. * Get the list of active textures for the whole sub materials list.
  20668. * @returns All the textures that will be used during the rendering
  20669. */
  20670. getActiveTextures(): BaseTexture[];
  20671. /**
  20672. * Gets the current class name of the material e.g. "MultiMaterial"
  20673. * Mainly use in serialization.
  20674. * @returns the class name
  20675. */
  20676. getClassName(): string;
  20677. /**
  20678. * Checks if the material is ready to render the requested sub mesh
  20679. * @param mesh Define the mesh the submesh belongs to
  20680. * @param subMesh Define the sub mesh to look readyness for
  20681. * @param useInstances Define whether or not the material is used with instances
  20682. * @returns true if ready, otherwise false
  20683. */
  20684. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  20685. /**
  20686. * Clones the current material and its related sub materials
  20687. * @param name Define the name of the newly cloned material
  20688. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  20689. * @returns the cloned material
  20690. */
  20691. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  20692. /**
  20693. * Serializes the materials into a JSON representation.
  20694. * @returns the JSON representation
  20695. */
  20696. serialize(): any;
  20697. /**
  20698. * Dispose the material and release its associated resources
  20699. * @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)
  20700. * @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)
  20701. * @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)
  20702. */
  20703. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  20704. /**
  20705. * Creates a MultiMaterial from parsed MultiMaterial data.
  20706. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  20707. * @param scene defines the hosting scene
  20708. * @returns a new MultiMaterial
  20709. */
  20710. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  20711. }
  20712. }
  20713. declare module BABYLON {
  20714. /**
  20715. * Base class for submeshes
  20716. */
  20717. export class BaseSubMesh {
  20718. /** @hidden */
  20719. _materialDefines: Nullable<MaterialDefines>;
  20720. /** @hidden */
  20721. _materialEffect: Nullable<Effect>;
  20722. /**
  20723. * Gets associated effect
  20724. */
  20725. readonly effect: Nullable<Effect>;
  20726. /**
  20727. * Sets associated effect (effect used to render this submesh)
  20728. * @param effect defines the effect to associate with
  20729. * @param defines defines the set of defines used to compile this effect
  20730. */
  20731. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  20732. }
  20733. /**
  20734. * Defines a subdivision inside a mesh
  20735. */
  20736. export class SubMesh extends BaseSubMesh implements ICullable {
  20737. /** the material index to use */
  20738. materialIndex: number;
  20739. /** vertex index start */
  20740. verticesStart: number;
  20741. /** vertices count */
  20742. verticesCount: number;
  20743. /** index start */
  20744. indexStart: number;
  20745. /** indices count */
  20746. indexCount: number;
  20747. /** @hidden */
  20748. _linesIndexCount: number;
  20749. private _mesh;
  20750. private _renderingMesh;
  20751. private _boundingInfo;
  20752. private _linesIndexBuffer;
  20753. /** @hidden */
  20754. _lastColliderWorldVertices: Nullable<Vector3[]>;
  20755. /** @hidden */
  20756. _trianglePlanes: Plane[];
  20757. /** @hidden */
  20758. _lastColliderTransformMatrix: Nullable<Matrix>;
  20759. /** @hidden */
  20760. _renderId: number;
  20761. /** @hidden */
  20762. _alphaIndex: number;
  20763. /** @hidden */
  20764. _distanceToCamera: number;
  20765. /** @hidden */
  20766. _id: number;
  20767. private _currentMaterial;
  20768. /**
  20769. * Add a new submesh to a mesh
  20770. * @param materialIndex defines the material index to use
  20771. * @param verticesStart defines vertex index start
  20772. * @param verticesCount defines vertices count
  20773. * @param indexStart defines index start
  20774. * @param indexCount defines indices count
  20775. * @param mesh defines the parent mesh
  20776. * @param renderingMesh defines an optional rendering mesh
  20777. * @param createBoundingBox defines if bounding box should be created for this submesh
  20778. * @returns the new submesh
  20779. */
  20780. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  20781. /**
  20782. * Creates a new submesh
  20783. * @param materialIndex defines the material index to use
  20784. * @param verticesStart defines vertex index start
  20785. * @param verticesCount defines vertices count
  20786. * @param indexStart defines index start
  20787. * @param indexCount defines indices count
  20788. * @param mesh defines the parent mesh
  20789. * @param renderingMesh defines an optional rendering mesh
  20790. * @param createBoundingBox defines if bounding box should be created for this submesh
  20791. */
  20792. constructor(
  20793. /** the material index to use */
  20794. materialIndex: number,
  20795. /** vertex index start */
  20796. verticesStart: number,
  20797. /** vertices count */
  20798. verticesCount: number,
  20799. /** index start */
  20800. indexStart: number,
  20801. /** indices count */
  20802. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  20803. /**
  20804. * Returns true if this submesh covers the entire parent mesh
  20805. * @ignorenaming
  20806. */
  20807. readonly IsGlobal: boolean;
  20808. /**
  20809. * Returns the submesh BoudingInfo object
  20810. * @returns current bounding info (or mesh's one if the submesh is global)
  20811. */
  20812. getBoundingInfo(): BoundingInfo;
  20813. /**
  20814. * Sets the submesh BoundingInfo
  20815. * @param boundingInfo defines the new bounding info to use
  20816. * @returns the SubMesh
  20817. */
  20818. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  20819. /**
  20820. * Returns the mesh of the current submesh
  20821. * @return the parent mesh
  20822. */
  20823. getMesh(): AbstractMesh;
  20824. /**
  20825. * Returns the rendering mesh of the submesh
  20826. * @returns the rendering mesh (could be different from parent mesh)
  20827. */
  20828. getRenderingMesh(): Mesh;
  20829. /**
  20830. * Returns the submesh material
  20831. * @returns null or the current material
  20832. */
  20833. getMaterial(): Nullable<Material>;
  20834. /**
  20835. * Sets a new updated BoundingInfo object to the submesh
  20836. * @param data defines an optional position array to use to determine the bounding info
  20837. * @returns the SubMesh
  20838. */
  20839. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  20840. /** @hidden */
  20841. _checkCollision(collider: Collider): boolean;
  20842. /**
  20843. * Updates the submesh BoundingInfo
  20844. * @param world defines the world matrix to use to update the bounding info
  20845. * @returns the submesh
  20846. */
  20847. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  20848. /**
  20849. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  20850. * @param frustumPlanes defines the frustum planes
  20851. * @returns true if the submesh is intersecting with the frustum
  20852. */
  20853. isInFrustum(frustumPlanes: Plane[]): boolean;
  20854. /**
  20855. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  20856. * @param frustumPlanes defines the frustum planes
  20857. * @returns true if the submesh is inside the frustum
  20858. */
  20859. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  20860. /**
  20861. * Renders the submesh
  20862. * @param enableAlphaMode defines if alpha needs to be used
  20863. * @returns the submesh
  20864. */
  20865. render(enableAlphaMode: boolean): SubMesh;
  20866. /**
  20867. * @hidden
  20868. */
  20869. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  20870. /**
  20871. * Checks if the submesh intersects with a ray
  20872. * @param ray defines the ray to test
  20873. * @returns true is the passed ray intersects the submesh bounding box
  20874. */
  20875. canIntersects(ray: Ray): boolean;
  20876. /**
  20877. * Intersects current submesh with a ray
  20878. * @param ray defines the ray to test
  20879. * @param positions defines mesh's positions array
  20880. * @param indices defines mesh's indices array
  20881. * @param fastCheck defines if only bounding info should be used
  20882. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  20883. * @returns intersection info or null if no intersection
  20884. */
  20885. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  20886. /** @hidden */
  20887. private _intersectLines;
  20888. /** @hidden */
  20889. private _intersectUnIndexedLines;
  20890. /** @hidden */
  20891. private _intersectTriangles;
  20892. /** @hidden */
  20893. private _intersectUnIndexedTriangles;
  20894. /** @hidden */
  20895. _rebuild(): void;
  20896. /**
  20897. * Creates a new submesh from the passed mesh
  20898. * @param newMesh defines the new hosting mesh
  20899. * @param newRenderingMesh defines an optional rendering mesh
  20900. * @returns the new submesh
  20901. */
  20902. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  20903. /**
  20904. * Release associated resources
  20905. */
  20906. dispose(): void;
  20907. /**
  20908. * Gets the class name
  20909. * @returns the string "SubMesh".
  20910. */
  20911. getClassName(): string;
  20912. /**
  20913. * Creates a new submesh from indices data
  20914. * @param materialIndex the index of the main mesh material
  20915. * @param startIndex the index where to start the copy in the mesh indices array
  20916. * @param indexCount the number of indices to copy then from the startIndex
  20917. * @param mesh the main mesh to create the submesh from
  20918. * @param renderingMesh the optional rendering mesh
  20919. * @returns a new submesh
  20920. */
  20921. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  20922. }
  20923. }
  20924. declare module BABYLON {
  20925. /**
  20926. * Class used to represent data loading progression
  20927. */
  20928. export class SceneLoaderFlags {
  20929. private static _ForceFullSceneLoadingForIncremental;
  20930. private static _ShowLoadingScreen;
  20931. private static _CleanBoneMatrixWeights;
  20932. private static _loggingLevel;
  20933. /**
  20934. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  20935. */
  20936. static ForceFullSceneLoadingForIncremental: boolean;
  20937. /**
  20938. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  20939. */
  20940. static ShowLoadingScreen: boolean;
  20941. /**
  20942. * Defines the current logging level (while loading the scene)
  20943. * @ignorenaming
  20944. */
  20945. static loggingLevel: number;
  20946. /**
  20947. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  20948. */
  20949. static CleanBoneMatrixWeights: boolean;
  20950. }
  20951. }
  20952. declare module BABYLON {
  20953. /**
  20954. * Class used to store geometry data (vertex buffers + index buffer)
  20955. */
  20956. export class Geometry implements IGetSetVerticesData {
  20957. /**
  20958. * Gets or sets the ID of the geometry
  20959. */
  20960. id: string;
  20961. /**
  20962. * Gets or sets the unique ID of the geometry
  20963. */
  20964. uniqueId: number;
  20965. /**
  20966. * Gets the delay loading state of the geometry (none by default which means not delayed)
  20967. */
  20968. delayLoadState: number;
  20969. /**
  20970. * Gets the file containing the data to load when running in delay load state
  20971. */
  20972. delayLoadingFile: Nullable<string>;
  20973. /**
  20974. * Callback called when the geometry is updated
  20975. */
  20976. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  20977. private _scene;
  20978. private _engine;
  20979. private _meshes;
  20980. private _totalVertices;
  20981. /** @hidden */
  20982. _indices: IndicesArray;
  20983. /** @hidden */
  20984. _vertexBuffers: {
  20985. [key: string]: VertexBuffer;
  20986. };
  20987. private _isDisposed;
  20988. private _extend;
  20989. private _boundingBias;
  20990. /** @hidden */
  20991. _delayInfo: Array<string>;
  20992. private _indexBuffer;
  20993. private _indexBufferIsUpdatable;
  20994. /** @hidden */
  20995. _boundingInfo: Nullable<BoundingInfo>;
  20996. /** @hidden */
  20997. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  20998. /** @hidden */
  20999. _softwareSkinningFrameId: number;
  21000. private _vertexArrayObjects;
  21001. private _updatable;
  21002. /** @hidden */
  21003. _positions: Nullable<Vector3[]>;
  21004. /**
  21005. * 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
  21006. */
  21007. /**
  21008. * 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
  21009. */
  21010. boundingBias: Vector2;
  21011. /**
  21012. * Static function used to attach a new empty geometry to a mesh
  21013. * @param mesh defines the mesh to attach the geometry to
  21014. * @returns the new Geometry
  21015. */
  21016. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  21017. /**
  21018. * Creates a new geometry
  21019. * @param id defines the unique ID
  21020. * @param scene defines the hosting scene
  21021. * @param vertexData defines the VertexData used to get geometry data
  21022. * @param updatable defines if geometry must be updatable (false by default)
  21023. * @param mesh defines the mesh that will be associated with the geometry
  21024. */
  21025. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  21026. /**
  21027. * Gets the current extend of the geometry
  21028. */
  21029. readonly extend: {
  21030. minimum: Vector3;
  21031. maximum: Vector3;
  21032. };
  21033. /**
  21034. * Gets the hosting scene
  21035. * @returns the hosting Scene
  21036. */
  21037. getScene(): Scene;
  21038. /**
  21039. * Gets the hosting engine
  21040. * @returns the hosting Engine
  21041. */
  21042. getEngine(): Engine;
  21043. /**
  21044. * Defines if the geometry is ready to use
  21045. * @returns true if the geometry is ready to be used
  21046. */
  21047. isReady(): boolean;
  21048. /**
  21049. * Gets a value indicating that the geometry should not be serialized
  21050. */
  21051. readonly doNotSerialize: boolean;
  21052. /** @hidden */
  21053. _rebuild(): void;
  21054. /**
  21055. * Affects all geometry data in one call
  21056. * @param vertexData defines the geometry data
  21057. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  21058. */
  21059. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  21060. /**
  21061. * Set specific vertex data
  21062. * @param kind defines the data kind (Position, normal, etc...)
  21063. * @param data defines the vertex data to use
  21064. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21065. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21066. */
  21067. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  21068. /**
  21069. * Removes a specific vertex data
  21070. * @param kind defines the data kind (Position, normal, etc...)
  21071. */
  21072. removeVerticesData(kind: string): void;
  21073. /**
  21074. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  21075. * @param buffer defines the vertex buffer to use
  21076. * @param totalVertices defines the total number of vertices for position kind (could be null)
  21077. */
  21078. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  21079. /**
  21080. * Update a specific vertex buffer
  21081. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  21082. * It will do nothing if the buffer is not updatable
  21083. * @param kind defines the data kind (Position, normal, etc...)
  21084. * @param data defines the data to use
  21085. * @param offset defines the offset in the target buffer where to store the data
  21086. * @param useBytes set to true if the offset is in bytes
  21087. */
  21088. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  21089. /**
  21090. * Update a specific vertex buffer
  21091. * This function will create a new buffer if the current one is not updatable
  21092. * @param kind defines the data kind (Position, normal, etc...)
  21093. * @param data defines the data to use
  21094. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  21095. */
  21096. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  21097. private _updateBoundingInfo;
  21098. /** @hidden */
  21099. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  21100. /**
  21101. * Gets total number of vertices
  21102. * @returns the total number of vertices
  21103. */
  21104. getTotalVertices(): number;
  21105. /**
  21106. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21107. * @param kind defines the data kind (Position, normal, etc...)
  21108. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21109. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21110. * @returns a float array containing vertex data
  21111. */
  21112. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21113. /**
  21114. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  21115. * @param kind defines the data kind (Position, normal, etc...)
  21116. * @returns true if the vertex buffer with the specified kind is updatable
  21117. */
  21118. isVertexBufferUpdatable(kind: string): boolean;
  21119. /**
  21120. * Gets a specific vertex buffer
  21121. * @param kind defines the data kind (Position, normal, etc...)
  21122. * @returns a VertexBuffer
  21123. */
  21124. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  21125. /**
  21126. * Returns all vertex buffers
  21127. * @return an object holding all vertex buffers indexed by kind
  21128. */
  21129. getVertexBuffers(): Nullable<{
  21130. [key: string]: VertexBuffer;
  21131. }>;
  21132. /**
  21133. * Gets a boolean indicating if specific vertex buffer is present
  21134. * @param kind defines the data kind (Position, normal, etc...)
  21135. * @returns true if data is present
  21136. */
  21137. isVerticesDataPresent(kind: string): boolean;
  21138. /**
  21139. * Gets a list of all attached data kinds (Position, normal, etc...)
  21140. * @returns a list of string containing all kinds
  21141. */
  21142. getVerticesDataKinds(): string[];
  21143. /**
  21144. * Update index buffer
  21145. * @param indices defines the indices to store in the index buffer
  21146. * @param offset defines the offset in the target buffer where to store the data
  21147. * @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)
  21148. */
  21149. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  21150. /**
  21151. * Creates a new index buffer
  21152. * @param indices defines the indices to store in the index buffer
  21153. * @param totalVertices defines the total number of vertices (could be null)
  21154. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  21155. */
  21156. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  21157. /**
  21158. * Return the total number of indices
  21159. * @returns the total number of indices
  21160. */
  21161. getTotalIndices(): number;
  21162. /**
  21163. * Gets the index buffer array
  21164. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21165. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21166. * @returns the index buffer array
  21167. */
  21168. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21169. /**
  21170. * Gets the index buffer
  21171. * @return the index buffer
  21172. */
  21173. getIndexBuffer(): Nullable<DataBuffer>;
  21174. /** @hidden */
  21175. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  21176. /**
  21177. * Release the associated resources for a specific mesh
  21178. * @param mesh defines the source mesh
  21179. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  21180. */
  21181. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  21182. /**
  21183. * Apply current geometry to a given mesh
  21184. * @param mesh defines the mesh to apply geometry to
  21185. */
  21186. applyToMesh(mesh: Mesh): void;
  21187. private _updateExtend;
  21188. private _applyToMesh;
  21189. private notifyUpdate;
  21190. /**
  21191. * Load the geometry if it was flagged as delay loaded
  21192. * @param scene defines the hosting scene
  21193. * @param onLoaded defines a callback called when the geometry is loaded
  21194. */
  21195. load(scene: Scene, onLoaded?: () => void): void;
  21196. private _queueLoad;
  21197. /**
  21198. * Invert the geometry to move from a right handed system to a left handed one.
  21199. */
  21200. toLeftHanded(): void;
  21201. /** @hidden */
  21202. _resetPointsArrayCache(): void;
  21203. /** @hidden */
  21204. _generatePointsArray(): boolean;
  21205. /**
  21206. * Gets a value indicating if the geometry is disposed
  21207. * @returns true if the geometry was disposed
  21208. */
  21209. isDisposed(): boolean;
  21210. private _disposeVertexArrayObjects;
  21211. /**
  21212. * Free all associated resources
  21213. */
  21214. dispose(): void;
  21215. /**
  21216. * Clone the current geometry into a new geometry
  21217. * @param id defines the unique ID of the new geometry
  21218. * @returns a new geometry object
  21219. */
  21220. copy(id: string): Geometry;
  21221. /**
  21222. * Serialize the current geometry info (and not the vertices data) into a JSON object
  21223. * @return a JSON representation of the current geometry data (without the vertices data)
  21224. */
  21225. serialize(): any;
  21226. private toNumberArray;
  21227. /**
  21228. * Serialize all vertices data into a JSON oject
  21229. * @returns a JSON representation of the current geometry data
  21230. */
  21231. serializeVerticeData(): any;
  21232. /**
  21233. * Extracts a clone of a mesh geometry
  21234. * @param mesh defines the source mesh
  21235. * @param id defines the unique ID of the new geometry object
  21236. * @returns the new geometry object
  21237. */
  21238. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  21239. /**
  21240. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  21241. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  21242. * Be aware Math.random() could cause collisions, but:
  21243. * "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"
  21244. * @returns a string containing a new GUID
  21245. */
  21246. static RandomId(): string;
  21247. /** @hidden */
  21248. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  21249. private static _CleanMatricesWeights;
  21250. /**
  21251. * Create a new geometry from persisted data (Using .babylon file format)
  21252. * @param parsedVertexData defines the persisted data
  21253. * @param scene defines the hosting scene
  21254. * @param rootUrl defines the root url to use to load assets (like delayed data)
  21255. * @returns the new geometry object
  21256. */
  21257. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  21258. }
  21259. }
  21260. declare module BABYLON {
  21261. /**
  21262. * Define an interface for all classes that will get and set the data on vertices
  21263. */
  21264. export interface IGetSetVerticesData {
  21265. /**
  21266. * Gets a boolean indicating if specific vertex data is present
  21267. * @param kind defines the vertex data kind to use
  21268. * @returns true is data kind is present
  21269. */
  21270. isVerticesDataPresent(kind: string): boolean;
  21271. /**
  21272. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21273. * @param kind defines the data kind (Position, normal, etc...)
  21274. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21275. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21276. * @returns a float array containing vertex data
  21277. */
  21278. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21279. /**
  21280. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  21281. * @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.
  21282. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21283. * @returns the indices array or an empty array if the mesh has no geometry
  21284. */
  21285. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21286. /**
  21287. * Set specific vertex data
  21288. * @param kind defines the data kind (Position, normal, etc...)
  21289. * @param data defines the vertex data to use
  21290. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21291. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21292. */
  21293. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  21294. /**
  21295. * Update a specific associated vertex buffer
  21296. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  21297. * - VertexBuffer.PositionKind
  21298. * - VertexBuffer.UVKind
  21299. * - VertexBuffer.UV2Kind
  21300. * - VertexBuffer.UV3Kind
  21301. * - VertexBuffer.UV4Kind
  21302. * - VertexBuffer.UV5Kind
  21303. * - VertexBuffer.UV6Kind
  21304. * - VertexBuffer.ColorKind
  21305. * - VertexBuffer.MatricesIndicesKind
  21306. * - VertexBuffer.MatricesIndicesExtraKind
  21307. * - VertexBuffer.MatricesWeightsKind
  21308. * - VertexBuffer.MatricesWeightsExtraKind
  21309. * @param data defines the data source
  21310. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  21311. * @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)
  21312. */
  21313. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  21314. /**
  21315. * Creates a new index buffer
  21316. * @param indices defines the indices to store in the index buffer
  21317. * @param totalVertices defines the total number of vertices (could be null)
  21318. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  21319. */
  21320. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  21321. }
  21322. /**
  21323. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  21324. */
  21325. export class VertexData {
  21326. /**
  21327. * Mesh side orientation : usually the external or front surface
  21328. */
  21329. static readonly FRONTSIDE: number;
  21330. /**
  21331. * Mesh side orientation : usually the internal or back surface
  21332. */
  21333. static readonly BACKSIDE: number;
  21334. /**
  21335. * Mesh side orientation : both internal and external or front and back surfaces
  21336. */
  21337. static readonly DOUBLESIDE: number;
  21338. /**
  21339. * Mesh side orientation : by default, `FRONTSIDE`
  21340. */
  21341. static readonly DEFAULTSIDE: number;
  21342. /**
  21343. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  21344. */
  21345. positions: Nullable<FloatArray>;
  21346. /**
  21347. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  21348. */
  21349. normals: Nullable<FloatArray>;
  21350. /**
  21351. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  21352. */
  21353. tangents: Nullable<FloatArray>;
  21354. /**
  21355. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21356. */
  21357. uvs: Nullable<FloatArray>;
  21358. /**
  21359. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21360. */
  21361. uvs2: Nullable<FloatArray>;
  21362. /**
  21363. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21364. */
  21365. uvs3: Nullable<FloatArray>;
  21366. /**
  21367. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21368. */
  21369. uvs4: Nullable<FloatArray>;
  21370. /**
  21371. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21372. */
  21373. uvs5: Nullable<FloatArray>;
  21374. /**
  21375. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21376. */
  21377. uvs6: Nullable<FloatArray>;
  21378. /**
  21379. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  21380. */
  21381. colors: Nullable<FloatArray>;
  21382. /**
  21383. * 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).
  21384. */
  21385. matricesIndices: Nullable<FloatArray>;
  21386. /**
  21387. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  21388. */
  21389. matricesWeights: Nullable<FloatArray>;
  21390. /**
  21391. * An array extending the number of possible indices
  21392. */
  21393. matricesIndicesExtra: Nullable<FloatArray>;
  21394. /**
  21395. * An array extending the number of possible weights when the number of indices is extended
  21396. */
  21397. matricesWeightsExtra: Nullable<FloatArray>;
  21398. /**
  21399. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  21400. */
  21401. indices: Nullable<IndicesArray>;
  21402. /**
  21403. * Uses the passed data array to set the set the values for the specified kind of data
  21404. * @param data a linear array of floating numbers
  21405. * @param kind the type of data that is being set, eg positions, colors etc
  21406. */
  21407. set(data: FloatArray, kind: string): void;
  21408. /**
  21409. * Associates the vertexData to the passed Mesh.
  21410. * Sets it as updatable or not (default `false`)
  21411. * @param mesh the mesh the vertexData is applied to
  21412. * @param updatable when used and having the value true allows new data to update the vertexData
  21413. * @returns the VertexData
  21414. */
  21415. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  21416. /**
  21417. * Associates the vertexData to the passed Geometry.
  21418. * Sets it as updatable or not (default `false`)
  21419. * @param geometry the geometry the vertexData is applied to
  21420. * @param updatable when used and having the value true allows new data to update the vertexData
  21421. * @returns VertexData
  21422. */
  21423. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  21424. /**
  21425. * Updates the associated mesh
  21426. * @param mesh the mesh to be updated
  21427. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  21428. * @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
  21429. * @returns VertexData
  21430. */
  21431. updateMesh(mesh: Mesh): VertexData;
  21432. /**
  21433. * Updates the associated geometry
  21434. * @param geometry the geometry to be updated
  21435. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  21436. * @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
  21437. * @returns VertexData.
  21438. */
  21439. updateGeometry(geometry: Geometry): VertexData;
  21440. private _applyTo;
  21441. private _update;
  21442. /**
  21443. * Transforms each position and each normal of the vertexData according to the passed Matrix
  21444. * @param matrix the transforming matrix
  21445. * @returns the VertexData
  21446. */
  21447. transform(matrix: Matrix): VertexData;
  21448. /**
  21449. * Merges the passed VertexData into the current one
  21450. * @param other the VertexData to be merged into the current one
  21451. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  21452. * @returns the modified VertexData
  21453. */
  21454. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  21455. private _mergeElement;
  21456. private _validate;
  21457. /**
  21458. * Serializes the VertexData
  21459. * @returns a serialized object
  21460. */
  21461. serialize(): any;
  21462. /**
  21463. * Extracts the vertexData from a mesh
  21464. * @param mesh the mesh from which to extract the VertexData
  21465. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  21466. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  21467. * @returns the object VertexData associated to the passed mesh
  21468. */
  21469. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  21470. /**
  21471. * Extracts the vertexData from the geometry
  21472. * @param geometry the geometry from which to extract the VertexData
  21473. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  21474. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  21475. * @returns the object VertexData associated to the passed mesh
  21476. */
  21477. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  21478. private static _ExtractFrom;
  21479. /**
  21480. * Creates the VertexData for a Ribbon
  21481. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  21482. * * pathArray array of paths, each of which an array of successive Vector3
  21483. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  21484. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  21485. * * 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
  21486. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21487. * * 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)
  21488. * * 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)
  21489. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  21490. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  21491. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  21492. * @returns the VertexData of the ribbon
  21493. */
  21494. static CreateRibbon(options: {
  21495. pathArray: Vector3[][];
  21496. closeArray?: boolean;
  21497. closePath?: boolean;
  21498. offset?: number;
  21499. sideOrientation?: number;
  21500. frontUVs?: Vector4;
  21501. backUVs?: Vector4;
  21502. invertUV?: boolean;
  21503. uvs?: Vector2[];
  21504. colors?: Color4[];
  21505. }): VertexData;
  21506. /**
  21507. * Creates the VertexData for a box
  21508. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21509. * * size sets the width, height and depth of the box to the value of size, optional default 1
  21510. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  21511. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  21512. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  21513. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  21514. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  21515. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21516. * * 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)
  21517. * * 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)
  21518. * @returns the VertexData of the box
  21519. */
  21520. static CreateBox(options: {
  21521. size?: number;
  21522. width?: number;
  21523. height?: number;
  21524. depth?: number;
  21525. faceUV?: Vector4[];
  21526. faceColors?: Color4[];
  21527. sideOrientation?: number;
  21528. frontUVs?: Vector4;
  21529. backUVs?: Vector4;
  21530. }): VertexData;
  21531. /**
  21532. * Creates the VertexData for a tiled box
  21533. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21534. * * faceTiles sets the pattern, tile size and number of tiles for a face
  21535. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  21536. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  21537. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21538. * @returns the VertexData of the box
  21539. */
  21540. static CreateTiledBox(options: {
  21541. pattern?: number;
  21542. width?: number;
  21543. height?: number;
  21544. depth?: number;
  21545. tileSize?: number;
  21546. tileWidth?: number;
  21547. tileHeight?: number;
  21548. alignHorizontal?: number;
  21549. alignVertical?: number;
  21550. faceUV?: Vector4[];
  21551. faceColors?: Color4[];
  21552. sideOrientation?: number;
  21553. }): VertexData;
  21554. /**
  21555. * Creates the VertexData for a tiled plane
  21556. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21557. * * pattern a limited pattern arrangement depending on the number
  21558. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  21559. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  21560. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  21561. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21562. * * 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)
  21563. * * 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)
  21564. * @returns the VertexData of the tiled plane
  21565. */
  21566. static CreateTiledPlane(options: {
  21567. pattern?: number;
  21568. tileSize?: number;
  21569. tileWidth?: number;
  21570. tileHeight?: number;
  21571. size?: number;
  21572. width?: number;
  21573. height?: number;
  21574. alignHorizontal?: number;
  21575. alignVertical?: number;
  21576. sideOrientation?: number;
  21577. frontUVs?: Vector4;
  21578. backUVs?: Vector4;
  21579. }): VertexData;
  21580. /**
  21581. * Creates the VertexData for an ellipsoid, defaults to a sphere
  21582. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21583. * * segments sets the number of horizontal strips optional, default 32
  21584. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  21585. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  21586. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  21587. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  21588. * * 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
  21589. * * 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
  21590. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21591. * * 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)
  21592. * * 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)
  21593. * @returns the VertexData of the ellipsoid
  21594. */
  21595. static CreateSphere(options: {
  21596. segments?: number;
  21597. diameter?: number;
  21598. diameterX?: number;
  21599. diameterY?: number;
  21600. diameterZ?: number;
  21601. arc?: number;
  21602. slice?: number;
  21603. sideOrientation?: number;
  21604. frontUVs?: Vector4;
  21605. backUVs?: Vector4;
  21606. }): VertexData;
  21607. /**
  21608. * Creates the VertexData for a cylinder, cone or prism
  21609. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21610. * * height sets the height (y direction) of the cylinder, optional, default 2
  21611. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  21612. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  21613. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  21614. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  21615. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  21616. * * 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
  21617. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  21618. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  21619. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  21620. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  21621. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21622. * * 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)
  21623. * * 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)
  21624. * @returns the VertexData of the cylinder, cone or prism
  21625. */
  21626. static CreateCylinder(options: {
  21627. height?: number;
  21628. diameterTop?: number;
  21629. diameterBottom?: number;
  21630. diameter?: number;
  21631. tessellation?: number;
  21632. subdivisions?: number;
  21633. arc?: number;
  21634. faceColors?: Color4[];
  21635. faceUV?: Vector4[];
  21636. hasRings?: boolean;
  21637. enclose?: boolean;
  21638. sideOrientation?: number;
  21639. frontUVs?: Vector4;
  21640. backUVs?: Vector4;
  21641. }): VertexData;
  21642. /**
  21643. * Creates the VertexData for a torus
  21644. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21645. * * diameter the diameter of the torus, optional default 1
  21646. * * thickness the diameter of the tube forming the torus, optional default 0.5
  21647. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  21648. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21649. * * 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)
  21650. * * 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)
  21651. * @returns the VertexData of the torus
  21652. */
  21653. static CreateTorus(options: {
  21654. diameter?: number;
  21655. thickness?: number;
  21656. tessellation?: number;
  21657. sideOrientation?: number;
  21658. frontUVs?: Vector4;
  21659. backUVs?: Vector4;
  21660. }): VertexData;
  21661. /**
  21662. * Creates the VertexData of the LineSystem
  21663. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  21664. * - lines an array of lines, each line being an array of successive Vector3
  21665. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  21666. * @returns the VertexData of the LineSystem
  21667. */
  21668. static CreateLineSystem(options: {
  21669. lines: Vector3[][];
  21670. colors?: Nullable<Color4[][]>;
  21671. }): VertexData;
  21672. /**
  21673. * Create the VertexData for a DashedLines
  21674. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  21675. * - points an array successive Vector3
  21676. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  21677. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  21678. * - dashNb the intended total number of dashes, optional, default 200
  21679. * @returns the VertexData for the DashedLines
  21680. */
  21681. static CreateDashedLines(options: {
  21682. points: Vector3[];
  21683. dashSize?: number;
  21684. gapSize?: number;
  21685. dashNb?: number;
  21686. }): VertexData;
  21687. /**
  21688. * Creates the VertexData for a Ground
  21689. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  21690. * - width the width (x direction) of the ground, optional, default 1
  21691. * - height the height (z direction) of the ground, optional, default 1
  21692. * - subdivisions the number of subdivisions per side, optional, default 1
  21693. * @returns the VertexData of the Ground
  21694. */
  21695. static CreateGround(options: {
  21696. width?: number;
  21697. height?: number;
  21698. subdivisions?: number;
  21699. subdivisionsX?: number;
  21700. subdivisionsY?: number;
  21701. }): VertexData;
  21702. /**
  21703. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  21704. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  21705. * * xmin the ground minimum X coordinate, optional, default -1
  21706. * * zmin the ground minimum Z coordinate, optional, default -1
  21707. * * xmax the ground maximum X coordinate, optional, default 1
  21708. * * zmax the ground maximum Z coordinate, optional, default 1
  21709. * * 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}
  21710. * * 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}
  21711. * @returns the VertexData of the TiledGround
  21712. */
  21713. static CreateTiledGround(options: {
  21714. xmin: number;
  21715. zmin: number;
  21716. xmax: number;
  21717. zmax: number;
  21718. subdivisions?: {
  21719. w: number;
  21720. h: number;
  21721. };
  21722. precision?: {
  21723. w: number;
  21724. h: number;
  21725. };
  21726. }): VertexData;
  21727. /**
  21728. * Creates the VertexData of the Ground designed from a heightmap
  21729. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  21730. * * width the width (x direction) of the ground
  21731. * * height the height (z direction) of the ground
  21732. * * subdivisions the number of subdivisions per side
  21733. * * minHeight the minimum altitude on the ground, optional, default 0
  21734. * * maxHeight the maximum altitude on the ground, optional default 1
  21735. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  21736. * * buffer the array holding the image color data
  21737. * * bufferWidth the width of image
  21738. * * bufferHeight the height of image
  21739. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  21740. * @returns the VertexData of the Ground designed from a heightmap
  21741. */
  21742. static CreateGroundFromHeightMap(options: {
  21743. width: number;
  21744. height: number;
  21745. subdivisions: number;
  21746. minHeight: number;
  21747. maxHeight: number;
  21748. colorFilter: Color3;
  21749. buffer: Uint8Array;
  21750. bufferWidth: number;
  21751. bufferHeight: number;
  21752. alphaFilter: number;
  21753. }): VertexData;
  21754. /**
  21755. * Creates the VertexData for a Plane
  21756. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  21757. * * size sets the width and height of the plane to the value of size, optional default 1
  21758. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  21759. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  21760. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21761. * * 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)
  21762. * * 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)
  21763. * @returns the VertexData of the box
  21764. */
  21765. static CreatePlane(options: {
  21766. size?: number;
  21767. width?: number;
  21768. height?: number;
  21769. sideOrientation?: number;
  21770. frontUVs?: Vector4;
  21771. backUVs?: Vector4;
  21772. }): VertexData;
  21773. /**
  21774. * Creates the VertexData of the Disc or regular Polygon
  21775. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  21776. * * radius the radius of the disc, optional default 0.5
  21777. * * tessellation the number of polygon sides, optional, default 64
  21778. * * 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
  21779. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21780. * * 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)
  21781. * * 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)
  21782. * @returns the VertexData of the box
  21783. */
  21784. static CreateDisc(options: {
  21785. radius?: number;
  21786. tessellation?: number;
  21787. arc?: number;
  21788. sideOrientation?: number;
  21789. frontUVs?: Vector4;
  21790. backUVs?: Vector4;
  21791. }): VertexData;
  21792. /**
  21793. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  21794. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  21795. * @param polygon a mesh built from polygonTriangulation.build()
  21796. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21797. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  21798. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  21799. * @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)
  21800. * @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)
  21801. * @returns the VertexData of the Polygon
  21802. */
  21803. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  21804. /**
  21805. * Creates the VertexData of the IcoSphere
  21806. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  21807. * * radius the radius of the IcoSphere, optional default 1
  21808. * * radiusX allows stretching in the x direction, optional, default radius
  21809. * * radiusY allows stretching in the y direction, optional, default radius
  21810. * * radiusZ allows stretching in the z direction, optional, default radius
  21811. * * flat when true creates a flat shaded mesh, optional, default true
  21812. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  21813. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21814. * * 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)
  21815. * * 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)
  21816. * @returns the VertexData of the IcoSphere
  21817. */
  21818. static CreateIcoSphere(options: {
  21819. radius?: number;
  21820. radiusX?: number;
  21821. radiusY?: number;
  21822. radiusZ?: number;
  21823. flat?: boolean;
  21824. subdivisions?: number;
  21825. sideOrientation?: number;
  21826. frontUVs?: Vector4;
  21827. backUVs?: Vector4;
  21828. }): VertexData;
  21829. /**
  21830. * Creates the VertexData for a Polyhedron
  21831. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  21832. * * type provided types are:
  21833. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  21834. * * 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)
  21835. * * size the size of the IcoSphere, optional default 1
  21836. * * sizeX allows stretching in the x direction, optional, default size
  21837. * * sizeY allows stretching in the y direction, optional, default size
  21838. * * sizeZ allows stretching in the z direction, optional, default size
  21839. * * 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
  21840. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  21841. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  21842. * * flat when true creates a flat shaded mesh, optional, default true
  21843. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  21844. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21845. * * 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)
  21846. * * 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)
  21847. * @returns the VertexData of the Polyhedron
  21848. */
  21849. static CreatePolyhedron(options: {
  21850. type?: number;
  21851. size?: number;
  21852. sizeX?: number;
  21853. sizeY?: number;
  21854. sizeZ?: number;
  21855. custom?: any;
  21856. faceUV?: Vector4[];
  21857. faceColors?: Color4[];
  21858. flat?: boolean;
  21859. sideOrientation?: number;
  21860. frontUVs?: Vector4;
  21861. backUVs?: Vector4;
  21862. }): VertexData;
  21863. /**
  21864. * Creates the VertexData for a TorusKnot
  21865. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  21866. * * radius the radius of the torus knot, optional, default 2
  21867. * * tube the thickness of the tube, optional, default 0.5
  21868. * * radialSegments the number of sides on each tube segments, optional, default 32
  21869. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  21870. * * p the number of windings around the z axis, optional, default 2
  21871. * * q the number of windings around the x axis, optional, default 3
  21872. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21873. * * 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)
  21874. * * 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)
  21875. * @returns the VertexData of the Torus Knot
  21876. */
  21877. static CreateTorusKnot(options: {
  21878. radius?: number;
  21879. tube?: number;
  21880. radialSegments?: number;
  21881. tubularSegments?: number;
  21882. p?: number;
  21883. q?: number;
  21884. sideOrientation?: number;
  21885. frontUVs?: Vector4;
  21886. backUVs?: Vector4;
  21887. }): VertexData;
  21888. /**
  21889. * Compute normals for given positions and indices
  21890. * @param positions an array of vertex positions, [...., x, y, z, ......]
  21891. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  21892. * @param normals an array of vertex normals, [...., x, y, z, ......]
  21893. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  21894. * * facetNormals : optional array of facet normals (vector3)
  21895. * * facetPositions : optional array of facet positions (vector3)
  21896. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  21897. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  21898. * * bInfo : optional bounding info, required for facetPartitioning computation
  21899. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  21900. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  21901. * * useRightHandedSystem: optional boolean to for right handed system computation
  21902. * * depthSort : optional boolean to enable the facet depth sort computation
  21903. * * distanceTo : optional Vector3 to compute the facet depth from this location
  21904. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  21905. */
  21906. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  21907. facetNormals?: any;
  21908. facetPositions?: any;
  21909. facetPartitioning?: any;
  21910. ratio?: number;
  21911. bInfo?: any;
  21912. bbSize?: Vector3;
  21913. subDiv?: any;
  21914. useRightHandedSystem?: boolean;
  21915. depthSort?: boolean;
  21916. distanceTo?: Vector3;
  21917. depthSortedFacets?: any;
  21918. }): void;
  21919. /** @hidden */
  21920. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  21921. /**
  21922. * Applies VertexData created from the imported parameters to the geometry
  21923. * @param parsedVertexData the parsed data from an imported file
  21924. * @param geometry the geometry to apply the VertexData to
  21925. */
  21926. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  21927. }
  21928. }
  21929. declare module BABYLON {
  21930. /**
  21931. * Defines a target to use with MorphTargetManager
  21932. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  21933. */
  21934. export class MorphTarget implements IAnimatable {
  21935. /** defines the name of the target */
  21936. name: string;
  21937. /**
  21938. * Gets or sets the list of animations
  21939. */
  21940. animations: Animation[];
  21941. private _scene;
  21942. private _positions;
  21943. private _normals;
  21944. private _tangents;
  21945. private _uvs;
  21946. private _influence;
  21947. /**
  21948. * Observable raised when the influence changes
  21949. */
  21950. onInfluenceChanged: Observable<boolean>;
  21951. /** @hidden */
  21952. _onDataLayoutChanged: Observable<void>;
  21953. /**
  21954. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  21955. */
  21956. influence: number;
  21957. /**
  21958. * Gets or sets the id of the morph Target
  21959. */
  21960. id: string;
  21961. private _animationPropertiesOverride;
  21962. /**
  21963. * Gets or sets the animation properties override
  21964. */
  21965. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  21966. /**
  21967. * Creates a new MorphTarget
  21968. * @param name defines the name of the target
  21969. * @param influence defines the influence to use
  21970. * @param scene defines the scene the morphtarget belongs to
  21971. */
  21972. constructor(
  21973. /** defines the name of the target */
  21974. name: string, influence?: number, scene?: Nullable<Scene>);
  21975. /**
  21976. * Gets a boolean defining if the target contains position data
  21977. */
  21978. readonly hasPositions: boolean;
  21979. /**
  21980. * Gets a boolean defining if the target contains normal data
  21981. */
  21982. readonly hasNormals: boolean;
  21983. /**
  21984. * Gets a boolean defining if the target contains tangent data
  21985. */
  21986. readonly hasTangents: boolean;
  21987. /**
  21988. * Gets a boolean defining if the target contains texture coordinates data
  21989. */
  21990. readonly hasUVs: boolean;
  21991. /**
  21992. * Affects position data to this target
  21993. * @param data defines the position data to use
  21994. */
  21995. setPositions(data: Nullable<FloatArray>): void;
  21996. /**
  21997. * Gets the position data stored in this target
  21998. * @returns a FloatArray containing the position data (or null if not present)
  21999. */
  22000. getPositions(): Nullable<FloatArray>;
  22001. /**
  22002. * Affects normal data to this target
  22003. * @param data defines the normal data to use
  22004. */
  22005. setNormals(data: Nullable<FloatArray>): void;
  22006. /**
  22007. * Gets the normal data stored in this target
  22008. * @returns a FloatArray containing the normal data (or null if not present)
  22009. */
  22010. getNormals(): Nullable<FloatArray>;
  22011. /**
  22012. * Affects tangent data to this target
  22013. * @param data defines the tangent data to use
  22014. */
  22015. setTangents(data: Nullable<FloatArray>): void;
  22016. /**
  22017. * Gets the tangent data stored in this target
  22018. * @returns a FloatArray containing the tangent data (or null if not present)
  22019. */
  22020. getTangents(): Nullable<FloatArray>;
  22021. /**
  22022. * Affects texture coordinates data to this target
  22023. * @param data defines the texture coordinates data to use
  22024. */
  22025. setUVs(data: Nullable<FloatArray>): void;
  22026. /**
  22027. * Gets the texture coordinates data stored in this target
  22028. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  22029. */
  22030. getUVs(): Nullable<FloatArray>;
  22031. /**
  22032. * Serializes the current target into a Serialization object
  22033. * @returns the serialized object
  22034. */
  22035. serialize(): any;
  22036. /**
  22037. * Returns the string "MorphTarget"
  22038. * @returns "MorphTarget"
  22039. */
  22040. getClassName(): string;
  22041. /**
  22042. * Creates a new target from serialized data
  22043. * @param serializationObject defines the serialized data to use
  22044. * @returns a new MorphTarget
  22045. */
  22046. static Parse(serializationObject: any): MorphTarget;
  22047. /**
  22048. * Creates a MorphTarget from mesh data
  22049. * @param mesh defines the source mesh
  22050. * @param name defines the name to use for the new target
  22051. * @param influence defines the influence to attach to the target
  22052. * @returns a new MorphTarget
  22053. */
  22054. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  22055. }
  22056. }
  22057. declare module BABYLON {
  22058. /**
  22059. * This class is used to deform meshes using morphing between different targets
  22060. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22061. */
  22062. export class MorphTargetManager {
  22063. private _targets;
  22064. private _targetInfluenceChangedObservers;
  22065. private _targetDataLayoutChangedObservers;
  22066. private _activeTargets;
  22067. private _scene;
  22068. private _influences;
  22069. private _supportsNormals;
  22070. private _supportsTangents;
  22071. private _supportsUVs;
  22072. private _vertexCount;
  22073. private _uniqueId;
  22074. private _tempInfluences;
  22075. /**
  22076. * Gets or sets a boolean indicating if normals must be morphed
  22077. */
  22078. enableNormalMorphing: boolean;
  22079. /**
  22080. * Gets or sets a boolean indicating if tangents must be morphed
  22081. */
  22082. enableTangentMorphing: boolean;
  22083. /**
  22084. * Gets or sets a boolean indicating if UV must be morphed
  22085. */
  22086. enableUVMorphing: boolean;
  22087. /**
  22088. * Creates a new MorphTargetManager
  22089. * @param scene defines the current scene
  22090. */
  22091. constructor(scene?: Nullable<Scene>);
  22092. /**
  22093. * Gets the unique ID of this manager
  22094. */
  22095. readonly uniqueId: number;
  22096. /**
  22097. * Gets the number of vertices handled by this manager
  22098. */
  22099. readonly vertexCount: number;
  22100. /**
  22101. * Gets a boolean indicating if this manager supports morphing of normals
  22102. */
  22103. readonly supportsNormals: boolean;
  22104. /**
  22105. * Gets a boolean indicating if this manager supports morphing of tangents
  22106. */
  22107. readonly supportsTangents: boolean;
  22108. /**
  22109. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  22110. */
  22111. readonly supportsUVs: boolean;
  22112. /**
  22113. * Gets the number of targets stored in this manager
  22114. */
  22115. readonly numTargets: number;
  22116. /**
  22117. * Gets the number of influencers (ie. the number of targets with influences > 0)
  22118. */
  22119. readonly numInfluencers: number;
  22120. /**
  22121. * Gets the list of influences (one per target)
  22122. */
  22123. readonly influences: Float32Array;
  22124. /**
  22125. * Gets the active target at specified index. An active target is a target with an influence > 0
  22126. * @param index defines the index to check
  22127. * @returns the requested target
  22128. */
  22129. getActiveTarget(index: number): MorphTarget;
  22130. /**
  22131. * Gets the target at specified index
  22132. * @param index defines the index to check
  22133. * @returns the requested target
  22134. */
  22135. getTarget(index: number): MorphTarget;
  22136. /**
  22137. * Add a new target to this manager
  22138. * @param target defines the target to add
  22139. */
  22140. addTarget(target: MorphTarget): void;
  22141. /**
  22142. * Removes a target from the manager
  22143. * @param target defines the target to remove
  22144. */
  22145. removeTarget(target: MorphTarget): void;
  22146. /**
  22147. * Serializes the current manager into a Serialization object
  22148. * @returns the serialized object
  22149. */
  22150. serialize(): any;
  22151. private _syncActiveTargets;
  22152. /**
  22153. * Syncrhonize the targets with all the meshes using this morph target manager
  22154. */
  22155. synchronize(): void;
  22156. /**
  22157. * Creates a new MorphTargetManager from serialized data
  22158. * @param serializationObject defines the serialized data
  22159. * @param scene defines the hosting scene
  22160. * @returns the new MorphTargetManager
  22161. */
  22162. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  22163. }
  22164. }
  22165. declare module BABYLON {
  22166. /**
  22167. * Class used to represent a specific level of detail of a mesh
  22168. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  22169. */
  22170. export class MeshLODLevel {
  22171. /** Defines the distance where this level should start being displayed */
  22172. distance: number;
  22173. /** Defines the mesh to use to render this level */
  22174. mesh: Nullable<Mesh>;
  22175. /**
  22176. * Creates a new LOD level
  22177. * @param distance defines the distance where this level should star being displayed
  22178. * @param mesh defines the mesh to use to render this level
  22179. */
  22180. constructor(
  22181. /** Defines the distance where this level should start being displayed */
  22182. distance: number,
  22183. /** Defines the mesh to use to render this level */
  22184. mesh: Nullable<Mesh>);
  22185. }
  22186. }
  22187. declare module BABYLON {
  22188. /**
  22189. * Mesh representing the gorund
  22190. */
  22191. export class GroundMesh extends Mesh {
  22192. /** If octree should be generated */
  22193. generateOctree: boolean;
  22194. private _heightQuads;
  22195. /** @hidden */
  22196. _subdivisionsX: number;
  22197. /** @hidden */
  22198. _subdivisionsY: number;
  22199. /** @hidden */
  22200. _width: number;
  22201. /** @hidden */
  22202. _height: number;
  22203. /** @hidden */
  22204. _minX: number;
  22205. /** @hidden */
  22206. _maxX: number;
  22207. /** @hidden */
  22208. _minZ: number;
  22209. /** @hidden */
  22210. _maxZ: number;
  22211. constructor(name: string, scene: Scene);
  22212. /**
  22213. * "GroundMesh"
  22214. * @returns "GroundMesh"
  22215. */
  22216. getClassName(): string;
  22217. /**
  22218. * The minimum of x and y subdivisions
  22219. */
  22220. readonly subdivisions: number;
  22221. /**
  22222. * X subdivisions
  22223. */
  22224. readonly subdivisionsX: number;
  22225. /**
  22226. * Y subdivisions
  22227. */
  22228. readonly subdivisionsY: number;
  22229. /**
  22230. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  22231. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  22232. * @param chunksCount the number of subdivisions for x and y
  22233. * @param octreeBlocksSize (Default: 32)
  22234. */
  22235. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  22236. /**
  22237. * Returns a height (y) value in the Worl system :
  22238. * the ground altitude at the coordinates (x, z) expressed in the World system.
  22239. * @param x x coordinate
  22240. * @param z z coordinate
  22241. * @returns the ground y position if (x, z) are outside the ground surface.
  22242. */
  22243. getHeightAtCoordinates(x: number, z: number): number;
  22244. /**
  22245. * Returns a normalized vector (Vector3) orthogonal to the ground
  22246. * at the ground coordinates (x, z) expressed in the World system.
  22247. * @param x x coordinate
  22248. * @param z z coordinate
  22249. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  22250. */
  22251. getNormalAtCoordinates(x: number, z: number): Vector3;
  22252. /**
  22253. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  22254. * at the ground coordinates (x, z) expressed in the World system.
  22255. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  22256. * @param x x coordinate
  22257. * @param z z coordinate
  22258. * @param ref vector to store the result
  22259. * @returns the GroundMesh.
  22260. */
  22261. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  22262. /**
  22263. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  22264. * if the ground has been updated.
  22265. * This can be used in the render loop.
  22266. * @returns the GroundMesh.
  22267. */
  22268. updateCoordinateHeights(): GroundMesh;
  22269. private _getFacetAt;
  22270. private _initHeightQuads;
  22271. private _computeHeightQuads;
  22272. /**
  22273. * Serializes this ground mesh
  22274. * @param serializationObject object to write serialization to
  22275. */
  22276. serialize(serializationObject: any): void;
  22277. /**
  22278. * Parses a serialized ground mesh
  22279. * @param parsedMesh the serialized mesh
  22280. * @param scene the scene to create the ground mesh in
  22281. * @returns the created ground mesh
  22282. */
  22283. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  22284. }
  22285. }
  22286. declare module BABYLON {
  22287. /**
  22288. * Interface for Physics-Joint data
  22289. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22290. */
  22291. export interface PhysicsJointData {
  22292. /**
  22293. * The main pivot of the joint
  22294. */
  22295. mainPivot?: Vector3;
  22296. /**
  22297. * The connected pivot of the joint
  22298. */
  22299. connectedPivot?: Vector3;
  22300. /**
  22301. * The main axis of the joint
  22302. */
  22303. mainAxis?: Vector3;
  22304. /**
  22305. * The connected axis of the joint
  22306. */
  22307. connectedAxis?: Vector3;
  22308. /**
  22309. * The collision of the joint
  22310. */
  22311. collision?: boolean;
  22312. /**
  22313. * Native Oimo/Cannon/Energy data
  22314. */
  22315. nativeParams?: any;
  22316. }
  22317. /**
  22318. * This is a holder class for the physics joint created by the physics plugin
  22319. * It holds a set of functions to control the underlying joint
  22320. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22321. */
  22322. export class PhysicsJoint {
  22323. /**
  22324. * The type of the physics joint
  22325. */
  22326. type: number;
  22327. /**
  22328. * The data for the physics joint
  22329. */
  22330. jointData: PhysicsJointData;
  22331. private _physicsJoint;
  22332. protected _physicsPlugin: IPhysicsEnginePlugin;
  22333. /**
  22334. * Initializes the physics joint
  22335. * @param type The type of the physics joint
  22336. * @param jointData The data for the physics joint
  22337. */
  22338. constructor(
  22339. /**
  22340. * The type of the physics joint
  22341. */
  22342. type: number,
  22343. /**
  22344. * The data for the physics joint
  22345. */
  22346. jointData: PhysicsJointData);
  22347. /**
  22348. * Gets the physics joint
  22349. */
  22350. /**
  22351. * Sets the physics joint
  22352. */
  22353. physicsJoint: any;
  22354. /**
  22355. * Sets the physics plugin
  22356. */
  22357. physicsPlugin: IPhysicsEnginePlugin;
  22358. /**
  22359. * Execute a function that is physics-plugin specific.
  22360. * @param {Function} func the function that will be executed.
  22361. * It accepts two parameters: the physics world and the physics joint
  22362. */
  22363. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  22364. /**
  22365. * Distance-Joint type
  22366. */
  22367. static DistanceJoint: number;
  22368. /**
  22369. * Hinge-Joint type
  22370. */
  22371. static HingeJoint: number;
  22372. /**
  22373. * Ball-and-Socket joint type
  22374. */
  22375. static BallAndSocketJoint: number;
  22376. /**
  22377. * Wheel-Joint type
  22378. */
  22379. static WheelJoint: number;
  22380. /**
  22381. * Slider-Joint type
  22382. */
  22383. static SliderJoint: number;
  22384. /**
  22385. * Prismatic-Joint type
  22386. */
  22387. static PrismaticJoint: number;
  22388. /**
  22389. * Universal-Joint type
  22390. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  22391. */
  22392. static UniversalJoint: number;
  22393. /**
  22394. * Hinge-Joint 2 type
  22395. */
  22396. static Hinge2Joint: number;
  22397. /**
  22398. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  22399. */
  22400. static PointToPointJoint: number;
  22401. /**
  22402. * Spring-Joint type
  22403. */
  22404. static SpringJoint: number;
  22405. /**
  22406. * Lock-Joint type
  22407. */
  22408. static LockJoint: number;
  22409. }
  22410. /**
  22411. * A class representing a physics distance joint
  22412. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22413. */
  22414. export class DistanceJoint extends PhysicsJoint {
  22415. /**
  22416. *
  22417. * @param jointData The data for the Distance-Joint
  22418. */
  22419. constructor(jointData: DistanceJointData);
  22420. /**
  22421. * Update the predefined distance.
  22422. * @param maxDistance The maximum preferred distance
  22423. * @param minDistance The minimum preferred distance
  22424. */
  22425. updateDistance(maxDistance: number, minDistance?: number): void;
  22426. }
  22427. /**
  22428. * Represents a Motor-Enabled Joint
  22429. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22430. */
  22431. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  22432. /**
  22433. * Initializes the Motor-Enabled Joint
  22434. * @param type The type of the joint
  22435. * @param jointData The physica joint data for the joint
  22436. */
  22437. constructor(type: number, jointData: PhysicsJointData);
  22438. /**
  22439. * Set the motor values.
  22440. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22441. * @param force the force to apply
  22442. * @param maxForce max force for this motor.
  22443. */
  22444. setMotor(force?: number, maxForce?: number): void;
  22445. /**
  22446. * Set the motor's limits.
  22447. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22448. * @param upperLimit The upper limit of the motor
  22449. * @param lowerLimit The lower limit of the motor
  22450. */
  22451. setLimit(upperLimit: number, lowerLimit?: number): void;
  22452. }
  22453. /**
  22454. * This class represents a single physics Hinge-Joint
  22455. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22456. */
  22457. export class HingeJoint extends MotorEnabledJoint {
  22458. /**
  22459. * Initializes the Hinge-Joint
  22460. * @param jointData The joint data for the Hinge-Joint
  22461. */
  22462. constructor(jointData: PhysicsJointData);
  22463. /**
  22464. * Set the motor values.
  22465. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22466. * @param {number} force the force to apply
  22467. * @param {number} maxForce max force for this motor.
  22468. */
  22469. setMotor(force?: number, maxForce?: number): void;
  22470. /**
  22471. * Set the motor's limits.
  22472. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22473. * @param upperLimit The upper limit of the motor
  22474. * @param lowerLimit The lower limit of the motor
  22475. */
  22476. setLimit(upperLimit: number, lowerLimit?: number): void;
  22477. }
  22478. /**
  22479. * This class represents a dual hinge physics joint (same as wheel joint)
  22480. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22481. */
  22482. export class Hinge2Joint extends MotorEnabledJoint {
  22483. /**
  22484. * Initializes the Hinge2-Joint
  22485. * @param jointData The joint data for the Hinge2-Joint
  22486. */
  22487. constructor(jointData: PhysicsJointData);
  22488. /**
  22489. * Set the motor values.
  22490. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22491. * @param {number} targetSpeed the speed the motor is to reach
  22492. * @param {number} maxForce max force for this motor.
  22493. * @param {motorIndex} the motor's index, 0 or 1.
  22494. */
  22495. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  22496. /**
  22497. * Set the motor limits.
  22498. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22499. * @param {number} upperLimit the upper limit
  22500. * @param {number} lowerLimit lower limit
  22501. * @param {motorIndex} the motor's index, 0 or 1.
  22502. */
  22503. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  22504. }
  22505. /**
  22506. * Interface for a motor enabled joint
  22507. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22508. */
  22509. export interface IMotorEnabledJoint {
  22510. /**
  22511. * Physics joint
  22512. */
  22513. physicsJoint: any;
  22514. /**
  22515. * Sets the motor of the motor-enabled joint
  22516. * @param force The force of the motor
  22517. * @param maxForce The maximum force of the motor
  22518. * @param motorIndex The index of the motor
  22519. */
  22520. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  22521. /**
  22522. * Sets the limit of the motor
  22523. * @param upperLimit The upper limit of the motor
  22524. * @param lowerLimit The lower limit of the motor
  22525. * @param motorIndex The index of the motor
  22526. */
  22527. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  22528. }
  22529. /**
  22530. * Joint data for a Distance-Joint
  22531. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22532. */
  22533. export interface DistanceJointData extends PhysicsJointData {
  22534. /**
  22535. * Max distance the 2 joint objects can be apart
  22536. */
  22537. maxDistance: number;
  22538. }
  22539. /**
  22540. * Joint data from a spring joint
  22541. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22542. */
  22543. export interface SpringJointData extends PhysicsJointData {
  22544. /**
  22545. * Length of the spring
  22546. */
  22547. length: number;
  22548. /**
  22549. * Stiffness of the spring
  22550. */
  22551. stiffness: number;
  22552. /**
  22553. * Damping of the spring
  22554. */
  22555. damping: number;
  22556. /** this callback will be called when applying the force to the impostors. */
  22557. forceApplicationCallback: () => void;
  22558. }
  22559. }
  22560. declare module BABYLON {
  22561. /**
  22562. * Holds the data for the raycast result
  22563. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22564. */
  22565. export class PhysicsRaycastResult {
  22566. private _hasHit;
  22567. private _hitDistance;
  22568. private _hitNormalWorld;
  22569. private _hitPointWorld;
  22570. private _rayFromWorld;
  22571. private _rayToWorld;
  22572. /**
  22573. * Gets if there was a hit
  22574. */
  22575. readonly hasHit: boolean;
  22576. /**
  22577. * Gets the distance from the hit
  22578. */
  22579. readonly hitDistance: number;
  22580. /**
  22581. * Gets the hit normal/direction in the world
  22582. */
  22583. readonly hitNormalWorld: Vector3;
  22584. /**
  22585. * Gets the hit point in the world
  22586. */
  22587. readonly hitPointWorld: Vector3;
  22588. /**
  22589. * Gets the ray "start point" of the ray in the world
  22590. */
  22591. readonly rayFromWorld: Vector3;
  22592. /**
  22593. * Gets the ray "end point" of the ray in the world
  22594. */
  22595. readonly rayToWorld: Vector3;
  22596. /**
  22597. * Sets the hit data (normal & point in world space)
  22598. * @param hitNormalWorld defines the normal in world space
  22599. * @param hitPointWorld defines the point in world space
  22600. */
  22601. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  22602. /**
  22603. * Sets the distance from the start point to the hit point
  22604. * @param distance
  22605. */
  22606. setHitDistance(distance: number): void;
  22607. /**
  22608. * Calculates the distance manually
  22609. */
  22610. calculateHitDistance(): void;
  22611. /**
  22612. * Resets all the values to default
  22613. * @param from The from point on world space
  22614. * @param to The to point on world space
  22615. */
  22616. reset(from?: Vector3, to?: Vector3): void;
  22617. }
  22618. /**
  22619. * Interface for the size containing width and height
  22620. */
  22621. interface IXYZ {
  22622. /**
  22623. * X
  22624. */
  22625. x: number;
  22626. /**
  22627. * Y
  22628. */
  22629. y: number;
  22630. /**
  22631. * Z
  22632. */
  22633. z: number;
  22634. }
  22635. }
  22636. declare module BABYLON {
  22637. /**
  22638. * Interface used to describe a physics joint
  22639. */
  22640. export interface PhysicsImpostorJoint {
  22641. /** Defines the main impostor to which the joint is linked */
  22642. mainImpostor: PhysicsImpostor;
  22643. /** Defines the impostor that is connected to the main impostor using this joint */
  22644. connectedImpostor: PhysicsImpostor;
  22645. /** Defines the joint itself */
  22646. joint: PhysicsJoint;
  22647. }
  22648. /** @hidden */
  22649. export interface IPhysicsEnginePlugin {
  22650. world: any;
  22651. name: string;
  22652. setGravity(gravity: Vector3): void;
  22653. setTimeStep(timeStep: number): void;
  22654. getTimeStep(): number;
  22655. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  22656. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  22657. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  22658. generatePhysicsBody(impostor: PhysicsImpostor): void;
  22659. removePhysicsBody(impostor: PhysicsImpostor): void;
  22660. generateJoint(joint: PhysicsImpostorJoint): void;
  22661. removeJoint(joint: PhysicsImpostorJoint): void;
  22662. isSupported(): boolean;
  22663. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  22664. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  22665. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  22666. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  22667. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  22668. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  22669. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  22670. getBodyMass(impostor: PhysicsImpostor): number;
  22671. getBodyFriction(impostor: PhysicsImpostor): number;
  22672. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  22673. getBodyRestitution(impostor: PhysicsImpostor): number;
  22674. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  22675. getBodyPressure?(impostor: PhysicsImpostor): number;
  22676. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  22677. getBodyStiffness?(impostor: PhysicsImpostor): number;
  22678. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  22679. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  22680. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  22681. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  22682. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  22683. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  22684. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  22685. sleepBody(impostor: PhysicsImpostor): void;
  22686. wakeUpBody(impostor: PhysicsImpostor): void;
  22687. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  22688. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  22689. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  22690. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  22691. getRadius(impostor: PhysicsImpostor): number;
  22692. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  22693. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  22694. dispose(): void;
  22695. }
  22696. /**
  22697. * Interface used to define a physics engine
  22698. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  22699. */
  22700. export interface IPhysicsEngine {
  22701. /**
  22702. * Gets the gravity vector used by the simulation
  22703. */
  22704. gravity: Vector3;
  22705. /**
  22706. * Sets the gravity vector used by the simulation
  22707. * @param gravity defines the gravity vector to use
  22708. */
  22709. setGravity(gravity: Vector3): void;
  22710. /**
  22711. * Set the time step of the physics engine.
  22712. * Default is 1/60.
  22713. * To slow it down, enter 1/600 for example.
  22714. * To speed it up, 1/30
  22715. * @param newTimeStep the new timestep to apply to this world.
  22716. */
  22717. setTimeStep(newTimeStep: number): void;
  22718. /**
  22719. * Get the time step of the physics engine.
  22720. * @returns the current time step
  22721. */
  22722. getTimeStep(): number;
  22723. /**
  22724. * Release all resources
  22725. */
  22726. dispose(): void;
  22727. /**
  22728. * Gets the name of the current physics plugin
  22729. * @returns the name of the plugin
  22730. */
  22731. getPhysicsPluginName(): string;
  22732. /**
  22733. * Adding a new impostor for the impostor tracking.
  22734. * This will be done by the impostor itself.
  22735. * @param impostor the impostor to add
  22736. */
  22737. addImpostor(impostor: PhysicsImpostor): void;
  22738. /**
  22739. * Remove an impostor from the engine.
  22740. * This impostor and its mesh will not longer be updated by the physics engine.
  22741. * @param impostor the impostor to remove
  22742. */
  22743. removeImpostor(impostor: PhysicsImpostor): void;
  22744. /**
  22745. * Add a joint to the physics engine
  22746. * @param mainImpostor defines the main impostor to which the joint is added.
  22747. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  22748. * @param joint defines the joint that will connect both impostors.
  22749. */
  22750. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  22751. /**
  22752. * Removes a joint from the simulation
  22753. * @param mainImpostor defines the impostor used with the joint
  22754. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  22755. * @param joint defines the joint to remove
  22756. */
  22757. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  22758. /**
  22759. * Gets the current plugin used to run the simulation
  22760. * @returns current plugin
  22761. */
  22762. getPhysicsPlugin(): IPhysicsEnginePlugin;
  22763. /**
  22764. * Gets the list of physic impostors
  22765. * @returns an array of PhysicsImpostor
  22766. */
  22767. getImpostors(): Array<PhysicsImpostor>;
  22768. /**
  22769. * Gets the impostor for a physics enabled object
  22770. * @param object defines the object impersonated by the impostor
  22771. * @returns the PhysicsImpostor or null if not found
  22772. */
  22773. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  22774. /**
  22775. * Gets the impostor for a physics body object
  22776. * @param body defines physics body used by the impostor
  22777. * @returns the PhysicsImpostor or null if not found
  22778. */
  22779. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  22780. /**
  22781. * Does a raycast in the physics world
  22782. * @param from when should the ray start?
  22783. * @param to when should the ray end?
  22784. * @returns PhysicsRaycastResult
  22785. */
  22786. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  22787. /**
  22788. * Called by the scene. No need to call it.
  22789. * @param delta defines the timespam between frames
  22790. */
  22791. _step(delta: number): void;
  22792. }
  22793. }
  22794. declare module BABYLON {
  22795. /**
  22796. * The interface for the physics imposter parameters
  22797. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22798. */
  22799. export interface PhysicsImpostorParameters {
  22800. /**
  22801. * The mass of the physics imposter
  22802. */
  22803. mass: number;
  22804. /**
  22805. * The friction of the physics imposter
  22806. */
  22807. friction?: number;
  22808. /**
  22809. * The coefficient of restitution of the physics imposter
  22810. */
  22811. restitution?: number;
  22812. /**
  22813. * The native options of the physics imposter
  22814. */
  22815. nativeOptions?: any;
  22816. /**
  22817. * Specifies if the parent should be ignored
  22818. */
  22819. ignoreParent?: boolean;
  22820. /**
  22821. * Specifies if bi-directional transformations should be disabled
  22822. */
  22823. disableBidirectionalTransformation?: boolean;
  22824. /**
  22825. * The pressure inside the physics imposter, soft object only
  22826. */
  22827. pressure?: number;
  22828. /**
  22829. * The stiffness the physics imposter, soft object only
  22830. */
  22831. stiffness?: number;
  22832. /**
  22833. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  22834. */
  22835. velocityIterations?: number;
  22836. /**
  22837. * The number of iterations used in maintaining consistent vertex positions, soft object only
  22838. */
  22839. positionIterations?: number;
  22840. /**
  22841. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  22842. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  22843. * Add to fix multiple points
  22844. */
  22845. fixedPoints?: number;
  22846. /**
  22847. * The collision margin around a soft object
  22848. */
  22849. margin?: number;
  22850. /**
  22851. * The collision margin around a soft object
  22852. */
  22853. damping?: number;
  22854. /**
  22855. * The path for a rope based on an extrusion
  22856. */
  22857. path?: any;
  22858. /**
  22859. * The shape of an extrusion used for a rope based on an extrusion
  22860. */
  22861. shape?: any;
  22862. }
  22863. /**
  22864. * Interface for a physics-enabled object
  22865. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22866. */
  22867. export interface IPhysicsEnabledObject {
  22868. /**
  22869. * The position of the physics-enabled object
  22870. */
  22871. position: Vector3;
  22872. /**
  22873. * The rotation of the physics-enabled object
  22874. */
  22875. rotationQuaternion: Nullable<Quaternion>;
  22876. /**
  22877. * The scale of the physics-enabled object
  22878. */
  22879. scaling: Vector3;
  22880. /**
  22881. * The rotation of the physics-enabled object
  22882. */
  22883. rotation?: Vector3;
  22884. /**
  22885. * The parent of the physics-enabled object
  22886. */
  22887. parent?: any;
  22888. /**
  22889. * The bounding info of the physics-enabled object
  22890. * @returns The bounding info of the physics-enabled object
  22891. */
  22892. getBoundingInfo(): BoundingInfo;
  22893. /**
  22894. * Computes the world matrix
  22895. * @param force Specifies if the world matrix should be computed by force
  22896. * @returns A world matrix
  22897. */
  22898. computeWorldMatrix(force: boolean): Matrix;
  22899. /**
  22900. * Gets the world matrix
  22901. * @returns A world matrix
  22902. */
  22903. getWorldMatrix?(): Matrix;
  22904. /**
  22905. * Gets the child meshes
  22906. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  22907. * @returns An array of abstract meshes
  22908. */
  22909. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  22910. /**
  22911. * Gets the vertex data
  22912. * @param kind The type of vertex data
  22913. * @returns A nullable array of numbers, or a float32 array
  22914. */
  22915. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  22916. /**
  22917. * Gets the indices from the mesh
  22918. * @returns A nullable array of index arrays
  22919. */
  22920. getIndices?(): Nullable<IndicesArray>;
  22921. /**
  22922. * Gets the scene from the mesh
  22923. * @returns the indices array or null
  22924. */
  22925. getScene?(): Scene;
  22926. /**
  22927. * Gets the absolute position from the mesh
  22928. * @returns the absolute position
  22929. */
  22930. getAbsolutePosition(): Vector3;
  22931. /**
  22932. * Gets the absolute pivot point from the mesh
  22933. * @returns the absolute pivot point
  22934. */
  22935. getAbsolutePivotPoint(): Vector3;
  22936. /**
  22937. * Rotates the mesh
  22938. * @param axis The axis of rotation
  22939. * @param amount The amount of rotation
  22940. * @param space The space of the rotation
  22941. * @returns The rotation transform node
  22942. */
  22943. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  22944. /**
  22945. * Translates the mesh
  22946. * @param axis The axis of translation
  22947. * @param distance The distance of translation
  22948. * @param space The space of the translation
  22949. * @returns The transform node
  22950. */
  22951. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  22952. /**
  22953. * Sets the absolute position of the mesh
  22954. * @param absolutePosition The absolute position of the mesh
  22955. * @returns The transform node
  22956. */
  22957. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  22958. /**
  22959. * Gets the class name of the mesh
  22960. * @returns The class name
  22961. */
  22962. getClassName(): string;
  22963. }
  22964. /**
  22965. * Represents a physics imposter
  22966. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22967. */
  22968. export class PhysicsImpostor {
  22969. /**
  22970. * The physics-enabled object used as the physics imposter
  22971. */
  22972. object: IPhysicsEnabledObject;
  22973. /**
  22974. * The type of the physics imposter
  22975. */
  22976. type: number;
  22977. private _options;
  22978. private _scene?;
  22979. /**
  22980. * The default object size of the imposter
  22981. */
  22982. static DEFAULT_OBJECT_SIZE: Vector3;
  22983. /**
  22984. * The identity quaternion of the imposter
  22985. */
  22986. static IDENTITY_QUATERNION: Quaternion;
  22987. /** @hidden */
  22988. _pluginData: any;
  22989. private _physicsEngine;
  22990. private _physicsBody;
  22991. private _bodyUpdateRequired;
  22992. private _onBeforePhysicsStepCallbacks;
  22993. private _onAfterPhysicsStepCallbacks;
  22994. /** @hidden */
  22995. _onPhysicsCollideCallbacks: Array<{
  22996. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  22997. otherImpostors: Array<PhysicsImpostor>;
  22998. }>;
  22999. private _deltaPosition;
  23000. private _deltaRotation;
  23001. private _deltaRotationConjugated;
  23002. /** @hidden */
  23003. _isFromLine: boolean;
  23004. private _parent;
  23005. private _isDisposed;
  23006. private static _tmpVecs;
  23007. private static _tmpQuat;
  23008. /**
  23009. * Specifies if the physics imposter is disposed
  23010. */
  23011. readonly isDisposed: boolean;
  23012. /**
  23013. * Gets the mass of the physics imposter
  23014. */
  23015. mass: number;
  23016. /**
  23017. * Gets the coefficient of friction
  23018. */
  23019. /**
  23020. * Sets the coefficient of friction
  23021. */
  23022. friction: number;
  23023. /**
  23024. * Gets the coefficient of restitution
  23025. */
  23026. /**
  23027. * Sets the coefficient of restitution
  23028. */
  23029. restitution: number;
  23030. /**
  23031. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  23032. */
  23033. /**
  23034. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  23035. */
  23036. pressure: number;
  23037. /**
  23038. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  23039. */
  23040. /**
  23041. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  23042. */
  23043. stiffness: number;
  23044. /**
  23045. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  23046. */
  23047. /**
  23048. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  23049. */
  23050. velocityIterations: number;
  23051. /**
  23052. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  23053. */
  23054. /**
  23055. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  23056. */
  23057. positionIterations: number;
  23058. /**
  23059. * The unique id of the physics imposter
  23060. * set by the physics engine when adding this impostor to the array
  23061. */
  23062. uniqueId: number;
  23063. /**
  23064. * @hidden
  23065. */
  23066. soft: boolean;
  23067. /**
  23068. * @hidden
  23069. */
  23070. segments: number;
  23071. private _joints;
  23072. /**
  23073. * Initializes the physics imposter
  23074. * @param object The physics-enabled object used as the physics imposter
  23075. * @param type The type of the physics imposter
  23076. * @param _options The options for the physics imposter
  23077. * @param _scene The Babylon scene
  23078. */
  23079. constructor(
  23080. /**
  23081. * The physics-enabled object used as the physics imposter
  23082. */
  23083. object: IPhysicsEnabledObject,
  23084. /**
  23085. * The type of the physics imposter
  23086. */
  23087. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  23088. /**
  23089. * This function will completly initialize this impostor.
  23090. * It will create a new body - but only if this mesh has no parent.
  23091. * If it has, this impostor will not be used other than to define the impostor
  23092. * of the child mesh.
  23093. * @hidden
  23094. */
  23095. _init(): void;
  23096. private _getPhysicsParent;
  23097. /**
  23098. * Should a new body be generated.
  23099. * @returns boolean specifying if body initialization is required
  23100. */
  23101. isBodyInitRequired(): boolean;
  23102. /**
  23103. * Sets the updated scaling
  23104. * @param updated Specifies if the scaling is updated
  23105. */
  23106. setScalingUpdated(): void;
  23107. /**
  23108. * Force a regeneration of this or the parent's impostor's body.
  23109. * Use under cautious - This will remove all joints already implemented.
  23110. */
  23111. forceUpdate(): void;
  23112. /**
  23113. * Gets the body that holds this impostor. Either its own, or its parent.
  23114. */
  23115. /**
  23116. * Set the physics body. Used mainly by the physics engine/plugin
  23117. */
  23118. physicsBody: any;
  23119. /**
  23120. * Get the parent of the physics imposter
  23121. * @returns Physics imposter or null
  23122. */
  23123. /**
  23124. * Sets the parent of the physics imposter
  23125. */
  23126. parent: Nullable<PhysicsImpostor>;
  23127. /**
  23128. * Resets the update flags
  23129. */
  23130. resetUpdateFlags(): void;
  23131. /**
  23132. * Gets the object extend size
  23133. * @returns the object extend size
  23134. */
  23135. getObjectExtendSize(): Vector3;
  23136. /**
  23137. * Gets the object center
  23138. * @returns The object center
  23139. */
  23140. getObjectCenter(): Vector3;
  23141. /**
  23142. * Get a specific parametes from the options parameter
  23143. * @param paramName The object parameter name
  23144. * @returns The object parameter
  23145. */
  23146. getParam(paramName: string): any;
  23147. /**
  23148. * Sets a specific parameter in the options given to the physics plugin
  23149. * @param paramName The parameter name
  23150. * @param value The value of the parameter
  23151. */
  23152. setParam(paramName: string, value: number): void;
  23153. /**
  23154. * Specifically change the body's mass option. Won't recreate the physics body object
  23155. * @param mass The mass of the physics imposter
  23156. */
  23157. setMass(mass: number): void;
  23158. /**
  23159. * Gets the linear velocity
  23160. * @returns linear velocity or null
  23161. */
  23162. getLinearVelocity(): Nullable<Vector3>;
  23163. /**
  23164. * Sets the linear velocity
  23165. * @param velocity linear velocity or null
  23166. */
  23167. setLinearVelocity(velocity: Nullable<Vector3>): void;
  23168. /**
  23169. * Gets the angular velocity
  23170. * @returns angular velocity or null
  23171. */
  23172. getAngularVelocity(): Nullable<Vector3>;
  23173. /**
  23174. * Sets the angular velocity
  23175. * @param velocity The velocity or null
  23176. */
  23177. setAngularVelocity(velocity: Nullable<Vector3>): void;
  23178. /**
  23179. * Execute a function with the physics plugin native code
  23180. * Provide a function the will have two variables - the world object and the physics body object
  23181. * @param func The function to execute with the physics plugin native code
  23182. */
  23183. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  23184. /**
  23185. * Register a function that will be executed before the physics world is stepping forward
  23186. * @param func The function to execute before the physics world is stepped forward
  23187. */
  23188. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23189. /**
  23190. * Unregister a function that will be executed before the physics world is stepping forward
  23191. * @param func The function to execute before the physics world is stepped forward
  23192. */
  23193. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23194. /**
  23195. * Register a function that will be executed after the physics step
  23196. * @param func The function to execute after physics step
  23197. */
  23198. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23199. /**
  23200. * Unregisters a function that will be executed after the physics step
  23201. * @param func The function to execute after physics step
  23202. */
  23203. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23204. /**
  23205. * register a function that will be executed when this impostor collides against a different body
  23206. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  23207. * @param func Callback that is executed on collision
  23208. */
  23209. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  23210. /**
  23211. * Unregisters the physics imposter on contact
  23212. * @param collideAgainst The physics object to collide against
  23213. * @param func Callback to execute on collision
  23214. */
  23215. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  23216. private _tmpQuat;
  23217. private _tmpQuat2;
  23218. /**
  23219. * Get the parent rotation
  23220. * @returns The parent rotation
  23221. */
  23222. getParentsRotation(): Quaternion;
  23223. /**
  23224. * this function is executed by the physics engine.
  23225. */
  23226. beforeStep: () => void;
  23227. /**
  23228. * this function is executed by the physics engine
  23229. */
  23230. afterStep: () => void;
  23231. /**
  23232. * Legacy collision detection event support
  23233. */
  23234. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  23235. /**
  23236. * event and body object due to cannon's event-based architecture.
  23237. */
  23238. onCollide: (e: {
  23239. body: any;
  23240. }) => void;
  23241. /**
  23242. * Apply a force
  23243. * @param force The force to apply
  23244. * @param contactPoint The contact point for the force
  23245. * @returns The physics imposter
  23246. */
  23247. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  23248. /**
  23249. * Apply an impulse
  23250. * @param force The impulse force
  23251. * @param contactPoint The contact point for the impulse force
  23252. * @returns The physics imposter
  23253. */
  23254. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  23255. /**
  23256. * A help function to create a joint
  23257. * @param otherImpostor A physics imposter used to create a joint
  23258. * @param jointType The type of joint
  23259. * @param jointData The data for the joint
  23260. * @returns The physics imposter
  23261. */
  23262. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  23263. /**
  23264. * Add a joint to this impostor with a different impostor
  23265. * @param otherImpostor A physics imposter used to add a joint
  23266. * @param joint The joint to add
  23267. * @returns The physics imposter
  23268. */
  23269. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  23270. /**
  23271. * Add an anchor to a cloth impostor
  23272. * @param otherImpostor rigid impostor to anchor to
  23273. * @param width ratio across width from 0 to 1
  23274. * @param height ratio up height from 0 to 1
  23275. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  23276. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  23277. * @returns impostor the soft imposter
  23278. */
  23279. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  23280. /**
  23281. * Add a hook to a rope impostor
  23282. * @param otherImpostor rigid impostor to anchor to
  23283. * @param length ratio across rope from 0 to 1
  23284. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  23285. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  23286. * @returns impostor the rope imposter
  23287. */
  23288. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  23289. /**
  23290. * Will keep this body still, in a sleep mode.
  23291. * @returns the physics imposter
  23292. */
  23293. sleep(): PhysicsImpostor;
  23294. /**
  23295. * Wake the body up.
  23296. * @returns The physics imposter
  23297. */
  23298. wakeUp(): PhysicsImpostor;
  23299. /**
  23300. * Clones the physics imposter
  23301. * @param newObject The physics imposter clones to this physics-enabled object
  23302. * @returns A nullable physics imposter
  23303. */
  23304. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  23305. /**
  23306. * Disposes the physics imposter
  23307. */
  23308. dispose(): void;
  23309. /**
  23310. * Sets the delta position
  23311. * @param position The delta position amount
  23312. */
  23313. setDeltaPosition(position: Vector3): void;
  23314. /**
  23315. * Sets the delta rotation
  23316. * @param rotation The delta rotation amount
  23317. */
  23318. setDeltaRotation(rotation: Quaternion): void;
  23319. /**
  23320. * Gets the box size of the physics imposter and stores the result in the input parameter
  23321. * @param result Stores the box size
  23322. * @returns The physics imposter
  23323. */
  23324. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  23325. /**
  23326. * Gets the radius of the physics imposter
  23327. * @returns Radius of the physics imposter
  23328. */
  23329. getRadius(): number;
  23330. /**
  23331. * Sync a bone with this impostor
  23332. * @param bone The bone to sync to the impostor.
  23333. * @param boneMesh The mesh that the bone is influencing.
  23334. * @param jointPivot The pivot of the joint / bone in local space.
  23335. * @param distToJoint Optional distance from the impostor to the joint.
  23336. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  23337. */
  23338. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  23339. /**
  23340. * Sync impostor to a bone
  23341. * @param bone The bone that the impostor will be synced to.
  23342. * @param boneMesh The mesh that the bone is influencing.
  23343. * @param jointPivot The pivot of the joint / bone in local space.
  23344. * @param distToJoint Optional distance from the impostor to the joint.
  23345. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  23346. * @param boneAxis Optional vector3 axis the bone is aligned with
  23347. */
  23348. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  23349. /**
  23350. * No-Imposter type
  23351. */
  23352. static NoImpostor: number;
  23353. /**
  23354. * Sphere-Imposter type
  23355. */
  23356. static SphereImpostor: number;
  23357. /**
  23358. * Box-Imposter type
  23359. */
  23360. static BoxImpostor: number;
  23361. /**
  23362. * Plane-Imposter type
  23363. */
  23364. static PlaneImpostor: number;
  23365. /**
  23366. * Mesh-imposter type
  23367. */
  23368. static MeshImpostor: number;
  23369. /**
  23370. * Capsule-Impostor type (Ammo.js plugin only)
  23371. */
  23372. static CapsuleImpostor: number;
  23373. /**
  23374. * Cylinder-Imposter type
  23375. */
  23376. static CylinderImpostor: number;
  23377. /**
  23378. * Particle-Imposter type
  23379. */
  23380. static ParticleImpostor: number;
  23381. /**
  23382. * Heightmap-Imposter type
  23383. */
  23384. static HeightmapImpostor: number;
  23385. /**
  23386. * ConvexHull-Impostor type (Ammo.js plugin only)
  23387. */
  23388. static ConvexHullImpostor: number;
  23389. /**
  23390. * Rope-Imposter type
  23391. */
  23392. static RopeImpostor: number;
  23393. /**
  23394. * Cloth-Imposter type
  23395. */
  23396. static ClothImpostor: number;
  23397. /**
  23398. * Softbody-Imposter type
  23399. */
  23400. static SoftbodyImpostor: number;
  23401. }
  23402. }
  23403. declare module BABYLON {
  23404. /**
  23405. * @hidden
  23406. **/
  23407. export class _CreationDataStorage {
  23408. closePath?: boolean;
  23409. closeArray?: boolean;
  23410. idx: number[];
  23411. dashSize: number;
  23412. gapSize: number;
  23413. path3D: Path3D;
  23414. pathArray: Vector3[][];
  23415. arc: number;
  23416. radius: number;
  23417. cap: number;
  23418. tessellation: number;
  23419. }
  23420. /**
  23421. * @hidden
  23422. **/
  23423. class _InstanceDataStorage {
  23424. visibleInstances: any;
  23425. batchCache: _InstancesBatch;
  23426. instancesBufferSize: number;
  23427. instancesBuffer: Nullable<Buffer>;
  23428. instancesData: Float32Array;
  23429. overridenInstanceCount: number;
  23430. isFrozen: boolean;
  23431. previousBatch: Nullable<_InstancesBatch>;
  23432. hardwareInstancedRendering: boolean;
  23433. sideOrientation: number;
  23434. }
  23435. /**
  23436. * @hidden
  23437. **/
  23438. export class _InstancesBatch {
  23439. mustReturn: boolean;
  23440. visibleInstances: Nullable<InstancedMesh[]>[];
  23441. renderSelf: boolean[];
  23442. hardwareInstancedRendering: boolean[];
  23443. }
  23444. /**
  23445. * Class used to represent renderable models
  23446. */
  23447. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  23448. /**
  23449. * Mesh side orientation : usually the external or front surface
  23450. */
  23451. static readonly FRONTSIDE: number;
  23452. /**
  23453. * Mesh side orientation : usually the internal or back surface
  23454. */
  23455. static readonly BACKSIDE: number;
  23456. /**
  23457. * Mesh side orientation : both internal and external or front and back surfaces
  23458. */
  23459. static readonly DOUBLESIDE: number;
  23460. /**
  23461. * Mesh side orientation : by default, `FRONTSIDE`
  23462. */
  23463. static readonly DEFAULTSIDE: number;
  23464. /**
  23465. * Mesh cap setting : no cap
  23466. */
  23467. static readonly NO_CAP: number;
  23468. /**
  23469. * Mesh cap setting : one cap at the beginning of the mesh
  23470. */
  23471. static readonly CAP_START: number;
  23472. /**
  23473. * Mesh cap setting : one cap at the end of the mesh
  23474. */
  23475. static readonly CAP_END: number;
  23476. /**
  23477. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  23478. */
  23479. static readonly CAP_ALL: number;
  23480. /**
  23481. * Mesh pattern setting : no flip or rotate
  23482. */
  23483. static readonly NO_FLIP: number;
  23484. /**
  23485. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  23486. */
  23487. static readonly FLIP_TILE: number;
  23488. /**
  23489. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  23490. */
  23491. static readonly ROTATE_TILE: number;
  23492. /**
  23493. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  23494. */
  23495. static readonly FLIP_ROW: number;
  23496. /**
  23497. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  23498. */
  23499. static readonly ROTATE_ROW: number;
  23500. /**
  23501. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  23502. */
  23503. static readonly FLIP_N_ROTATE_TILE: number;
  23504. /**
  23505. * Mesh pattern setting : rotate pattern and rotate
  23506. */
  23507. static readonly FLIP_N_ROTATE_ROW: number;
  23508. /**
  23509. * Mesh tile positioning : part tiles same on left/right or top/bottom
  23510. */
  23511. static readonly CENTER: number;
  23512. /**
  23513. * Mesh tile positioning : part tiles on left
  23514. */
  23515. static readonly LEFT: number;
  23516. /**
  23517. * Mesh tile positioning : part tiles on right
  23518. */
  23519. static readonly RIGHT: number;
  23520. /**
  23521. * Mesh tile positioning : part tiles on top
  23522. */
  23523. static readonly TOP: number;
  23524. /**
  23525. * Mesh tile positioning : part tiles on bottom
  23526. */
  23527. static readonly BOTTOM: number;
  23528. /**
  23529. * Gets the default side orientation.
  23530. * @param orientation the orientation to value to attempt to get
  23531. * @returns the default orientation
  23532. * @hidden
  23533. */
  23534. static _GetDefaultSideOrientation(orientation?: number): number;
  23535. private _internalMeshDataInfo;
  23536. /**
  23537. * An event triggered before rendering the mesh
  23538. */
  23539. readonly onBeforeRenderObservable: Observable<Mesh>;
  23540. /**
  23541. * An event triggered before binding the mesh
  23542. */
  23543. readonly onBeforeBindObservable: Observable<Mesh>;
  23544. /**
  23545. * An event triggered after rendering the mesh
  23546. */
  23547. readonly onAfterRenderObservable: Observable<Mesh>;
  23548. /**
  23549. * An event triggered before drawing the mesh
  23550. */
  23551. readonly onBeforeDrawObservable: Observable<Mesh>;
  23552. private _onBeforeDrawObserver;
  23553. /**
  23554. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  23555. */
  23556. onBeforeDraw: () => void;
  23557. readonly hasInstances: boolean;
  23558. /**
  23559. * Gets the delay loading state of the mesh (when delay loading is turned on)
  23560. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  23561. */
  23562. delayLoadState: number;
  23563. /**
  23564. * Gets the list of instances created from this mesh
  23565. * it is not supposed to be modified manually.
  23566. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  23567. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  23568. */
  23569. instances: InstancedMesh[];
  23570. /**
  23571. * Gets the file containing delay loading data for this mesh
  23572. */
  23573. delayLoadingFile: string;
  23574. /** @hidden */
  23575. _binaryInfo: any;
  23576. /**
  23577. * User defined function used to change how LOD level selection is done
  23578. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  23579. */
  23580. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  23581. /**
  23582. * Gets or sets the morph target manager
  23583. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  23584. */
  23585. morphTargetManager: Nullable<MorphTargetManager>;
  23586. /** @hidden */
  23587. _creationDataStorage: Nullable<_CreationDataStorage>;
  23588. /** @hidden */
  23589. _geometry: Nullable<Geometry>;
  23590. /** @hidden */
  23591. _delayInfo: Array<string>;
  23592. /** @hidden */
  23593. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  23594. /** @hidden */
  23595. _instanceDataStorage: _InstanceDataStorage;
  23596. private _effectiveMaterial;
  23597. /** @hidden */
  23598. _shouldGenerateFlatShading: boolean;
  23599. /** @hidden */
  23600. _originalBuilderSideOrientation: number;
  23601. /**
  23602. * Use this property to change the original side orientation defined at construction time
  23603. */
  23604. overrideMaterialSideOrientation: Nullable<number>;
  23605. /**
  23606. * Gets the source mesh (the one used to clone this one from)
  23607. */
  23608. readonly source: Nullable<Mesh>;
  23609. /**
  23610. * Gets or sets a boolean indicating that this mesh does not use index buffer
  23611. */
  23612. isUnIndexed: boolean;
  23613. /**
  23614. * @constructor
  23615. * @param name The value used by scene.getMeshByName() to do a lookup.
  23616. * @param scene The scene to add this mesh to.
  23617. * @param parent The parent of this mesh, if it has one
  23618. * @param source An optional Mesh from which geometry is shared, cloned.
  23619. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  23620. * When false, achieved by calling a clone(), also passing False.
  23621. * This will make creation of children, recursive.
  23622. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  23623. */
  23624. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  23625. instantiateHierarchy(newParent?: Nullable<TransformNode>): Nullable<TransformNode>;
  23626. /**
  23627. * Gets the class name
  23628. * @returns the string "Mesh".
  23629. */
  23630. getClassName(): string;
  23631. /** @hidden */
  23632. readonly _isMesh: boolean;
  23633. /**
  23634. * Returns a description of this mesh
  23635. * @param fullDetails define if full details about this mesh must be used
  23636. * @returns a descriptive string representing this mesh
  23637. */
  23638. toString(fullDetails?: boolean): string;
  23639. /** @hidden */
  23640. _unBindEffect(): void;
  23641. /**
  23642. * Gets a boolean indicating if this mesh has LOD
  23643. */
  23644. readonly hasLODLevels: boolean;
  23645. /**
  23646. * Gets the list of MeshLODLevel associated with the current mesh
  23647. * @returns an array of MeshLODLevel
  23648. */
  23649. getLODLevels(): MeshLODLevel[];
  23650. private _sortLODLevels;
  23651. /**
  23652. * Add a mesh as LOD level triggered at the given distance.
  23653. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  23654. * @param distance The distance from the center of the object to show this level
  23655. * @param mesh The mesh to be added as LOD level (can be null)
  23656. * @return This mesh (for chaining)
  23657. */
  23658. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  23659. /**
  23660. * Returns the LOD level mesh at the passed distance or null if not found.
  23661. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  23662. * @param distance The distance from the center of the object to show this level
  23663. * @returns a Mesh or `null`
  23664. */
  23665. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  23666. /**
  23667. * Remove a mesh from the LOD array
  23668. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  23669. * @param mesh defines the mesh to be removed
  23670. * @return This mesh (for chaining)
  23671. */
  23672. removeLODLevel(mesh: Mesh): Mesh;
  23673. /**
  23674. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  23675. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  23676. * @param camera defines the camera to use to compute distance
  23677. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  23678. * @return This mesh (for chaining)
  23679. */
  23680. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  23681. /**
  23682. * Gets the mesh internal Geometry object
  23683. */
  23684. readonly geometry: Nullable<Geometry>;
  23685. /**
  23686. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  23687. * @returns the total number of vertices
  23688. */
  23689. getTotalVertices(): number;
  23690. /**
  23691. * Returns the content of an associated vertex buffer
  23692. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  23693. * - VertexBuffer.PositionKind
  23694. * - VertexBuffer.UVKind
  23695. * - VertexBuffer.UV2Kind
  23696. * - VertexBuffer.UV3Kind
  23697. * - VertexBuffer.UV4Kind
  23698. * - VertexBuffer.UV5Kind
  23699. * - VertexBuffer.UV6Kind
  23700. * - VertexBuffer.ColorKind
  23701. * - VertexBuffer.MatricesIndicesKind
  23702. * - VertexBuffer.MatricesIndicesExtraKind
  23703. * - VertexBuffer.MatricesWeightsKind
  23704. * - VertexBuffer.MatricesWeightsExtraKind
  23705. * @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
  23706. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  23707. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  23708. */
  23709. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  23710. /**
  23711. * Returns the mesh VertexBuffer object from the requested `kind`
  23712. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  23713. * - VertexBuffer.PositionKind
  23714. * - VertexBuffer.NormalKind
  23715. * - VertexBuffer.UVKind
  23716. * - VertexBuffer.UV2Kind
  23717. * - VertexBuffer.UV3Kind
  23718. * - VertexBuffer.UV4Kind
  23719. * - VertexBuffer.UV5Kind
  23720. * - VertexBuffer.UV6Kind
  23721. * - VertexBuffer.ColorKind
  23722. * - VertexBuffer.MatricesIndicesKind
  23723. * - VertexBuffer.MatricesIndicesExtraKind
  23724. * - VertexBuffer.MatricesWeightsKind
  23725. * - VertexBuffer.MatricesWeightsExtraKind
  23726. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  23727. */
  23728. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  23729. /**
  23730. * Tests if a specific vertex buffer is associated with this mesh
  23731. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  23732. * - VertexBuffer.PositionKind
  23733. * - VertexBuffer.NormalKind
  23734. * - VertexBuffer.UVKind
  23735. * - VertexBuffer.UV2Kind
  23736. * - VertexBuffer.UV3Kind
  23737. * - VertexBuffer.UV4Kind
  23738. * - VertexBuffer.UV5Kind
  23739. * - VertexBuffer.UV6Kind
  23740. * - VertexBuffer.ColorKind
  23741. * - VertexBuffer.MatricesIndicesKind
  23742. * - VertexBuffer.MatricesIndicesExtraKind
  23743. * - VertexBuffer.MatricesWeightsKind
  23744. * - VertexBuffer.MatricesWeightsExtraKind
  23745. * @returns a boolean
  23746. */
  23747. isVerticesDataPresent(kind: string): boolean;
  23748. /**
  23749. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  23750. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  23751. * - VertexBuffer.PositionKind
  23752. * - VertexBuffer.UVKind
  23753. * - VertexBuffer.UV2Kind
  23754. * - VertexBuffer.UV3Kind
  23755. * - VertexBuffer.UV4Kind
  23756. * - VertexBuffer.UV5Kind
  23757. * - VertexBuffer.UV6Kind
  23758. * - VertexBuffer.ColorKind
  23759. * - VertexBuffer.MatricesIndicesKind
  23760. * - VertexBuffer.MatricesIndicesExtraKind
  23761. * - VertexBuffer.MatricesWeightsKind
  23762. * - VertexBuffer.MatricesWeightsExtraKind
  23763. * @returns a boolean
  23764. */
  23765. isVertexBufferUpdatable(kind: string): boolean;
  23766. /**
  23767. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  23768. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  23769. * - VertexBuffer.PositionKind
  23770. * - VertexBuffer.NormalKind
  23771. * - VertexBuffer.UVKind
  23772. * - VertexBuffer.UV2Kind
  23773. * - VertexBuffer.UV3Kind
  23774. * - VertexBuffer.UV4Kind
  23775. * - VertexBuffer.UV5Kind
  23776. * - VertexBuffer.UV6Kind
  23777. * - VertexBuffer.ColorKind
  23778. * - VertexBuffer.MatricesIndicesKind
  23779. * - VertexBuffer.MatricesIndicesExtraKind
  23780. * - VertexBuffer.MatricesWeightsKind
  23781. * - VertexBuffer.MatricesWeightsExtraKind
  23782. * @returns an array of strings
  23783. */
  23784. getVerticesDataKinds(): string[];
  23785. /**
  23786. * Returns a positive integer : the total number of indices in this mesh geometry.
  23787. * @returns the numner of indices or zero if the mesh has no geometry.
  23788. */
  23789. getTotalIndices(): number;
  23790. /**
  23791. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  23792. * @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.
  23793. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23794. * @returns the indices array or an empty array if the mesh has no geometry
  23795. */
  23796. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  23797. readonly isBlocked: boolean;
  23798. /**
  23799. * Determine if the current mesh is ready to be rendered
  23800. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  23801. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  23802. * @returns true if all associated assets are ready (material, textures, shaders)
  23803. */
  23804. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  23805. /**
  23806. * 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.
  23807. */
  23808. readonly areNormalsFrozen: boolean;
  23809. /**
  23810. * 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.
  23811. * @returns the current mesh
  23812. */
  23813. freezeNormals(): Mesh;
  23814. /**
  23815. * 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
  23816. * @returns the current mesh
  23817. */
  23818. unfreezeNormals(): Mesh;
  23819. /**
  23820. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  23821. */
  23822. overridenInstanceCount: number;
  23823. /** @hidden */
  23824. _preActivate(): Mesh;
  23825. /** @hidden */
  23826. _preActivateForIntermediateRendering(renderId: number): Mesh;
  23827. /** @hidden */
  23828. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  23829. /**
  23830. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  23831. * This means the mesh underlying bounding box and sphere are recomputed.
  23832. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  23833. * @returns the current mesh
  23834. */
  23835. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  23836. /** @hidden */
  23837. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  23838. /**
  23839. * This function will subdivide the mesh into multiple submeshes
  23840. * @param count defines the expected number of submeshes
  23841. */
  23842. subdivide(count: number): void;
  23843. /**
  23844. * Copy a FloatArray into a specific associated vertex buffer
  23845. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  23846. * - VertexBuffer.PositionKind
  23847. * - VertexBuffer.UVKind
  23848. * - VertexBuffer.UV2Kind
  23849. * - VertexBuffer.UV3Kind
  23850. * - VertexBuffer.UV4Kind
  23851. * - VertexBuffer.UV5Kind
  23852. * - VertexBuffer.UV6Kind
  23853. * - VertexBuffer.ColorKind
  23854. * - VertexBuffer.MatricesIndicesKind
  23855. * - VertexBuffer.MatricesIndicesExtraKind
  23856. * - VertexBuffer.MatricesWeightsKind
  23857. * - VertexBuffer.MatricesWeightsExtraKind
  23858. * @param data defines the data source
  23859. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  23860. * @param stride defines the data stride size (can be null)
  23861. * @returns the current mesh
  23862. */
  23863. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  23864. /**
  23865. * Flags an associated vertex buffer as updatable
  23866. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  23867. * - VertexBuffer.PositionKind
  23868. * - VertexBuffer.UVKind
  23869. * - VertexBuffer.UV2Kind
  23870. * - VertexBuffer.UV3Kind
  23871. * - VertexBuffer.UV4Kind
  23872. * - VertexBuffer.UV5Kind
  23873. * - VertexBuffer.UV6Kind
  23874. * - VertexBuffer.ColorKind
  23875. * - VertexBuffer.MatricesIndicesKind
  23876. * - VertexBuffer.MatricesIndicesExtraKind
  23877. * - VertexBuffer.MatricesWeightsKind
  23878. * - VertexBuffer.MatricesWeightsExtraKind
  23879. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  23880. */
  23881. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  23882. /**
  23883. * Sets the mesh global Vertex Buffer
  23884. * @param buffer defines the buffer to use
  23885. * @returns the current mesh
  23886. */
  23887. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  23888. /**
  23889. * Update a specific associated vertex buffer
  23890. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  23891. * - VertexBuffer.PositionKind
  23892. * - VertexBuffer.UVKind
  23893. * - VertexBuffer.UV2Kind
  23894. * - VertexBuffer.UV3Kind
  23895. * - VertexBuffer.UV4Kind
  23896. * - VertexBuffer.UV5Kind
  23897. * - VertexBuffer.UV6Kind
  23898. * - VertexBuffer.ColorKind
  23899. * - VertexBuffer.MatricesIndicesKind
  23900. * - VertexBuffer.MatricesIndicesExtraKind
  23901. * - VertexBuffer.MatricesWeightsKind
  23902. * - VertexBuffer.MatricesWeightsExtraKind
  23903. * @param data defines the data source
  23904. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  23905. * @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)
  23906. * @returns the current mesh
  23907. */
  23908. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  23909. /**
  23910. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  23911. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  23912. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  23913. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  23914. * @returns the current mesh
  23915. */
  23916. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  23917. /**
  23918. * Creates a un-shared specific occurence of the geometry for the mesh.
  23919. * @returns the current mesh
  23920. */
  23921. makeGeometryUnique(): Mesh;
  23922. /**
  23923. * Set the index buffer of this mesh
  23924. * @param indices defines the source data
  23925. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  23926. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  23927. * @returns the current mesh
  23928. */
  23929. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  23930. /**
  23931. * Update the current index buffer
  23932. * @param indices defines the source data
  23933. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  23934. * @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)
  23935. * @returns the current mesh
  23936. */
  23937. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  23938. /**
  23939. * Invert the geometry to move from a right handed system to a left handed one.
  23940. * @returns the current mesh
  23941. */
  23942. toLeftHanded(): Mesh;
  23943. /** @hidden */
  23944. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  23945. /** @hidden */
  23946. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  23947. /**
  23948. * Registers for this mesh a javascript function called just before the rendering process
  23949. * @param func defines the function to call before rendering this mesh
  23950. * @returns the current mesh
  23951. */
  23952. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  23953. /**
  23954. * Disposes a previously registered javascript function called before the rendering
  23955. * @param func defines the function to remove
  23956. * @returns the current mesh
  23957. */
  23958. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  23959. /**
  23960. * Registers for this mesh a javascript function called just after the rendering is complete
  23961. * @param func defines the function to call after rendering this mesh
  23962. * @returns the current mesh
  23963. */
  23964. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  23965. /**
  23966. * Disposes a previously registered javascript function called after the rendering.
  23967. * @param func defines the function to remove
  23968. * @returns the current mesh
  23969. */
  23970. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  23971. /** @hidden */
  23972. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  23973. /** @hidden */
  23974. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  23975. /** @hidden */
  23976. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  23977. /** @hidden */
  23978. _rebuild(): void;
  23979. /** @hidden */
  23980. _freeze(): void;
  23981. /** @hidden */
  23982. _unFreeze(): void;
  23983. /**
  23984. * 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
  23985. * @param subMesh defines the subMesh to render
  23986. * @param enableAlphaMode defines if alpha mode can be changed
  23987. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  23988. * @returns the current mesh
  23989. */
  23990. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  23991. private _onBeforeDraw;
  23992. /**
  23993. * Renormalize the mesh and patch it up if there are no weights
  23994. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  23995. * However in the case of zero weights then we set just a single influence to 1.
  23996. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  23997. */
  23998. cleanMatrixWeights(): void;
  23999. private normalizeSkinFourWeights;
  24000. private normalizeSkinWeightsAndExtra;
  24001. /**
  24002. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  24003. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  24004. * the user know there was an issue with importing the mesh
  24005. * @returns a validation object with skinned, valid and report string
  24006. */
  24007. validateSkinning(): {
  24008. skinned: boolean;
  24009. valid: boolean;
  24010. report: string;
  24011. };
  24012. /** @hidden */
  24013. _checkDelayState(): Mesh;
  24014. private _queueLoad;
  24015. /**
  24016. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  24017. * A mesh is in the frustum if its bounding box intersects the frustum
  24018. * @param frustumPlanes defines the frustum to test
  24019. * @returns true if the mesh is in the frustum planes
  24020. */
  24021. isInFrustum(frustumPlanes: Plane[]): boolean;
  24022. /**
  24023. * Sets the mesh material by the material or multiMaterial `id` property
  24024. * @param id is a string identifying the material or the multiMaterial
  24025. * @returns the current mesh
  24026. */
  24027. setMaterialByID(id: string): Mesh;
  24028. /**
  24029. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  24030. * @returns an array of IAnimatable
  24031. */
  24032. getAnimatables(): IAnimatable[];
  24033. /**
  24034. * Modifies the mesh geometry according to the passed transformation matrix.
  24035. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  24036. * The mesh normals are modified using the same transformation.
  24037. * Note that, under the hood, this method sets a new VertexBuffer each call.
  24038. * @param transform defines the transform matrix to use
  24039. * @see http://doc.babylonjs.com/resources/baking_transformations
  24040. * @returns the current mesh
  24041. */
  24042. bakeTransformIntoVertices(transform: Matrix): Mesh;
  24043. /**
  24044. * Modifies the mesh geometry according to its own current World Matrix.
  24045. * The mesh World Matrix is then reset.
  24046. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  24047. * Note that, under the hood, this method sets a new VertexBuffer each call.
  24048. * @see http://doc.babylonjs.com/resources/baking_transformations
  24049. * @returns the current mesh
  24050. */
  24051. bakeCurrentTransformIntoVertices(): Mesh;
  24052. /** @hidden */
  24053. readonly _positions: Nullable<Vector3[]>;
  24054. /** @hidden */
  24055. _resetPointsArrayCache(): Mesh;
  24056. /** @hidden */
  24057. _generatePointsArray(): boolean;
  24058. /**
  24059. * Returns a new Mesh object generated from the current mesh properties.
  24060. * This method must not get confused with createInstance()
  24061. * @param name is a string, the name given to the new mesh
  24062. * @param newParent can be any Node object (default `null`)
  24063. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  24064. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  24065. * @returns a new mesh
  24066. */
  24067. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Nullable<AbstractMesh>;
  24068. /**
  24069. * Releases resources associated with this mesh.
  24070. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24071. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24072. */
  24073. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24074. /**
  24075. * Modifies the mesh geometry according to a displacement map.
  24076. * 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.
  24077. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  24078. * @param url is a string, the URL from the image file is to be downloaded.
  24079. * @param minHeight is the lower limit of the displacement.
  24080. * @param maxHeight is the upper limit of the displacement.
  24081. * @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.
  24082. * @param uvOffset is an optional vector2 used to offset UV.
  24083. * @param uvScale is an optional vector2 used to scale UV.
  24084. * @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.
  24085. * @returns the Mesh.
  24086. */
  24087. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  24088. /**
  24089. * Modifies the mesh geometry according to a displacementMap buffer.
  24090. * 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.
  24091. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  24092. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  24093. * @param heightMapWidth is the width of the buffer image.
  24094. * @param heightMapHeight is the height of the buffer image.
  24095. * @param minHeight is the lower limit of the displacement.
  24096. * @param maxHeight is the upper limit of the displacement.
  24097. * @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.
  24098. * @param uvOffset is an optional vector2 used to offset UV.
  24099. * @param uvScale is an optional vector2 used to scale UV.
  24100. * @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.
  24101. * @returns the Mesh.
  24102. */
  24103. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  24104. /**
  24105. * Modify the mesh to get a flat shading rendering.
  24106. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  24107. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  24108. * @returns current mesh
  24109. */
  24110. convertToFlatShadedMesh(): Mesh;
  24111. /**
  24112. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  24113. * In other words, more vertices, no more indices and a single bigger VBO.
  24114. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  24115. * @returns current mesh
  24116. */
  24117. convertToUnIndexedMesh(): Mesh;
  24118. /**
  24119. * Inverses facet orientations.
  24120. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24121. * @param flipNormals will also inverts the normals
  24122. * @returns current mesh
  24123. */
  24124. flipFaces(flipNormals?: boolean): Mesh;
  24125. /**
  24126. * Increase the number of facets and hence vertices in a mesh
  24127. * Vertex normals are interpolated from existing vertex normals
  24128. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24129. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  24130. */
  24131. increaseVertices(numberPerEdge: number): void;
  24132. /**
  24133. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  24134. * This will undo any application of covertToFlatShadedMesh
  24135. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24136. */
  24137. forceSharedVertices(): void;
  24138. /** @hidden */
  24139. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  24140. /** @hidden */
  24141. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  24142. /**
  24143. * Creates a new InstancedMesh object from the mesh model.
  24144. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24145. * @param name defines the name of the new instance
  24146. * @returns a new InstancedMesh
  24147. */
  24148. createInstance(name: string): InstancedMesh;
  24149. /**
  24150. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  24151. * After this call, all the mesh instances have the same submeshes than the current mesh.
  24152. * @returns the current mesh
  24153. */
  24154. synchronizeInstances(): Mesh;
  24155. /**
  24156. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  24157. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  24158. * This should be used together with the simplification to avoid disappearing triangles.
  24159. * @param successCallback an optional success callback to be called after the optimization finished.
  24160. * @returns the current mesh
  24161. */
  24162. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  24163. /**
  24164. * Serialize current mesh
  24165. * @param serializationObject defines the object which will receive the serialization data
  24166. */
  24167. serialize(serializationObject: any): void;
  24168. /** @hidden */
  24169. _syncGeometryWithMorphTargetManager(): void;
  24170. /** @hidden */
  24171. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  24172. /**
  24173. * Returns a new Mesh object parsed from the source provided.
  24174. * @param parsedMesh is the source
  24175. * @param scene defines the hosting scene
  24176. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  24177. * @returns a new Mesh
  24178. */
  24179. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  24180. /**
  24181. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  24182. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24183. * @param name defines the name of the mesh to create
  24184. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  24185. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  24186. * @param closePath creates a seam between the first and the last points of each path of the path array
  24187. * @param offset is taken in account only if the `pathArray` is containing a single path
  24188. * @param scene defines the hosting scene
  24189. * @param updatable defines if the mesh must be flagged as updatable
  24190. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24191. * @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)
  24192. * @returns a new Mesh
  24193. */
  24194. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24195. /**
  24196. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  24197. * @param name defines the name of the mesh to create
  24198. * @param radius sets the radius size (float) of the polygon (default 0.5)
  24199. * @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
  24200. * @param scene defines the hosting scene
  24201. * @param updatable defines if the mesh must be flagged as updatable
  24202. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24203. * @returns a new Mesh
  24204. */
  24205. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  24206. /**
  24207. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  24208. * @param name defines the name of the mesh to create
  24209. * @param size sets the size (float) of each box side (default 1)
  24210. * @param scene defines the hosting scene
  24211. * @param updatable defines if the mesh must be flagged as updatable
  24212. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24213. * @returns a new Mesh
  24214. */
  24215. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  24216. /**
  24217. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  24218. * @param name defines the name of the mesh to create
  24219. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  24220. * @param diameter sets the diameter size (float) of the sphere (default 1)
  24221. * @param scene defines the hosting scene
  24222. * @param updatable defines if the mesh must be flagged as updatable
  24223. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24224. * @returns a new Mesh
  24225. */
  24226. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24227. /**
  24228. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  24229. * @param name defines the name of the mesh to create
  24230. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  24231. * @param diameter sets the diameter size (float) of the sphere (default 1)
  24232. * @param scene defines the hosting scene
  24233. * @returns a new Mesh
  24234. */
  24235. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  24236. /**
  24237. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  24238. * @param name defines the name of the mesh to create
  24239. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  24240. * @param diameterTop set the top cap diameter (floats, default 1)
  24241. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  24242. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  24243. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  24244. * @param scene defines the hosting scene
  24245. * @param updatable defines if the mesh must be flagged as updatable
  24246. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24247. * @returns a new Mesh
  24248. */
  24249. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  24250. /**
  24251. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  24252. * @param name defines the name of the mesh to create
  24253. * @param diameter sets the diameter size (float) of the torus (default 1)
  24254. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  24255. * @param tessellation sets the number of torus sides (postive integer, default 16)
  24256. * @param scene defines the hosting scene
  24257. * @param updatable defines if the mesh must be flagged as updatable
  24258. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24259. * @returns a new Mesh
  24260. */
  24261. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24262. /**
  24263. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  24264. * @param name defines the name of the mesh to create
  24265. * @param radius sets the global radius size (float) of the torus knot (default 2)
  24266. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  24267. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  24268. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  24269. * @param p the number of windings on X axis (positive integers, default 2)
  24270. * @param q the number of windings on Y axis (positive integers, default 3)
  24271. * @param scene defines the hosting scene
  24272. * @param updatable defines if the mesh must be flagged as updatable
  24273. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24274. * @returns a new Mesh
  24275. */
  24276. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24277. /**
  24278. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  24279. * @param name defines the name of the mesh to create
  24280. * @param points is an array successive Vector3
  24281. * @param scene defines the hosting scene
  24282. * @param updatable defines if the mesh must be flagged as updatable
  24283. * @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).
  24284. * @returns a new Mesh
  24285. */
  24286. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  24287. /**
  24288. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  24289. * @param name defines the name of the mesh to create
  24290. * @param points is an array successive Vector3
  24291. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  24292. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  24293. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  24294. * @param scene defines the hosting scene
  24295. * @param updatable defines if the mesh must be flagged as updatable
  24296. * @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)
  24297. * @returns a new Mesh
  24298. */
  24299. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  24300. /**
  24301. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  24302. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  24303. * 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.
  24304. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24305. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  24306. * Remember you can only change the shape positions, not their number when updating a polygon.
  24307. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  24308. * @param name defines the name of the mesh to create
  24309. * @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
  24310. * @param scene defines the hosting scene
  24311. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  24312. * @param updatable defines if the mesh must be flagged as updatable
  24313. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24314. * @param earcutInjection can be used to inject your own earcut reference
  24315. * @returns a new Mesh
  24316. */
  24317. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  24318. /**
  24319. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  24320. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  24321. * @param name defines the name of the mesh to create
  24322. * @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
  24323. * @param depth defines the height of extrusion
  24324. * @param scene defines the hosting scene
  24325. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  24326. * @param updatable defines if the mesh must be flagged as updatable
  24327. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24328. * @param earcutInjection can be used to inject your own earcut reference
  24329. * @returns a new Mesh
  24330. */
  24331. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  24332. /**
  24333. * Creates an extruded shape mesh.
  24334. * 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
  24335. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24336. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  24337. * @param name defines the name of the mesh to create
  24338. * @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
  24339. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  24340. * @param scale is the value to scale the shape
  24341. * @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
  24342. * @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
  24343. * @param scene defines the hosting scene
  24344. * @param updatable defines if the mesh must be flagged as updatable
  24345. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24346. * @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)
  24347. * @returns a new Mesh
  24348. */
  24349. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24350. /**
  24351. * Creates an custom extruded shape mesh.
  24352. * The custom extrusion is a parametric shape.
  24353. * It has no predefined shape. Its final shape will depend on the input parameters.
  24354. * Please consider using the same method from the MeshBuilder class instead
  24355. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  24356. * @param name defines the name of the mesh to create
  24357. * @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
  24358. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  24359. * @param scaleFunction is a custom Javascript function called on each path point
  24360. * @param rotationFunction is a custom Javascript function called on each path point
  24361. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  24362. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  24363. * @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
  24364. * @param scene defines the hosting scene
  24365. * @param updatable defines if the mesh must be flagged as updatable
  24366. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24367. * @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)
  24368. * @returns a new Mesh
  24369. */
  24370. 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;
  24371. /**
  24372. * Creates lathe mesh.
  24373. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  24374. * Please consider using the same method from the MeshBuilder class instead
  24375. * @param name defines the name of the mesh to create
  24376. * @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
  24377. * @param radius is the radius value of the lathe
  24378. * @param tessellation is the side number of the lathe.
  24379. * @param scene defines the hosting scene
  24380. * @param updatable defines if the mesh must be flagged as updatable
  24381. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24382. * @returns a new Mesh
  24383. */
  24384. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24385. /**
  24386. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  24387. * @param name defines the name of the mesh to create
  24388. * @param size sets the size (float) of both sides of the plane at once (default 1)
  24389. * @param scene defines the hosting scene
  24390. * @param updatable defines if the mesh must be flagged as updatable
  24391. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24392. * @returns a new Mesh
  24393. */
  24394. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24395. /**
  24396. * Creates a ground mesh.
  24397. * Please consider using the same method from the MeshBuilder class instead
  24398. * @param name defines the name of the mesh to create
  24399. * @param width set the width of the ground
  24400. * @param height set the height of the ground
  24401. * @param subdivisions sets the number of subdivisions per side
  24402. * @param scene defines the hosting scene
  24403. * @param updatable defines if the mesh must be flagged as updatable
  24404. * @returns a new Mesh
  24405. */
  24406. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  24407. /**
  24408. * Creates a tiled ground mesh.
  24409. * Please consider using the same method from the MeshBuilder class instead
  24410. * @param name defines the name of the mesh to create
  24411. * @param xmin set the ground minimum X coordinate
  24412. * @param zmin set the ground minimum Y coordinate
  24413. * @param xmax set the ground maximum X coordinate
  24414. * @param zmax set the ground maximum Z coordinate
  24415. * @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
  24416. * @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
  24417. * @param scene defines the hosting scene
  24418. * @param updatable defines if the mesh must be flagged as updatable
  24419. * @returns a new Mesh
  24420. */
  24421. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  24422. w: number;
  24423. h: number;
  24424. }, precision: {
  24425. w: number;
  24426. h: number;
  24427. }, scene: Scene, updatable?: boolean): Mesh;
  24428. /**
  24429. * Creates a ground mesh from a height map.
  24430. * Please consider using the same method from the MeshBuilder class instead
  24431. * @see http://doc.babylonjs.com/babylon101/height_map
  24432. * @param name defines the name of the mesh to create
  24433. * @param url sets the URL of the height map image resource
  24434. * @param width set the ground width size
  24435. * @param height set the ground height size
  24436. * @param subdivisions sets the number of subdivision per side
  24437. * @param minHeight is the minimum altitude on the ground
  24438. * @param maxHeight is the maximum altitude on the ground
  24439. * @param scene defines the hosting scene
  24440. * @param updatable defines if the mesh must be flagged as updatable
  24441. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  24442. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  24443. * @returns a new Mesh
  24444. */
  24445. 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;
  24446. /**
  24447. * Creates a tube mesh.
  24448. * The tube is a parametric shape.
  24449. * It has no predefined shape. Its final shape will depend on the input parameters.
  24450. * Please consider using the same method from the MeshBuilder class instead
  24451. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24452. * @param name defines the name of the mesh to create
  24453. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  24454. * @param radius sets the tube radius size
  24455. * @param tessellation is the number of sides on the tubular surface
  24456. * @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
  24457. * @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
  24458. * @param scene defines the hosting scene
  24459. * @param updatable defines if the mesh must be flagged as updatable
  24460. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24461. * @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)
  24462. * @returns a new Mesh
  24463. */
  24464. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  24465. (i: number, distance: number): number;
  24466. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24467. /**
  24468. * Creates a polyhedron mesh.
  24469. * Please consider using the same method from the MeshBuilder class instead.
  24470. * * 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
  24471. * * The parameter `size` (positive float, default 1) sets the polygon size
  24472. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  24473. * * 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`
  24474. * * 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
  24475. * * 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)`)
  24476. * * 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
  24477. * * 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
  24478. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24479. * * 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
  24480. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24481. * @param name defines the name of the mesh to create
  24482. * @param options defines the options used to create the mesh
  24483. * @param scene defines the hosting scene
  24484. * @returns a new Mesh
  24485. */
  24486. static CreatePolyhedron(name: string, options: {
  24487. type?: number;
  24488. size?: number;
  24489. sizeX?: number;
  24490. sizeY?: number;
  24491. sizeZ?: number;
  24492. custom?: any;
  24493. faceUV?: Vector4[];
  24494. faceColors?: Color4[];
  24495. updatable?: boolean;
  24496. sideOrientation?: number;
  24497. }, scene: Scene): Mesh;
  24498. /**
  24499. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  24500. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  24501. * * 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`)
  24502. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  24503. * * 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
  24504. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24505. * * 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
  24506. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24507. * @param name defines the name of the mesh
  24508. * @param options defines the options used to create the mesh
  24509. * @param scene defines the hosting scene
  24510. * @returns a new Mesh
  24511. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  24512. */
  24513. static CreateIcoSphere(name: string, options: {
  24514. radius?: number;
  24515. flat?: boolean;
  24516. subdivisions?: number;
  24517. sideOrientation?: number;
  24518. updatable?: boolean;
  24519. }, scene: Scene): Mesh;
  24520. /**
  24521. * Creates a decal mesh.
  24522. * Please consider using the same method from the MeshBuilder class instead.
  24523. * A decal is a mesh usually applied as a model onto the surface of another mesh
  24524. * @param name defines the name of the mesh
  24525. * @param sourceMesh defines the mesh receiving the decal
  24526. * @param position sets the position of the decal in world coordinates
  24527. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  24528. * @param size sets the decal scaling
  24529. * @param angle sets the angle to rotate the decal
  24530. * @returns a new Mesh
  24531. */
  24532. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  24533. /**
  24534. * Prepare internal position array for software CPU skinning
  24535. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  24536. */
  24537. setPositionsForCPUSkinning(): Float32Array;
  24538. /**
  24539. * Prepare internal normal array for software CPU skinning
  24540. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  24541. */
  24542. setNormalsForCPUSkinning(): Float32Array;
  24543. /**
  24544. * Updates the vertex buffer by applying transformation from the bones
  24545. * @param skeleton defines the skeleton to apply to current mesh
  24546. * @returns the current mesh
  24547. */
  24548. applySkeleton(skeleton: Skeleton): Mesh;
  24549. /**
  24550. * 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
  24551. * @param meshes defines the list of meshes to scan
  24552. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  24553. */
  24554. static MinMax(meshes: AbstractMesh[]): {
  24555. min: Vector3;
  24556. max: Vector3;
  24557. };
  24558. /**
  24559. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  24560. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  24561. * @returns a vector3
  24562. */
  24563. static Center(meshesOrMinMaxVector: {
  24564. min: Vector3;
  24565. max: Vector3;
  24566. } | AbstractMesh[]): Vector3;
  24567. /**
  24568. * Merge the array of meshes into a single mesh for performance reasons.
  24569. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  24570. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  24571. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  24572. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  24573. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  24574. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  24575. * @returns a new mesh
  24576. */
  24577. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  24578. /** @hidden */
  24579. addInstance(instance: InstancedMesh): void;
  24580. /** @hidden */
  24581. removeInstance(instance: InstancedMesh): void;
  24582. }
  24583. }
  24584. declare module BABYLON {
  24585. /**
  24586. * This is the base class of all the camera used in the application.
  24587. * @see http://doc.babylonjs.com/features/cameras
  24588. */
  24589. export class Camera extends Node {
  24590. /** @hidden */
  24591. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  24592. /**
  24593. * This is the default projection mode used by the cameras.
  24594. * It helps recreating a feeling of perspective and better appreciate depth.
  24595. * This is the best way to simulate real life cameras.
  24596. */
  24597. static readonly PERSPECTIVE_CAMERA: number;
  24598. /**
  24599. * This helps creating camera with an orthographic mode.
  24600. * 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.
  24601. */
  24602. static readonly ORTHOGRAPHIC_CAMERA: number;
  24603. /**
  24604. * This is the default FOV mode for perspective cameras.
  24605. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  24606. */
  24607. static readonly FOVMODE_VERTICAL_FIXED: number;
  24608. /**
  24609. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  24610. */
  24611. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  24612. /**
  24613. * This specifies ther is no need for a camera rig.
  24614. * Basically only one eye is rendered corresponding to the camera.
  24615. */
  24616. static readonly RIG_MODE_NONE: number;
  24617. /**
  24618. * Simulates a camera Rig with one blue eye and one red eye.
  24619. * This can be use with 3d blue and red glasses.
  24620. */
  24621. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  24622. /**
  24623. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  24624. */
  24625. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  24626. /**
  24627. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  24628. */
  24629. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  24630. /**
  24631. * Defines that both eyes of the camera will be rendered over under each other.
  24632. */
  24633. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  24634. /**
  24635. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  24636. */
  24637. static readonly RIG_MODE_VR: number;
  24638. /**
  24639. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  24640. */
  24641. static readonly RIG_MODE_WEBVR: number;
  24642. /**
  24643. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  24644. */
  24645. static readonly RIG_MODE_CUSTOM: number;
  24646. /**
  24647. * Defines if by default attaching controls should prevent the default javascript event to continue.
  24648. */
  24649. static ForceAttachControlToAlwaysPreventDefault: boolean;
  24650. /**
  24651. * Define the input manager associated with the camera.
  24652. */
  24653. inputs: CameraInputsManager<Camera>;
  24654. /** @hidden */
  24655. _position: Vector3;
  24656. /**
  24657. * Define the current local position of the camera in the scene
  24658. */
  24659. position: Vector3;
  24660. /**
  24661. * The vector the camera should consider as up.
  24662. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  24663. */
  24664. upVector: Vector3;
  24665. /**
  24666. * Define the current limit on the left side for an orthographic camera
  24667. * In scene unit
  24668. */
  24669. orthoLeft: Nullable<number>;
  24670. /**
  24671. * Define the current limit on the right side for an orthographic camera
  24672. * In scene unit
  24673. */
  24674. orthoRight: Nullable<number>;
  24675. /**
  24676. * Define the current limit on the bottom side for an orthographic camera
  24677. * In scene unit
  24678. */
  24679. orthoBottom: Nullable<number>;
  24680. /**
  24681. * Define the current limit on the top side for an orthographic camera
  24682. * In scene unit
  24683. */
  24684. orthoTop: Nullable<number>;
  24685. /**
  24686. * Field Of View is set in Radians. (default is 0.8)
  24687. */
  24688. fov: number;
  24689. /**
  24690. * Define the minimum distance the camera can see from.
  24691. * This is important to note that the depth buffer are not infinite and the closer it starts
  24692. * the more your scene might encounter depth fighting issue.
  24693. */
  24694. minZ: number;
  24695. /**
  24696. * Define the maximum distance the camera can see to.
  24697. * This is important to note that the depth buffer are not infinite and the further it end
  24698. * the more your scene might encounter depth fighting issue.
  24699. */
  24700. maxZ: number;
  24701. /**
  24702. * Define the default inertia of the camera.
  24703. * This helps giving a smooth feeling to the camera movement.
  24704. */
  24705. inertia: number;
  24706. /**
  24707. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  24708. */
  24709. mode: number;
  24710. /**
  24711. * Define wether the camera is intermediate.
  24712. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  24713. */
  24714. isIntermediate: boolean;
  24715. /**
  24716. * Define the viewport of the camera.
  24717. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  24718. */
  24719. viewport: Viewport;
  24720. /**
  24721. * Restricts the camera to viewing objects with the same layerMask.
  24722. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  24723. */
  24724. layerMask: number;
  24725. /**
  24726. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  24727. */
  24728. fovMode: number;
  24729. /**
  24730. * Rig mode of the camera.
  24731. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  24732. * This is normally controlled byt the camera themselves as internal use.
  24733. */
  24734. cameraRigMode: number;
  24735. /**
  24736. * Defines the distance between both "eyes" in case of a RIG
  24737. */
  24738. interaxialDistance: number;
  24739. /**
  24740. * Defines if stereoscopic rendering is done side by side or over under.
  24741. */
  24742. isStereoscopicSideBySide: boolean;
  24743. /**
  24744. * 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
  24745. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  24746. * else in the scene. (Eg. security camera)
  24747. *
  24748. * To change the final output target of the camera, camera.outputRenderTarget should be used instead (eg. webXR renders to a render target corrisponding to an HMD)
  24749. */
  24750. customRenderTargets: RenderTargetTexture[];
  24751. /**
  24752. * When set, the camera will render to this render target instead of the default canvas
  24753. *
  24754. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  24755. */
  24756. outputRenderTarget: Nullable<RenderTargetTexture>;
  24757. /**
  24758. * Observable triggered when the camera view matrix has changed.
  24759. */
  24760. onViewMatrixChangedObservable: Observable<Camera>;
  24761. /**
  24762. * Observable triggered when the camera Projection matrix has changed.
  24763. */
  24764. onProjectionMatrixChangedObservable: Observable<Camera>;
  24765. /**
  24766. * Observable triggered when the inputs have been processed.
  24767. */
  24768. onAfterCheckInputsObservable: Observable<Camera>;
  24769. /**
  24770. * Observable triggered when reset has been called and applied to the camera.
  24771. */
  24772. onRestoreStateObservable: Observable<Camera>;
  24773. /** @hidden */
  24774. _cameraRigParams: any;
  24775. /** @hidden */
  24776. _rigCameras: Camera[];
  24777. /** @hidden */
  24778. _rigPostProcess: Nullable<PostProcess>;
  24779. protected _webvrViewMatrix: Matrix;
  24780. /** @hidden */
  24781. _skipRendering: boolean;
  24782. /** @hidden */
  24783. _projectionMatrix: Matrix;
  24784. /** @hidden */
  24785. _postProcesses: Nullable<PostProcess>[];
  24786. /** @hidden */
  24787. _activeMeshes: SmartArray<AbstractMesh>;
  24788. protected _globalPosition: Vector3;
  24789. /** @hidden */
  24790. _computedViewMatrix: Matrix;
  24791. private _doNotComputeProjectionMatrix;
  24792. private _transformMatrix;
  24793. private _frustumPlanes;
  24794. private _refreshFrustumPlanes;
  24795. private _storedFov;
  24796. private _stateStored;
  24797. /**
  24798. * Instantiates a new camera object.
  24799. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  24800. * @see http://doc.babylonjs.com/features/cameras
  24801. * @param name Defines the name of the camera in the scene
  24802. * @param position Defines the position of the camera
  24803. * @param scene Defines the scene the camera belongs too
  24804. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  24805. */
  24806. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  24807. /**
  24808. * Store current camera state (fov, position, etc..)
  24809. * @returns the camera
  24810. */
  24811. storeState(): Camera;
  24812. /**
  24813. * Restores the camera state values if it has been stored. You must call storeState() first
  24814. */
  24815. protected _restoreStateValues(): boolean;
  24816. /**
  24817. * Restored camera state. You must call storeState() first.
  24818. * @returns true if restored and false otherwise
  24819. */
  24820. restoreState(): boolean;
  24821. /**
  24822. * Gets the class name of the camera.
  24823. * @returns the class name
  24824. */
  24825. getClassName(): string;
  24826. /** @hidden */
  24827. readonly _isCamera: boolean;
  24828. /**
  24829. * Gets a string representation of the camera useful for debug purpose.
  24830. * @param fullDetails Defines that a more verboe level of logging is required
  24831. * @returns the string representation
  24832. */
  24833. toString(fullDetails?: boolean): string;
  24834. /**
  24835. * Gets the current world space position of the camera.
  24836. */
  24837. readonly globalPosition: Vector3;
  24838. /**
  24839. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  24840. * @returns the active meshe list
  24841. */
  24842. getActiveMeshes(): SmartArray<AbstractMesh>;
  24843. /**
  24844. * Check wether a mesh is part of the current active mesh list of the camera
  24845. * @param mesh Defines the mesh to check
  24846. * @returns true if active, false otherwise
  24847. */
  24848. isActiveMesh(mesh: Mesh): boolean;
  24849. /**
  24850. * Is this camera ready to be used/rendered
  24851. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  24852. * @return true if the camera is ready
  24853. */
  24854. isReady(completeCheck?: boolean): boolean;
  24855. /** @hidden */
  24856. _initCache(): void;
  24857. /** @hidden */
  24858. _updateCache(ignoreParentClass?: boolean): void;
  24859. /** @hidden */
  24860. _isSynchronized(): boolean;
  24861. /** @hidden */
  24862. _isSynchronizedViewMatrix(): boolean;
  24863. /** @hidden */
  24864. _isSynchronizedProjectionMatrix(): boolean;
  24865. /**
  24866. * Attach the input controls to a specific dom element to get the input from.
  24867. * @param element Defines the element the controls should be listened from
  24868. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  24869. */
  24870. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  24871. /**
  24872. * Detach the current controls from the specified dom element.
  24873. * @param element Defines the element to stop listening the inputs from
  24874. */
  24875. detachControl(element: HTMLElement): void;
  24876. /**
  24877. * Update the camera state according to the different inputs gathered during the frame.
  24878. */
  24879. update(): void;
  24880. /** @hidden */
  24881. _checkInputs(): void;
  24882. /** @hidden */
  24883. readonly rigCameras: Camera[];
  24884. /**
  24885. * Gets the post process used by the rig cameras
  24886. */
  24887. readonly rigPostProcess: Nullable<PostProcess>;
  24888. /**
  24889. * Internal, gets the first post proces.
  24890. * @returns the first post process to be run on this camera.
  24891. */
  24892. _getFirstPostProcess(): Nullable<PostProcess>;
  24893. private _cascadePostProcessesToRigCams;
  24894. /**
  24895. * Attach a post process to the camera.
  24896. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  24897. * @param postProcess The post process to attach to the camera
  24898. * @param insertAt The position of the post process in case several of them are in use in the scene
  24899. * @returns the position the post process has been inserted at
  24900. */
  24901. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  24902. /**
  24903. * Detach a post process to the camera.
  24904. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  24905. * @param postProcess The post process to detach from the camera
  24906. */
  24907. detachPostProcess(postProcess: PostProcess): void;
  24908. /**
  24909. * Gets the current world matrix of the camera
  24910. */
  24911. getWorldMatrix(): Matrix;
  24912. /** @hidden */
  24913. _getViewMatrix(): Matrix;
  24914. /**
  24915. * Gets the current view matrix of the camera.
  24916. * @param force forces the camera to recompute the matrix without looking at the cached state
  24917. * @returns the view matrix
  24918. */
  24919. getViewMatrix(force?: boolean): Matrix;
  24920. /**
  24921. * Freeze the projection matrix.
  24922. * It will prevent the cache check of the camera projection compute and can speed up perf
  24923. * if no parameter of the camera are meant to change
  24924. * @param projection Defines manually a projection if necessary
  24925. */
  24926. freezeProjectionMatrix(projection?: Matrix): void;
  24927. /**
  24928. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  24929. */
  24930. unfreezeProjectionMatrix(): void;
  24931. /**
  24932. * Gets the current projection matrix of the camera.
  24933. * @param force forces the camera to recompute the matrix without looking at the cached state
  24934. * @returns the projection matrix
  24935. */
  24936. getProjectionMatrix(force?: boolean): Matrix;
  24937. /**
  24938. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  24939. * @returns a Matrix
  24940. */
  24941. getTransformationMatrix(): Matrix;
  24942. private _updateFrustumPlanes;
  24943. /**
  24944. * Checks if a cullable object (mesh...) is in the camera frustum
  24945. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  24946. * @param target The object to check
  24947. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  24948. * @returns true if the object is in frustum otherwise false
  24949. */
  24950. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  24951. /**
  24952. * Checks if a cullable object (mesh...) is in the camera frustum
  24953. * Unlike isInFrustum this cheks the full bounding box
  24954. * @param target The object to check
  24955. * @returns true if the object is in frustum otherwise false
  24956. */
  24957. isCompletelyInFrustum(target: ICullable): boolean;
  24958. /**
  24959. * Gets a ray in the forward direction from the camera.
  24960. * @param length Defines the length of the ray to create
  24961. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  24962. * @param origin Defines the start point of the ray which defaults to the camera position
  24963. * @returns the forward ray
  24964. */
  24965. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  24966. /**
  24967. * Releases resources associated with this node.
  24968. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24969. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24970. */
  24971. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24972. /** @hidden */
  24973. _isLeftCamera: boolean;
  24974. /**
  24975. * Gets the left camera of a rig setup in case of Rigged Camera
  24976. */
  24977. readonly isLeftCamera: boolean;
  24978. /** @hidden */
  24979. _isRightCamera: boolean;
  24980. /**
  24981. * Gets the right camera of a rig setup in case of Rigged Camera
  24982. */
  24983. readonly isRightCamera: boolean;
  24984. /**
  24985. * Gets the left camera of a rig setup in case of Rigged Camera
  24986. */
  24987. readonly leftCamera: Nullable<FreeCamera>;
  24988. /**
  24989. * Gets the right camera of a rig setup in case of Rigged Camera
  24990. */
  24991. readonly rightCamera: Nullable<FreeCamera>;
  24992. /**
  24993. * Gets the left camera target of a rig setup in case of Rigged Camera
  24994. * @returns the target position
  24995. */
  24996. getLeftTarget(): Nullable<Vector3>;
  24997. /**
  24998. * Gets the right camera target of a rig setup in case of Rigged Camera
  24999. * @returns the target position
  25000. */
  25001. getRightTarget(): Nullable<Vector3>;
  25002. /**
  25003. * @hidden
  25004. */
  25005. setCameraRigMode(mode: number, rigParams: any): void;
  25006. /** @hidden */
  25007. static _setStereoscopicRigMode(camera: Camera): void;
  25008. /** @hidden */
  25009. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  25010. /** @hidden */
  25011. static _setVRRigMode(camera: Camera, rigParams: any): void;
  25012. /** @hidden */
  25013. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  25014. /** @hidden */
  25015. _getVRProjectionMatrix(): Matrix;
  25016. protected _updateCameraRotationMatrix(): void;
  25017. protected _updateWebVRCameraRotationMatrix(): void;
  25018. /**
  25019. * This function MUST be overwritten by the different WebVR cameras available.
  25020. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  25021. * @hidden
  25022. */
  25023. _getWebVRProjectionMatrix(): Matrix;
  25024. /**
  25025. * This function MUST be overwritten by the different WebVR cameras available.
  25026. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  25027. * @hidden
  25028. */
  25029. _getWebVRViewMatrix(): Matrix;
  25030. /** @hidden */
  25031. setCameraRigParameter(name: string, value: any): void;
  25032. /**
  25033. * needs to be overridden by children so sub has required properties to be copied
  25034. * @hidden
  25035. */
  25036. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  25037. /**
  25038. * May need to be overridden by children
  25039. * @hidden
  25040. */
  25041. _updateRigCameras(): void;
  25042. /** @hidden */
  25043. _setupInputs(): void;
  25044. /**
  25045. * Serialiaze the camera setup to a json represention
  25046. * @returns the JSON representation
  25047. */
  25048. serialize(): any;
  25049. /**
  25050. * Clones the current camera.
  25051. * @param name The cloned camera name
  25052. * @returns the cloned camera
  25053. */
  25054. clone(name: string): Camera;
  25055. /**
  25056. * Gets the direction of the camera relative to a given local axis.
  25057. * @param localAxis Defines the reference axis to provide a relative direction.
  25058. * @return the direction
  25059. */
  25060. getDirection(localAxis: Vector3): Vector3;
  25061. /**
  25062. * Returns the current camera absolute rotation
  25063. */
  25064. readonly absoluteRotation: Quaternion;
  25065. /**
  25066. * Gets the direction of the camera relative to a given local axis into a passed vector.
  25067. * @param localAxis Defines the reference axis to provide a relative direction.
  25068. * @param result Defines the vector to store the result in
  25069. */
  25070. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  25071. /**
  25072. * Gets a camera constructor for a given camera type
  25073. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  25074. * @param name The name of the camera the result will be able to instantiate
  25075. * @param scene The scene the result will construct the camera in
  25076. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  25077. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  25078. * @returns a factory method to construc the camera
  25079. */
  25080. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  25081. /**
  25082. * Compute the world matrix of the camera.
  25083. * @returns the camera workd matrix
  25084. */
  25085. computeWorldMatrix(): Matrix;
  25086. /**
  25087. * Parse a JSON and creates the camera from the parsed information
  25088. * @param parsedCamera The JSON to parse
  25089. * @param scene The scene to instantiate the camera in
  25090. * @returns the newly constructed camera
  25091. */
  25092. static Parse(parsedCamera: any, scene: Scene): Camera;
  25093. }
  25094. }
  25095. declare module BABYLON {
  25096. /**
  25097. * Class containing static functions to help procedurally build meshes
  25098. */
  25099. export class DiscBuilder {
  25100. /**
  25101. * Creates a plane polygonal mesh. By default, this is a disc
  25102. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  25103. * * 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
  25104. * * 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
  25105. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  25106. * * 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
  25107. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25108. * @param name defines the name of the mesh
  25109. * @param options defines the options used to create the mesh
  25110. * @param scene defines the hosting scene
  25111. * @returns the plane polygonal mesh
  25112. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  25113. */
  25114. static CreateDisc(name: string, options: {
  25115. radius?: number;
  25116. tessellation?: number;
  25117. arc?: number;
  25118. updatable?: boolean;
  25119. sideOrientation?: number;
  25120. frontUVs?: Vector4;
  25121. backUVs?: Vector4;
  25122. }, scene?: Nullable<Scene>): Mesh;
  25123. }
  25124. }
  25125. declare module BABYLON {
  25126. /**
  25127. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  25128. *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.
  25129. * The SPS is also a particle system. It provides some methods to manage the particles.
  25130. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  25131. *
  25132. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  25133. */
  25134. export class SolidParticleSystem implements IDisposable {
  25135. /**
  25136. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  25137. * Example : var p = SPS.particles[i];
  25138. */
  25139. particles: SolidParticle[];
  25140. /**
  25141. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  25142. */
  25143. nbParticles: number;
  25144. /**
  25145. * If the particles must ever face the camera (default false). Useful for planar particles.
  25146. */
  25147. billboard: boolean;
  25148. /**
  25149. * Recompute normals when adding a shape
  25150. */
  25151. recomputeNormals: boolean;
  25152. /**
  25153. * This a counter ofr your own usage. It's not set by any SPS functions.
  25154. */
  25155. counter: number;
  25156. /**
  25157. * The SPS name. This name is also given to the underlying mesh.
  25158. */
  25159. name: string;
  25160. /**
  25161. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  25162. */
  25163. mesh: Mesh;
  25164. /**
  25165. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  25166. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  25167. */
  25168. vars: any;
  25169. /**
  25170. * This array is populated when the SPS is set as 'pickable'.
  25171. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  25172. * Each element of this array is an object `{idx: int, faceId: int}`.
  25173. * `idx` is the picked particle index in the `SPS.particles` array
  25174. * `faceId` is the picked face index counted within this particle.
  25175. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  25176. */
  25177. pickedParticles: {
  25178. idx: number;
  25179. faceId: number;
  25180. }[];
  25181. /**
  25182. * This array is populated when `enableDepthSort` is set to true.
  25183. * Each element of this array is an instance of the class DepthSortedParticle.
  25184. */
  25185. depthSortedParticles: DepthSortedParticle[];
  25186. /**
  25187. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  25188. * @hidden
  25189. */
  25190. _bSphereOnly: boolean;
  25191. /**
  25192. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  25193. * @hidden
  25194. */
  25195. _bSphereRadiusFactor: number;
  25196. private _scene;
  25197. private _positions;
  25198. private _indices;
  25199. private _normals;
  25200. private _colors;
  25201. private _uvs;
  25202. private _indices32;
  25203. private _positions32;
  25204. private _normals32;
  25205. private _fixedNormal32;
  25206. private _colors32;
  25207. private _uvs32;
  25208. private _index;
  25209. private _updatable;
  25210. private _pickable;
  25211. private _isVisibilityBoxLocked;
  25212. private _alwaysVisible;
  25213. private _depthSort;
  25214. private _expandable;
  25215. private _shapeCounter;
  25216. private _copy;
  25217. private _color;
  25218. private _computeParticleColor;
  25219. private _computeParticleTexture;
  25220. private _computeParticleRotation;
  25221. private _computeParticleVertex;
  25222. private _computeBoundingBox;
  25223. private _depthSortParticles;
  25224. private _camera;
  25225. private _mustUnrotateFixedNormals;
  25226. private _particlesIntersect;
  25227. private _needs32Bits;
  25228. /**
  25229. * Creates a SPS (Solid Particle System) object.
  25230. * @param name (String) is the SPS name, this will be the underlying mesh name.
  25231. * @param scene (Scene) is the scene in which the SPS is added.
  25232. * @param options defines the options of the sps e.g.
  25233. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  25234. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  25235. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  25236. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  25237. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  25238. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  25239. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  25240. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  25241. */
  25242. constructor(name: string, scene: Scene, options?: {
  25243. updatable?: boolean;
  25244. isPickable?: boolean;
  25245. enableDepthSort?: boolean;
  25246. particleIntersection?: boolean;
  25247. boundingSphereOnly?: boolean;
  25248. bSphereRadiusFactor?: number;
  25249. expandable?: boolean;
  25250. });
  25251. /**
  25252. * Builds the SPS underlying mesh. Returns a standard Mesh.
  25253. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  25254. * @returns the created mesh
  25255. */
  25256. buildMesh(): Mesh;
  25257. /**
  25258. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  25259. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  25260. * Thus the particles generated from `digest()` have their property `position` set yet.
  25261. * @param mesh ( Mesh ) is the mesh to be digested
  25262. * @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
  25263. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  25264. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  25265. * @returns the current SPS
  25266. */
  25267. digest(mesh: Mesh, options?: {
  25268. facetNb?: number;
  25269. number?: number;
  25270. delta?: number;
  25271. }): SolidParticleSystem;
  25272. private _unrotateFixedNormals;
  25273. private _resetCopy;
  25274. private _meshBuilder;
  25275. private _posToShape;
  25276. private _uvsToShapeUV;
  25277. private _addParticle;
  25278. /**
  25279. * Adds some particles to the SPS from the model shape. Returns the shape id.
  25280. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  25281. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  25282. * @param nb (positive integer) the number of particles to be created from this model
  25283. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  25284. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  25285. * @returns the number of shapes in the system
  25286. */
  25287. addShape(mesh: Mesh, nb: number, options?: {
  25288. positionFunction?: any;
  25289. vertexFunction?: any;
  25290. }): number;
  25291. private _rebuildParticle;
  25292. /**
  25293. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  25294. * @returns the SPS.
  25295. */
  25296. rebuildMesh(): SolidParticleSystem;
  25297. /**
  25298. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  25299. * This method calls `updateParticle()` for each particle of the SPS.
  25300. * For an animated SPS, it is usually called within the render loop.
  25301. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  25302. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  25303. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  25304. * @returns the SPS.
  25305. */
  25306. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  25307. /**
  25308. * Disposes the SPS.
  25309. */
  25310. dispose(): void;
  25311. /**
  25312. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  25313. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25314. * @returns the SPS.
  25315. */
  25316. refreshVisibleSize(): SolidParticleSystem;
  25317. /**
  25318. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  25319. * @param size the size (float) of the visibility box
  25320. * note : this doesn't lock the SPS mesh bounding box.
  25321. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25322. */
  25323. setVisibilityBox(size: number): void;
  25324. /**
  25325. * Gets whether the SPS as always visible or not
  25326. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25327. */
  25328. /**
  25329. * Sets the SPS as always visible or not
  25330. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25331. */
  25332. isAlwaysVisible: boolean;
  25333. /**
  25334. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  25335. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25336. */
  25337. /**
  25338. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  25339. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25340. */
  25341. isVisibilityBoxLocked: boolean;
  25342. /**
  25343. * Tells to `setParticles()` to compute the particle rotations or not.
  25344. * Default value : true. The SPS is faster when it's set to false.
  25345. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  25346. */
  25347. /**
  25348. * Gets if `setParticles()` computes the particle rotations or not.
  25349. * Default value : true. The SPS is faster when it's set to false.
  25350. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  25351. */
  25352. computeParticleRotation: boolean;
  25353. /**
  25354. * Tells to `setParticles()` to compute the particle colors or not.
  25355. * Default value : true. The SPS is faster when it's set to false.
  25356. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  25357. */
  25358. /**
  25359. * Gets if `setParticles()` computes the particle colors or not.
  25360. * Default value : true. The SPS is faster when it's set to false.
  25361. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  25362. */
  25363. computeParticleColor: boolean;
  25364. /**
  25365. * Gets if `setParticles()` computes the particle textures or not.
  25366. * Default value : true. The SPS is faster when it's set to false.
  25367. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  25368. */
  25369. computeParticleTexture: boolean;
  25370. /**
  25371. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  25372. * Default value : false. The SPS is faster when it's set to false.
  25373. * Note : the particle custom vertex positions aren't stored values.
  25374. */
  25375. /**
  25376. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  25377. * Default value : false. The SPS is faster when it's set to false.
  25378. * Note : the particle custom vertex positions aren't stored values.
  25379. */
  25380. computeParticleVertex: boolean;
  25381. /**
  25382. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  25383. */
  25384. /**
  25385. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  25386. */
  25387. computeBoundingBox: boolean;
  25388. /**
  25389. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  25390. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  25391. * Default : `true`
  25392. */
  25393. /**
  25394. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  25395. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  25396. * Default : `true`
  25397. */
  25398. depthSortParticles: boolean;
  25399. /**
  25400. * Gets if the SPS is created as expandable at construction time.
  25401. * Default : `false`
  25402. */
  25403. readonly expandable: boolean;
  25404. /**
  25405. * This function does nothing. It may be overwritten to set all the particle first values.
  25406. * The SPS doesn't call this function, you may have to call it by your own.
  25407. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  25408. */
  25409. initParticles(): void;
  25410. /**
  25411. * This function does nothing. It may be overwritten to recycle a particle.
  25412. * The SPS doesn't call this function, you may have to call it by your own.
  25413. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  25414. * @param particle The particle to recycle
  25415. * @returns the recycled particle
  25416. */
  25417. recycleParticle(particle: SolidParticle): SolidParticle;
  25418. /**
  25419. * Updates a particle : this function should be overwritten by the user.
  25420. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  25421. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  25422. * @example : just set a particle position or velocity and recycle conditions
  25423. * @param particle The particle to update
  25424. * @returns the updated particle
  25425. */
  25426. updateParticle(particle: SolidParticle): SolidParticle;
  25427. /**
  25428. * Updates a vertex of a particle : it can be overwritten by the user.
  25429. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  25430. * @param particle the current particle
  25431. * @param vertex the current index of the current particle
  25432. * @param pt the index of the current vertex in the particle shape
  25433. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  25434. * @example : just set a vertex particle position
  25435. * @returns the updated vertex
  25436. */
  25437. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  25438. /**
  25439. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  25440. * This does nothing and may be overwritten by the user.
  25441. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25442. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25443. * @param update the boolean update value actually passed to setParticles()
  25444. */
  25445. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  25446. /**
  25447. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  25448. * This will be passed three parameters.
  25449. * This does nothing and may be overwritten by the user.
  25450. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25451. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25452. * @param update the boolean update value actually passed to setParticles()
  25453. */
  25454. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  25455. }
  25456. }
  25457. declare module BABYLON {
  25458. /**
  25459. * Represents one particle of a solid particle system.
  25460. */
  25461. export class SolidParticle {
  25462. /**
  25463. * particle global index
  25464. */
  25465. idx: number;
  25466. /**
  25467. * The color of the particle
  25468. */
  25469. color: Nullable<Color4>;
  25470. /**
  25471. * The world space position of the particle.
  25472. */
  25473. position: Vector3;
  25474. /**
  25475. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  25476. */
  25477. rotation: Vector3;
  25478. /**
  25479. * The world space rotation quaternion of the particle.
  25480. */
  25481. rotationQuaternion: Nullable<Quaternion>;
  25482. /**
  25483. * The scaling of the particle.
  25484. */
  25485. scaling: Vector3;
  25486. /**
  25487. * The uvs of the particle.
  25488. */
  25489. uvs: Vector4;
  25490. /**
  25491. * The current speed of the particle.
  25492. */
  25493. velocity: Vector3;
  25494. /**
  25495. * The pivot point in the particle local space.
  25496. */
  25497. pivot: Vector3;
  25498. /**
  25499. * Must the particle be translated from its pivot point in its local space ?
  25500. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  25501. * Default : false
  25502. */
  25503. translateFromPivot: boolean;
  25504. /**
  25505. * Is the particle active or not ?
  25506. */
  25507. alive: boolean;
  25508. /**
  25509. * Is the particle visible or not ?
  25510. */
  25511. isVisible: boolean;
  25512. /**
  25513. * Index of this particle in the global "positions" array (Internal use)
  25514. * @hidden
  25515. */
  25516. _pos: number;
  25517. /**
  25518. * @hidden Index of this particle in the global "indices" array (Internal use)
  25519. */
  25520. _ind: number;
  25521. /**
  25522. * @hidden ModelShape of this particle (Internal use)
  25523. */
  25524. _model: ModelShape;
  25525. /**
  25526. * ModelShape id of this particle
  25527. */
  25528. shapeId: number;
  25529. /**
  25530. * Index of the particle in its shape id
  25531. */
  25532. idxInShape: number;
  25533. /**
  25534. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  25535. */
  25536. _modelBoundingInfo: BoundingInfo;
  25537. /**
  25538. * @hidden Particle BoundingInfo object (Internal use)
  25539. */
  25540. _boundingInfo: BoundingInfo;
  25541. /**
  25542. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  25543. */
  25544. _sps: SolidParticleSystem;
  25545. /**
  25546. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  25547. */
  25548. _stillInvisible: boolean;
  25549. /**
  25550. * @hidden Last computed particle rotation matrix
  25551. */
  25552. _rotationMatrix: number[];
  25553. /**
  25554. * Parent particle Id, if any.
  25555. * Default null.
  25556. */
  25557. parentId: Nullable<number>;
  25558. /**
  25559. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  25560. * The possible values are :
  25561. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  25562. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  25563. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  25564. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  25565. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  25566. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  25567. * */
  25568. cullingStrategy: number;
  25569. /**
  25570. * @hidden Internal global position in the SPS.
  25571. */
  25572. _globalPosition: Vector3;
  25573. /**
  25574. * Creates a Solid Particle object.
  25575. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  25576. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  25577. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  25578. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  25579. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  25580. * @param shapeId (integer) is the model shape identifier in the SPS.
  25581. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  25582. * @param sps defines the sps it is associated to
  25583. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  25584. */
  25585. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  25586. /**
  25587. * Legacy support, changed scale to scaling
  25588. */
  25589. /**
  25590. * Legacy support, changed scale to scaling
  25591. */
  25592. scale: Vector3;
  25593. /**
  25594. * Legacy support, changed quaternion to rotationQuaternion
  25595. */
  25596. /**
  25597. * Legacy support, changed quaternion to rotationQuaternion
  25598. */
  25599. quaternion: Nullable<Quaternion>;
  25600. /**
  25601. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  25602. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  25603. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  25604. * @returns true if it intersects
  25605. */
  25606. intersectsMesh(target: Mesh | SolidParticle): boolean;
  25607. /**
  25608. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  25609. * A particle is in the frustum if its bounding box intersects the frustum
  25610. * @param frustumPlanes defines the frustum to test
  25611. * @returns true if the particle is in the frustum planes
  25612. */
  25613. isInFrustum(frustumPlanes: Plane[]): boolean;
  25614. /**
  25615. * get the rotation matrix of the particle
  25616. * @hidden
  25617. */
  25618. getRotationMatrix(m: Matrix): void;
  25619. }
  25620. /**
  25621. * Represents the shape of the model used by one particle of a solid particle system.
  25622. * SPS internal tool, don't use it manually.
  25623. */
  25624. export class ModelShape {
  25625. /**
  25626. * The shape id
  25627. * @hidden
  25628. */
  25629. shapeID: number;
  25630. /**
  25631. * flat array of model positions (internal use)
  25632. * @hidden
  25633. */
  25634. _shape: Vector3[];
  25635. /**
  25636. * flat array of model UVs (internal use)
  25637. * @hidden
  25638. */
  25639. _shapeUV: number[];
  25640. /**
  25641. * length of the shape in the model indices array (internal use)
  25642. * @hidden
  25643. */
  25644. _indicesLength: number;
  25645. /**
  25646. * Custom position function (internal use)
  25647. * @hidden
  25648. */
  25649. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  25650. /**
  25651. * Custom vertex function (internal use)
  25652. * @hidden
  25653. */
  25654. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  25655. /**
  25656. * 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.
  25657. * SPS internal tool, don't use it manually.
  25658. * @hidden
  25659. */
  25660. 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>);
  25661. }
  25662. /**
  25663. * Represents a Depth Sorted Particle in the solid particle system.
  25664. */
  25665. export class DepthSortedParticle {
  25666. /**
  25667. * Index of the particle in the "indices" array
  25668. */
  25669. ind: number;
  25670. /**
  25671. * Length of the particle shape in the "indices" array
  25672. */
  25673. indicesLength: number;
  25674. /**
  25675. * Squared distance from the particle to the camera
  25676. */
  25677. sqDistance: number;
  25678. }
  25679. }
  25680. declare module BABYLON {
  25681. /**
  25682. * @hidden
  25683. */
  25684. export class _MeshCollisionData {
  25685. _checkCollisions: boolean;
  25686. _collisionMask: number;
  25687. _collisionGroup: number;
  25688. _collider: Nullable<Collider>;
  25689. _oldPositionForCollisions: Vector3;
  25690. _diffPositionForCollisions: Vector3;
  25691. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  25692. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  25693. }
  25694. }
  25695. declare module BABYLON {
  25696. /** @hidden */
  25697. class _FacetDataStorage {
  25698. facetPositions: Vector3[];
  25699. facetNormals: Vector3[];
  25700. facetPartitioning: number[][];
  25701. facetNb: number;
  25702. partitioningSubdivisions: number;
  25703. partitioningBBoxRatio: number;
  25704. facetDataEnabled: boolean;
  25705. facetParameters: any;
  25706. bbSize: Vector3;
  25707. subDiv: {
  25708. max: number;
  25709. X: number;
  25710. Y: number;
  25711. Z: number;
  25712. };
  25713. facetDepthSort: boolean;
  25714. facetDepthSortEnabled: boolean;
  25715. depthSortedIndices: IndicesArray;
  25716. depthSortedFacets: {
  25717. ind: number;
  25718. sqDistance: number;
  25719. }[];
  25720. facetDepthSortFunction: (f1: {
  25721. ind: number;
  25722. sqDistance: number;
  25723. }, f2: {
  25724. ind: number;
  25725. sqDistance: number;
  25726. }) => number;
  25727. facetDepthSortFrom: Vector3;
  25728. facetDepthSortOrigin: Vector3;
  25729. invertedMatrix: Matrix;
  25730. }
  25731. /**
  25732. * @hidden
  25733. **/
  25734. class _InternalAbstractMeshDataInfo {
  25735. _hasVertexAlpha: boolean;
  25736. _useVertexColors: boolean;
  25737. _numBoneInfluencers: number;
  25738. _applyFog: boolean;
  25739. _receiveShadows: boolean;
  25740. _facetData: _FacetDataStorage;
  25741. _visibility: number;
  25742. _skeleton: Nullable<Skeleton>;
  25743. _layerMask: number;
  25744. _computeBonesUsingShaders: boolean;
  25745. _isActive: boolean;
  25746. _onlyForInstances: boolean;
  25747. _isActiveIntermediate: boolean;
  25748. _onlyForInstancesIntermediate: boolean;
  25749. }
  25750. /**
  25751. * Class used to store all common mesh properties
  25752. */
  25753. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  25754. /** No occlusion */
  25755. static OCCLUSION_TYPE_NONE: number;
  25756. /** Occlusion set to optimisitic */
  25757. static OCCLUSION_TYPE_OPTIMISTIC: number;
  25758. /** Occlusion set to strict */
  25759. static OCCLUSION_TYPE_STRICT: number;
  25760. /** Use an accurante occlusion algorithm */
  25761. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  25762. /** Use a conservative occlusion algorithm */
  25763. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  25764. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  25765. * Test order :
  25766. * Is the bounding sphere outside the frustum ?
  25767. * If not, are the bounding box vertices outside the frustum ?
  25768. * It not, then the cullable object is in the frustum.
  25769. */
  25770. static readonly CULLINGSTRATEGY_STANDARD: number;
  25771. /** Culling strategy : Bounding Sphere Only.
  25772. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  25773. * It's also less accurate than the standard because some not visible objects can still be selected.
  25774. * Test : is the bounding sphere outside the frustum ?
  25775. * If not, then the cullable object is in the frustum.
  25776. */
  25777. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  25778. /** Culling strategy : Optimistic Inclusion.
  25779. * This in an inclusion test first, then the standard exclusion test.
  25780. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  25781. * 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.
  25782. * Anyway, it's as accurate as the standard strategy.
  25783. * Test :
  25784. * Is the cullable object bounding sphere center in the frustum ?
  25785. * If not, apply the default culling strategy.
  25786. */
  25787. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  25788. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  25789. * This in an inclusion test first, then the bounding sphere only exclusion test.
  25790. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  25791. * 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.
  25792. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  25793. * Test :
  25794. * Is the cullable object bounding sphere center in the frustum ?
  25795. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  25796. */
  25797. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  25798. /**
  25799. * No billboard
  25800. */
  25801. static readonly BILLBOARDMODE_NONE: number;
  25802. /** Billboard on X axis */
  25803. static readonly BILLBOARDMODE_X: number;
  25804. /** Billboard on Y axis */
  25805. static readonly BILLBOARDMODE_Y: number;
  25806. /** Billboard on Z axis */
  25807. static readonly BILLBOARDMODE_Z: number;
  25808. /** Billboard on all axes */
  25809. static readonly BILLBOARDMODE_ALL: number;
  25810. /** Billboard on using position instead of orientation */
  25811. static readonly BILLBOARDMODE_USE_POSITION: number;
  25812. /** @hidden */
  25813. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  25814. /**
  25815. * The culling strategy to use to check whether the mesh must be rendered or not.
  25816. * This value can be changed at any time and will be used on the next render mesh selection.
  25817. * The possible values are :
  25818. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  25819. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  25820. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  25821. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  25822. * Please read each static variable documentation to get details about the culling process.
  25823. * */
  25824. cullingStrategy: number;
  25825. /**
  25826. * Gets the number of facets in the mesh
  25827. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  25828. */
  25829. readonly facetNb: number;
  25830. /**
  25831. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  25832. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  25833. */
  25834. partitioningSubdivisions: number;
  25835. /**
  25836. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  25837. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  25838. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  25839. */
  25840. partitioningBBoxRatio: number;
  25841. /**
  25842. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  25843. * Works only for updatable meshes.
  25844. * Doesn't work with multi-materials
  25845. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  25846. */
  25847. mustDepthSortFacets: boolean;
  25848. /**
  25849. * The location (Vector3) where the facet depth sort must be computed from.
  25850. * By default, the active camera position.
  25851. * Used only when facet depth sort is enabled
  25852. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  25853. */
  25854. facetDepthSortFrom: Vector3;
  25855. /**
  25856. * gets a boolean indicating if facetData is enabled
  25857. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  25858. */
  25859. readonly isFacetDataEnabled: boolean;
  25860. /** @hidden */
  25861. _updateNonUniformScalingState(value: boolean): boolean;
  25862. /**
  25863. * An event triggered when this mesh collides with another one
  25864. */
  25865. onCollideObservable: Observable<AbstractMesh>;
  25866. /** Set a function to call when this mesh collides with another one */
  25867. onCollide: () => void;
  25868. /**
  25869. * An event triggered when the collision's position changes
  25870. */
  25871. onCollisionPositionChangeObservable: Observable<Vector3>;
  25872. /** Set a function to call when the collision's position changes */
  25873. onCollisionPositionChange: () => void;
  25874. /**
  25875. * An event triggered when material is changed
  25876. */
  25877. onMaterialChangedObservable: Observable<AbstractMesh>;
  25878. /**
  25879. * Gets or sets the orientation for POV movement & rotation
  25880. */
  25881. definedFacingForward: boolean;
  25882. /** @hidden */
  25883. _occlusionQuery: Nullable<WebGLQuery>;
  25884. /** @hidden */
  25885. _renderingGroup: Nullable<RenderingGroup>;
  25886. /**
  25887. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  25888. */
  25889. /**
  25890. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  25891. */
  25892. visibility: number;
  25893. /** Gets or sets the alpha index used to sort transparent meshes
  25894. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  25895. */
  25896. alphaIndex: number;
  25897. /**
  25898. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  25899. */
  25900. isVisible: boolean;
  25901. /**
  25902. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  25903. */
  25904. isPickable: boolean;
  25905. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  25906. showSubMeshesBoundingBox: boolean;
  25907. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  25908. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  25909. */
  25910. isBlocker: boolean;
  25911. /**
  25912. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  25913. */
  25914. enablePointerMoveEvents: boolean;
  25915. /**
  25916. * Specifies the rendering group id for this mesh (0 by default)
  25917. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  25918. */
  25919. renderingGroupId: number;
  25920. private _material;
  25921. /** Gets or sets current material */
  25922. material: Nullable<Material>;
  25923. /**
  25924. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  25925. * @see http://doc.babylonjs.com/babylon101/shadows
  25926. */
  25927. receiveShadows: boolean;
  25928. /** Defines color to use when rendering outline */
  25929. outlineColor: Color3;
  25930. /** Define width to use when rendering outline */
  25931. outlineWidth: number;
  25932. /** Defines color to use when rendering overlay */
  25933. overlayColor: Color3;
  25934. /** Defines alpha to use when rendering overlay */
  25935. overlayAlpha: number;
  25936. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  25937. hasVertexAlpha: boolean;
  25938. /** 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) */
  25939. useVertexColors: boolean;
  25940. /**
  25941. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  25942. */
  25943. computeBonesUsingShaders: boolean;
  25944. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  25945. numBoneInfluencers: number;
  25946. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  25947. applyFog: boolean;
  25948. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  25949. useOctreeForRenderingSelection: boolean;
  25950. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  25951. useOctreeForPicking: boolean;
  25952. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  25953. useOctreeForCollisions: boolean;
  25954. /**
  25955. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  25956. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  25957. */
  25958. layerMask: number;
  25959. /**
  25960. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  25961. */
  25962. alwaysSelectAsActiveMesh: boolean;
  25963. /**
  25964. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  25965. */
  25966. doNotSyncBoundingInfo: boolean;
  25967. /**
  25968. * Gets or sets the current action manager
  25969. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  25970. */
  25971. actionManager: Nullable<AbstractActionManager>;
  25972. private _meshCollisionData;
  25973. /**
  25974. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  25975. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25976. */
  25977. ellipsoid: Vector3;
  25978. /**
  25979. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  25980. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25981. */
  25982. ellipsoidOffset: Vector3;
  25983. /**
  25984. * Gets or sets a collision mask used to mask collisions (default is -1).
  25985. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  25986. */
  25987. collisionMask: number;
  25988. /**
  25989. * Gets or sets the current collision group mask (-1 by default).
  25990. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  25991. */
  25992. collisionGroup: number;
  25993. /**
  25994. * Defines edge width used when edgesRenderer is enabled
  25995. * @see https://www.babylonjs-playground.com/#10OJSG#13
  25996. */
  25997. edgesWidth: number;
  25998. /**
  25999. * Defines edge color used when edgesRenderer is enabled
  26000. * @see https://www.babylonjs-playground.com/#10OJSG#13
  26001. */
  26002. edgesColor: Color4;
  26003. /** @hidden */
  26004. _edgesRenderer: Nullable<IEdgesRenderer>;
  26005. /** @hidden */
  26006. _masterMesh: Nullable<AbstractMesh>;
  26007. /** @hidden */
  26008. _boundingInfo: Nullable<BoundingInfo>;
  26009. /** @hidden */
  26010. _renderId: number;
  26011. /**
  26012. * Gets or sets the list of subMeshes
  26013. * @see http://doc.babylonjs.com/how_to/multi_materials
  26014. */
  26015. subMeshes: SubMesh[];
  26016. /** @hidden */
  26017. _intersectionsInProgress: AbstractMesh[];
  26018. /** @hidden */
  26019. _unIndexed: boolean;
  26020. /** @hidden */
  26021. _lightSources: Light[];
  26022. /** Gets the list of lights affecting that mesh */
  26023. readonly lightSources: Light[];
  26024. /** @hidden */
  26025. readonly _positions: Nullable<Vector3[]>;
  26026. /** @hidden */
  26027. _waitingData: {
  26028. lods: Nullable<any>;
  26029. actions: Nullable<any>;
  26030. freezeWorldMatrix: Nullable<boolean>;
  26031. };
  26032. /** @hidden */
  26033. _bonesTransformMatrices: Nullable<Float32Array>;
  26034. /** @hidden */
  26035. _transformMatrixTexture: Nullable<RawTexture>;
  26036. /**
  26037. * Gets or sets a skeleton to apply skining transformations
  26038. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  26039. */
  26040. skeleton: Nullable<Skeleton>;
  26041. /**
  26042. * An event triggered when the mesh is rebuilt.
  26043. */
  26044. onRebuildObservable: Observable<AbstractMesh>;
  26045. /**
  26046. * Creates a new AbstractMesh
  26047. * @param name defines the name of the mesh
  26048. * @param scene defines the hosting scene
  26049. */
  26050. constructor(name: string, scene?: Nullable<Scene>);
  26051. /**
  26052. * Returns the string "AbstractMesh"
  26053. * @returns "AbstractMesh"
  26054. */
  26055. getClassName(): string;
  26056. /**
  26057. * Gets a string representation of the current mesh
  26058. * @param fullDetails defines a boolean indicating if full details must be included
  26059. * @returns a string representation of the current mesh
  26060. */
  26061. toString(fullDetails?: boolean): string;
  26062. /**
  26063. * @hidden
  26064. */
  26065. protected _getEffectiveParent(): Nullable<Node>;
  26066. /** @hidden */
  26067. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  26068. /** @hidden */
  26069. _rebuild(): void;
  26070. /** @hidden */
  26071. _resyncLightSources(): void;
  26072. /** @hidden */
  26073. _resyncLighSource(light: Light): void;
  26074. /** @hidden */
  26075. _unBindEffect(): void;
  26076. /** @hidden */
  26077. _removeLightSource(light: Light, dispose: boolean): void;
  26078. private _markSubMeshesAsDirty;
  26079. /** @hidden */
  26080. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  26081. /** @hidden */
  26082. _markSubMeshesAsAttributesDirty(): void;
  26083. /** @hidden */
  26084. _markSubMeshesAsMiscDirty(): void;
  26085. /**
  26086. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  26087. */
  26088. scaling: Vector3;
  26089. /**
  26090. * Returns true if the mesh is blocked. Implemented by child classes
  26091. */
  26092. readonly isBlocked: boolean;
  26093. /**
  26094. * Returns the mesh itself by default. Implemented by child classes
  26095. * @param camera defines the camera to use to pick the right LOD level
  26096. * @returns the currentAbstractMesh
  26097. */
  26098. getLOD(camera: Camera): Nullable<AbstractMesh>;
  26099. /**
  26100. * Returns 0 by default. Implemented by child classes
  26101. * @returns an integer
  26102. */
  26103. getTotalVertices(): number;
  26104. /**
  26105. * Returns a positive integer : the total number of indices in this mesh geometry.
  26106. * @returns the numner of indices or zero if the mesh has no geometry.
  26107. */
  26108. getTotalIndices(): number;
  26109. /**
  26110. * Returns null by default. Implemented by child classes
  26111. * @returns null
  26112. */
  26113. getIndices(): Nullable<IndicesArray>;
  26114. /**
  26115. * Returns the array of the requested vertex data kind. Implemented by child classes
  26116. * @param kind defines the vertex data kind to use
  26117. * @returns null
  26118. */
  26119. getVerticesData(kind: string): Nullable<FloatArray>;
  26120. /**
  26121. * Sets the vertex data of the mesh geometry for the requested `kind`.
  26122. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  26123. * Note that a new underlying VertexBuffer object is created each call.
  26124. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  26125. * @param kind defines vertex data kind:
  26126. * * VertexBuffer.PositionKind
  26127. * * VertexBuffer.UVKind
  26128. * * VertexBuffer.UV2Kind
  26129. * * VertexBuffer.UV3Kind
  26130. * * VertexBuffer.UV4Kind
  26131. * * VertexBuffer.UV5Kind
  26132. * * VertexBuffer.UV6Kind
  26133. * * VertexBuffer.ColorKind
  26134. * * VertexBuffer.MatricesIndicesKind
  26135. * * VertexBuffer.MatricesIndicesExtraKind
  26136. * * VertexBuffer.MatricesWeightsKind
  26137. * * VertexBuffer.MatricesWeightsExtraKind
  26138. * @param data defines the data source
  26139. * @param updatable defines if the data must be flagged as updatable (or static)
  26140. * @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
  26141. * @returns the current mesh
  26142. */
  26143. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  26144. /**
  26145. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  26146. * If the mesh has no geometry, it is simply returned as it is.
  26147. * @param kind defines vertex data kind:
  26148. * * VertexBuffer.PositionKind
  26149. * * VertexBuffer.UVKind
  26150. * * VertexBuffer.UV2Kind
  26151. * * VertexBuffer.UV3Kind
  26152. * * VertexBuffer.UV4Kind
  26153. * * VertexBuffer.UV5Kind
  26154. * * VertexBuffer.UV6Kind
  26155. * * VertexBuffer.ColorKind
  26156. * * VertexBuffer.MatricesIndicesKind
  26157. * * VertexBuffer.MatricesIndicesExtraKind
  26158. * * VertexBuffer.MatricesWeightsKind
  26159. * * VertexBuffer.MatricesWeightsExtraKind
  26160. * @param data defines the data source
  26161. * @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
  26162. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  26163. * @returns the current mesh
  26164. */
  26165. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  26166. /**
  26167. * Sets the mesh indices,
  26168. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  26169. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  26170. * @param totalVertices Defines the total number of vertices
  26171. * @returns the current mesh
  26172. */
  26173. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  26174. /**
  26175. * Gets a boolean indicating if specific vertex data is present
  26176. * @param kind defines the vertex data kind to use
  26177. * @returns true is data kind is present
  26178. */
  26179. isVerticesDataPresent(kind: string): boolean;
  26180. /**
  26181. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  26182. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  26183. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  26184. * @returns a BoundingInfo
  26185. */
  26186. getBoundingInfo(): BoundingInfo;
  26187. /**
  26188. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  26189. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  26190. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  26191. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  26192. * @returns the current mesh
  26193. */
  26194. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  26195. /**
  26196. * Overwrite the current bounding info
  26197. * @param boundingInfo defines the new bounding info
  26198. * @returns the current mesh
  26199. */
  26200. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  26201. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  26202. readonly useBones: boolean;
  26203. /** @hidden */
  26204. _preActivate(): void;
  26205. /** @hidden */
  26206. _preActivateForIntermediateRendering(renderId: number): void;
  26207. /** @hidden */
  26208. _activate(renderId: number, intermediateRendering: boolean): boolean;
  26209. /** @hidden */
  26210. _postActivate(): void;
  26211. /** @hidden */
  26212. _freeze(): void;
  26213. /** @hidden */
  26214. _unFreeze(): void;
  26215. /**
  26216. * Gets the current world matrix
  26217. * @returns a Matrix
  26218. */
  26219. getWorldMatrix(): Matrix;
  26220. /** @hidden */
  26221. _getWorldMatrixDeterminant(): number;
  26222. /**
  26223. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  26224. */
  26225. readonly isAnInstance: boolean;
  26226. /**
  26227. * Gets a boolean indicating if this mesh has instances
  26228. */
  26229. readonly hasInstances: boolean;
  26230. /**
  26231. * Perform relative position change from the point of view of behind the front of the mesh.
  26232. * This is performed taking into account the meshes current rotation, so you do not have to care.
  26233. * Supports definition of mesh facing forward or backward
  26234. * @param amountRight defines the distance on the right axis
  26235. * @param amountUp defines the distance on the up axis
  26236. * @param amountForward defines the distance on the forward axis
  26237. * @returns the current mesh
  26238. */
  26239. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  26240. /**
  26241. * Calculate relative position change from the point of view of behind the front of the mesh.
  26242. * This is performed taking into account the meshes current rotation, so you do not have to care.
  26243. * Supports definition of mesh facing forward or backward
  26244. * @param amountRight defines the distance on the right axis
  26245. * @param amountUp defines the distance on the up axis
  26246. * @param amountForward defines the distance on the forward axis
  26247. * @returns the new displacement vector
  26248. */
  26249. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  26250. /**
  26251. * Perform relative rotation change from the point of view of behind the front of the mesh.
  26252. * Supports definition of mesh facing forward or backward
  26253. * @param flipBack defines the flip
  26254. * @param twirlClockwise defines the twirl
  26255. * @param tiltRight defines the tilt
  26256. * @returns the current mesh
  26257. */
  26258. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  26259. /**
  26260. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  26261. * Supports definition of mesh facing forward or backward.
  26262. * @param flipBack defines the flip
  26263. * @param twirlClockwise defines the twirl
  26264. * @param tiltRight defines the tilt
  26265. * @returns the new rotation vector
  26266. */
  26267. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  26268. /**
  26269. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  26270. * This means the mesh underlying bounding box and sphere are recomputed.
  26271. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  26272. * @returns the current mesh
  26273. */
  26274. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  26275. /** @hidden */
  26276. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  26277. /** @hidden */
  26278. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  26279. /** @hidden */
  26280. _updateBoundingInfo(): AbstractMesh;
  26281. /** @hidden */
  26282. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  26283. /** @hidden */
  26284. protected _afterComputeWorldMatrix(): void;
  26285. /** @hidden */
  26286. readonly _effectiveMesh: AbstractMesh;
  26287. /**
  26288. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  26289. * A mesh is in the frustum if its bounding box intersects the frustum
  26290. * @param frustumPlanes defines the frustum to test
  26291. * @returns true if the mesh is in the frustum planes
  26292. */
  26293. isInFrustum(frustumPlanes: Plane[]): boolean;
  26294. /**
  26295. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  26296. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  26297. * @param frustumPlanes defines the frustum to test
  26298. * @returns true if the mesh is completely in the frustum planes
  26299. */
  26300. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  26301. /**
  26302. * True if the mesh intersects another mesh or a SolidParticle object
  26303. * @param mesh defines a target mesh or SolidParticle to test
  26304. * @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)
  26305. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  26306. * @returns true if there is an intersection
  26307. */
  26308. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  26309. /**
  26310. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  26311. * @param point defines the point to test
  26312. * @returns true if there is an intersection
  26313. */
  26314. intersectsPoint(point: Vector3): boolean;
  26315. /**
  26316. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  26317. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26318. */
  26319. checkCollisions: boolean;
  26320. /**
  26321. * Gets Collider object used to compute collisions (not physics)
  26322. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26323. */
  26324. readonly collider: Nullable<Collider>;
  26325. /**
  26326. * Move the mesh using collision engine
  26327. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26328. * @param displacement defines the requested displacement vector
  26329. * @returns the current mesh
  26330. */
  26331. moveWithCollisions(displacement: Vector3): AbstractMesh;
  26332. private _onCollisionPositionChange;
  26333. /** @hidden */
  26334. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  26335. /** @hidden */
  26336. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  26337. /** @hidden */
  26338. _checkCollision(collider: Collider): AbstractMesh;
  26339. /** @hidden */
  26340. _generatePointsArray(): boolean;
  26341. /**
  26342. * Checks if the passed Ray intersects with the mesh
  26343. * @param ray defines the ray to use
  26344. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  26345. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  26346. * @returns the picking info
  26347. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  26348. */
  26349. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  26350. /**
  26351. * Clones the current mesh
  26352. * @param name defines the mesh name
  26353. * @param newParent defines the new mesh parent
  26354. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  26355. * @returns the new mesh
  26356. */
  26357. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  26358. /**
  26359. * Disposes all the submeshes of the current meshnp
  26360. * @returns the current mesh
  26361. */
  26362. releaseSubMeshes(): AbstractMesh;
  26363. /**
  26364. * Releases resources associated with this abstract mesh.
  26365. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26366. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26367. */
  26368. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26369. /**
  26370. * Adds the passed mesh as a child to the current mesh
  26371. * @param mesh defines the child mesh
  26372. * @returns the current mesh
  26373. */
  26374. addChild(mesh: AbstractMesh): AbstractMesh;
  26375. /**
  26376. * Removes the passed mesh from the current mesh children list
  26377. * @param mesh defines the child mesh
  26378. * @returns the current mesh
  26379. */
  26380. removeChild(mesh: AbstractMesh): AbstractMesh;
  26381. /** @hidden */
  26382. private _initFacetData;
  26383. /**
  26384. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  26385. * This method can be called within the render loop.
  26386. * 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
  26387. * @returns the current mesh
  26388. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26389. */
  26390. updateFacetData(): AbstractMesh;
  26391. /**
  26392. * Returns the facetLocalNormals array.
  26393. * The normals are expressed in the mesh local spac
  26394. * @returns an array of Vector3
  26395. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26396. */
  26397. getFacetLocalNormals(): Vector3[];
  26398. /**
  26399. * Returns the facetLocalPositions array.
  26400. * The facet positions are expressed in the mesh local space
  26401. * @returns an array of Vector3
  26402. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26403. */
  26404. getFacetLocalPositions(): Vector3[];
  26405. /**
  26406. * Returns the facetLocalPartioning array
  26407. * @returns an array of array of numbers
  26408. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26409. */
  26410. getFacetLocalPartitioning(): number[][];
  26411. /**
  26412. * Returns the i-th facet position in the world system.
  26413. * This method allocates a new Vector3 per call
  26414. * @param i defines the facet index
  26415. * @returns a new Vector3
  26416. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26417. */
  26418. getFacetPosition(i: number): Vector3;
  26419. /**
  26420. * Sets the reference Vector3 with the i-th facet position in the world system
  26421. * @param i defines the facet index
  26422. * @param ref defines the target vector
  26423. * @returns the current mesh
  26424. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26425. */
  26426. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  26427. /**
  26428. * Returns the i-th facet normal in the world system.
  26429. * This method allocates a new Vector3 per call
  26430. * @param i defines the facet index
  26431. * @returns a new Vector3
  26432. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26433. */
  26434. getFacetNormal(i: number): Vector3;
  26435. /**
  26436. * Sets the reference Vector3 with the i-th facet normal in the world system
  26437. * @param i defines the facet index
  26438. * @param ref defines the target vector
  26439. * @returns the current mesh
  26440. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26441. */
  26442. getFacetNormalToRef(i: number, ref: Vector3): this;
  26443. /**
  26444. * 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)
  26445. * @param x defines x coordinate
  26446. * @param y defines y coordinate
  26447. * @param z defines z coordinate
  26448. * @returns the array of facet indexes
  26449. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26450. */
  26451. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  26452. /**
  26453. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  26454. * @param projected sets as the (x,y,z) world projection on the facet
  26455. * @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
  26456. * @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
  26457. * @param x defines x coordinate
  26458. * @param y defines y coordinate
  26459. * @param z defines z coordinate
  26460. * @returns the face index if found (or null instead)
  26461. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26462. */
  26463. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  26464. /**
  26465. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  26466. * @param projected sets as the (x,y,z) local projection on the facet
  26467. * @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
  26468. * @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
  26469. * @param x defines x coordinate
  26470. * @param y defines y coordinate
  26471. * @param z defines z coordinate
  26472. * @returns the face index if found (or null instead)
  26473. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26474. */
  26475. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  26476. /**
  26477. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  26478. * @returns the parameters
  26479. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26480. */
  26481. getFacetDataParameters(): any;
  26482. /**
  26483. * Disables the feature FacetData and frees the related memory
  26484. * @returns the current mesh
  26485. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26486. */
  26487. disableFacetData(): AbstractMesh;
  26488. /**
  26489. * Updates the AbstractMesh indices array
  26490. * @param indices defines the data source
  26491. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  26492. * @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)
  26493. * @returns the current mesh
  26494. */
  26495. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  26496. /**
  26497. * Creates new normals data for the mesh
  26498. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  26499. * @returns the current mesh
  26500. */
  26501. createNormals(updatable: boolean): AbstractMesh;
  26502. /**
  26503. * Align the mesh with a normal
  26504. * @param normal defines the normal to use
  26505. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  26506. * @returns the current mesh
  26507. */
  26508. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  26509. /** @hidden */
  26510. _checkOcclusionQuery(): boolean;
  26511. /**
  26512. * Disables the mesh edge rendering mode
  26513. * @returns the currentAbstractMesh
  26514. */
  26515. disableEdgesRendering(): AbstractMesh;
  26516. /**
  26517. * Enables the edge rendering mode on the mesh.
  26518. * This mode makes the mesh edges visible
  26519. * @param epsilon defines the maximal distance between two angles to detect a face
  26520. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  26521. * @returns the currentAbstractMesh
  26522. * @see https://www.babylonjs-playground.com/#19O9TU#0
  26523. */
  26524. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  26525. }
  26526. }
  26527. declare module BABYLON {
  26528. /**
  26529. * Interface used to define ActionEvent
  26530. */
  26531. export interface IActionEvent {
  26532. /** The mesh or sprite that triggered the action */
  26533. source: any;
  26534. /** The X mouse cursor position at the time of the event */
  26535. pointerX: number;
  26536. /** The Y mouse cursor position at the time of the event */
  26537. pointerY: number;
  26538. /** The mesh that is currently pointed at (can be null) */
  26539. meshUnderPointer: Nullable<AbstractMesh>;
  26540. /** the original (browser) event that triggered the ActionEvent */
  26541. sourceEvent?: any;
  26542. /** additional data for the event */
  26543. additionalData?: any;
  26544. }
  26545. /**
  26546. * ActionEvent is the event being sent when an action is triggered.
  26547. */
  26548. export class ActionEvent implements IActionEvent {
  26549. /** The mesh or sprite that triggered the action */
  26550. source: any;
  26551. /** The X mouse cursor position at the time of the event */
  26552. pointerX: number;
  26553. /** The Y mouse cursor position at the time of the event */
  26554. pointerY: number;
  26555. /** The mesh that is currently pointed at (can be null) */
  26556. meshUnderPointer: Nullable<AbstractMesh>;
  26557. /** the original (browser) event that triggered the ActionEvent */
  26558. sourceEvent?: any;
  26559. /** additional data for the event */
  26560. additionalData?: any;
  26561. /**
  26562. * Creates a new ActionEvent
  26563. * @param source The mesh or sprite that triggered the action
  26564. * @param pointerX The X mouse cursor position at the time of the event
  26565. * @param pointerY The Y mouse cursor position at the time of the event
  26566. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  26567. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  26568. * @param additionalData additional data for the event
  26569. */
  26570. constructor(
  26571. /** The mesh or sprite that triggered the action */
  26572. source: any,
  26573. /** The X mouse cursor position at the time of the event */
  26574. pointerX: number,
  26575. /** The Y mouse cursor position at the time of the event */
  26576. pointerY: number,
  26577. /** The mesh that is currently pointed at (can be null) */
  26578. meshUnderPointer: Nullable<AbstractMesh>,
  26579. /** the original (browser) event that triggered the ActionEvent */
  26580. sourceEvent?: any,
  26581. /** additional data for the event */
  26582. additionalData?: any);
  26583. /**
  26584. * Helper function to auto-create an ActionEvent from a source mesh.
  26585. * @param source The source mesh that triggered the event
  26586. * @param evt The original (browser) event
  26587. * @param additionalData additional data for the event
  26588. * @returns the new ActionEvent
  26589. */
  26590. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  26591. /**
  26592. * Helper function to auto-create an ActionEvent from a source sprite
  26593. * @param source The source sprite that triggered the event
  26594. * @param scene Scene associated with the sprite
  26595. * @param evt The original (browser) event
  26596. * @param additionalData additional data for the event
  26597. * @returns the new ActionEvent
  26598. */
  26599. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  26600. /**
  26601. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  26602. * @param scene the scene where the event occurred
  26603. * @param evt The original (browser) event
  26604. * @returns the new ActionEvent
  26605. */
  26606. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  26607. /**
  26608. * Helper function to auto-create an ActionEvent from a primitive
  26609. * @param prim defines the target primitive
  26610. * @param pointerPos defines the pointer position
  26611. * @param evt The original (browser) event
  26612. * @param additionalData additional data for the event
  26613. * @returns the new ActionEvent
  26614. */
  26615. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  26616. }
  26617. }
  26618. declare module BABYLON {
  26619. /**
  26620. * Abstract class used to decouple action Manager from scene and meshes.
  26621. * Do not instantiate.
  26622. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  26623. */
  26624. export abstract class AbstractActionManager implements IDisposable {
  26625. /** Gets the list of active triggers */
  26626. static Triggers: {
  26627. [key: string]: number;
  26628. };
  26629. /** Gets the cursor to use when hovering items */
  26630. hoverCursor: string;
  26631. /** Gets the list of actions */
  26632. actions: IAction[];
  26633. /**
  26634. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  26635. */
  26636. isRecursive: boolean;
  26637. /**
  26638. * Releases all associated resources
  26639. */
  26640. abstract dispose(): void;
  26641. /**
  26642. * Does this action manager has pointer triggers
  26643. */
  26644. abstract readonly hasPointerTriggers: boolean;
  26645. /**
  26646. * Does this action manager has pick triggers
  26647. */
  26648. abstract readonly hasPickTriggers: boolean;
  26649. /**
  26650. * Process a specific trigger
  26651. * @param trigger defines the trigger to process
  26652. * @param evt defines the event details to be processed
  26653. */
  26654. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  26655. /**
  26656. * Does this action manager handles actions of any of the given triggers
  26657. * @param triggers defines the triggers to be tested
  26658. * @return a boolean indicating whether one (or more) of the triggers is handled
  26659. */
  26660. abstract hasSpecificTriggers(triggers: number[]): boolean;
  26661. /**
  26662. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  26663. * speed.
  26664. * @param triggerA defines the trigger to be tested
  26665. * @param triggerB defines the trigger to be tested
  26666. * @return a boolean indicating whether one (or more) of the triggers is handled
  26667. */
  26668. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  26669. /**
  26670. * Does this action manager handles actions of a given trigger
  26671. * @param trigger defines the trigger to be tested
  26672. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  26673. * @return whether the trigger is handled
  26674. */
  26675. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  26676. /**
  26677. * Serialize this manager to a JSON object
  26678. * @param name defines the property name to store this manager
  26679. * @returns a JSON representation of this manager
  26680. */
  26681. abstract serialize(name: string): any;
  26682. /**
  26683. * Registers an action to this action manager
  26684. * @param action defines the action to be registered
  26685. * @return the action amended (prepared) after registration
  26686. */
  26687. abstract registerAction(action: IAction): Nullable<IAction>;
  26688. /**
  26689. * Unregisters an action to this action manager
  26690. * @param action defines the action to be unregistered
  26691. * @return a boolean indicating whether the action has been unregistered
  26692. */
  26693. abstract unregisterAction(action: IAction): Boolean;
  26694. /**
  26695. * Does exist one action manager with at least one trigger
  26696. **/
  26697. static readonly HasTriggers: boolean;
  26698. /**
  26699. * Does exist one action manager with at least one pick trigger
  26700. **/
  26701. static readonly HasPickTriggers: boolean;
  26702. /**
  26703. * Does exist one action manager that handles actions of a given trigger
  26704. * @param trigger defines the trigger to be tested
  26705. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  26706. **/
  26707. static HasSpecificTrigger(trigger: number): boolean;
  26708. }
  26709. }
  26710. declare module BABYLON {
  26711. /**
  26712. * Defines how a node can be built from a string name.
  26713. */
  26714. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  26715. /**
  26716. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  26717. */
  26718. export class Node implements IBehaviorAware<Node> {
  26719. /** @hidden */
  26720. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  26721. private static _NodeConstructors;
  26722. /**
  26723. * Add a new node constructor
  26724. * @param type defines the type name of the node to construct
  26725. * @param constructorFunc defines the constructor function
  26726. */
  26727. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  26728. /**
  26729. * Returns a node constructor based on type name
  26730. * @param type defines the type name
  26731. * @param name defines the new node name
  26732. * @param scene defines the hosting scene
  26733. * @param options defines optional options to transmit to constructors
  26734. * @returns the new constructor or null
  26735. */
  26736. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  26737. /**
  26738. * Gets or sets the name of the node
  26739. */
  26740. name: string;
  26741. /**
  26742. * Gets or sets the id of the node
  26743. */
  26744. id: string;
  26745. /**
  26746. * Gets or sets the unique id of the node
  26747. */
  26748. uniqueId: number;
  26749. /**
  26750. * Gets or sets a string used to store user defined state for the node
  26751. */
  26752. state: string;
  26753. /**
  26754. * Gets or sets an object used to store user defined information for the node
  26755. */
  26756. metadata: any;
  26757. /**
  26758. * For internal use only. Please do not use.
  26759. */
  26760. reservedDataStore: any;
  26761. /**
  26762. * List of inspectable custom properties (used by the Inspector)
  26763. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  26764. */
  26765. inspectableCustomProperties: IInspectable[];
  26766. private _doNotSerialize;
  26767. /**
  26768. * Gets or sets a boolean used to define if the node must be serialized
  26769. */
  26770. doNotSerialize: boolean;
  26771. /** @hidden */
  26772. _isDisposed: boolean;
  26773. /**
  26774. * Gets a list of Animations associated with the node
  26775. */
  26776. animations: Animation[];
  26777. protected _ranges: {
  26778. [name: string]: Nullable<AnimationRange>;
  26779. };
  26780. /**
  26781. * Callback raised when the node is ready to be used
  26782. */
  26783. onReady: Nullable<(node: Node) => void>;
  26784. private _isEnabled;
  26785. private _isParentEnabled;
  26786. private _isReady;
  26787. /** @hidden */
  26788. _currentRenderId: number;
  26789. private _parentUpdateId;
  26790. /** @hidden */
  26791. _childUpdateId: number;
  26792. /** @hidden */
  26793. _waitingParentId: Nullable<string>;
  26794. /** @hidden */
  26795. _scene: Scene;
  26796. /** @hidden */
  26797. _cache: any;
  26798. private _parentNode;
  26799. private _children;
  26800. /** @hidden */
  26801. _worldMatrix: Matrix;
  26802. /** @hidden */
  26803. _worldMatrixDeterminant: number;
  26804. /** @hidden */
  26805. _worldMatrixDeterminantIsDirty: boolean;
  26806. /** @hidden */
  26807. private _sceneRootNodesIndex;
  26808. /**
  26809. * Gets a boolean indicating if the node has been disposed
  26810. * @returns true if the node was disposed
  26811. */
  26812. isDisposed(): boolean;
  26813. /**
  26814. * Gets or sets the parent of the node (without keeping the current position in the scene)
  26815. * @see https://doc.babylonjs.com/how_to/parenting
  26816. */
  26817. parent: Nullable<Node>;
  26818. private addToSceneRootNodes;
  26819. private removeFromSceneRootNodes;
  26820. private _animationPropertiesOverride;
  26821. /**
  26822. * Gets or sets the animation properties override
  26823. */
  26824. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  26825. /**
  26826. * Gets a string idenfifying the name of the class
  26827. * @returns "Node" string
  26828. */
  26829. getClassName(): string;
  26830. /** @hidden */
  26831. readonly _isNode: boolean;
  26832. /**
  26833. * An event triggered when the mesh is disposed
  26834. */
  26835. onDisposeObservable: Observable<Node>;
  26836. private _onDisposeObserver;
  26837. /**
  26838. * Sets a callback that will be raised when the node will be disposed
  26839. */
  26840. onDispose: () => void;
  26841. /**
  26842. * Creates a new Node
  26843. * @param name the name and id to be given to this node
  26844. * @param scene the scene this node will be added to
  26845. * @param addToRootNodes the node will be added to scene.rootNodes
  26846. */
  26847. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  26848. /**
  26849. * Gets the scene of the node
  26850. * @returns a scene
  26851. */
  26852. getScene(): Scene;
  26853. /**
  26854. * Gets the engine of the node
  26855. * @returns a Engine
  26856. */
  26857. getEngine(): Engine;
  26858. private _behaviors;
  26859. /**
  26860. * Attach a behavior to the node
  26861. * @see http://doc.babylonjs.com/features/behaviour
  26862. * @param behavior defines the behavior to attach
  26863. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  26864. * @returns the current Node
  26865. */
  26866. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  26867. /**
  26868. * Remove an attached behavior
  26869. * @see http://doc.babylonjs.com/features/behaviour
  26870. * @param behavior defines the behavior to attach
  26871. * @returns the current Node
  26872. */
  26873. removeBehavior(behavior: Behavior<Node>): Node;
  26874. /**
  26875. * Gets the list of attached behaviors
  26876. * @see http://doc.babylonjs.com/features/behaviour
  26877. */
  26878. readonly behaviors: Behavior<Node>[];
  26879. /**
  26880. * Gets an attached behavior by name
  26881. * @param name defines the name of the behavior to look for
  26882. * @see http://doc.babylonjs.com/features/behaviour
  26883. * @returns null if behavior was not found else the requested behavior
  26884. */
  26885. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  26886. /**
  26887. * Returns the latest update of the World matrix
  26888. * @returns a Matrix
  26889. */
  26890. getWorldMatrix(): Matrix;
  26891. /** @hidden */
  26892. _getWorldMatrixDeterminant(): number;
  26893. /**
  26894. * Returns directly the latest state of the mesh World matrix.
  26895. * A Matrix is returned.
  26896. */
  26897. readonly worldMatrixFromCache: Matrix;
  26898. /** @hidden */
  26899. _initCache(): void;
  26900. /** @hidden */
  26901. updateCache(force?: boolean): void;
  26902. /** @hidden */
  26903. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  26904. /** @hidden */
  26905. _updateCache(ignoreParentClass?: boolean): void;
  26906. /** @hidden */
  26907. _isSynchronized(): boolean;
  26908. /** @hidden */
  26909. _markSyncedWithParent(): void;
  26910. /** @hidden */
  26911. isSynchronizedWithParent(): boolean;
  26912. /** @hidden */
  26913. isSynchronized(): boolean;
  26914. /**
  26915. * Is this node ready to be used/rendered
  26916. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  26917. * @return true if the node is ready
  26918. */
  26919. isReady(completeCheck?: boolean): boolean;
  26920. /**
  26921. * Is this node enabled?
  26922. * 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
  26923. * @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
  26924. * @return whether this node (and its parent) is enabled
  26925. */
  26926. isEnabled(checkAncestors?: boolean): boolean;
  26927. /** @hidden */
  26928. protected _syncParentEnabledState(): void;
  26929. /**
  26930. * Set the enabled state of this node
  26931. * @param value defines the new enabled state
  26932. */
  26933. setEnabled(value: boolean): void;
  26934. /**
  26935. * Is this node a descendant of the given node?
  26936. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  26937. * @param ancestor defines the parent node to inspect
  26938. * @returns a boolean indicating if this node is a descendant of the given node
  26939. */
  26940. isDescendantOf(ancestor: Node): boolean;
  26941. /** @hidden */
  26942. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  26943. /**
  26944. * Will return all nodes that have this node as ascendant
  26945. * @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
  26946. * @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
  26947. * @return all children nodes of all types
  26948. */
  26949. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  26950. /**
  26951. * Get all child-meshes of this node
  26952. * @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)
  26953. * @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
  26954. * @returns an array of AbstractMesh
  26955. */
  26956. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  26957. /**
  26958. * Get all direct children of this node
  26959. * @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
  26960. * @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)
  26961. * @returns an array of Node
  26962. */
  26963. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  26964. /** @hidden */
  26965. _setReady(state: boolean): void;
  26966. /**
  26967. * Get an animation by name
  26968. * @param name defines the name of the animation to look for
  26969. * @returns null if not found else the requested animation
  26970. */
  26971. getAnimationByName(name: string): Nullable<Animation>;
  26972. /**
  26973. * Creates an animation range for this node
  26974. * @param name defines the name of the range
  26975. * @param from defines the starting key
  26976. * @param to defines the end key
  26977. */
  26978. createAnimationRange(name: string, from: number, to: number): void;
  26979. /**
  26980. * Delete a specific animation range
  26981. * @param name defines the name of the range to delete
  26982. * @param deleteFrames defines if animation frames from the range must be deleted as well
  26983. */
  26984. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  26985. /**
  26986. * Get an animation range by name
  26987. * @param name defines the name of the animation range to look for
  26988. * @returns null if not found else the requested animation range
  26989. */
  26990. getAnimationRange(name: string): Nullable<AnimationRange>;
  26991. /**
  26992. * Gets the list of all animation ranges defined on this node
  26993. * @returns an array
  26994. */
  26995. getAnimationRanges(): Nullable<AnimationRange>[];
  26996. /**
  26997. * Will start the animation sequence
  26998. * @param name defines the range frames for animation sequence
  26999. * @param loop defines if the animation should loop (false by default)
  27000. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  27001. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  27002. * @returns the object created for this animation. If range does not exist, it will return null
  27003. */
  27004. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  27005. /**
  27006. * Serialize animation ranges into a JSON compatible object
  27007. * @returns serialization object
  27008. */
  27009. serializeAnimationRanges(): any;
  27010. /**
  27011. * Computes the world matrix of the node
  27012. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  27013. * @returns the world matrix
  27014. */
  27015. computeWorldMatrix(force?: boolean): Matrix;
  27016. /**
  27017. * Releases resources associated with this node.
  27018. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  27019. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  27020. */
  27021. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  27022. /**
  27023. * Parse animation range data from a serialization object and store them into a given node
  27024. * @param node defines where to store the animation ranges
  27025. * @param parsedNode defines the serialization object to read data from
  27026. * @param scene defines the hosting scene
  27027. */
  27028. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  27029. /**
  27030. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  27031. * @param includeDescendants Include bounding info from descendants as well (true by default)
  27032. * @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
  27033. * @returns the new bounding vectors
  27034. */
  27035. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  27036. min: Vector3;
  27037. max: Vector3;
  27038. };
  27039. }
  27040. }
  27041. declare module BABYLON {
  27042. /**
  27043. * @hidden
  27044. */
  27045. export class _IAnimationState {
  27046. key: number;
  27047. repeatCount: number;
  27048. workValue?: any;
  27049. loopMode?: number;
  27050. offsetValue?: any;
  27051. highLimitValue?: any;
  27052. }
  27053. /**
  27054. * Class used to store any kind of animation
  27055. */
  27056. export class Animation {
  27057. /**Name of the animation */
  27058. name: string;
  27059. /**Property to animate */
  27060. targetProperty: string;
  27061. /**The frames per second of the animation */
  27062. framePerSecond: number;
  27063. /**The data type of the animation */
  27064. dataType: number;
  27065. /**The loop mode of the animation */
  27066. loopMode?: number | undefined;
  27067. /**Specifies if blending should be enabled */
  27068. enableBlending?: boolean | undefined;
  27069. /**
  27070. * Use matrix interpolation instead of using direct key value when animating matrices
  27071. */
  27072. static AllowMatricesInterpolation: boolean;
  27073. /**
  27074. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  27075. */
  27076. static AllowMatrixDecomposeForInterpolation: boolean;
  27077. /**
  27078. * Stores the key frames of the animation
  27079. */
  27080. private _keys;
  27081. /**
  27082. * Stores the easing function of the animation
  27083. */
  27084. private _easingFunction;
  27085. /**
  27086. * @hidden Internal use only
  27087. */
  27088. _runtimeAnimations: RuntimeAnimation[];
  27089. /**
  27090. * The set of event that will be linked to this animation
  27091. */
  27092. private _events;
  27093. /**
  27094. * Stores an array of target property paths
  27095. */
  27096. targetPropertyPath: string[];
  27097. /**
  27098. * Stores the blending speed of the animation
  27099. */
  27100. blendingSpeed: number;
  27101. /**
  27102. * Stores the animation ranges for the animation
  27103. */
  27104. private _ranges;
  27105. /**
  27106. * @hidden Internal use
  27107. */
  27108. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  27109. /**
  27110. * Sets up an animation
  27111. * @param property The property to animate
  27112. * @param animationType The animation type to apply
  27113. * @param framePerSecond The frames per second of the animation
  27114. * @param easingFunction The easing function used in the animation
  27115. * @returns The created animation
  27116. */
  27117. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  27118. /**
  27119. * Create and start an animation on a node
  27120. * @param name defines the name of the global animation that will be run on all nodes
  27121. * @param node defines the root node where the animation will take place
  27122. * @param targetProperty defines property to animate
  27123. * @param framePerSecond defines the number of frame per second yo use
  27124. * @param totalFrame defines the number of frames in total
  27125. * @param from defines the initial value
  27126. * @param to defines the final value
  27127. * @param loopMode defines which loop mode you want to use (off by default)
  27128. * @param easingFunction defines the easing function to use (linear by default)
  27129. * @param onAnimationEnd defines the callback to call when animation end
  27130. * @returns the animatable created for this animation
  27131. */
  27132. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  27133. /**
  27134. * Create and start an animation on a node and its descendants
  27135. * @param name defines the name of the global animation that will be run on all nodes
  27136. * @param node defines the root node where the animation will take place
  27137. * @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
  27138. * @param targetProperty defines property to animate
  27139. * @param framePerSecond defines the number of frame per second to use
  27140. * @param totalFrame defines the number of frames in total
  27141. * @param from defines the initial value
  27142. * @param to defines the final value
  27143. * @param loopMode defines which loop mode you want to use (off by default)
  27144. * @param easingFunction defines the easing function to use (linear by default)
  27145. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  27146. * @returns the list of animatables created for all nodes
  27147. * @example https://www.babylonjs-playground.com/#MH0VLI
  27148. */
  27149. 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[]>;
  27150. /**
  27151. * Creates a new animation, merges it with the existing animations and starts it
  27152. * @param name Name of the animation
  27153. * @param node Node which contains the scene that begins the animations
  27154. * @param targetProperty Specifies which property to animate
  27155. * @param framePerSecond The frames per second of the animation
  27156. * @param totalFrame The total number of frames
  27157. * @param from The frame at the beginning of the animation
  27158. * @param to The frame at the end of the animation
  27159. * @param loopMode Specifies the loop mode of the animation
  27160. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  27161. * @param onAnimationEnd Callback to run once the animation is complete
  27162. * @returns Nullable animation
  27163. */
  27164. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  27165. /**
  27166. * Transition property of an host to the target Value
  27167. * @param property The property to transition
  27168. * @param targetValue The target Value of the property
  27169. * @param host The object where the property to animate belongs
  27170. * @param scene Scene used to run the animation
  27171. * @param frameRate Framerate (in frame/s) to use
  27172. * @param transition The transition type we want to use
  27173. * @param duration The duration of the animation, in milliseconds
  27174. * @param onAnimationEnd Callback trigger at the end of the animation
  27175. * @returns Nullable animation
  27176. */
  27177. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  27178. /**
  27179. * Return the array of runtime animations currently using this animation
  27180. */
  27181. readonly runtimeAnimations: RuntimeAnimation[];
  27182. /**
  27183. * Specifies if any of the runtime animations are currently running
  27184. */
  27185. readonly hasRunningRuntimeAnimations: boolean;
  27186. /**
  27187. * Initializes the animation
  27188. * @param name Name of the animation
  27189. * @param targetProperty Property to animate
  27190. * @param framePerSecond The frames per second of the animation
  27191. * @param dataType The data type of the animation
  27192. * @param loopMode The loop mode of the animation
  27193. * @param enableBlending Specifies if blending should be enabled
  27194. */
  27195. constructor(
  27196. /**Name of the animation */
  27197. name: string,
  27198. /**Property to animate */
  27199. targetProperty: string,
  27200. /**The frames per second of the animation */
  27201. framePerSecond: number,
  27202. /**The data type of the animation */
  27203. dataType: number,
  27204. /**The loop mode of the animation */
  27205. loopMode?: number | undefined,
  27206. /**Specifies if blending should be enabled */
  27207. enableBlending?: boolean | undefined);
  27208. /**
  27209. * Converts the animation to a string
  27210. * @param fullDetails support for multiple levels of logging within scene loading
  27211. * @returns String form of the animation
  27212. */
  27213. toString(fullDetails?: boolean): string;
  27214. /**
  27215. * Add an event to this animation
  27216. * @param event Event to add
  27217. */
  27218. addEvent(event: AnimationEvent): void;
  27219. /**
  27220. * Remove all events found at the given frame
  27221. * @param frame The frame to remove events from
  27222. */
  27223. removeEvents(frame: number): void;
  27224. /**
  27225. * Retrieves all the events from the animation
  27226. * @returns Events from the animation
  27227. */
  27228. getEvents(): AnimationEvent[];
  27229. /**
  27230. * Creates an animation range
  27231. * @param name Name of the animation range
  27232. * @param from Starting frame of the animation range
  27233. * @param to Ending frame of the animation
  27234. */
  27235. createRange(name: string, from: number, to: number): void;
  27236. /**
  27237. * Deletes an animation range by name
  27238. * @param name Name of the animation range to delete
  27239. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  27240. */
  27241. deleteRange(name: string, deleteFrames?: boolean): void;
  27242. /**
  27243. * Gets the animation range by name, or null if not defined
  27244. * @param name Name of the animation range
  27245. * @returns Nullable animation range
  27246. */
  27247. getRange(name: string): Nullable<AnimationRange>;
  27248. /**
  27249. * Gets the key frames from the animation
  27250. * @returns The key frames of the animation
  27251. */
  27252. getKeys(): Array<IAnimationKey>;
  27253. /**
  27254. * Gets the highest frame rate of the animation
  27255. * @returns Highest frame rate of the animation
  27256. */
  27257. getHighestFrame(): number;
  27258. /**
  27259. * Gets the easing function of the animation
  27260. * @returns Easing function of the animation
  27261. */
  27262. getEasingFunction(): IEasingFunction;
  27263. /**
  27264. * Sets the easing function of the animation
  27265. * @param easingFunction A custom mathematical formula for animation
  27266. */
  27267. setEasingFunction(easingFunction: EasingFunction): void;
  27268. /**
  27269. * Interpolates a scalar linearly
  27270. * @param startValue Start value of the animation curve
  27271. * @param endValue End value of the animation curve
  27272. * @param gradient Scalar amount to interpolate
  27273. * @returns Interpolated scalar value
  27274. */
  27275. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  27276. /**
  27277. * Interpolates a scalar cubically
  27278. * @param startValue Start value of the animation curve
  27279. * @param outTangent End tangent of the animation
  27280. * @param endValue End value of the animation curve
  27281. * @param inTangent Start tangent of the animation curve
  27282. * @param gradient Scalar amount to interpolate
  27283. * @returns Interpolated scalar value
  27284. */
  27285. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  27286. /**
  27287. * Interpolates a quaternion using a spherical linear interpolation
  27288. * @param startValue Start value of the animation curve
  27289. * @param endValue End value of the animation curve
  27290. * @param gradient Scalar amount to interpolate
  27291. * @returns Interpolated quaternion value
  27292. */
  27293. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  27294. /**
  27295. * Interpolates a quaternion cubically
  27296. * @param startValue Start value of the animation curve
  27297. * @param outTangent End tangent of the animation curve
  27298. * @param endValue End value of the animation curve
  27299. * @param inTangent Start tangent of the animation curve
  27300. * @param gradient Scalar amount to interpolate
  27301. * @returns Interpolated quaternion value
  27302. */
  27303. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  27304. /**
  27305. * Interpolates a Vector3 linearl
  27306. * @param startValue Start value of the animation curve
  27307. * @param endValue End value of the animation curve
  27308. * @param gradient Scalar amount to interpolate
  27309. * @returns Interpolated scalar value
  27310. */
  27311. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  27312. /**
  27313. * Interpolates a Vector3 cubically
  27314. * @param startValue Start value of the animation curve
  27315. * @param outTangent End tangent of the animation
  27316. * @param endValue End value of the animation curve
  27317. * @param inTangent Start tangent of the animation curve
  27318. * @param gradient Scalar amount to interpolate
  27319. * @returns InterpolatedVector3 value
  27320. */
  27321. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  27322. /**
  27323. * Interpolates a Vector2 linearly
  27324. * @param startValue Start value of the animation curve
  27325. * @param endValue End value of the animation curve
  27326. * @param gradient Scalar amount to interpolate
  27327. * @returns Interpolated Vector2 value
  27328. */
  27329. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  27330. /**
  27331. * Interpolates a Vector2 cubically
  27332. * @param startValue Start value of the animation curve
  27333. * @param outTangent End tangent of the animation
  27334. * @param endValue End value of the animation curve
  27335. * @param inTangent Start tangent of the animation curve
  27336. * @param gradient Scalar amount to interpolate
  27337. * @returns Interpolated Vector2 value
  27338. */
  27339. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  27340. /**
  27341. * Interpolates a size linearly
  27342. * @param startValue Start value of the animation curve
  27343. * @param endValue End value of the animation curve
  27344. * @param gradient Scalar amount to interpolate
  27345. * @returns Interpolated Size value
  27346. */
  27347. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  27348. /**
  27349. * Interpolates a Color3 linearly
  27350. * @param startValue Start value of the animation curve
  27351. * @param endValue End value of the animation curve
  27352. * @param gradient Scalar amount to interpolate
  27353. * @returns Interpolated Color3 value
  27354. */
  27355. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  27356. /**
  27357. * @hidden Internal use only
  27358. */
  27359. _getKeyValue(value: any): any;
  27360. /**
  27361. * @hidden Internal use only
  27362. */
  27363. _interpolate(currentFrame: number, state: _IAnimationState): any;
  27364. /**
  27365. * Defines the function to use to interpolate matrices
  27366. * @param startValue defines the start matrix
  27367. * @param endValue defines the end matrix
  27368. * @param gradient defines the gradient between both matrices
  27369. * @param result defines an optional target matrix where to store the interpolation
  27370. * @returns the interpolated matrix
  27371. */
  27372. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  27373. /**
  27374. * Makes a copy of the animation
  27375. * @returns Cloned animation
  27376. */
  27377. clone(): Animation;
  27378. /**
  27379. * Sets the key frames of the animation
  27380. * @param values The animation key frames to set
  27381. */
  27382. setKeys(values: Array<IAnimationKey>): void;
  27383. /**
  27384. * Serializes the animation to an object
  27385. * @returns Serialized object
  27386. */
  27387. serialize(): any;
  27388. /**
  27389. * Float animation type
  27390. */
  27391. private static _ANIMATIONTYPE_FLOAT;
  27392. /**
  27393. * Vector3 animation type
  27394. */
  27395. private static _ANIMATIONTYPE_VECTOR3;
  27396. /**
  27397. * Quaternion animation type
  27398. */
  27399. private static _ANIMATIONTYPE_QUATERNION;
  27400. /**
  27401. * Matrix animation type
  27402. */
  27403. private static _ANIMATIONTYPE_MATRIX;
  27404. /**
  27405. * Color3 animation type
  27406. */
  27407. private static _ANIMATIONTYPE_COLOR3;
  27408. /**
  27409. * Vector2 animation type
  27410. */
  27411. private static _ANIMATIONTYPE_VECTOR2;
  27412. /**
  27413. * Size animation type
  27414. */
  27415. private static _ANIMATIONTYPE_SIZE;
  27416. /**
  27417. * Relative Loop Mode
  27418. */
  27419. private static _ANIMATIONLOOPMODE_RELATIVE;
  27420. /**
  27421. * Cycle Loop Mode
  27422. */
  27423. private static _ANIMATIONLOOPMODE_CYCLE;
  27424. /**
  27425. * Constant Loop Mode
  27426. */
  27427. private static _ANIMATIONLOOPMODE_CONSTANT;
  27428. /**
  27429. * Get the float animation type
  27430. */
  27431. static readonly ANIMATIONTYPE_FLOAT: number;
  27432. /**
  27433. * Get the Vector3 animation type
  27434. */
  27435. static readonly ANIMATIONTYPE_VECTOR3: number;
  27436. /**
  27437. * Get the Vector2 animation type
  27438. */
  27439. static readonly ANIMATIONTYPE_VECTOR2: number;
  27440. /**
  27441. * Get the Size animation type
  27442. */
  27443. static readonly ANIMATIONTYPE_SIZE: number;
  27444. /**
  27445. * Get the Quaternion animation type
  27446. */
  27447. static readonly ANIMATIONTYPE_QUATERNION: number;
  27448. /**
  27449. * Get the Matrix animation type
  27450. */
  27451. static readonly ANIMATIONTYPE_MATRIX: number;
  27452. /**
  27453. * Get the Color3 animation type
  27454. */
  27455. static readonly ANIMATIONTYPE_COLOR3: number;
  27456. /**
  27457. * Get the Relative Loop Mode
  27458. */
  27459. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  27460. /**
  27461. * Get the Cycle Loop Mode
  27462. */
  27463. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  27464. /**
  27465. * Get the Constant Loop Mode
  27466. */
  27467. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  27468. /** @hidden */
  27469. static _UniversalLerp(left: any, right: any, amount: number): any;
  27470. /**
  27471. * Parses an animation object and creates an animation
  27472. * @param parsedAnimation Parsed animation object
  27473. * @returns Animation object
  27474. */
  27475. static Parse(parsedAnimation: any): Animation;
  27476. /**
  27477. * Appends the serialized animations from the source animations
  27478. * @param source Source containing the animations
  27479. * @param destination Target to store the animations
  27480. */
  27481. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  27482. }
  27483. }
  27484. declare module BABYLON {
  27485. /**
  27486. * Interface containing an array of animations
  27487. */
  27488. export interface IAnimatable {
  27489. /**
  27490. * Array of animations
  27491. */
  27492. animations: Nullable<Array<Animation>>;
  27493. }
  27494. }
  27495. declare module BABYLON {
  27496. /**
  27497. * This represents all the required information to add a fresnel effect on a material:
  27498. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27499. */
  27500. export class FresnelParameters {
  27501. private _isEnabled;
  27502. /**
  27503. * Define if the fresnel effect is enable or not.
  27504. */
  27505. isEnabled: boolean;
  27506. /**
  27507. * Define the color used on edges (grazing angle)
  27508. */
  27509. leftColor: Color3;
  27510. /**
  27511. * Define the color used on center
  27512. */
  27513. rightColor: Color3;
  27514. /**
  27515. * Define bias applied to computed fresnel term
  27516. */
  27517. bias: number;
  27518. /**
  27519. * Defined the power exponent applied to fresnel term
  27520. */
  27521. power: number;
  27522. /**
  27523. * Clones the current fresnel and its valuues
  27524. * @returns a clone fresnel configuration
  27525. */
  27526. clone(): FresnelParameters;
  27527. /**
  27528. * Serializes the current fresnel parameters to a JSON representation.
  27529. * @return the JSON serialization
  27530. */
  27531. serialize(): any;
  27532. /**
  27533. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  27534. * @param parsedFresnelParameters Define the JSON representation
  27535. * @returns the parsed parameters
  27536. */
  27537. static Parse(parsedFresnelParameters: any): FresnelParameters;
  27538. }
  27539. }
  27540. declare module BABYLON {
  27541. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  27542. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27543. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27544. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27545. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27546. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27547. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27548. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27549. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27550. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27551. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27552. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27553. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27554. /**
  27555. * Decorator used to define property that can be serialized as reference to a camera
  27556. * @param sourceName defines the name of the property to decorate
  27557. */
  27558. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27559. /**
  27560. * Class used to help serialization objects
  27561. */
  27562. export class SerializationHelper {
  27563. /** @hidden */
  27564. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  27565. /** @hidden */
  27566. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  27567. /** @hidden */
  27568. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  27569. /** @hidden */
  27570. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  27571. /**
  27572. * Appends the serialized animations from the source animations
  27573. * @param source Source containing the animations
  27574. * @param destination Target to store the animations
  27575. */
  27576. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  27577. /**
  27578. * Static function used to serialized a specific entity
  27579. * @param entity defines the entity to serialize
  27580. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  27581. * @returns a JSON compatible object representing the serialization of the entity
  27582. */
  27583. static Serialize<T>(entity: T, serializationObject?: any): any;
  27584. /**
  27585. * Creates a new entity from a serialization data object
  27586. * @param creationFunction defines a function used to instanciated the new entity
  27587. * @param source defines the source serialization data
  27588. * @param scene defines the hosting scene
  27589. * @param rootUrl defines the root url for resources
  27590. * @returns a new entity
  27591. */
  27592. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  27593. /**
  27594. * Clones an object
  27595. * @param creationFunction defines the function used to instanciate the new object
  27596. * @param source defines the source object
  27597. * @returns the cloned object
  27598. */
  27599. static Clone<T>(creationFunction: () => T, source: T): T;
  27600. /**
  27601. * Instanciates a new object based on a source one (some data will be shared between both object)
  27602. * @param creationFunction defines the function used to instanciate the new object
  27603. * @param source defines the source object
  27604. * @returns the new object
  27605. */
  27606. static Instanciate<T>(creationFunction: () => T, source: T): T;
  27607. }
  27608. }
  27609. declare module BABYLON {
  27610. /**
  27611. * Class used to manipulate GUIDs
  27612. */
  27613. export class GUID {
  27614. /**
  27615. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  27616. * Be aware Math.random() could cause collisions, but:
  27617. * "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"
  27618. * @returns a pseudo random id
  27619. */
  27620. static RandomId(): string;
  27621. }
  27622. }
  27623. declare module BABYLON {
  27624. /**
  27625. * Base class of all the textures in babylon.
  27626. * It groups all the common properties the materials, post process, lights... might need
  27627. * in order to make a correct use of the texture.
  27628. */
  27629. export class BaseTexture implements IAnimatable {
  27630. /**
  27631. * Default anisotropic filtering level for the application.
  27632. * It is set to 4 as a good tradeoff between perf and quality.
  27633. */
  27634. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  27635. /**
  27636. * Gets or sets the unique id of the texture
  27637. */
  27638. uniqueId: number;
  27639. /**
  27640. * Define the name of the texture.
  27641. */
  27642. name: string;
  27643. /**
  27644. * Gets or sets an object used to store user defined information.
  27645. */
  27646. metadata: any;
  27647. /**
  27648. * For internal use only. Please do not use.
  27649. */
  27650. reservedDataStore: any;
  27651. private _hasAlpha;
  27652. /**
  27653. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  27654. */
  27655. hasAlpha: boolean;
  27656. /**
  27657. * Defines if the alpha value should be determined via the rgb values.
  27658. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  27659. */
  27660. getAlphaFromRGB: boolean;
  27661. /**
  27662. * Intensity or strength of the texture.
  27663. * It is commonly used by materials to fine tune the intensity of the texture
  27664. */
  27665. level: number;
  27666. /**
  27667. * Define the UV chanel to use starting from 0 and defaulting to 0.
  27668. * This is part of the texture as textures usually maps to one uv set.
  27669. */
  27670. coordinatesIndex: number;
  27671. private _coordinatesMode;
  27672. /**
  27673. * How a texture is mapped.
  27674. *
  27675. * | Value | Type | Description |
  27676. * | ----- | ----------------------------------- | ----------- |
  27677. * | 0 | EXPLICIT_MODE | |
  27678. * | 1 | SPHERICAL_MODE | |
  27679. * | 2 | PLANAR_MODE | |
  27680. * | 3 | CUBIC_MODE | |
  27681. * | 4 | PROJECTION_MODE | |
  27682. * | 5 | SKYBOX_MODE | |
  27683. * | 6 | INVCUBIC_MODE | |
  27684. * | 7 | EQUIRECTANGULAR_MODE | |
  27685. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  27686. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  27687. */
  27688. coordinatesMode: number;
  27689. /**
  27690. * | Value | Type | Description |
  27691. * | ----- | ------------------ | ----------- |
  27692. * | 0 | CLAMP_ADDRESSMODE | |
  27693. * | 1 | WRAP_ADDRESSMODE | |
  27694. * | 2 | MIRROR_ADDRESSMODE | |
  27695. */
  27696. wrapU: number;
  27697. /**
  27698. * | Value | Type | Description |
  27699. * | ----- | ------------------ | ----------- |
  27700. * | 0 | CLAMP_ADDRESSMODE | |
  27701. * | 1 | WRAP_ADDRESSMODE | |
  27702. * | 2 | MIRROR_ADDRESSMODE | |
  27703. */
  27704. wrapV: number;
  27705. /**
  27706. * | Value | Type | Description |
  27707. * | ----- | ------------------ | ----------- |
  27708. * | 0 | CLAMP_ADDRESSMODE | |
  27709. * | 1 | WRAP_ADDRESSMODE | |
  27710. * | 2 | MIRROR_ADDRESSMODE | |
  27711. */
  27712. wrapR: number;
  27713. /**
  27714. * With compliant hardware and browser (supporting anisotropic filtering)
  27715. * this defines the level of anisotropic filtering in the texture.
  27716. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  27717. */
  27718. anisotropicFilteringLevel: number;
  27719. /**
  27720. * Define if the texture is a cube texture or if false a 2d texture.
  27721. */
  27722. isCube: boolean;
  27723. /**
  27724. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  27725. */
  27726. is3D: boolean;
  27727. /**
  27728. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  27729. * HDR texture are usually stored in linear space.
  27730. * This only impacts the PBR and Background materials
  27731. */
  27732. gammaSpace: boolean;
  27733. /**
  27734. * Gets or sets whether or not the texture contains RGBD data.
  27735. */
  27736. isRGBD: boolean;
  27737. /**
  27738. * Is Z inverted in the texture (useful in a cube texture).
  27739. */
  27740. invertZ: boolean;
  27741. /**
  27742. * Are mip maps generated for this texture or not.
  27743. */
  27744. readonly noMipmap: boolean;
  27745. /**
  27746. * @hidden
  27747. */
  27748. lodLevelInAlpha: boolean;
  27749. /**
  27750. * With prefiltered texture, defined the offset used during the prefiltering steps.
  27751. */
  27752. lodGenerationOffset: number;
  27753. /**
  27754. * With prefiltered texture, defined the scale used during the prefiltering steps.
  27755. */
  27756. lodGenerationScale: number;
  27757. /**
  27758. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  27759. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  27760. * average roughness values.
  27761. */
  27762. linearSpecularLOD: boolean;
  27763. /**
  27764. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  27765. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  27766. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  27767. */
  27768. irradianceTexture: Nullable<BaseTexture>;
  27769. /**
  27770. * Define if the texture is a render target.
  27771. */
  27772. isRenderTarget: boolean;
  27773. /**
  27774. * Define the unique id of the texture in the scene.
  27775. */
  27776. readonly uid: string;
  27777. /**
  27778. * Return a string representation of the texture.
  27779. * @returns the texture as a string
  27780. */
  27781. toString(): string;
  27782. /**
  27783. * Get the class name of the texture.
  27784. * @returns "BaseTexture"
  27785. */
  27786. getClassName(): string;
  27787. /**
  27788. * Define the list of animation attached to the texture.
  27789. */
  27790. animations: Animation[];
  27791. /**
  27792. * An event triggered when the texture is disposed.
  27793. */
  27794. onDisposeObservable: Observable<BaseTexture>;
  27795. private _onDisposeObserver;
  27796. /**
  27797. * Callback triggered when the texture has been disposed.
  27798. * Kept for back compatibility, you can use the onDisposeObservable instead.
  27799. */
  27800. onDispose: () => void;
  27801. /**
  27802. * Define the current state of the loading sequence when in delayed load mode.
  27803. */
  27804. delayLoadState: number;
  27805. private _scene;
  27806. /** @hidden */
  27807. _texture: Nullable<InternalTexture>;
  27808. private _uid;
  27809. /**
  27810. * Define if the texture is preventinga material to render or not.
  27811. * If not and the texture is not ready, the engine will use a default black texture instead.
  27812. */
  27813. readonly isBlocking: boolean;
  27814. /**
  27815. * Instantiates a new BaseTexture.
  27816. * Base class of all the textures in babylon.
  27817. * It groups all the common properties the materials, post process, lights... might need
  27818. * in order to make a correct use of the texture.
  27819. * @param scene Define the scene the texture blongs to
  27820. */
  27821. constructor(scene: Nullable<Scene>);
  27822. /**
  27823. * Get the scene the texture belongs to.
  27824. * @returns the scene or null if undefined
  27825. */
  27826. getScene(): Nullable<Scene>;
  27827. /**
  27828. * Get the texture transform matrix used to offset tile the texture for istance.
  27829. * @returns the transformation matrix
  27830. */
  27831. getTextureMatrix(): Matrix;
  27832. /**
  27833. * Get the texture reflection matrix used to rotate/transform the reflection.
  27834. * @returns the reflection matrix
  27835. */
  27836. getReflectionTextureMatrix(): Matrix;
  27837. /**
  27838. * Get the underlying lower level texture from Babylon.
  27839. * @returns the insternal texture
  27840. */
  27841. getInternalTexture(): Nullable<InternalTexture>;
  27842. /**
  27843. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  27844. * @returns true if ready or not blocking
  27845. */
  27846. isReadyOrNotBlocking(): boolean;
  27847. /**
  27848. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  27849. * @returns true if fully ready
  27850. */
  27851. isReady(): boolean;
  27852. private _cachedSize;
  27853. /**
  27854. * Get the size of the texture.
  27855. * @returns the texture size.
  27856. */
  27857. getSize(): ISize;
  27858. /**
  27859. * Get the base size of the texture.
  27860. * It can be different from the size if the texture has been resized for POT for instance
  27861. * @returns the base size
  27862. */
  27863. getBaseSize(): ISize;
  27864. /**
  27865. * Update the sampling mode of the texture.
  27866. * Default is Trilinear mode.
  27867. *
  27868. * | Value | Type | Description |
  27869. * | ----- | ------------------ | ----------- |
  27870. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  27871. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  27872. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  27873. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  27874. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  27875. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  27876. * | 7 | NEAREST_LINEAR | |
  27877. * | 8 | NEAREST_NEAREST | |
  27878. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  27879. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  27880. * | 11 | LINEAR_LINEAR | |
  27881. * | 12 | LINEAR_NEAREST | |
  27882. *
  27883. * > _mag_: magnification filter (close to the viewer)
  27884. * > _min_: minification filter (far from the viewer)
  27885. * > _mip_: filter used between mip map levels
  27886. *@param samplingMode Define the new sampling mode of the texture
  27887. */
  27888. updateSamplingMode(samplingMode: number): void;
  27889. /**
  27890. * Scales the texture if is `canRescale()`
  27891. * @param ratio the resize factor we want to use to rescale
  27892. */
  27893. scale(ratio: number): void;
  27894. /**
  27895. * Get if the texture can rescale.
  27896. */
  27897. readonly canRescale: boolean;
  27898. /** @hidden */
  27899. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  27900. /** @hidden */
  27901. _rebuild(): void;
  27902. /**
  27903. * Triggers the load sequence in delayed load mode.
  27904. */
  27905. delayLoad(): void;
  27906. /**
  27907. * Clones the texture.
  27908. * @returns the cloned texture
  27909. */
  27910. clone(): Nullable<BaseTexture>;
  27911. /**
  27912. * Get the texture underlying type (INT, FLOAT...)
  27913. */
  27914. readonly textureType: number;
  27915. /**
  27916. * Get the texture underlying format (RGB, RGBA...)
  27917. */
  27918. readonly textureFormat: number;
  27919. /**
  27920. * Indicates that textures need to be re-calculated for all materials
  27921. */
  27922. protected _markAllSubMeshesAsTexturesDirty(): void;
  27923. /**
  27924. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  27925. * This will returns an RGBA array buffer containing either in values (0-255) or
  27926. * float values (0-1) depending of the underlying buffer type.
  27927. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  27928. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  27929. * @param buffer defines a user defined buffer to fill with data (can be null)
  27930. * @returns The Array buffer containing the pixels data.
  27931. */
  27932. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  27933. /**
  27934. * Release and destroy the underlying lower level texture aka internalTexture.
  27935. */
  27936. releaseInternalTexture(): void;
  27937. /** @hidden */
  27938. readonly _lodTextureHigh: Nullable<BaseTexture>;
  27939. /** @hidden */
  27940. readonly _lodTextureMid: Nullable<BaseTexture>;
  27941. /** @hidden */
  27942. readonly _lodTextureLow: Nullable<BaseTexture>;
  27943. /**
  27944. * Dispose the texture and release its associated resources.
  27945. */
  27946. dispose(): void;
  27947. /**
  27948. * Serialize the texture into a JSON representation that can be parsed later on.
  27949. * @returns the JSON representation of the texture
  27950. */
  27951. serialize(): any;
  27952. /**
  27953. * Helper function to be called back once a list of texture contains only ready textures.
  27954. * @param textures Define the list of textures to wait for
  27955. * @param callback Define the callback triggered once the entire list will be ready
  27956. */
  27957. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  27958. }
  27959. }
  27960. declare module BABYLON {
  27961. /**
  27962. * Options to be used when creating an effect.
  27963. */
  27964. export interface IEffectCreationOptions {
  27965. /**
  27966. * Atrributes that will be used in the shader.
  27967. */
  27968. attributes: string[];
  27969. /**
  27970. * Uniform varible names that will be set in the shader.
  27971. */
  27972. uniformsNames: string[];
  27973. /**
  27974. * Uniform buffer varible names that will be set in the shader.
  27975. */
  27976. uniformBuffersNames: string[];
  27977. /**
  27978. * Sampler texture variable names that will be set in the shader.
  27979. */
  27980. samplers: string[];
  27981. /**
  27982. * Define statements that will be set in the shader.
  27983. */
  27984. defines: any;
  27985. /**
  27986. * Possible fallbacks for this effect to improve performance when needed.
  27987. */
  27988. fallbacks: Nullable<IEffectFallbacks>;
  27989. /**
  27990. * Callback that will be called when the shader is compiled.
  27991. */
  27992. onCompiled: Nullable<(effect: Effect) => void>;
  27993. /**
  27994. * Callback that will be called if an error occurs during shader compilation.
  27995. */
  27996. onError: Nullable<(effect: Effect, errors: string) => void>;
  27997. /**
  27998. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  27999. */
  28000. indexParameters?: any;
  28001. /**
  28002. * Max number of lights that can be used in the shader.
  28003. */
  28004. maxSimultaneousLights?: number;
  28005. /**
  28006. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  28007. */
  28008. transformFeedbackVaryings?: Nullable<string[]>;
  28009. }
  28010. /**
  28011. * Effect containing vertex and fragment shader that can be executed on an object.
  28012. */
  28013. export class Effect implements IDisposable {
  28014. /**
  28015. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  28016. */
  28017. static ShadersRepository: string;
  28018. /**
  28019. * Name of the effect.
  28020. */
  28021. name: any;
  28022. /**
  28023. * String container all the define statements that should be set on the shader.
  28024. */
  28025. defines: string;
  28026. /**
  28027. * Callback that will be called when the shader is compiled.
  28028. */
  28029. onCompiled: Nullable<(effect: Effect) => void>;
  28030. /**
  28031. * Callback that will be called if an error occurs during shader compilation.
  28032. */
  28033. onError: Nullable<(effect: Effect, errors: string) => void>;
  28034. /**
  28035. * Callback that will be called when effect is bound.
  28036. */
  28037. onBind: Nullable<(effect: Effect) => void>;
  28038. /**
  28039. * Unique ID of the effect.
  28040. */
  28041. uniqueId: number;
  28042. /**
  28043. * Observable that will be called when the shader is compiled.
  28044. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  28045. */
  28046. onCompileObservable: Observable<Effect>;
  28047. /**
  28048. * Observable that will be called if an error occurs during shader compilation.
  28049. */
  28050. onErrorObservable: Observable<Effect>;
  28051. /** @hidden */
  28052. _onBindObservable: Nullable<Observable<Effect>>;
  28053. /**
  28054. * Observable that will be called when effect is bound.
  28055. */
  28056. readonly onBindObservable: Observable<Effect>;
  28057. /** @hidden */
  28058. _bonesComputationForcedToCPU: boolean;
  28059. private static _uniqueIdSeed;
  28060. private _engine;
  28061. private _uniformBuffersNames;
  28062. private _uniformsNames;
  28063. private _samplerList;
  28064. private _samplers;
  28065. private _isReady;
  28066. private _compilationError;
  28067. private _allFallbacksProcessed;
  28068. private _attributesNames;
  28069. private _attributes;
  28070. private _uniforms;
  28071. /**
  28072. * Key for the effect.
  28073. * @hidden
  28074. */
  28075. _key: string;
  28076. private _indexParameters;
  28077. private _fallbacks;
  28078. private _vertexSourceCode;
  28079. private _fragmentSourceCode;
  28080. private _vertexSourceCodeOverride;
  28081. private _fragmentSourceCodeOverride;
  28082. private _transformFeedbackVaryings;
  28083. /**
  28084. * Compiled shader to webGL program.
  28085. * @hidden
  28086. */
  28087. _pipelineContext: Nullable<IPipelineContext>;
  28088. private _valueCache;
  28089. private static _baseCache;
  28090. /**
  28091. * Instantiates an effect.
  28092. * An effect can be used to create/manage/execute vertex and fragment shaders.
  28093. * @param baseName Name of the effect.
  28094. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  28095. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  28096. * @param samplers List of sampler variables that will be passed to the shader.
  28097. * @param engine Engine to be used to render the effect
  28098. * @param defines Define statements to be added to the shader.
  28099. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  28100. * @param onCompiled Callback that will be called when the shader is compiled.
  28101. * @param onError Callback that will be called if an error occurs during shader compilation.
  28102. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  28103. */
  28104. constructor(baseName: any, attributesNamesOrOptions: string[] | IEffectCreationOptions, uniformsNamesOrEngine: string[] | ThinEngine, samplers?: Nullable<string[]>, engine?: ThinEngine, defines?: Nullable<string>, fallbacks?: Nullable<IEffectFallbacks>, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any);
  28105. private _useFinalCode;
  28106. /**
  28107. * Unique key for this effect
  28108. */
  28109. readonly key: string;
  28110. /**
  28111. * If the effect has been compiled and prepared.
  28112. * @returns if the effect is compiled and prepared.
  28113. */
  28114. isReady(): boolean;
  28115. private _isReadyInternal;
  28116. /**
  28117. * The engine the effect was initialized with.
  28118. * @returns the engine.
  28119. */
  28120. getEngine(): Engine;
  28121. /**
  28122. * The pipeline context for this effect
  28123. * @returns the associated pipeline context
  28124. */
  28125. getPipelineContext(): Nullable<IPipelineContext>;
  28126. /**
  28127. * The set of names of attribute variables for the shader.
  28128. * @returns An array of attribute names.
  28129. */
  28130. getAttributesNames(): string[];
  28131. /**
  28132. * Returns the attribute at the given index.
  28133. * @param index The index of the attribute.
  28134. * @returns The location of the attribute.
  28135. */
  28136. getAttributeLocation(index: number): number;
  28137. /**
  28138. * Returns the attribute based on the name of the variable.
  28139. * @param name of the attribute to look up.
  28140. * @returns the attribute location.
  28141. */
  28142. getAttributeLocationByName(name: string): number;
  28143. /**
  28144. * The number of attributes.
  28145. * @returns the numnber of attributes.
  28146. */
  28147. getAttributesCount(): number;
  28148. /**
  28149. * Gets the index of a uniform variable.
  28150. * @param uniformName of the uniform to look up.
  28151. * @returns the index.
  28152. */
  28153. getUniformIndex(uniformName: string): number;
  28154. /**
  28155. * Returns the attribute based on the name of the variable.
  28156. * @param uniformName of the uniform to look up.
  28157. * @returns the location of the uniform.
  28158. */
  28159. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  28160. /**
  28161. * Returns an array of sampler variable names
  28162. * @returns The array of sampler variable neames.
  28163. */
  28164. getSamplers(): string[];
  28165. /**
  28166. * The error from the last compilation.
  28167. * @returns the error string.
  28168. */
  28169. getCompilationError(): string;
  28170. /**
  28171. * Gets a boolean indicating that all fallbacks were used during compilation
  28172. * @returns true if all fallbacks were used
  28173. */
  28174. allFallbacksProcessed(): boolean;
  28175. /**
  28176. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  28177. * @param func The callback to be used.
  28178. */
  28179. executeWhenCompiled(func: (effect: Effect) => void): void;
  28180. private _checkIsReady;
  28181. private _loadShader;
  28182. /**
  28183. * Recompiles the webGL program
  28184. * @param vertexSourceCode The source code for the vertex shader.
  28185. * @param fragmentSourceCode The source code for the fragment shader.
  28186. * @param onCompiled Callback called when completed.
  28187. * @param onError Callback called on error.
  28188. * @hidden
  28189. */
  28190. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  28191. /**
  28192. * Prepares the effect
  28193. * @hidden
  28194. */
  28195. _prepareEffect(): void;
  28196. private _processCompilationErrors;
  28197. /**
  28198. * Checks if the effect is supported. (Must be called after compilation)
  28199. */
  28200. readonly isSupported: boolean;
  28201. /**
  28202. * Binds a texture to the engine to be used as output of the shader.
  28203. * @param channel Name of the output variable.
  28204. * @param texture Texture to bind.
  28205. * @hidden
  28206. */
  28207. _bindTexture(channel: string, texture: InternalTexture): void;
  28208. /**
  28209. * Sets a texture on the engine to be used in the shader.
  28210. * @param channel Name of the sampler variable.
  28211. * @param texture Texture to set.
  28212. */
  28213. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  28214. /**
  28215. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  28216. * @param channel Name of the sampler variable.
  28217. * @param texture Texture to set.
  28218. */
  28219. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  28220. /**
  28221. * Sets an array of textures on the engine to be used in the shader.
  28222. * @param channel Name of the variable.
  28223. * @param textures Textures to set.
  28224. */
  28225. setTextureArray(channel: string, textures: BaseTexture[]): void;
  28226. /**
  28227. * 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)
  28228. * @param channel Name of the sampler variable.
  28229. * @param postProcess Post process to get the input texture from.
  28230. */
  28231. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  28232. /**
  28233. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  28234. * 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)
  28235. * @param channel Name of the sampler variable.
  28236. * @param postProcess Post process to get the output texture from.
  28237. */
  28238. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  28239. /** @hidden */
  28240. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  28241. /** @hidden */
  28242. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  28243. /** @hidden */
  28244. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  28245. /** @hidden */
  28246. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  28247. /**
  28248. * Binds a buffer to a uniform.
  28249. * @param buffer Buffer to bind.
  28250. * @param name Name of the uniform variable to bind to.
  28251. */
  28252. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  28253. /**
  28254. * Binds block to a uniform.
  28255. * @param blockName Name of the block to bind.
  28256. * @param index Index to bind.
  28257. */
  28258. bindUniformBlock(blockName: string, index: number): void;
  28259. /**
  28260. * Sets an interger value on a uniform variable.
  28261. * @param uniformName Name of the variable.
  28262. * @param value Value to be set.
  28263. * @returns this effect.
  28264. */
  28265. setInt(uniformName: string, value: number): Effect;
  28266. /**
  28267. * Sets an int array on a uniform variable.
  28268. * @param uniformName Name of the variable.
  28269. * @param array array to be set.
  28270. * @returns this effect.
  28271. */
  28272. setIntArray(uniformName: string, array: Int32Array): Effect;
  28273. /**
  28274. * 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)
  28275. * @param uniformName Name of the variable.
  28276. * @param array array to be set.
  28277. * @returns this effect.
  28278. */
  28279. setIntArray2(uniformName: string, array: Int32Array): Effect;
  28280. /**
  28281. * 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)
  28282. * @param uniformName Name of the variable.
  28283. * @param array array to be set.
  28284. * @returns this effect.
  28285. */
  28286. setIntArray3(uniformName: string, array: Int32Array): Effect;
  28287. /**
  28288. * 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)
  28289. * @param uniformName Name of the variable.
  28290. * @param array array to be set.
  28291. * @returns this effect.
  28292. */
  28293. setIntArray4(uniformName: string, array: Int32Array): Effect;
  28294. /**
  28295. * Sets an float array on a uniform variable.
  28296. * @param uniformName Name of the variable.
  28297. * @param array array to be set.
  28298. * @returns this effect.
  28299. */
  28300. setFloatArray(uniformName: string, array: Float32Array): Effect;
  28301. /**
  28302. * 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)
  28303. * @param uniformName Name of the variable.
  28304. * @param array array to be set.
  28305. * @returns this effect.
  28306. */
  28307. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  28308. /**
  28309. * 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)
  28310. * @param uniformName Name of the variable.
  28311. * @param array array to be set.
  28312. * @returns this effect.
  28313. */
  28314. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  28315. /**
  28316. * 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)
  28317. * @param uniformName Name of the variable.
  28318. * @param array array to be set.
  28319. * @returns this effect.
  28320. */
  28321. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  28322. /**
  28323. * Sets an array on a uniform variable.
  28324. * @param uniformName Name of the variable.
  28325. * @param array array to be set.
  28326. * @returns this effect.
  28327. */
  28328. setArray(uniformName: string, array: number[]): Effect;
  28329. /**
  28330. * 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)
  28331. * @param uniformName Name of the variable.
  28332. * @param array array to be set.
  28333. * @returns this effect.
  28334. */
  28335. setArray2(uniformName: string, array: number[]): Effect;
  28336. /**
  28337. * 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)
  28338. * @param uniformName Name of the variable.
  28339. * @param array array to be set.
  28340. * @returns this effect.
  28341. */
  28342. setArray3(uniformName: string, array: number[]): Effect;
  28343. /**
  28344. * 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)
  28345. * @param uniformName Name of the variable.
  28346. * @param array array to be set.
  28347. * @returns this effect.
  28348. */
  28349. setArray4(uniformName: string, array: number[]): Effect;
  28350. /**
  28351. * Sets matrices on a uniform variable.
  28352. * @param uniformName Name of the variable.
  28353. * @param matrices matrices to be set.
  28354. * @returns this effect.
  28355. */
  28356. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  28357. /**
  28358. * Sets matrix on a uniform variable.
  28359. * @param uniformName Name of the variable.
  28360. * @param matrix matrix to be set.
  28361. * @returns this effect.
  28362. */
  28363. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  28364. /**
  28365. * 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)
  28366. * @param uniformName Name of the variable.
  28367. * @param matrix matrix to be set.
  28368. * @returns this effect.
  28369. */
  28370. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  28371. /**
  28372. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  28373. * @param uniformName Name of the variable.
  28374. * @param matrix matrix to be set.
  28375. * @returns this effect.
  28376. */
  28377. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  28378. /**
  28379. * Sets a float on a uniform variable.
  28380. * @param uniformName Name of the variable.
  28381. * @param value value to be set.
  28382. * @returns this effect.
  28383. */
  28384. setFloat(uniformName: string, value: number): Effect;
  28385. /**
  28386. * Sets a boolean on a uniform variable.
  28387. * @param uniformName Name of the variable.
  28388. * @param bool value to be set.
  28389. * @returns this effect.
  28390. */
  28391. setBool(uniformName: string, bool: boolean): Effect;
  28392. /**
  28393. * Sets a Vector2 on a uniform variable.
  28394. * @param uniformName Name of the variable.
  28395. * @param vector2 vector2 to be set.
  28396. * @returns this effect.
  28397. */
  28398. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  28399. /**
  28400. * Sets a float2 on a uniform variable.
  28401. * @param uniformName Name of the variable.
  28402. * @param x First float in float2.
  28403. * @param y Second float in float2.
  28404. * @returns this effect.
  28405. */
  28406. setFloat2(uniformName: string, x: number, y: number): Effect;
  28407. /**
  28408. * Sets a Vector3 on a uniform variable.
  28409. * @param uniformName Name of the variable.
  28410. * @param vector3 Value to be set.
  28411. * @returns this effect.
  28412. */
  28413. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  28414. /**
  28415. * Sets a float3 on a uniform variable.
  28416. * @param uniformName Name of the variable.
  28417. * @param x First float in float3.
  28418. * @param y Second float in float3.
  28419. * @param z Third float in float3.
  28420. * @returns this effect.
  28421. */
  28422. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  28423. /**
  28424. * Sets a Vector4 on a uniform variable.
  28425. * @param uniformName Name of the variable.
  28426. * @param vector4 Value to be set.
  28427. * @returns this effect.
  28428. */
  28429. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  28430. /**
  28431. * Sets a float4 on a uniform variable.
  28432. * @param uniformName Name of the variable.
  28433. * @param x First float in float4.
  28434. * @param y Second float in float4.
  28435. * @param z Third float in float4.
  28436. * @param w Fourth float in float4.
  28437. * @returns this effect.
  28438. */
  28439. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  28440. /**
  28441. * Sets a Color3 on a uniform variable.
  28442. * @param uniformName Name of the variable.
  28443. * @param color3 Value to be set.
  28444. * @returns this effect.
  28445. */
  28446. setColor3(uniformName: string, color3: IColor3Like): Effect;
  28447. /**
  28448. * Sets a Color4 on a uniform variable.
  28449. * @param uniformName Name of the variable.
  28450. * @param color3 Value to be set.
  28451. * @param alpha Alpha value to be set.
  28452. * @returns this effect.
  28453. */
  28454. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  28455. /**
  28456. * Sets a Color4 on a uniform variable
  28457. * @param uniformName defines the name of the variable
  28458. * @param color4 defines the value to be set
  28459. * @returns this effect.
  28460. */
  28461. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  28462. /** Release all associated resources */
  28463. dispose(): void;
  28464. /**
  28465. * This function will add a new shader to the shader store
  28466. * @param name the name of the shader
  28467. * @param pixelShader optional pixel shader content
  28468. * @param vertexShader optional vertex shader content
  28469. */
  28470. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  28471. /**
  28472. * Store of each shader (The can be looked up using effect.key)
  28473. */
  28474. static ShadersStore: {
  28475. [key: string]: string;
  28476. };
  28477. /**
  28478. * Store of each included file for a shader (The can be looked up using effect.key)
  28479. */
  28480. static IncludesShadersStore: {
  28481. [key: string]: string;
  28482. };
  28483. /**
  28484. * Resets the cache of effects.
  28485. */
  28486. static ResetCache(): void;
  28487. }
  28488. }
  28489. declare module BABYLON {
  28490. /**
  28491. * Class used to describe the capabilities of the engine relatively to the current browser
  28492. */
  28493. export class EngineCapabilities {
  28494. /** Maximum textures units per fragment shader */
  28495. maxTexturesImageUnits: number;
  28496. /** Maximum texture units per vertex shader */
  28497. maxVertexTextureImageUnits: number;
  28498. /** Maximum textures units in the entire pipeline */
  28499. maxCombinedTexturesImageUnits: number;
  28500. /** Maximum texture size */
  28501. maxTextureSize: number;
  28502. /** Maximum cube texture size */
  28503. maxCubemapTextureSize: number;
  28504. /** Maximum render texture size */
  28505. maxRenderTextureSize: number;
  28506. /** Maximum number of vertex attributes */
  28507. maxVertexAttribs: number;
  28508. /** Maximum number of varyings */
  28509. maxVaryingVectors: number;
  28510. /** Maximum number of uniforms per vertex shader */
  28511. maxVertexUniformVectors: number;
  28512. /** Maximum number of uniforms per fragment shader */
  28513. maxFragmentUniformVectors: number;
  28514. /** Defines if standard derivates (dx/dy) are supported */
  28515. standardDerivatives: boolean;
  28516. /** Defines if s3tc texture compression is supported */
  28517. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  28518. /** Defines if pvrtc texture compression is supported */
  28519. pvrtc: any;
  28520. /** Defines if etc1 texture compression is supported */
  28521. etc1: any;
  28522. /** Defines if etc2 texture compression is supported */
  28523. etc2: any;
  28524. /** Defines if astc texture compression is supported */
  28525. astc: any;
  28526. /** Defines if float textures are supported */
  28527. textureFloat: boolean;
  28528. /** Defines if vertex array objects are supported */
  28529. vertexArrayObject: boolean;
  28530. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  28531. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  28532. /** Gets the maximum level of anisotropy supported */
  28533. maxAnisotropy: number;
  28534. /** Defines if instancing is supported */
  28535. instancedArrays: boolean;
  28536. /** Defines if 32 bits indices are supported */
  28537. uintIndices: boolean;
  28538. /** Defines if high precision shaders are supported */
  28539. highPrecisionShaderSupported: boolean;
  28540. /** Defines if depth reading in the fragment shader is supported */
  28541. fragmentDepthSupported: boolean;
  28542. /** Defines if float texture linear filtering is supported*/
  28543. textureFloatLinearFiltering: boolean;
  28544. /** Defines if rendering to float textures is supported */
  28545. textureFloatRender: boolean;
  28546. /** Defines if half float textures are supported*/
  28547. textureHalfFloat: boolean;
  28548. /** Defines if half float texture linear filtering is supported*/
  28549. textureHalfFloatLinearFiltering: boolean;
  28550. /** Defines if rendering to half float textures is supported */
  28551. textureHalfFloatRender: boolean;
  28552. /** Defines if textureLOD shader command is supported */
  28553. textureLOD: boolean;
  28554. /** Defines if draw buffers extension is supported */
  28555. drawBuffersExtension: boolean;
  28556. /** Defines if depth textures are supported */
  28557. depthTextureExtension: boolean;
  28558. /** Defines if float color buffer are supported */
  28559. colorBufferFloat: boolean;
  28560. /** Gets disjoint timer query extension (null if not supported) */
  28561. timerQuery: EXT_disjoint_timer_query;
  28562. /** Defines if timestamp can be used with timer query */
  28563. canUseTimestampForTimerQuery: boolean;
  28564. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  28565. multiview: any;
  28566. /** Function used to let the system compiles shaders in background */
  28567. parallelShaderCompile: {
  28568. COMPLETION_STATUS_KHR: number;
  28569. };
  28570. /** Max number of texture samples for MSAA */
  28571. maxMSAASamples: number;
  28572. /** Defines if the blend min max extension is supported */
  28573. blendMinMax: boolean;
  28574. }
  28575. }
  28576. declare module BABYLON {
  28577. /**
  28578. * @hidden
  28579. **/
  28580. export class DepthCullingState {
  28581. private _isDepthTestDirty;
  28582. private _isDepthMaskDirty;
  28583. private _isDepthFuncDirty;
  28584. private _isCullFaceDirty;
  28585. private _isCullDirty;
  28586. private _isZOffsetDirty;
  28587. private _isFrontFaceDirty;
  28588. private _depthTest;
  28589. private _depthMask;
  28590. private _depthFunc;
  28591. private _cull;
  28592. private _cullFace;
  28593. private _zOffset;
  28594. private _frontFace;
  28595. /**
  28596. * Initializes the state.
  28597. */
  28598. constructor();
  28599. readonly isDirty: boolean;
  28600. zOffset: number;
  28601. cullFace: Nullable<number>;
  28602. cull: Nullable<boolean>;
  28603. depthFunc: Nullable<number>;
  28604. depthMask: boolean;
  28605. depthTest: boolean;
  28606. frontFace: Nullable<number>;
  28607. reset(): void;
  28608. apply(gl: WebGLRenderingContext): void;
  28609. }
  28610. }
  28611. declare module BABYLON {
  28612. /**
  28613. * @hidden
  28614. **/
  28615. export class StencilState {
  28616. /** 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 */
  28617. static readonly ALWAYS: number;
  28618. /** Passed to stencilOperation to specify that stencil value must be kept */
  28619. static readonly KEEP: number;
  28620. /** Passed to stencilOperation to specify that stencil value must be replaced */
  28621. static readonly REPLACE: number;
  28622. private _isStencilTestDirty;
  28623. private _isStencilMaskDirty;
  28624. private _isStencilFuncDirty;
  28625. private _isStencilOpDirty;
  28626. private _stencilTest;
  28627. private _stencilMask;
  28628. private _stencilFunc;
  28629. private _stencilFuncRef;
  28630. private _stencilFuncMask;
  28631. private _stencilOpStencilFail;
  28632. private _stencilOpDepthFail;
  28633. private _stencilOpStencilDepthPass;
  28634. readonly isDirty: boolean;
  28635. stencilFunc: number;
  28636. stencilFuncRef: number;
  28637. stencilFuncMask: number;
  28638. stencilOpStencilFail: number;
  28639. stencilOpDepthFail: number;
  28640. stencilOpStencilDepthPass: number;
  28641. stencilMask: number;
  28642. stencilTest: boolean;
  28643. constructor();
  28644. reset(): void;
  28645. apply(gl: WebGLRenderingContext): void;
  28646. }
  28647. }
  28648. declare module BABYLON {
  28649. /**
  28650. * @hidden
  28651. **/
  28652. export class AlphaState {
  28653. private _isAlphaBlendDirty;
  28654. private _isBlendFunctionParametersDirty;
  28655. private _isBlendEquationParametersDirty;
  28656. private _isBlendConstantsDirty;
  28657. private _alphaBlend;
  28658. private _blendFunctionParameters;
  28659. private _blendEquationParameters;
  28660. private _blendConstants;
  28661. /**
  28662. * Initializes the state.
  28663. */
  28664. constructor();
  28665. readonly isDirty: boolean;
  28666. alphaBlend: boolean;
  28667. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  28668. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  28669. setAlphaEquationParameters(rgb: number, alpha: number): void;
  28670. reset(): void;
  28671. apply(gl: WebGLRenderingContext): void;
  28672. }
  28673. }
  28674. declare module BABYLON {
  28675. /** @hidden */
  28676. export class WebGL2ShaderProcessor implements IShaderProcessor {
  28677. attributeProcessor(attribute: string): string;
  28678. varyingProcessor(varying: string, isFragment: boolean): string;
  28679. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  28680. }
  28681. }
  28682. declare module BABYLON {
  28683. /**
  28684. * Interface for attribute information associated with buffer instanciation
  28685. */
  28686. export class InstancingAttributeInfo {
  28687. /**
  28688. * Index/offset of the attribute in the vertex shader
  28689. */
  28690. index: number;
  28691. /**
  28692. * size of the attribute, 1, 2, 3 or 4
  28693. */
  28694. attributeSize: number;
  28695. /**
  28696. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  28697. * default is FLOAT
  28698. */
  28699. attribyteType: number;
  28700. /**
  28701. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  28702. */
  28703. normalized: boolean;
  28704. /**
  28705. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  28706. */
  28707. offset: number;
  28708. /**
  28709. * Name of the GLSL attribute, for debugging purpose only
  28710. */
  28711. attributeName: string;
  28712. }
  28713. }
  28714. declare module BABYLON {
  28715. interface ThinEngine {
  28716. /**
  28717. * Update a video texture
  28718. * @param texture defines the texture to update
  28719. * @param video defines the video element to use
  28720. * @param invertY defines if data must be stored with Y axis inverted
  28721. */
  28722. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  28723. }
  28724. }
  28725. declare module BABYLON {
  28726. /**
  28727. * Settings for finer control over video usage
  28728. */
  28729. export interface VideoTextureSettings {
  28730. /**
  28731. * Applies `autoplay` to video, if specified
  28732. */
  28733. autoPlay?: boolean;
  28734. /**
  28735. * Applies `loop` to video, if specified
  28736. */
  28737. loop?: boolean;
  28738. /**
  28739. * Automatically updates internal texture from video at every frame in the render loop
  28740. */
  28741. autoUpdateTexture: boolean;
  28742. /**
  28743. * Image src displayed during the video loading or until the user interacts with the video.
  28744. */
  28745. poster?: string;
  28746. }
  28747. /**
  28748. * If you want to display a video in your scene, this is the special texture for that.
  28749. * This special texture works similar to other textures, with the exception of a few parameters.
  28750. * @see https://doc.babylonjs.com/how_to/video_texture
  28751. */
  28752. export class VideoTexture extends Texture {
  28753. /**
  28754. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  28755. */
  28756. readonly autoUpdateTexture: boolean;
  28757. /**
  28758. * The video instance used by the texture internally
  28759. */
  28760. readonly video: HTMLVideoElement;
  28761. private _onUserActionRequestedObservable;
  28762. /**
  28763. * Event triggerd when a dom action is required by the user to play the video.
  28764. * This happens due to recent changes in browser policies preventing video to auto start.
  28765. */
  28766. readonly onUserActionRequestedObservable: Observable<Texture>;
  28767. private _generateMipMaps;
  28768. private _engine;
  28769. private _stillImageCaptured;
  28770. private _displayingPosterTexture;
  28771. private _settings;
  28772. private _createInternalTextureOnEvent;
  28773. private _frameId;
  28774. /**
  28775. * Creates a video texture.
  28776. * If you want to display a video in your scene, this is the special texture for that.
  28777. * This special texture works similar to other textures, with the exception of a few parameters.
  28778. * @see https://doc.babylonjs.com/how_to/video_texture
  28779. * @param name optional name, will detect from video source, if not defined
  28780. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  28781. * @param scene is obviously the current scene.
  28782. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  28783. * @param invertY is false by default but can be used to invert video on Y axis
  28784. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  28785. * @param settings allows finer control over video usage
  28786. */
  28787. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  28788. private _getName;
  28789. private _getVideo;
  28790. private _createInternalTexture;
  28791. private reset;
  28792. /**
  28793. * @hidden Internal method to initiate `update`.
  28794. */
  28795. _rebuild(): void;
  28796. /**
  28797. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  28798. */
  28799. update(): void;
  28800. /**
  28801. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  28802. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  28803. */
  28804. updateTexture(isVisible: boolean): void;
  28805. protected _updateInternalTexture: () => void;
  28806. /**
  28807. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  28808. * @param url New url.
  28809. */
  28810. updateURL(url: string): void;
  28811. /**
  28812. * Dispose the texture and release its associated resources.
  28813. */
  28814. dispose(): void;
  28815. /**
  28816. * Creates a video texture straight from a stream.
  28817. * @param scene Define the scene the texture should be created in
  28818. * @param stream Define the stream the texture should be created from
  28819. * @returns The created video texture as a promise
  28820. */
  28821. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  28822. /**
  28823. * Creates a video texture straight from your WebCam video feed.
  28824. * @param scene Define the scene the texture should be created in
  28825. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  28826. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  28827. * @returns The created video texture as a promise
  28828. */
  28829. static CreateFromWebCamAsync(scene: Scene, constraints: {
  28830. minWidth: number;
  28831. maxWidth: number;
  28832. minHeight: number;
  28833. maxHeight: number;
  28834. deviceId: string;
  28835. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  28836. /**
  28837. * Creates a video texture straight from your WebCam video feed.
  28838. * @param scene Define the scene the texture should be created in
  28839. * @param onReady Define a callback to triggered once the texture will be ready
  28840. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  28841. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  28842. */
  28843. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  28844. minWidth: number;
  28845. maxWidth: number;
  28846. minHeight: number;
  28847. maxHeight: number;
  28848. deviceId: string;
  28849. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  28850. }
  28851. }
  28852. declare module BABYLON {
  28853. /**
  28854. * Defines the interface used by objects working like Scene
  28855. * @hidden
  28856. */
  28857. interface ISceneLike {
  28858. _addPendingData(data: any): void;
  28859. _removePendingData(data: any): void;
  28860. offlineProvider: IOfflineProvider;
  28861. }
  28862. /** Interface defining initialization parameters for Engine class */
  28863. export interface EngineOptions extends WebGLContextAttributes {
  28864. /**
  28865. * Defines if the engine should no exceed a specified device ratio
  28866. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  28867. */
  28868. limitDeviceRatio?: number;
  28869. /**
  28870. * Defines if webvr should be enabled automatically
  28871. * @see http://doc.babylonjs.com/how_to/webvr_camera
  28872. */
  28873. autoEnableWebVR?: boolean;
  28874. /**
  28875. * Defines if webgl2 should be turned off even if supported
  28876. * @see http://doc.babylonjs.com/features/webgl2
  28877. */
  28878. disableWebGL2Support?: boolean;
  28879. /**
  28880. * Defines if webaudio should be initialized as well
  28881. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  28882. */
  28883. audioEngine?: boolean;
  28884. /**
  28885. * Defines if animations should run using a deterministic lock step
  28886. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  28887. */
  28888. deterministicLockstep?: boolean;
  28889. /** Defines the maximum steps to use with deterministic lock step mode */
  28890. lockstepMaxSteps?: number;
  28891. /**
  28892. * Defines that engine should ignore context lost events
  28893. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  28894. */
  28895. doNotHandleContextLost?: boolean;
  28896. /**
  28897. * Defines that engine should ignore modifying touch action attribute and style
  28898. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  28899. */
  28900. doNotHandleTouchAction?: boolean;
  28901. /**
  28902. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  28903. */
  28904. useHighPrecisionFloats?: boolean;
  28905. }
  28906. /**
  28907. * The base engine class (root of all engines)
  28908. */
  28909. export class ThinEngine {
  28910. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  28911. static ExceptionList: ({
  28912. key: string;
  28913. capture: string;
  28914. captureConstraint: number;
  28915. targets: string[];
  28916. } | {
  28917. key: string;
  28918. capture: null;
  28919. captureConstraint: null;
  28920. targets: string[];
  28921. })[];
  28922. /** @hidden */
  28923. static _TextureLoaders: IInternalTextureLoader[];
  28924. /**
  28925. * Returns the current npm package of the sdk
  28926. */
  28927. static readonly NpmPackage: string;
  28928. /**
  28929. * Returns the current version of the framework
  28930. */
  28931. static readonly Version: string;
  28932. /**
  28933. * Returns a string describing the current engine
  28934. */
  28935. readonly description: string;
  28936. /**
  28937. * Gets or sets the epsilon value used by collision engine
  28938. */
  28939. static CollisionsEpsilon: number;
  28940. /**
  28941. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  28942. */
  28943. static ShadersRepository: string;
  28944. /** @hidden */
  28945. _shaderProcessor: IShaderProcessor;
  28946. /**
  28947. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  28948. */
  28949. forcePOTTextures: boolean;
  28950. /**
  28951. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  28952. */
  28953. isFullscreen: boolean;
  28954. /**
  28955. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  28956. */
  28957. cullBackFaces: boolean;
  28958. /**
  28959. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  28960. */
  28961. renderEvenInBackground: boolean;
  28962. /**
  28963. * Gets or sets a boolean indicating that cache can be kept between frames
  28964. */
  28965. preventCacheWipeBetweenFrames: boolean;
  28966. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  28967. validateShaderPrograms: boolean;
  28968. /**
  28969. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  28970. */
  28971. disableUniformBuffers: boolean;
  28972. /** @hidden */
  28973. _uniformBuffers: UniformBuffer[];
  28974. /**
  28975. * Gets a boolean indicating that the engine supports uniform buffers
  28976. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28977. */
  28978. readonly supportsUniformBuffers: boolean;
  28979. /** @hidden */
  28980. _gl: WebGLRenderingContext;
  28981. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  28982. protected _windowIsBackground: boolean;
  28983. protected _webGLVersion: number;
  28984. protected _highPrecisionShadersAllowed: boolean;
  28985. /** @hidden */
  28986. readonly _shouldUseHighPrecisionShader: boolean;
  28987. /**
  28988. * Gets a boolean indicating that only power of 2 textures are supported
  28989. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  28990. */
  28991. readonly needPOTTextures: boolean;
  28992. /** @hidden */
  28993. _badOS: boolean;
  28994. /** @hidden */
  28995. _badDesktopOS: boolean;
  28996. private _hardwareScalingLevel;
  28997. /** @hidden */
  28998. _caps: EngineCapabilities;
  28999. private _isStencilEnable;
  29000. protected _colorWrite: boolean;
  29001. private _glVersion;
  29002. private _glRenderer;
  29003. private _glVendor;
  29004. /** @hidden */
  29005. _videoTextureSupported: boolean;
  29006. protected _renderingQueueLaunched: boolean;
  29007. protected _activeRenderLoops: (() => void)[];
  29008. /**
  29009. * Observable signaled when a context lost event is raised
  29010. */
  29011. onContextLostObservable: Observable<ThinEngine>;
  29012. /**
  29013. * Observable signaled when a context restored event is raised
  29014. */
  29015. onContextRestoredObservable: Observable<ThinEngine>;
  29016. private _onContextLost;
  29017. private _onContextRestored;
  29018. protected _contextWasLost: boolean;
  29019. /** @hidden */
  29020. _doNotHandleContextLost: boolean;
  29021. /**
  29022. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  29023. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  29024. */
  29025. doNotHandleContextLost: boolean;
  29026. /**
  29027. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  29028. */
  29029. disableVertexArrayObjects: boolean;
  29030. /** @hidden */
  29031. protected _depthCullingState: DepthCullingState;
  29032. /** @hidden */
  29033. protected _stencilState: StencilState;
  29034. /** @hidden */
  29035. protected _alphaState: AlphaState;
  29036. /** @hidden */
  29037. _internalTexturesCache: InternalTexture[];
  29038. /** @hidden */
  29039. protected _activeChannel: number;
  29040. private _currentTextureChannel;
  29041. /** @hidden */
  29042. protected _boundTexturesCache: {
  29043. [key: string]: Nullable<InternalTexture>;
  29044. };
  29045. /** @hidden */
  29046. protected _currentEffect: Nullable<Effect>;
  29047. /** @hidden */
  29048. protected _currentProgram: Nullable<WebGLProgram>;
  29049. private _compiledEffects;
  29050. private _vertexAttribArraysEnabled;
  29051. /** @hidden */
  29052. protected _cachedViewport: Nullable<IViewportLike>;
  29053. private _cachedVertexArrayObject;
  29054. /** @hidden */
  29055. protected _cachedVertexBuffers: any;
  29056. /** @hidden */
  29057. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  29058. /** @hidden */
  29059. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  29060. /** @hidden */
  29061. _currentRenderTarget: Nullable<InternalTexture>;
  29062. private _uintIndicesCurrentlySet;
  29063. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  29064. /** @hidden */
  29065. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  29066. private _currentBufferPointers;
  29067. private _currentInstanceLocations;
  29068. private _currentInstanceBuffers;
  29069. private _textureUnits;
  29070. /** @hidden */
  29071. _workingCanvas: Nullable<HTMLCanvasElement>;
  29072. /** @hidden */
  29073. _workingContext: Nullable<CanvasRenderingContext2D>;
  29074. /** @hidden */
  29075. _bindedRenderFunction: any;
  29076. private _vaoRecordInProgress;
  29077. private _mustWipeVertexAttributes;
  29078. private _emptyTexture;
  29079. private _emptyCubeTexture;
  29080. private _emptyTexture3D;
  29081. /** @hidden */
  29082. _frameHandler: number;
  29083. private _nextFreeTextureSlots;
  29084. private _maxSimultaneousTextures;
  29085. private _activeRequests;
  29086. protected _texturesSupported: string[];
  29087. /** @hidden */
  29088. _textureFormatInUse: Nullable<string>;
  29089. protected readonly _supportsHardwareTextureRescaling: boolean;
  29090. /**
  29091. * Gets the list of texture formats supported
  29092. */
  29093. readonly texturesSupported: Array<string>;
  29094. /**
  29095. * Gets the list of texture formats in use
  29096. */
  29097. readonly textureFormatInUse: Nullable<string>;
  29098. /**
  29099. * Gets the current viewport
  29100. */
  29101. readonly currentViewport: Nullable<IViewportLike>;
  29102. /**
  29103. * Gets the default empty texture
  29104. */
  29105. readonly emptyTexture: InternalTexture;
  29106. /**
  29107. * Gets the default empty 3D texture
  29108. */
  29109. readonly emptyTexture3D: InternalTexture;
  29110. /**
  29111. * Gets the default empty cube texture
  29112. */
  29113. readonly emptyCubeTexture: InternalTexture;
  29114. /**
  29115. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  29116. */
  29117. readonly premultipliedAlpha: boolean;
  29118. /**
  29119. * Observable event triggered before each texture is initialized
  29120. */
  29121. onBeforeTextureInitObservable: Observable<Texture>;
  29122. /**
  29123. * Creates a new engine
  29124. * @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
  29125. * @param antialias defines enable antialiasing (default: false)
  29126. * @param options defines further options to be sent to the getContext() function
  29127. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  29128. */
  29129. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  29130. private _rebuildInternalTextures;
  29131. private _rebuildEffects;
  29132. /**
  29133. * Gets a boolean indicating if all created effects are ready
  29134. * @returns true if all effects are ready
  29135. */
  29136. areAllEffectsReady(): boolean;
  29137. protected _rebuildBuffers(): void;
  29138. private _initGLContext;
  29139. /**
  29140. * Gets version of the current webGL context
  29141. */
  29142. readonly webGLVersion: number;
  29143. /**
  29144. * Gets a string idenfifying the name of the class
  29145. * @returns "Engine" string
  29146. */
  29147. getClassName(): string;
  29148. /**
  29149. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  29150. */
  29151. readonly isStencilEnable: boolean;
  29152. /** @hidden */
  29153. _prepareWorkingCanvas(): void;
  29154. /**
  29155. * Reset the texture cache to empty state
  29156. */
  29157. resetTextureCache(): void;
  29158. /**
  29159. * Gets an object containing information about the current webGL context
  29160. * @returns an object containing the vender, the renderer and the version of the current webGL context
  29161. */
  29162. getGlInfo(): {
  29163. vendor: string;
  29164. renderer: string;
  29165. version: string;
  29166. };
  29167. /**
  29168. * Defines the hardware scaling level.
  29169. * By default the hardware scaling level is computed from the window device ratio.
  29170. * 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.
  29171. * @param level defines the level to use
  29172. */
  29173. setHardwareScalingLevel(level: number): void;
  29174. /**
  29175. * Gets the current hardware scaling level.
  29176. * By default the hardware scaling level is computed from the window device ratio.
  29177. * 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.
  29178. * @returns a number indicating the current hardware scaling level
  29179. */
  29180. getHardwareScalingLevel(): number;
  29181. /**
  29182. * Gets the list of loaded textures
  29183. * @returns an array containing all loaded textures
  29184. */
  29185. getLoadedTexturesCache(): InternalTexture[];
  29186. /**
  29187. * Gets the object containing all engine capabilities
  29188. * @returns the EngineCapabilities object
  29189. */
  29190. getCaps(): EngineCapabilities;
  29191. /**
  29192. * stop executing a render loop function and remove it from the execution array
  29193. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  29194. */
  29195. stopRenderLoop(renderFunction?: () => void): void;
  29196. /** @hidden */
  29197. _renderLoop(): void;
  29198. /**
  29199. * Gets the HTML canvas attached with the current webGL context
  29200. * @returns a HTML canvas
  29201. */
  29202. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  29203. /**
  29204. * Gets host window
  29205. * @returns the host window object
  29206. */
  29207. getHostWindow(): Window;
  29208. /**
  29209. * Gets the current render width
  29210. * @param useScreen defines if screen size must be used (or the current render target if any)
  29211. * @returns a number defining the current render width
  29212. */
  29213. getRenderWidth(useScreen?: boolean): number;
  29214. /**
  29215. * Gets the current render height
  29216. * @param useScreen defines if screen size must be used (or the current render target if any)
  29217. * @returns a number defining the current render height
  29218. */
  29219. getRenderHeight(useScreen?: boolean): number;
  29220. /**
  29221. * Can be used to override the current requestAnimationFrame requester.
  29222. * @hidden
  29223. */
  29224. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  29225. /**
  29226. * Register and execute a render loop. The engine can have more than one render function
  29227. * @param renderFunction defines the function to continuously execute
  29228. */
  29229. runRenderLoop(renderFunction: () => void): void;
  29230. /**
  29231. * Clear the current render buffer or the current render target (if any is set up)
  29232. * @param color defines the color to use
  29233. * @param backBuffer defines if the back buffer must be cleared
  29234. * @param depth defines if the depth buffer must be cleared
  29235. * @param stencil defines if the stencil buffer must be cleared
  29236. */
  29237. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  29238. private _viewportCached;
  29239. /** @hidden */
  29240. _viewport(x: number, y: number, width: number, height: number): void;
  29241. /**
  29242. * Set the WebGL's viewport
  29243. * @param viewport defines the viewport element to be used
  29244. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  29245. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  29246. */
  29247. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  29248. /**
  29249. * Begin a new frame
  29250. */
  29251. beginFrame(): void;
  29252. /**
  29253. * Enf the current frame
  29254. */
  29255. endFrame(): void;
  29256. /**
  29257. * Resize the view according to the canvas' size
  29258. */
  29259. resize(): void;
  29260. /**
  29261. * Force a specific size of the canvas
  29262. * @param width defines the new canvas' width
  29263. * @param height defines the new canvas' height
  29264. */
  29265. setSize(width: number, height: number): void;
  29266. /**
  29267. * Binds the frame buffer to the specified texture.
  29268. * @param texture The texture to render to or null for the default canvas
  29269. * @param faceIndex The face of the texture to render to in case of cube texture
  29270. * @param requiredWidth The width of the target to render to
  29271. * @param requiredHeight The height of the target to render to
  29272. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  29273. * @param depthStencilTexture The depth stencil texture to use to render
  29274. * @param lodLevel defines le lod level to bind to the frame buffer
  29275. */
  29276. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  29277. /** @hidden */
  29278. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  29279. /**
  29280. * Unbind the current render target texture from the webGL context
  29281. * @param texture defines the render target texture to unbind
  29282. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  29283. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  29284. */
  29285. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  29286. /**
  29287. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  29288. */
  29289. flushFramebuffer(): void;
  29290. /**
  29291. * Unbind the current render target and bind the default framebuffer
  29292. */
  29293. restoreDefaultFramebuffer(): void;
  29294. private _resetVertexBufferBinding;
  29295. /**
  29296. * Creates a vertex buffer
  29297. * @param data the data for the vertex buffer
  29298. * @returns the new WebGL static buffer
  29299. */
  29300. createVertexBuffer(data: DataArray): DataBuffer;
  29301. private _createVertexBuffer;
  29302. /**
  29303. * Creates a dynamic vertex buffer
  29304. * @param data the data for the dynamic vertex buffer
  29305. * @returns the new WebGL dynamic buffer
  29306. */
  29307. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  29308. /**
  29309. * Updates a dynamic vertex buffer.
  29310. * @param vertexBuffer the vertex buffer to update
  29311. * @param data the data used to update the vertex buffer
  29312. * @param byteOffset the byte offset of the data
  29313. * @param byteLength the byte length of the data
  29314. */
  29315. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  29316. protected _resetIndexBufferBinding(): void;
  29317. /**
  29318. * Creates a new index buffer
  29319. * @param indices defines the content of the index buffer
  29320. * @param updatable defines if the index buffer must be updatable
  29321. * @returns a new webGL buffer
  29322. */
  29323. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  29324. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  29325. /**
  29326. * Bind a webGL buffer to the webGL context
  29327. * @param buffer defines the buffer to bind
  29328. */
  29329. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  29330. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  29331. private bindBuffer;
  29332. /**
  29333. * update the bound buffer with the given data
  29334. * @param data defines the data to update
  29335. */
  29336. updateArrayBuffer(data: Float32Array): void;
  29337. private _vertexAttribPointer;
  29338. private _bindIndexBufferWithCache;
  29339. private _bindVertexBuffersAttributes;
  29340. /**
  29341. * Records a vertex array object
  29342. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  29343. * @param vertexBuffers defines the list of vertex buffers to store
  29344. * @param indexBuffer defines the index buffer to store
  29345. * @param effect defines the effect to store
  29346. * @returns the new vertex array object
  29347. */
  29348. recordVertexArrayObject(vertexBuffers: {
  29349. [key: string]: VertexBuffer;
  29350. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  29351. /**
  29352. * Bind a specific vertex array object
  29353. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  29354. * @param vertexArrayObject defines the vertex array object to bind
  29355. * @param indexBuffer defines the index buffer to bind
  29356. */
  29357. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  29358. /**
  29359. * Bind webGl buffers directly to the webGL context
  29360. * @param vertexBuffer defines the vertex buffer to bind
  29361. * @param indexBuffer defines the index buffer to bind
  29362. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  29363. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  29364. * @param effect defines the effect associated with the vertex buffer
  29365. */
  29366. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  29367. private _unbindVertexArrayObject;
  29368. /**
  29369. * Bind a list of vertex buffers to the webGL context
  29370. * @param vertexBuffers defines the list of vertex buffers to bind
  29371. * @param indexBuffer defines the index buffer to bind
  29372. * @param effect defines the effect associated with the vertex buffers
  29373. */
  29374. bindBuffers(vertexBuffers: {
  29375. [key: string]: Nullable<VertexBuffer>;
  29376. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  29377. /**
  29378. * Unbind all instance attributes
  29379. */
  29380. unbindInstanceAttributes(): void;
  29381. /**
  29382. * Release and free the memory of a vertex array object
  29383. * @param vao defines the vertex array object to delete
  29384. */
  29385. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  29386. /** @hidden */
  29387. _releaseBuffer(buffer: DataBuffer): boolean;
  29388. protected _deleteBuffer(buffer: DataBuffer): void;
  29389. /**
  29390. * Creates a webGL buffer to use with instanciation
  29391. * @param capacity defines the size of the buffer
  29392. * @returns the webGL buffer
  29393. */
  29394. createInstancesBuffer(capacity: number): DataBuffer;
  29395. /**
  29396. * Delete a webGL buffer used with instanciation
  29397. * @param buffer defines the webGL buffer to delete
  29398. */
  29399. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  29400. /**
  29401. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  29402. * @param instancesBuffer defines the webGL buffer to update and bind
  29403. * @param data defines the data to store in the buffer
  29404. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  29405. */
  29406. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  29407. /**
  29408. * Apply all cached states (depth, culling, stencil and alpha)
  29409. */
  29410. applyStates(): void;
  29411. /**
  29412. * Send a draw order
  29413. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  29414. * @param indexStart defines the starting index
  29415. * @param indexCount defines the number of index to draw
  29416. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29417. */
  29418. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  29419. /**
  29420. * Draw a list of points
  29421. * @param verticesStart defines the index of first vertex to draw
  29422. * @param verticesCount defines the count of vertices to draw
  29423. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29424. */
  29425. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  29426. /**
  29427. * Draw a list of unindexed primitives
  29428. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  29429. * @param verticesStart defines the index of first vertex to draw
  29430. * @param verticesCount defines the count of vertices to draw
  29431. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29432. */
  29433. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  29434. /**
  29435. * Draw a list of indexed primitives
  29436. * @param fillMode defines the primitive to use
  29437. * @param indexStart defines the starting index
  29438. * @param indexCount defines the number of index to draw
  29439. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29440. */
  29441. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  29442. /**
  29443. * Draw a list of unindexed primitives
  29444. * @param fillMode defines the primitive to use
  29445. * @param verticesStart defines the index of first vertex to draw
  29446. * @param verticesCount defines the count of vertices to draw
  29447. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29448. */
  29449. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  29450. private _drawMode;
  29451. /** @hidden */
  29452. protected _reportDrawCall(): void;
  29453. /** @hidden */
  29454. _releaseEffect(effect: Effect): void;
  29455. /** @hidden */
  29456. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  29457. /**
  29458. * Create a new effect (used to store vertex/fragment shaders)
  29459. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  29460. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  29461. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  29462. * @param samplers defines an array of string used to represent textures
  29463. * @param defines defines the string containing the defines to use to compile the shaders
  29464. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  29465. * @param onCompiled defines a function to call when the effect creation is successful
  29466. * @param onError defines a function to call when the effect creation has failed
  29467. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  29468. * @returns the new Effect
  29469. */
  29470. createEffect(baseName: any, attributesNamesOrOptions: string[] | IEffectCreationOptions, uniformsNamesOrEngine: string[] | ThinEngine, samplers?: string[], defines?: string, fallbacks?: IEffectFallbacks, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any): Effect;
  29471. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  29472. private _compileShader;
  29473. private _compileRawShader;
  29474. /**
  29475. * Directly creates a webGL program
  29476. * @param pipelineContext defines the pipeline context to attach to
  29477. * @param vertexCode defines the vertex shader code to use
  29478. * @param fragmentCode defines the fragment shader code to use
  29479. * @param context defines the webGL context to use (if not set, the current one will be used)
  29480. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  29481. * @returns the new webGL program
  29482. */
  29483. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  29484. /**
  29485. * Creates a webGL program
  29486. * @param pipelineContext defines the pipeline context to attach to
  29487. * @param vertexCode defines the vertex shader code to use
  29488. * @param fragmentCode defines the fragment shader code to use
  29489. * @param defines defines the string containing the defines to use to compile the shaders
  29490. * @param context defines the webGL context to use (if not set, the current one will be used)
  29491. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  29492. * @returns the new webGL program
  29493. */
  29494. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  29495. /**
  29496. * Creates a new pipeline context
  29497. * @returns the new pipeline
  29498. */
  29499. createPipelineContext(): IPipelineContext;
  29500. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  29501. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  29502. /** @hidden */
  29503. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  29504. /** @hidden */
  29505. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  29506. /** @hidden */
  29507. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  29508. /**
  29509. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  29510. * @param pipelineContext defines the pipeline context to use
  29511. * @param uniformsNames defines the list of uniform names
  29512. * @returns an array of webGL uniform locations
  29513. */
  29514. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  29515. /**
  29516. * Gets the lsit of active attributes for a given webGL program
  29517. * @param pipelineContext defines the pipeline context to use
  29518. * @param attributesNames defines the list of attribute names to get
  29519. * @returns an array of indices indicating the offset of each attribute
  29520. */
  29521. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  29522. /**
  29523. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  29524. * @param effect defines the effect to activate
  29525. */
  29526. enableEffect(effect: Nullable<Effect>): void;
  29527. /**
  29528. * Set the value of an uniform to an array of int32
  29529. * @param uniform defines the webGL uniform location where to store the value
  29530. * @param array defines the array of int32 to store
  29531. */
  29532. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  29533. /**
  29534. * Set the value of an uniform to an array of int32 (stored as vec2)
  29535. * @param uniform defines the webGL uniform location where to store the value
  29536. * @param array defines the array of int32 to store
  29537. */
  29538. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  29539. /**
  29540. * Set the value of an uniform to an array of int32 (stored as vec3)
  29541. * @param uniform defines the webGL uniform location where to store the value
  29542. * @param array defines the array of int32 to store
  29543. */
  29544. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  29545. /**
  29546. * Set the value of an uniform to an array of int32 (stored as vec4)
  29547. * @param uniform defines the webGL uniform location where to store the value
  29548. * @param array defines the array of int32 to store
  29549. */
  29550. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  29551. /**
  29552. * Set the value of an uniform to an array of float32
  29553. * @param uniform defines the webGL uniform location where to store the value
  29554. * @param array defines the array of float32 to store
  29555. */
  29556. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  29557. /**
  29558. * Set the value of an uniform to an array of float32 (stored as vec2)
  29559. * @param uniform defines the webGL uniform location where to store the value
  29560. * @param array defines the array of float32 to store
  29561. */
  29562. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  29563. /**
  29564. * Set the value of an uniform to an array of float32 (stored as vec3)
  29565. * @param uniform defines the webGL uniform location where to store the value
  29566. * @param array defines the array of float32 to store
  29567. */
  29568. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  29569. /**
  29570. * Set the value of an uniform to an array of float32 (stored as vec4)
  29571. * @param uniform defines the webGL uniform location where to store the value
  29572. * @param array defines the array of float32 to store
  29573. */
  29574. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  29575. /**
  29576. * Set the value of an uniform to an array of number
  29577. * @param uniform defines the webGL uniform location where to store the value
  29578. * @param array defines the array of number to store
  29579. */
  29580. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  29581. /**
  29582. * Set the value of an uniform to an array of number (stored as vec2)
  29583. * @param uniform defines the webGL uniform location where to store the value
  29584. * @param array defines the array of number to store
  29585. */
  29586. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  29587. /**
  29588. * Set the value of an uniform to an array of number (stored as vec3)
  29589. * @param uniform defines the webGL uniform location where to store the value
  29590. * @param array defines the array of number to store
  29591. */
  29592. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  29593. /**
  29594. * Set the value of an uniform to an array of number (stored as vec4)
  29595. * @param uniform defines the webGL uniform location where to store the value
  29596. * @param array defines the array of number to store
  29597. */
  29598. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  29599. /**
  29600. * Set the value of an uniform to an array of float32 (stored as matrices)
  29601. * @param uniform defines the webGL uniform location where to store the value
  29602. * @param matrices defines the array of float32 to store
  29603. */
  29604. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  29605. /**
  29606. * Set the value of an uniform to a matrix (3x3)
  29607. * @param uniform defines the webGL uniform location where to store the value
  29608. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  29609. */
  29610. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  29611. /**
  29612. * Set the value of an uniform to a matrix (2x2)
  29613. * @param uniform defines the webGL uniform location where to store the value
  29614. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  29615. */
  29616. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  29617. /**
  29618. * Set the value of an uniform to a number (int)
  29619. * @param uniform defines the webGL uniform location where to store the value
  29620. * @param value defines the int number to store
  29621. */
  29622. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  29623. /**
  29624. * Set the value of an uniform to a number (float)
  29625. * @param uniform defines the webGL uniform location where to store the value
  29626. * @param value defines the float number to store
  29627. */
  29628. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  29629. /**
  29630. * Set the value of an uniform to a vec2
  29631. * @param uniform defines the webGL uniform location where to store the value
  29632. * @param x defines the 1st component of the value
  29633. * @param y defines the 2nd component of the value
  29634. */
  29635. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  29636. /**
  29637. * Set the value of an uniform to a vec3
  29638. * @param uniform defines the webGL uniform location where to store the value
  29639. * @param x defines the 1st component of the value
  29640. * @param y defines the 2nd component of the value
  29641. * @param z defines the 3rd component of the value
  29642. */
  29643. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  29644. /**
  29645. * Set the value of an uniform to a boolean
  29646. * @param uniform defines the webGL uniform location where to store the value
  29647. * @param bool defines the boolean to store
  29648. */
  29649. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  29650. /**
  29651. * Set the value of an uniform to a vec4
  29652. * @param uniform defines the webGL uniform location where to store the value
  29653. * @param x defines the 1st component of the value
  29654. * @param y defines the 2nd component of the value
  29655. * @param z defines the 3rd component of the value
  29656. * @param w defines the 4th component of the value
  29657. */
  29658. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  29659. /**
  29660. * Sets a Color4 on a uniform variable
  29661. * @param uniform defines the uniform location
  29662. * @param color4 defines the value to be set
  29663. */
  29664. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: IColor4Like): void;
  29665. /**
  29666. * Gets the depth culling state manager
  29667. */
  29668. readonly depthCullingState: DepthCullingState;
  29669. /**
  29670. * Gets the alpha state manager
  29671. */
  29672. readonly alphaState: AlphaState;
  29673. /**
  29674. * Gets the stencil state manager
  29675. */
  29676. readonly stencilState: StencilState;
  29677. /**
  29678. * Clears the list of texture accessible through engine.
  29679. * This can help preventing texture load conflict due to name collision.
  29680. */
  29681. clearInternalTexturesCache(): void;
  29682. /**
  29683. * Force the entire cache to be cleared
  29684. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  29685. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  29686. */
  29687. wipeCaches(bruteForce?: boolean): void;
  29688. /** @hidden */
  29689. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  29690. min: number;
  29691. mag: number;
  29692. };
  29693. /** @hidden */
  29694. _createTexture(): WebGLTexture;
  29695. /**
  29696. * Usually called from Texture.ts.
  29697. * Passed information to create a WebGLTexture
  29698. * @param urlArg defines a value which contains one of the following:
  29699. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  29700. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  29701. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  29702. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  29703. * @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)
  29704. * @param scene needed for loading to the correct scene
  29705. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  29706. * @param onLoad optional callback to be called upon successful completion
  29707. * @param onError optional callback to be called upon failure
  29708. * @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
  29709. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  29710. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  29711. * @param forcedExtension defines the extension to use to pick the right loader
  29712. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  29713. * @returns a InternalTexture for assignment back into BABYLON.Texture
  29714. */
  29715. createTexture(urlArg: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<ISceneLike>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, excludeLoaders?: Array<IInternalTextureLoader>): InternalTexture;
  29716. /**
  29717. * @hidden
  29718. */
  29719. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  29720. /**
  29721. * Creates a raw texture
  29722. * @param data defines the data to store in the texture
  29723. * @param width defines the width of the texture
  29724. * @param height defines the height of the texture
  29725. * @param format defines the format of the data
  29726. * @param generateMipMaps defines if the engine should generate the mip levels
  29727. * @param invertY defines if data must be stored with Y axis inverted
  29728. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  29729. * @param compression defines the compression used (null by default)
  29730. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  29731. * @returns the raw texture inside an InternalTexture
  29732. */
  29733. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  29734. /**
  29735. * Creates a new raw cube texture
  29736. * @param data defines the array of data to use to create each face
  29737. * @param size defines the size of the textures
  29738. * @param format defines the format of the data
  29739. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  29740. * @param generateMipMaps defines if the engine should generate the mip levels
  29741. * @param invertY defines if data must be stored with Y axis inverted
  29742. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  29743. * @param compression defines the compression used (null by default)
  29744. * @returns the cube texture as an InternalTexture
  29745. */
  29746. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  29747. /**
  29748. * Creates a new raw 3D texture
  29749. * @param data defines the data used to create the texture
  29750. * @param width defines the width of the texture
  29751. * @param height defines the height of the texture
  29752. * @param depth defines the depth of the texture
  29753. * @param format defines the format of the texture
  29754. * @param generateMipMaps defines if the engine must generate mip levels
  29755. * @param invertY defines if data must be stored with Y axis inverted
  29756. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  29757. * @param compression defines the compressed used (can be null)
  29758. * @param textureType defines the compressed used (can be null)
  29759. * @returns a new raw 3D texture (stored in an InternalTexture)
  29760. */
  29761. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  29762. private _unpackFlipYCached;
  29763. /**
  29764. * In case you are sharing the context with other applications, it might
  29765. * be interested to not cache the unpack flip y state to ensure a consistent
  29766. * value would be set.
  29767. */
  29768. enableUnpackFlipYCached: boolean;
  29769. /** @hidden */
  29770. _unpackFlipY(value: boolean): void;
  29771. /** @hidden */
  29772. _getUnpackAlignement(): number;
  29773. /**
  29774. * Update the sampling mode of a given texture
  29775. * @param samplingMode defines the required sampling mode
  29776. * @param texture defines the texture to update
  29777. */
  29778. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  29779. /**
  29780. * Updates a depth texture Comparison Mode and Function.
  29781. * If the comparison Function is equal to 0, the mode will be set to none.
  29782. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  29783. * @param texture The texture to set the comparison function for
  29784. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  29785. */
  29786. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  29787. /** @hidden */
  29788. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  29789. width: number;
  29790. height: number;
  29791. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  29792. /**
  29793. * Creates a depth stencil texture.
  29794. * This is only available in WebGL 2 or with the depth texture extension available.
  29795. * @param size The size of face edge in the texture.
  29796. * @param options The options defining the texture.
  29797. * @returns The texture
  29798. */
  29799. createDepthStencilTexture(size: number | {
  29800. width: number;
  29801. height: number;
  29802. }, options: DepthTextureCreationOptions): InternalTexture;
  29803. /**
  29804. * Creates a depth stencil texture.
  29805. * This is only available in WebGL 2 or with the depth texture extension available.
  29806. * @param size The size of face edge in the texture.
  29807. * @param options The options defining the texture.
  29808. * @returns The texture
  29809. */
  29810. private _createDepthStencilTexture;
  29811. /** @hidden */
  29812. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  29813. /** @hidden */
  29814. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  29815. /** @hidden */
  29816. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  29817. /** @hidden */
  29818. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  29819. /**
  29820. * @hidden
  29821. */
  29822. _setCubeMapTextureParams(loadMipmap: boolean): void;
  29823. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  29824. private _prepareWebGLTexture;
  29825. /** @hidden */
  29826. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  29827. /** @hidden */
  29828. _releaseFramebufferObjects(texture: InternalTexture): void;
  29829. /** @hidden */
  29830. _releaseTexture(texture: InternalTexture): void;
  29831. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  29832. protected _setProgram(program: WebGLProgram): void;
  29833. protected _boundUniforms: {
  29834. [key: number]: WebGLUniformLocation;
  29835. };
  29836. /**
  29837. * Binds an effect to the webGL context
  29838. * @param effect defines the effect to bind
  29839. */
  29840. bindSamplers(effect: Effect): void;
  29841. private _activateCurrentTexture;
  29842. /** @hidden */
  29843. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  29844. /** @hidden */
  29845. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  29846. /**
  29847. * Unbind all textures from the webGL context
  29848. */
  29849. unbindAllTextures(): void;
  29850. /**
  29851. * Sets a texture to the according uniform.
  29852. * @param channel The texture channel
  29853. * @param uniform The uniform to set
  29854. * @param texture The texture to apply
  29855. */
  29856. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  29857. private _bindSamplerUniformToChannel;
  29858. private _getTextureWrapMode;
  29859. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  29860. /**
  29861. * Sets an array of texture to the webGL context
  29862. * @param channel defines the channel where the texture array must be set
  29863. * @param uniform defines the associated uniform location
  29864. * @param textures defines the array of textures to bind
  29865. */
  29866. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  29867. /** @hidden */
  29868. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  29869. private _setTextureParameterFloat;
  29870. private _setTextureParameterInteger;
  29871. /**
  29872. * Unbind all vertex attributes from the webGL context
  29873. */
  29874. unbindAllAttributes(): void;
  29875. /**
  29876. * 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
  29877. */
  29878. releaseEffects(): void;
  29879. /**
  29880. * Dispose and release all associated resources
  29881. */
  29882. dispose(): void;
  29883. /**
  29884. * Attach a new callback raised when context lost event is fired
  29885. * @param callback defines the callback to call
  29886. */
  29887. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  29888. /**
  29889. * Attach a new callback raised when context restored event is fired
  29890. * @param callback defines the callback to call
  29891. */
  29892. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  29893. /**
  29894. * Get the current error code of the webGL context
  29895. * @returns the error code
  29896. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  29897. */
  29898. getError(): number;
  29899. private _canRenderToFloatFramebuffer;
  29900. private _canRenderToHalfFloatFramebuffer;
  29901. private _canRenderToFramebuffer;
  29902. /** @hidden */
  29903. _getWebGLTextureType(type: number): number;
  29904. /** @hidden */
  29905. _getInternalFormat(format: number): number;
  29906. /** @hidden */
  29907. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  29908. /** @hidden */
  29909. _getRGBAMultiSampleBufferFormat(type: number): number;
  29910. /** @hidden */
  29911. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: IWebRequest, exception?: any) => void): IFileRequest;
  29912. /**
  29913. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  29914. * @returns true if the engine can be created
  29915. * @ignorenaming
  29916. */
  29917. static isSupported(): boolean;
  29918. /**
  29919. * Find the next highest power of two.
  29920. * @param x Number to start search from.
  29921. * @return Next highest power of two.
  29922. */
  29923. static CeilingPOT(x: number): number;
  29924. /**
  29925. * Find the next lowest power of two.
  29926. * @param x Number to start search from.
  29927. * @return Next lowest power of two.
  29928. */
  29929. static FloorPOT(x: number): number;
  29930. /**
  29931. * Find the nearest power of two.
  29932. * @param x Number to start search from.
  29933. * @return Next nearest power of two.
  29934. */
  29935. static NearestPOT(x: number): number;
  29936. /**
  29937. * Get the closest exponent of two
  29938. * @param value defines the value to approximate
  29939. * @param max defines the maximum value to return
  29940. * @param mode defines how to define the closest value
  29941. * @returns closest exponent of two of the given value
  29942. */
  29943. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  29944. /**
  29945. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  29946. * @param func - the function to be called
  29947. * @param requester - the object that will request the next frame. Falls back to window.
  29948. * @returns frame number
  29949. */
  29950. static QueueNewFrame(func: () => void, requester?: any): number;
  29951. }
  29952. }
  29953. declare module BABYLON {
  29954. /**
  29955. * Class representing spherical harmonics coefficients to the 3rd degree
  29956. */
  29957. export class SphericalHarmonics {
  29958. /**
  29959. * Defines whether or not the harmonics have been prescaled for rendering.
  29960. */
  29961. preScaled: boolean;
  29962. /**
  29963. * The l0,0 coefficients of the spherical harmonics
  29964. */
  29965. l00: Vector3;
  29966. /**
  29967. * The l1,-1 coefficients of the spherical harmonics
  29968. */
  29969. l1_1: Vector3;
  29970. /**
  29971. * The l1,0 coefficients of the spherical harmonics
  29972. */
  29973. l10: Vector3;
  29974. /**
  29975. * The l1,1 coefficients of the spherical harmonics
  29976. */
  29977. l11: Vector3;
  29978. /**
  29979. * The l2,-2 coefficients of the spherical harmonics
  29980. */
  29981. l2_2: Vector3;
  29982. /**
  29983. * The l2,-1 coefficients of the spherical harmonics
  29984. */
  29985. l2_1: Vector3;
  29986. /**
  29987. * The l2,0 coefficients of the spherical harmonics
  29988. */
  29989. l20: Vector3;
  29990. /**
  29991. * The l2,1 coefficients of the spherical harmonics
  29992. */
  29993. l21: Vector3;
  29994. /**
  29995. * The l2,2 coefficients of the spherical harmonics
  29996. */
  29997. l22: Vector3;
  29998. /**
  29999. * Adds a light to the spherical harmonics
  30000. * @param direction the direction of the light
  30001. * @param color the color of the light
  30002. * @param deltaSolidAngle the delta solid angle of the light
  30003. */
  30004. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  30005. /**
  30006. * Scales the spherical harmonics by the given amount
  30007. * @param scale the amount to scale
  30008. */
  30009. scaleInPlace(scale: number): void;
  30010. /**
  30011. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  30012. *
  30013. * ```
  30014. * E_lm = A_l * L_lm
  30015. * ```
  30016. *
  30017. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  30018. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  30019. * the scaling factors are given in equation 9.
  30020. */
  30021. convertIncidentRadianceToIrradiance(): void;
  30022. /**
  30023. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  30024. *
  30025. * ```
  30026. * L = (1/pi) * E * rho
  30027. * ```
  30028. *
  30029. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  30030. */
  30031. convertIrradianceToLambertianRadiance(): void;
  30032. /**
  30033. * Integrates the reconstruction coefficients directly in to the SH preventing further
  30034. * required operations at run time.
  30035. *
  30036. * This is simply done by scaling back the SH with Ylm constants parameter.
  30037. * The trigonometric part being applied by the shader at run time.
  30038. */
  30039. preScaleForRendering(): void;
  30040. /**
  30041. * Constructs a spherical harmonics from an array.
  30042. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  30043. * @returns the spherical harmonics
  30044. */
  30045. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  30046. /**
  30047. * Gets the spherical harmonics from polynomial
  30048. * @param polynomial the spherical polynomial
  30049. * @returns the spherical harmonics
  30050. */
  30051. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  30052. }
  30053. /**
  30054. * Class representing spherical polynomial coefficients to the 3rd degree
  30055. */
  30056. export class SphericalPolynomial {
  30057. private _harmonics;
  30058. /**
  30059. * The spherical harmonics used to create the polynomials.
  30060. */
  30061. readonly preScaledHarmonics: SphericalHarmonics;
  30062. /**
  30063. * The x coefficients of the spherical polynomial
  30064. */
  30065. x: Vector3;
  30066. /**
  30067. * The y coefficients of the spherical polynomial
  30068. */
  30069. y: Vector3;
  30070. /**
  30071. * The z coefficients of the spherical polynomial
  30072. */
  30073. z: Vector3;
  30074. /**
  30075. * The xx coefficients of the spherical polynomial
  30076. */
  30077. xx: Vector3;
  30078. /**
  30079. * The yy coefficients of the spherical polynomial
  30080. */
  30081. yy: Vector3;
  30082. /**
  30083. * The zz coefficients of the spherical polynomial
  30084. */
  30085. zz: Vector3;
  30086. /**
  30087. * The xy coefficients of the spherical polynomial
  30088. */
  30089. xy: Vector3;
  30090. /**
  30091. * The yz coefficients of the spherical polynomial
  30092. */
  30093. yz: Vector3;
  30094. /**
  30095. * The zx coefficients of the spherical polynomial
  30096. */
  30097. zx: Vector3;
  30098. /**
  30099. * Adds an ambient color to the spherical polynomial
  30100. * @param color the color to add
  30101. */
  30102. addAmbient(color: Color3): void;
  30103. /**
  30104. * Scales the spherical polynomial by the given amount
  30105. * @param scale the amount to scale
  30106. */
  30107. scaleInPlace(scale: number): void;
  30108. /**
  30109. * Gets the spherical polynomial from harmonics
  30110. * @param harmonics the spherical harmonics
  30111. * @returns the spherical polynomial
  30112. */
  30113. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  30114. /**
  30115. * Constructs a spherical polynomial from an array.
  30116. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  30117. * @returns the spherical polynomial
  30118. */
  30119. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  30120. }
  30121. }
  30122. declare module BABYLON {
  30123. /**
  30124. * Defines the source of the internal texture
  30125. */
  30126. export enum InternalTextureSource {
  30127. /**
  30128. * The source of the texture data is unknown
  30129. */
  30130. Unknown = 0,
  30131. /**
  30132. * Texture data comes from an URL
  30133. */
  30134. Url = 1,
  30135. /**
  30136. * Texture data is only used for temporary storage
  30137. */
  30138. Temp = 2,
  30139. /**
  30140. * Texture data comes from raw data (ArrayBuffer)
  30141. */
  30142. Raw = 3,
  30143. /**
  30144. * Texture content is dynamic (video or dynamic texture)
  30145. */
  30146. Dynamic = 4,
  30147. /**
  30148. * Texture content is generated by rendering to it
  30149. */
  30150. RenderTarget = 5,
  30151. /**
  30152. * Texture content is part of a multi render target process
  30153. */
  30154. MultiRenderTarget = 6,
  30155. /**
  30156. * Texture data comes from a cube data file
  30157. */
  30158. Cube = 7,
  30159. /**
  30160. * Texture data comes from a raw cube data
  30161. */
  30162. CubeRaw = 8,
  30163. /**
  30164. * Texture data come from a prefiltered cube data file
  30165. */
  30166. CubePrefiltered = 9,
  30167. /**
  30168. * Texture content is raw 3D data
  30169. */
  30170. Raw3D = 10,
  30171. /**
  30172. * Texture content is a depth texture
  30173. */
  30174. Depth = 11,
  30175. /**
  30176. * Texture data comes from a raw cube data encoded with RGBD
  30177. */
  30178. CubeRawRGBD = 12
  30179. }
  30180. /**
  30181. * Class used to store data associated with WebGL texture data for the engine
  30182. * This class should not be used directly
  30183. */
  30184. export class InternalTexture {
  30185. /** @hidden */
  30186. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  30187. /**
  30188. * Defines if the texture is ready
  30189. */
  30190. isReady: boolean;
  30191. /**
  30192. * Defines if the texture is a cube texture
  30193. */
  30194. isCube: boolean;
  30195. /**
  30196. * Defines if the texture contains 3D data
  30197. */
  30198. is3D: boolean;
  30199. /**
  30200. * Defines if the texture contains multiview data
  30201. */
  30202. isMultiview: boolean;
  30203. /**
  30204. * Gets the URL used to load this texture
  30205. */
  30206. url: string;
  30207. /**
  30208. * Gets the sampling mode of the texture
  30209. */
  30210. samplingMode: number;
  30211. /**
  30212. * Gets a boolean indicating if the texture needs mipmaps generation
  30213. */
  30214. generateMipMaps: boolean;
  30215. /**
  30216. * Gets the number of samples used by the texture (WebGL2+ only)
  30217. */
  30218. samples: number;
  30219. /**
  30220. * Gets the type of the texture (int, float...)
  30221. */
  30222. type: number;
  30223. /**
  30224. * Gets the format of the texture (RGB, RGBA...)
  30225. */
  30226. format: number;
  30227. /**
  30228. * Observable called when the texture is loaded
  30229. */
  30230. onLoadedObservable: Observable<InternalTexture>;
  30231. /**
  30232. * Gets the width of the texture
  30233. */
  30234. width: number;
  30235. /**
  30236. * Gets the height of the texture
  30237. */
  30238. height: number;
  30239. /**
  30240. * Gets the depth of the texture
  30241. */
  30242. depth: number;
  30243. /**
  30244. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  30245. */
  30246. baseWidth: number;
  30247. /**
  30248. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  30249. */
  30250. baseHeight: number;
  30251. /**
  30252. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  30253. */
  30254. baseDepth: number;
  30255. /**
  30256. * Gets a boolean indicating if the texture is inverted on Y axis
  30257. */
  30258. invertY: boolean;
  30259. /** @hidden */
  30260. _invertVScale: boolean;
  30261. /** @hidden */
  30262. _associatedChannel: number;
  30263. /** @hidden */
  30264. _source: InternalTextureSource;
  30265. /** @hidden */
  30266. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>;
  30267. /** @hidden */
  30268. _bufferView: Nullable<ArrayBufferView>;
  30269. /** @hidden */
  30270. _bufferViewArray: Nullable<ArrayBufferView[]>;
  30271. /** @hidden */
  30272. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  30273. /** @hidden */
  30274. _size: number;
  30275. /** @hidden */
  30276. _extension: string;
  30277. /** @hidden */
  30278. _files: Nullable<string[]>;
  30279. /** @hidden */
  30280. _workingCanvas: Nullable<HTMLCanvasElement>;
  30281. /** @hidden */
  30282. _workingContext: Nullable<CanvasRenderingContext2D>;
  30283. /** @hidden */
  30284. _framebuffer: Nullable<WebGLFramebuffer>;
  30285. /** @hidden */
  30286. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  30287. /** @hidden */
  30288. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  30289. /** @hidden */
  30290. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  30291. /** @hidden */
  30292. _attachments: Nullable<number[]>;
  30293. /** @hidden */
  30294. _cachedCoordinatesMode: Nullable<number>;
  30295. /** @hidden */
  30296. _cachedWrapU: Nullable<number>;
  30297. /** @hidden */
  30298. _cachedWrapV: Nullable<number>;
  30299. /** @hidden */
  30300. _cachedWrapR: Nullable<number>;
  30301. /** @hidden */
  30302. _cachedAnisotropicFilteringLevel: Nullable<number>;
  30303. /** @hidden */
  30304. _isDisabled: boolean;
  30305. /** @hidden */
  30306. _compression: Nullable<string>;
  30307. /** @hidden */
  30308. _generateStencilBuffer: boolean;
  30309. /** @hidden */
  30310. _generateDepthBuffer: boolean;
  30311. /** @hidden */
  30312. _comparisonFunction: number;
  30313. /** @hidden */
  30314. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  30315. /** @hidden */
  30316. _lodGenerationScale: number;
  30317. /** @hidden */
  30318. _lodGenerationOffset: number;
  30319. /** @hidden */
  30320. _colorTextureArray: Nullable<WebGLTexture>;
  30321. /** @hidden */
  30322. _depthStencilTextureArray: Nullable<WebGLTexture>;
  30323. /** @hidden */
  30324. _lodTextureHigh: Nullable<BaseTexture>;
  30325. /** @hidden */
  30326. _lodTextureMid: Nullable<BaseTexture>;
  30327. /** @hidden */
  30328. _lodTextureLow: Nullable<BaseTexture>;
  30329. /** @hidden */
  30330. _isRGBD: boolean;
  30331. /** @hidden */
  30332. _linearSpecularLOD: boolean;
  30333. /** @hidden */
  30334. _irradianceTexture: Nullable<BaseTexture>;
  30335. /** @hidden */
  30336. _webGLTexture: Nullable<WebGLTexture>;
  30337. /** @hidden */
  30338. _references: number;
  30339. private _engine;
  30340. /**
  30341. * Gets the Engine the texture belongs to.
  30342. * @returns The babylon engine
  30343. */
  30344. getEngine(): ThinEngine;
  30345. /**
  30346. * Gets the data source type of the texture
  30347. */
  30348. readonly source: InternalTextureSource;
  30349. /**
  30350. * Creates a new InternalTexture
  30351. * @param engine defines the engine to use
  30352. * @param source defines the type of data that will be used
  30353. * @param delayAllocation if the texture allocation should be delayed (default: false)
  30354. */
  30355. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  30356. /**
  30357. * Increments the number of references (ie. the number of Texture that point to it)
  30358. */
  30359. incrementReferences(): void;
  30360. /**
  30361. * Change the size of the texture (not the size of the content)
  30362. * @param width defines the new width
  30363. * @param height defines the new height
  30364. * @param depth defines the new depth (1 by default)
  30365. */
  30366. updateSize(width: int, height: int, depth?: int): void;
  30367. /** @hidden */
  30368. _rebuild(): void;
  30369. /** @hidden */
  30370. _swapAndDie(target: InternalTexture): void;
  30371. /**
  30372. * Dispose the current allocated resources
  30373. */
  30374. dispose(): void;
  30375. }
  30376. }
  30377. declare module BABYLON {
  30378. /**
  30379. * Class used to work with sound analyzer using fast fourier transform (FFT)
  30380. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  30381. */
  30382. export class Analyser {
  30383. /**
  30384. * Gets or sets the smoothing
  30385. * @ignorenaming
  30386. */
  30387. SMOOTHING: number;
  30388. /**
  30389. * Gets or sets the FFT table size
  30390. * @ignorenaming
  30391. */
  30392. FFT_SIZE: number;
  30393. /**
  30394. * Gets or sets the bar graph amplitude
  30395. * @ignorenaming
  30396. */
  30397. BARGRAPHAMPLITUDE: number;
  30398. /**
  30399. * Gets or sets the position of the debug canvas
  30400. * @ignorenaming
  30401. */
  30402. DEBUGCANVASPOS: {
  30403. x: number;
  30404. y: number;
  30405. };
  30406. /**
  30407. * Gets or sets the debug canvas size
  30408. * @ignorenaming
  30409. */
  30410. DEBUGCANVASSIZE: {
  30411. width: number;
  30412. height: number;
  30413. };
  30414. private _byteFreqs;
  30415. private _byteTime;
  30416. private _floatFreqs;
  30417. private _webAudioAnalyser;
  30418. private _debugCanvas;
  30419. private _debugCanvasContext;
  30420. private _scene;
  30421. private _registerFunc;
  30422. private _audioEngine;
  30423. /**
  30424. * Creates a new analyser
  30425. * @param scene defines hosting scene
  30426. */
  30427. constructor(scene: Scene);
  30428. /**
  30429. * Get the number of data values you will have to play with for the visualization
  30430. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  30431. * @returns a number
  30432. */
  30433. getFrequencyBinCount(): number;
  30434. /**
  30435. * Gets the current frequency data as a byte array
  30436. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  30437. * @returns a Uint8Array
  30438. */
  30439. getByteFrequencyData(): Uint8Array;
  30440. /**
  30441. * Gets the current waveform as a byte array
  30442. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  30443. * @returns a Uint8Array
  30444. */
  30445. getByteTimeDomainData(): Uint8Array;
  30446. /**
  30447. * Gets the current frequency data as a float array
  30448. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  30449. * @returns a Float32Array
  30450. */
  30451. getFloatFrequencyData(): Float32Array;
  30452. /**
  30453. * Renders the debug canvas
  30454. */
  30455. drawDebugCanvas(): void;
  30456. /**
  30457. * Stops rendering the debug canvas and removes it
  30458. */
  30459. stopDebugCanvas(): void;
  30460. /**
  30461. * Connects two audio nodes
  30462. * @param inputAudioNode defines first node to connect
  30463. * @param outputAudioNode defines second node to connect
  30464. */
  30465. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  30466. /**
  30467. * Releases all associated resources
  30468. */
  30469. dispose(): void;
  30470. }
  30471. }
  30472. declare module BABYLON {
  30473. /**
  30474. * This represents an audio engine and it is responsible
  30475. * to play, synchronize and analyse sounds throughout the application.
  30476. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  30477. */
  30478. export interface IAudioEngine extends IDisposable {
  30479. /**
  30480. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  30481. */
  30482. readonly canUseWebAudio: boolean;
  30483. /**
  30484. * Gets the current AudioContext if available.
  30485. */
  30486. readonly audioContext: Nullable<AudioContext>;
  30487. /**
  30488. * The master gain node defines the global audio volume of your audio engine.
  30489. */
  30490. readonly masterGain: GainNode;
  30491. /**
  30492. * Gets whether or not mp3 are supported by your browser.
  30493. */
  30494. readonly isMP3supported: boolean;
  30495. /**
  30496. * Gets whether or not ogg are supported by your browser.
  30497. */
  30498. readonly isOGGsupported: boolean;
  30499. /**
  30500. * Defines if Babylon should emit a warning if WebAudio is not supported.
  30501. * @ignoreNaming
  30502. */
  30503. WarnedWebAudioUnsupported: boolean;
  30504. /**
  30505. * Defines if the audio engine relies on a custom unlocked button.
  30506. * In this case, the embedded button will not be displayed.
  30507. */
  30508. useCustomUnlockedButton: boolean;
  30509. /**
  30510. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  30511. */
  30512. readonly unlocked: boolean;
  30513. /**
  30514. * Event raised when audio has been unlocked on the browser.
  30515. */
  30516. onAudioUnlockedObservable: Observable<AudioEngine>;
  30517. /**
  30518. * Event raised when audio has been locked on the browser.
  30519. */
  30520. onAudioLockedObservable: Observable<AudioEngine>;
  30521. /**
  30522. * Flags the audio engine in Locked state.
  30523. * This happens due to new browser policies preventing audio to autoplay.
  30524. */
  30525. lock(): void;
  30526. /**
  30527. * Unlocks the audio engine once a user action has been done on the dom.
  30528. * This is helpful to resume play once browser policies have been satisfied.
  30529. */
  30530. unlock(): void;
  30531. }
  30532. /**
  30533. * This represents the default audio engine used in babylon.
  30534. * It is responsible to play, synchronize and analyse sounds throughout the application.
  30535. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  30536. */
  30537. export class AudioEngine implements IAudioEngine {
  30538. private _audioContext;
  30539. private _audioContextInitialized;
  30540. private _muteButton;
  30541. private _hostElement;
  30542. /**
  30543. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  30544. */
  30545. canUseWebAudio: boolean;
  30546. /**
  30547. * The master gain node defines the global audio volume of your audio engine.
  30548. */
  30549. masterGain: GainNode;
  30550. /**
  30551. * Defines if Babylon should emit a warning if WebAudio is not supported.
  30552. * @ignoreNaming
  30553. */
  30554. WarnedWebAudioUnsupported: boolean;
  30555. /**
  30556. * Gets whether or not mp3 are supported by your browser.
  30557. */
  30558. isMP3supported: boolean;
  30559. /**
  30560. * Gets whether or not ogg are supported by your browser.
  30561. */
  30562. isOGGsupported: boolean;
  30563. /**
  30564. * Gets whether audio has been unlocked on the device.
  30565. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  30566. * a user interaction has happened.
  30567. */
  30568. unlocked: boolean;
  30569. /**
  30570. * Defines if the audio engine relies on a custom unlocked button.
  30571. * In this case, the embedded button will not be displayed.
  30572. */
  30573. useCustomUnlockedButton: boolean;
  30574. /**
  30575. * Event raised when audio has been unlocked on the browser.
  30576. */
  30577. onAudioUnlockedObservable: Observable<AudioEngine>;
  30578. /**
  30579. * Event raised when audio has been locked on the browser.
  30580. */
  30581. onAudioLockedObservable: Observable<AudioEngine>;
  30582. /**
  30583. * Gets the current AudioContext if available.
  30584. */
  30585. readonly audioContext: Nullable<AudioContext>;
  30586. private _connectedAnalyser;
  30587. /**
  30588. * Instantiates a new audio engine.
  30589. *
  30590. * There should be only one per page as some browsers restrict the number
  30591. * of audio contexts you can create.
  30592. * @param hostElement defines the host element where to display the mute icon if necessary
  30593. */
  30594. constructor(hostElement?: Nullable<HTMLElement>);
  30595. /**
  30596. * Flags the audio engine in Locked state.
  30597. * This happens due to new browser policies preventing audio to autoplay.
  30598. */
  30599. lock(): void;
  30600. /**
  30601. * Unlocks the audio engine once a user action has been done on the dom.
  30602. * This is helpful to resume play once browser policies have been satisfied.
  30603. */
  30604. unlock(): void;
  30605. private _resumeAudioContext;
  30606. private _initializeAudioContext;
  30607. private _tryToRun;
  30608. private _triggerRunningState;
  30609. private _triggerSuspendedState;
  30610. private _displayMuteButton;
  30611. private _moveButtonToTopLeft;
  30612. private _onResize;
  30613. private _hideMuteButton;
  30614. /**
  30615. * Destroy and release the resources associated with the audio ccontext.
  30616. */
  30617. dispose(): void;
  30618. /**
  30619. * Gets the global volume sets on the master gain.
  30620. * @returns the global volume if set or -1 otherwise
  30621. */
  30622. getGlobalVolume(): number;
  30623. /**
  30624. * Sets the global volume of your experience (sets on the master gain).
  30625. * @param newVolume Defines the new global volume of the application
  30626. */
  30627. setGlobalVolume(newVolume: number): void;
  30628. /**
  30629. * Connect the audio engine to an audio analyser allowing some amazing
  30630. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  30631. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  30632. * @param analyser The analyser to connect to the engine
  30633. */
  30634. connectToAnalyser(analyser: Analyser): void;
  30635. }
  30636. }
  30637. declare module BABYLON {
  30638. /**
  30639. * Interface used to present a loading screen while loading a scene
  30640. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  30641. */
  30642. export interface ILoadingScreen {
  30643. /**
  30644. * Function called to display the loading screen
  30645. */
  30646. displayLoadingUI: () => void;
  30647. /**
  30648. * Function called to hide the loading screen
  30649. */
  30650. hideLoadingUI: () => void;
  30651. /**
  30652. * Gets or sets the color to use for the background
  30653. */
  30654. loadingUIBackgroundColor: string;
  30655. /**
  30656. * Gets or sets the text to display while loading
  30657. */
  30658. loadingUIText: string;
  30659. }
  30660. /**
  30661. * Class used for the default loading screen
  30662. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  30663. */
  30664. export class DefaultLoadingScreen implements ILoadingScreen {
  30665. private _renderingCanvas;
  30666. private _loadingText;
  30667. private _loadingDivBackgroundColor;
  30668. private _loadingDiv;
  30669. private _loadingTextDiv;
  30670. /** Gets or sets the logo url to use for the default loading screen */
  30671. static DefaultLogoUrl: string;
  30672. /** Gets or sets the spinner url to use for the default loading screen */
  30673. static DefaultSpinnerUrl: string;
  30674. /**
  30675. * Creates a new default loading screen
  30676. * @param _renderingCanvas defines the canvas used to render the scene
  30677. * @param _loadingText defines the default text to display
  30678. * @param _loadingDivBackgroundColor defines the default background color
  30679. */
  30680. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  30681. /**
  30682. * Function called to display the loading screen
  30683. */
  30684. displayLoadingUI(): void;
  30685. /**
  30686. * Function called to hide the loading screen
  30687. */
  30688. hideLoadingUI(): void;
  30689. /**
  30690. * Gets or sets the text to display while loading
  30691. */
  30692. loadingUIText: string;
  30693. /**
  30694. * Gets or sets the color to use for the background
  30695. */
  30696. loadingUIBackgroundColor: string;
  30697. private _resizeLoadingUI;
  30698. }
  30699. }
  30700. declare module BABYLON {
  30701. /**
  30702. * Interface for any object that can request an animation frame
  30703. */
  30704. export interface ICustomAnimationFrameRequester {
  30705. /**
  30706. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  30707. */
  30708. renderFunction?: Function;
  30709. /**
  30710. * Called to request the next frame to render to
  30711. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  30712. */
  30713. requestAnimationFrame: Function;
  30714. /**
  30715. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  30716. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  30717. */
  30718. requestID?: number;
  30719. }
  30720. }
  30721. declare module BABYLON {
  30722. /**
  30723. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  30724. */
  30725. export class PerformanceMonitor {
  30726. private _enabled;
  30727. private _rollingFrameTime;
  30728. private _lastFrameTimeMs;
  30729. /**
  30730. * constructor
  30731. * @param frameSampleSize The number of samples required to saturate the sliding window
  30732. */
  30733. constructor(frameSampleSize?: number);
  30734. /**
  30735. * Samples current frame
  30736. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  30737. */
  30738. sampleFrame(timeMs?: number): void;
  30739. /**
  30740. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  30741. */
  30742. readonly averageFrameTime: number;
  30743. /**
  30744. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  30745. */
  30746. readonly averageFrameTimeVariance: number;
  30747. /**
  30748. * Returns the frame time of the most recent frame
  30749. */
  30750. readonly instantaneousFrameTime: number;
  30751. /**
  30752. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  30753. */
  30754. readonly averageFPS: number;
  30755. /**
  30756. * Returns the average framerate in frames per second using the most recent frame time
  30757. */
  30758. readonly instantaneousFPS: number;
  30759. /**
  30760. * Returns true if enough samples have been taken to completely fill the sliding window
  30761. */
  30762. readonly isSaturated: boolean;
  30763. /**
  30764. * Enables contributions to the sliding window sample set
  30765. */
  30766. enable(): void;
  30767. /**
  30768. * Disables contributions to the sliding window sample set
  30769. * Samples will not be interpolated over the disabled period
  30770. */
  30771. disable(): void;
  30772. /**
  30773. * Returns true if sampling is enabled
  30774. */
  30775. readonly isEnabled: boolean;
  30776. /**
  30777. * Resets performance monitor
  30778. */
  30779. reset(): void;
  30780. }
  30781. /**
  30782. * RollingAverage
  30783. *
  30784. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  30785. */
  30786. export class RollingAverage {
  30787. /**
  30788. * Current average
  30789. */
  30790. average: number;
  30791. /**
  30792. * Current variance
  30793. */
  30794. variance: number;
  30795. protected _samples: Array<number>;
  30796. protected _sampleCount: number;
  30797. protected _pos: number;
  30798. protected _m2: number;
  30799. /**
  30800. * constructor
  30801. * @param length The number of samples required to saturate the sliding window
  30802. */
  30803. constructor(length: number);
  30804. /**
  30805. * Adds a sample to the sample set
  30806. * @param v The sample value
  30807. */
  30808. add(v: number): void;
  30809. /**
  30810. * Returns previously added values or null if outside of history or outside the sliding window domain
  30811. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  30812. * @return Value previously recorded with add() or null if outside of range
  30813. */
  30814. history(i: number): number;
  30815. /**
  30816. * Returns true if enough samples have been taken to completely fill the sliding window
  30817. * @return true if sample-set saturated
  30818. */
  30819. isSaturated(): boolean;
  30820. /**
  30821. * Resets the rolling average (equivalent to 0 samples taken so far)
  30822. */
  30823. reset(): void;
  30824. /**
  30825. * Wraps a value around the sample range boundaries
  30826. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  30827. * @return Wrapped position in sample range
  30828. */
  30829. protected _wrapPosition(i: number): number;
  30830. }
  30831. }
  30832. declare module BABYLON {
  30833. /**
  30834. * This class is used to track a performance counter which is number based.
  30835. * The user has access to many properties which give statistics of different nature.
  30836. *
  30837. * The implementer can track two kinds of Performance Counter: time and count.
  30838. * 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.
  30839. * 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.
  30840. */
  30841. export class PerfCounter {
  30842. /**
  30843. * Gets or sets a global boolean to turn on and off all the counters
  30844. */
  30845. static Enabled: boolean;
  30846. /**
  30847. * Returns the smallest value ever
  30848. */
  30849. readonly min: number;
  30850. /**
  30851. * Returns the biggest value ever
  30852. */
  30853. readonly max: number;
  30854. /**
  30855. * Returns the average value since the performance counter is running
  30856. */
  30857. readonly average: number;
  30858. /**
  30859. * Returns the average value of the last second the counter was monitored
  30860. */
  30861. readonly lastSecAverage: number;
  30862. /**
  30863. * Returns the current value
  30864. */
  30865. readonly current: number;
  30866. /**
  30867. * Gets the accumulated total
  30868. */
  30869. readonly total: number;
  30870. /**
  30871. * Gets the total value count
  30872. */
  30873. readonly count: number;
  30874. /**
  30875. * Creates a new counter
  30876. */
  30877. constructor();
  30878. /**
  30879. * Call this method to start monitoring a new frame.
  30880. * 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.
  30881. */
  30882. fetchNewFrame(): void;
  30883. /**
  30884. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  30885. * @param newCount the count value to add to the monitored count
  30886. * @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.
  30887. */
  30888. addCount(newCount: number, fetchResult: boolean): void;
  30889. /**
  30890. * Start monitoring this performance counter
  30891. */
  30892. beginMonitoring(): void;
  30893. /**
  30894. * Compute the time lapsed since the previous beginMonitoring() call.
  30895. * @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
  30896. */
  30897. endMonitoring(newFrame?: boolean): void;
  30898. private _fetchResult;
  30899. private _startMonitoringTime;
  30900. private _min;
  30901. private _max;
  30902. private _average;
  30903. private _current;
  30904. private _totalValueCount;
  30905. private _totalAccumulated;
  30906. private _lastSecAverage;
  30907. private _lastSecAccumulated;
  30908. private _lastSecTime;
  30909. private _lastSecValueCount;
  30910. }
  30911. }
  30912. declare module BABYLON {
  30913. /**
  30914. * Defines the interface used by display changed events
  30915. */
  30916. export interface IDisplayChangedEventArgs {
  30917. /** Gets the vrDisplay object (if any) */
  30918. vrDisplay: Nullable<any>;
  30919. /** Gets a boolean indicating if webVR is supported */
  30920. vrSupported: boolean;
  30921. }
  30922. /**
  30923. * Defines the interface used by objects containing a viewport (like a camera)
  30924. */
  30925. interface IViewportOwnerLike {
  30926. /**
  30927. * Gets or sets the viewport
  30928. */
  30929. viewport: IViewportLike;
  30930. }
  30931. /**
  30932. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  30933. */
  30934. export class Engine extends ThinEngine {
  30935. /** Defines that alpha blending is disabled */
  30936. static readonly ALPHA_DISABLE: number;
  30937. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  30938. static readonly ALPHA_ADD: number;
  30939. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  30940. static readonly ALPHA_COMBINE: number;
  30941. /** Defines that alpha blending to DEST - SRC * DEST */
  30942. static readonly ALPHA_SUBTRACT: number;
  30943. /** Defines that alpha blending to SRC * DEST */
  30944. static readonly ALPHA_MULTIPLY: number;
  30945. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  30946. static readonly ALPHA_MAXIMIZED: number;
  30947. /** Defines that alpha blending to SRC + DEST */
  30948. static readonly ALPHA_ONEONE: number;
  30949. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  30950. static readonly ALPHA_PREMULTIPLIED: number;
  30951. /**
  30952. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  30953. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  30954. */
  30955. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  30956. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  30957. static readonly ALPHA_INTERPOLATE: number;
  30958. /**
  30959. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  30960. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  30961. */
  30962. static readonly ALPHA_SCREENMODE: number;
  30963. /** Defines that the ressource is not delayed*/
  30964. static readonly DELAYLOADSTATE_NONE: number;
  30965. /** Defines that the ressource was successfully delay loaded */
  30966. static readonly DELAYLOADSTATE_LOADED: number;
  30967. /** Defines that the ressource is currently delay loading */
  30968. static readonly DELAYLOADSTATE_LOADING: number;
  30969. /** Defines that the ressource is delayed and has not started loading */
  30970. static readonly DELAYLOADSTATE_NOTLOADED: number;
  30971. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  30972. static readonly NEVER: number;
  30973. /** 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 */
  30974. static readonly ALWAYS: number;
  30975. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  30976. static readonly LESS: number;
  30977. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  30978. static readonly EQUAL: number;
  30979. /** 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 */
  30980. static readonly LEQUAL: number;
  30981. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  30982. static readonly GREATER: number;
  30983. /** 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 */
  30984. static readonly GEQUAL: number;
  30985. /** 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 */
  30986. static readonly NOTEQUAL: number;
  30987. /** Passed to stencilOperation to specify that stencil value must be kept */
  30988. static readonly KEEP: number;
  30989. /** Passed to stencilOperation to specify that stencil value must be replaced */
  30990. static readonly REPLACE: number;
  30991. /** Passed to stencilOperation to specify that stencil value must be incremented */
  30992. static readonly INCR: number;
  30993. /** Passed to stencilOperation to specify that stencil value must be decremented */
  30994. static readonly DECR: number;
  30995. /** Passed to stencilOperation to specify that stencil value must be inverted */
  30996. static readonly INVERT: number;
  30997. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  30998. static readonly INCR_WRAP: number;
  30999. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  31000. static readonly DECR_WRAP: number;
  31001. /** Texture is not repeating outside of 0..1 UVs */
  31002. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  31003. /** Texture is repeating outside of 0..1 UVs */
  31004. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  31005. /** Texture is repeating and mirrored */
  31006. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  31007. /** ALPHA */
  31008. static readonly TEXTUREFORMAT_ALPHA: number;
  31009. /** LUMINANCE */
  31010. static readonly TEXTUREFORMAT_LUMINANCE: number;
  31011. /** LUMINANCE_ALPHA */
  31012. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  31013. /** RGB */
  31014. static readonly TEXTUREFORMAT_RGB: number;
  31015. /** RGBA */
  31016. static readonly TEXTUREFORMAT_RGBA: number;
  31017. /** RED */
  31018. static readonly TEXTUREFORMAT_RED: number;
  31019. /** RED (2nd reference) */
  31020. static readonly TEXTUREFORMAT_R: number;
  31021. /** RG */
  31022. static readonly TEXTUREFORMAT_RG: number;
  31023. /** RED_INTEGER */
  31024. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  31025. /** RED_INTEGER (2nd reference) */
  31026. static readonly TEXTUREFORMAT_R_INTEGER: number;
  31027. /** RG_INTEGER */
  31028. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  31029. /** RGB_INTEGER */
  31030. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  31031. /** RGBA_INTEGER */
  31032. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  31033. /** UNSIGNED_BYTE */
  31034. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  31035. /** UNSIGNED_BYTE (2nd reference) */
  31036. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  31037. /** FLOAT */
  31038. static readonly TEXTURETYPE_FLOAT: number;
  31039. /** HALF_FLOAT */
  31040. static readonly TEXTURETYPE_HALF_FLOAT: number;
  31041. /** BYTE */
  31042. static readonly TEXTURETYPE_BYTE: number;
  31043. /** SHORT */
  31044. static readonly TEXTURETYPE_SHORT: number;
  31045. /** UNSIGNED_SHORT */
  31046. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  31047. /** INT */
  31048. static readonly TEXTURETYPE_INT: number;
  31049. /** UNSIGNED_INT */
  31050. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  31051. /** UNSIGNED_SHORT_4_4_4_4 */
  31052. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  31053. /** UNSIGNED_SHORT_5_5_5_1 */
  31054. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  31055. /** UNSIGNED_SHORT_5_6_5 */
  31056. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  31057. /** UNSIGNED_INT_2_10_10_10_REV */
  31058. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  31059. /** UNSIGNED_INT_24_8 */
  31060. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  31061. /** UNSIGNED_INT_10F_11F_11F_REV */
  31062. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  31063. /** UNSIGNED_INT_5_9_9_9_REV */
  31064. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  31065. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  31066. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  31067. /** nearest is mag = nearest and min = nearest and mip = linear */
  31068. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  31069. /** Bilinear is mag = linear and min = linear and mip = nearest */
  31070. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  31071. /** Trilinear is mag = linear and min = linear and mip = linear */
  31072. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  31073. /** nearest is mag = nearest and min = nearest and mip = linear */
  31074. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  31075. /** Bilinear is mag = linear and min = linear and mip = nearest */
  31076. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  31077. /** Trilinear is mag = linear and min = linear and mip = linear */
  31078. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  31079. /** mag = nearest and min = nearest and mip = nearest */
  31080. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  31081. /** mag = nearest and min = linear and mip = nearest */
  31082. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  31083. /** mag = nearest and min = linear and mip = linear */
  31084. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  31085. /** mag = nearest and min = linear and mip = none */
  31086. static readonly TEXTURE_NEAREST_LINEAR: number;
  31087. /** mag = nearest and min = nearest and mip = none */
  31088. static readonly TEXTURE_NEAREST_NEAREST: number;
  31089. /** mag = linear and min = nearest and mip = nearest */
  31090. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  31091. /** mag = linear and min = nearest and mip = linear */
  31092. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  31093. /** mag = linear and min = linear and mip = none */
  31094. static readonly TEXTURE_LINEAR_LINEAR: number;
  31095. /** mag = linear and min = nearest and mip = none */
  31096. static readonly TEXTURE_LINEAR_NEAREST: number;
  31097. /** Explicit coordinates mode */
  31098. static readonly TEXTURE_EXPLICIT_MODE: number;
  31099. /** Spherical coordinates mode */
  31100. static readonly TEXTURE_SPHERICAL_MODE: number;
  31101. /** Planar coordinates mode */
  31102. static readonly TEXTURE_PLANAR_MODE: number;
  31103. /** Cubic coordinates mode */
  31104. static readonly TEXTURE_CUBIC_MODE: number;
  31105. /** Projection coordinates mode */
  31106. static readonly TEXTURE_PROJECTION_MODE: number;
  31107. /** Skybox coordinates mode */
  31108. static readonly TEXTURE_SKYBOX_MODE: number;
  31109. /** Inverse Cubic coordinates mode */
  31110. static readonly TEXTURE_INVCUBIC_MODE: number;
  31111. /** Equirectangular coordinates mode */
  31112. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  31113. /** Equirectangular Fixed coordinates mode */
  31114. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  31115. /** Equirectangular Fixed Mirrored coordinates mode */
  31116. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  31117. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  31118. static readonly SCALEMODE_FLOOR: number;
  31119. /** Defines that texture rescaling will look for the nearest power of 2 size */
  31120. static readonly SCALEMODE_NEAREST: number;
  31121. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  31122. static readonly SCALEMODE_CEILING: number;
  31123. /**
  31124. * Returns the current npm package of the sdk
  31125. */
  31126. static readonly NpmPackage: string;
  31127. /**
  31128. * Returns the current version of the framework
  31129. */
  31130. static readonly Version: string;
  31131. /** Gets the list of created engines */
  31132. static readonly Instances: Engine[];
  31133. /**
  31134. * Gets the latest created engine
  31135. */
  31136. static readonly LastCreatedEngine: Nullable<Engine>;
  31137. /**
  31138. * Gets the latest created scene
  31139. */
  31140. static readonly LastCreatedScene: Nullable<Scene>;
  31141. /**
  31142. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  31143. * @param flag defines which part of the materials must be marked as dirty
  31144. * @param predicate defines a predicate used to filter which materials should be affected
  31145. */
  31146. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  31147. /**
  31148. * Method called to create the default loading screen.
  31149. * This can be overriden in your own app.
  31150. * @param canvas The rendering canvas element
  31151. * @returns The loading screen
  31152. */
  31153. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  31154. /**
  31155. * Method called to create the default rescale post process on each engine.
  31156. */
  31157. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  31158. /**
  31159. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  31160. **/
  31161. enableOfflineSupport: boolean;
  31162. /**
  31163. * 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)
  31164. **/
  31165. disableManifestCheck: boolean;
  31166. /**
  31167. * Gets the list of created scenes
  31168. */
  31169. scenes: Scene[];
  31170. /**
  31171. * Event raised when a new scene is created
  31172. */
  31173. onNewSceneAddedObservable: Observable<Scene>;
  31174. /**
  31175. * Gets the list of created postprocesses
  31176. */
  31177. postProcesses: PostProcess[];
  31178. /**
  31179. * Gets a boolean indicating if the pointer is currently locked
  31180. */
  31181. isPointerLock: boolean;
  31182. /**
  31183. * Observable event triggered each time the rendering canvas is resized
  31184. */
  31185. onResizeObservable: Observable<Engine>;
  31186. /**
  31187. * Observable event triggered each time the canvas loses focus
  31188. */
  31189. onCanvasBlurObservable: Observable<Engine>;
  31190. /**
  31191. * Observable event triggered each time the canvas gains focus
  31192. */
  31193. onCanvasFocusObservable: Observable<Engine>;
  31194. /**
  31195. * Observable event triggered each time the canvas receives pointerout event
  31196. */
  31197. onCanvasPointerOutObservable: Observable<PointerEvent>;
  31198. /**
  31199. * Observable raised when the engine begins a new frame
  31200. */
  31201. onBeginFrameObservable: Observable<Engine>;
  31202. /**
  31203. * If set, will be used to request the next animation frame for the render loop
  31204. */
  31205. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  31206. /**
  31207. * Observable raised when the engine ends the current frame
  31208. */
  31209. onEndFrameObservable: Observable<Engine>;
  31210. /**
  31211. * Observable raised when the engine is about to compile a shader
  31212. */
  31213. onBeforeShaderCompilationObservable: Observable<Engine>;
  31214. /**
  31215. * Observable raised when the engine has jsut compiled a shader
  31216. */
  31217. onAfterShaderCompilationObservable: Observable<Engine>;
  31218. /**
  31219. * Gets the audio engine
  31220. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  31221. * @ignorenaming
  31222. */
  31223. static audioEngine: IAudioEngine;
  31224. /**
  31225. * Default AudioEngine factory responsible of creating the Audio Engine.
  31226. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  31227. */
  31228. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  31229. /**
  31230. * Default offline support factory responsible of creating a tool used to store data locally.
  31231. * By default, this will create a Database object if the workload has been embedded.
  31232. */
  31233. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  31234. private _loadingScreen;
  31235. private _pointerLockRequested;
  31236. private _dummyFramebuffer;
  31237. private _rescalePostProcess;
  31238. /** @hidden */
  31239. protected _alphaMode: number;
  31240. /** @hidden */
  31241. protected _alphaEquation: number;
  31242. private _deterministicLockstep;
  31243. private _lockstepMaxSteps;
  31244. protected readonly _supportsHardwareTextureRescaling: boolean;
  31245. private _fps;
  31246. private _deltaTime;
  31247. /** @hidden */
  31248. _drawCalls: PerfCounter;
  31249. /**
  31250. * Turn this value on if you want to pause FPS computation when in background
  31251. */
  31252. disablePerformanceMonitorInBackground: boolean;
  31253. private _performanceMonitor;
  31254. /**
  31255. * Gets the performance monitor attached to this engine
  31256. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  31257. */
  31258. readonly performanceMonitor: PerformanceMonitor;
  31259. private _onFocus;
  31260. private _onBlur;
  31261. private _onCanvasPointerOut;
  31262. private _onCanvasBlur;
  31263. private _onCanvasFocus;
  31264. private _onFullscreenChange;
  31265. private _onPointerLockChange;
  31266. /**
  31267. * Creates a new engine
  31268. * @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
  31269. * @param antialias defines enable antialiasing (default: false)
  31270. * @param options defines further options to be sent to the getContext() function
  31271. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  31272. */
  31273. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  31274. /**
  31275. * Gets current aspect ratio
  31276. * @param viewportOwner defines the camera to use to get the aspect ratio
  31277. * @param useScreen defines if screen size must be used (or the current render target if any)
  31278. * @returns a number defining the aspect ratio
  31279. */
  31280. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  31281. /**
  31282. * Gets current screen aspect ratio
  31283. * @returns a number defining the aspect ratio
  31284. */
  31285. getScreenAspectRatio(): number;
  31286. /**
  31287. * Gets host document
  31288. * @returns the host document object
  31289. */
  31290. getHostDocument(): Document;
  31291. /**
  31292. * Gets the client rect of the HTML canvas attached with the current webGL context
  31293. * @returns a client rectanglee
  31294. */
  31295. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  31296. /**
  31297. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  31298. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31299. * @returns true if engine is in deterministic lock step mode
  31300. */
  31301. isDeterministicLockStep(): boolean;
  31302. /**
  31303. * Gets the max steps when engine is running in deterministic lock step
  31304. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31305. * @returns the max steps
  31306. */
  31307. getLockstepMaxSteps(): number;
  31308. /**
  31309. * Force the mipmap generation for the given render target texture
  31310. * @param texture defines the render target texture to use
  31311. */
  31312. generateMipMapsForCubemap(texture: InternalTexture): void;
  31313. /** States */
  31314. /**
  31315. * Set various states to the webGL context
  31316. * @param culling defines backface culling state
  31317. * @param zOffset defines the value to apply to zOffset (0 by default)
  31318. * @param force defines if states must be applied even if cache is up to date
  31319. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  31320. */
  31321. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  31322. /**
  31323. * Set the z offset to apply to current rendering
  31324. * @param value defines the offset to apply
  31325. */
  31326. setZOffset(value: number): void;
  31327. /**
  31328. * Gets the current value of the zOffset
  31329. * @returns the current zOffset state
  31330. */
  31331. getZOffset(): number;
  31332. /**
  31333. * Enable or disable depth buffering
  31334. * @param enable defines the state to set
  31335. */
  31336. setDepthBuffer(enable: boolean): void;
  31337. /**
  31338. * Gets a boolean indicating if depth writing is enabled
  31339. * @returns the current depth writing state
  31340. */
  31341. getDepthWrite(): boolean;
  31342. /**
  31343. * Enable or disable depth writing
  31344. * @param enable defines the state to set
  31345. */
  31346. setDepthWrite(enable: boolean): void;
  31347. /**
  31348. * Enable or disable color writing
  31349. * @param enable defines the state to set
  31350. */
  31351. setColorWrite(enable: boolean): void;
  31352. /**
  31353. * Gets a boolean indicating if color writing is enabled
  31354. * @returns the current color writing state
  31355. */
  31356. getColorWrite(): boolean;
  31357. /**
  31358. * Sets alpha constants used by some alpha blending modes
  31359. * @param r defines the red component
  31360. * @param g defines the green component
  31361. * @param b defines the blue component
  31362. * @param a defines the alpha component
  31363. */
  31364. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  31365. /**
  31366. * Sets the current alpha mode
  31367. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  31368. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  31369. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  31370. */
  31371. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  31372. /**
  31373. * Gets the current alpha mode
  31374. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  31375. * @returns the current alpha mode
  31376. */
  31377. getAlphaMode(): number;
  31378. /**
  31379. * Sets the current alpha equation
  31380. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  31381. */
  31382. setAlphaEquation(equation: number): void;
  31383. /**
  31384. * Gets the current alpha equation.
  31385. * @returns the current alpha equation
  31386. */
  31387. getAlphaEquation(): number;
  31388. /**
  31389. * Gets a boolean indicating if stencil buffer is enabled
  31390. * @returns the current stencil buffer state
  31391. */
  31392. getStencilBuffer(): boolean;
  31393. /**
  31394. * Enable or disable the stencil buffer
  31395. * @param enable defines if the stencil buffer must be enabled or disabled
  31396. */
  31397. setStencilBuffer(enable: boolean): void;
  31398. /**
  31399. * Gets the current stencil mask
  31400. * @returns a number defining the new stencil mask to use
  31401. */
  31402. getStencilMask(): number;
  31403. /**
  31404. * Sets the current stencil mask
  31405. * @param mask defines the new stencil mask to use
  31406. */
  31407. setStencilMask(mask: number): void;
  31408. /**
  31409. * Gets the current stencil function
  31410. * @returns a number defining the stencil function to use
  31411. */
  31412. getStencilFunction(): number;
  31413. /**
  31414. * Gets the current stencil reference value
  31415. * @returns a number defining the stencil reference value to use
  31416. */
  31417. getStencilFunctionReference(): number;
  31418. /**
  31419. * Gets the current stencil mask
  31420. * @returns a number defining the stencil mask to use
  31421. */
  31422. getStencilFunctionMask(): number;
  31423. /**
  31424. * Sets the current stencil function
  31425. * @param stencilFunc defines the new stencil function to use
  31426. */
  31427. setStencilFunction(stencilFunc: number): void;
  31428. /**
  31429. * Sets the current stencil reference
  31430. * @param reference defines the new stencil reference to use
  31431. */
  31432. setStencilFunctionReference(reference: number): void;
  31433. /**
  31434. * Sets the current stencil mask
  31435. * @param mask defines the new stencil mask to use
  31436. */
  31437. setStencilFunctionMask(mask: number): void;
  31438. /**
  31439. * Gets the current stencil operation when stencil fails
  31440. * @returns a number defining stencil operation to use when stencil fails
  31441. */
  31442. getStencilOperationFail(): number;
  31443. /**
  31444. * Gets the current stencil operation when depth fails
  31445. * @returns a number defining stencil operation to use when depth fails
  31446. */
  31447. getStencilOperationDepthFail(): number;
  31448. /**
  31449. * Gets the current stencil operation when stencil passes
  31450. * @returns a number defining stencil operation to use when stencil passes
  31451. */
  31452. getStencilOperationPass(): number;
  31453. /**
  31454. * Sets the stencil operation to use when stencil fails
  31455. * @param operation defines the stencil operation to use when stencil fails
  31456. */
  31457. setStencilOperationFail(operation: number): void;
  31458. /**
  31459. * Sets the stencil operation to use when depth fails
  31460. * @param operation defines the stencil operation to use when depth fails
  31461. */
  31462. setStencilOperationDepthFail(operation: number): void;
  31463. /**
  31464. * Sets the stencil operation to use when stencil passes
  31465. * @param operation defines the stencil operation to use when stencil passes
  31466. */
  31467. setStencilOperationPass(operation: number): void;
  31468. /**
  31469. * Sets a boolean indicating if the dithering state is enabled or disabled
  31470. * @param value defines the dithering state
  31471. */
  31472. setDitheringState(value: boolean): void;
  31473. /**
  31474. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  31475. * @param value defines the rasterizer state
  31476. */
  31477. setRasterizerState(value: boolean): void;
  31478. /**
  31479. * Gets the current depth function
  31480. * @returns a number defining the depth function
  31481. */
  31482. getDepthFunction(): Nullable<number>;
  31483. /**
  31484. * Sets the current depth function
  31485. * @param depthFunc defines the function to use
  31486. */
  31487. setDepthFunction(depthFunc: number): void;
  31488. /**
  31489. * Sets the current depth function to GREATER
  31490. */
  31491. setDepthFunctionToGreater(): void;
  31492. /**
  31493. * Sets the current depth function to GEQUAL
  31494. */
  31495. setDepthFunctionToGreaterOrEqual(): void;
  31496. /**
  31497. * Sets the current depth function to LESS
  31498. */
  31499. setDepthFunctionToLess(): void;
  31500. /**
  31501. * Sets the current depth function to LEQUAL
  31502. */
  31503. setDepthFunctionToLessOrEqual(): void;
  31504. private _cachedStencilBuffer;
  31505. private _cachedStencilFunction;
  31506. private _cachedStencilMask;
  31507. private _cachedStencilOperationPass;
  31508. private _cachedStencilOperationFail;
  31509. private _cachedStencilOperationDepthFail;
  31510. private _cachedStencilReference;
  31511. /**
  31512. * Caches the the state of the stencil buffer
  31513. */
  31514. cacheStencilState(): void;
  31515. /**
  31516. * Restores the state of the stencil buffer
  31517. */
  31518. restoreStencilState(): void;
  31519. /**
  31520. * Directly set the WebGL Viewport
  31521. * @param x defines the x coordinate of the viewport (in screen space)
  31522. * @param y defines the y coordinate of the viewport (in screen space)
  31523. * @param width defines the width of the viewport (in screen space)
  31524. * @param height defines the height of the viewport (in screen space)
  31525. * @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
  31526. */
  31527. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  31528. /**
  31529. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  31530. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  31531. * @param y defines the y-coordinate of the corner of the clear rectangle
  31532. * @param width defines the width of the clear rectangle
  31533. * @param height defines the height of the clear rectangle
  31534. * @param clearColor defines the clear color
  31535. */
  31536. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  31537. /**
  31538. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  31539. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  31540. * @param y defines the y-coordinate of the corner of the clear rectangle
  31541. * @param width defines the width of the clear rectangle
  31542. * @param height defines the height of the clear rectangle
  31543. */
  31544. enableScissor(x: number, y: number, width: number, height: number): void;
  31545. /**
  31546. * Disable previously set scissor test rectangle
  31547. */
  31548. disableScissor(): void;
  31549. protected _reportDrawCall(): void;
  31550. /**
  31551. * Initializes a webVR display and starts listening to display change events
  31552. * The onVRDisplayChangedObservable will be notified upon these changes
  31553. * @returns The onVRDisplayChangedObservable
  31554. */
  31555. initWebVR(): Observable<IDisplayChangedEventArgs>;
  31556. /** @hidden */
  31557. _prepareVRComponent(): void;
  31558. /** @hidden */
  31559. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  31560. /** @hidden */
  31561. _submitVRFrame(): void;
  31562. /**
  31563. * Call this function to leave webVR mode
  31564. * Will do nothing if webVR is not supported or if there is no webVR device
  31565. * @see http://doc.babylonjs.com/how_to/webvr_camera
  31566. */
  31567. disableVR(): void;
  31568. /**
  31569. * Gets a boolean indicating that the system is in VR mode and is presenting
  31570. * @returns true if VR mode is engaged
  31571. */
  31572. isVRPresenting(): boolean;
  31573. /** @hidden */
  31574. _requestVRFrame(): void;
  31575. /** @hidden */
  31576. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  31577. /**
  31578. * Gets the source code of the vertex shader associated with a specific webGL program
  31579. * @param program defines the program to use
  31580. * @returns a string containing the source code of the vertex shader associated with the program
  31581. */
  31582. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  31583. /**
  31584. * Gets the source code of the fragment shader associated with a specific webGL program
  31585. * @param program defines the program to use
  31586. * @returns a string containing the source code of the fragment shader associated with the program
  31587. */
  31588. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  31589. /**
  31590. * Reads pixels from the current frame buffer. Please note that this function can be slow
  31591. * @param x defines the x coordinate of the rectangle where pixels must be read
  31592. * @param y defines the y coordinate of the rectangle where pixels must be read
  31593. * @param width defines the width of the rectangle where pixels must be read
  31594. * @param height defines the height of the rectangle where pixels must be read
  31595. * @returns a Uint8Array containing RGBA colors
  31596. */
  31597. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  31598. /**
  31599. * Sets a depth stencil texture from a render target to the according uniform.
  31600. * @param channel The texture channel
  31601. * @param uniform The uniform to set
  31602. * @param texture The render target texture containing the depth stencil texture to apply
  31603. */
  31604. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  31605. /**
  31606. * Sets a texture to the webGL context from a postprocess
  31607. * @param channel defines the channel to use
  31608. * @param postProcess defines the source postprocess
  31609. */
  31610. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  31611. /**
  31612. * Binds the output of the passed in post process to the texture channel specified
  31613. * @param channel The channel the texture should be bound to
  31614. * @param postProcess The post process which's output should be bound
  31615. */
  31616. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  31617. /** @hidden */
  31618. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  31619. protected _rebuildBuffers(): void;
  31620. _renderLoop(): void;
  31621. /**
  31622. * Toggle full screen mode
  31623. * @param requestPointerLock defines if a pointer lock should be requested from the user
  31624. */
  31625. switchFullscreen(requestPointerLock: boolean): void;
  31626. /**
  31627. * Enters full screen mode
  31628. * @param requestPointerLock defines if a pointer lock should be requested from the user
  31629. */
  31630. enterFullscreen(requestPointerLock: boolean): void;
  31631. /**
  31632. * Exits full screen mode
  31633. */
  31634. exitFullscreen(): void;
  31635. /**
  31636. * Enters Pointerlock mode
  31637. */
  31638. enterPointerlock(): void;
  31639. /**
  31640. * Exits Pointerlock mode
  31641. */
  31642. exitPointerlock(): void;
  31643. /**
  31644. * Begin a new frame
  31645. */
  31646. beginFrame(): void;
  31647. /**
  31648. * Enf the current frame
  31649. */
  31650. endFrame(): void;
  31651. resize(): void;
  31652. /**
  31653. * Set the compressed texture format to use, based on the formats you have, and the formats
  31654. * supported by the hardware / browser.
  31655. *
  31656. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  31657. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  31658. * to API arguments needed to compressed textures. This puts the burden on the container
  31659. * generator to house the arcane code for determining these for current & future formats.
  31660. *
  31661. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  31662. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  31663. *
  31664. * Note: The result of this call is not taken into account when a texture is base64.
  31665. *
  31666. * @param formatsAvailable defines the list of those format families you have created
  31667. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  31668. *
  31669. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  31670. * @returns The extension selected.
  31671. */
  31672. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  31673. /**
  31674. * Force a specific size of the canvas
  31675. * @param width defines the new canvas' width
  31676. * @param height defines the new canvas' height
  31677. */
  31678. setSize(width: number, height: number): void;
  31679. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  31680. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31681. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31682. _releaseTexture(texture: InternalTexture): void;
  31683. /**
  31684. * @hidden
  31685. * Rescales a texture
  31686. * @param source input texutre
  31687. * @param destination destination texture
  31688. * @param scene scene to use to render the resize
  31689. * @param internalFormat format to use when resizing
  31690. * @param onComplete callback to be called when resize has completed
  31691. */
  31692. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  31693. /**
  31694. * Gets the current framerate
  31695. * @returns a number representing the framerate
  31696. */
  31697. getFps(): number;
  31698. /**
  31699. * Gets the time spent between current and previous frame
  31700. * @returns a number representing the delta time in ms
  31701. */
  31702. getDeltaTime(): number;
  31703. private _measureFps;
  31704. /**
  31705. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  31706. * @param renderTarget The render target to set the frame buffer for
  31707. */
  31708. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  31709. /**
  31710. * Update a dynamic index buffer
  31711. * @param indexBuffer defines the target index buffer
  31712. * @param indices defines the data to update
  31713. * @param offset defines the offset in the target index buffer where update should start
  31714. */
  31715. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  31716. /**
  31717. * Updates the sample count of a render target texture
  31718. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  31719. * @param texture defines the texture to update
  31720. * @param samples defines the sample count to set
  31721. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  31722. */
  31723. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  31724. /** @hidden */
  31725. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  31726. dispose(): void;
  31727. private _disableTouchAction;
  31728. /**
  31729. * Display the loading screen
  31730. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31731. */
  31732. displayLoadingUI(): void;
  31733. /**
  31734. * Hide the loading screen
  31735. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31736. */
  31737. hideLoadingUI(): void;
  31738. /**
  31739. * Gets the current loading screen object
  31740. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31741. */
  31742. /**
  31743. * Sets the current loading screen object
  31744. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31745. */
  31746. loadingScreen: ILoadingScreen;
  31747. /**
  31748. * Sets the current loading screen text
  31749. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31750. */
  31751. loadingUIText: string;
  31752. /**
  31753. * Sets the current loading screen background color
  31754. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31755. */
  31756. loadingUIBackgroundColor: string;
  31757. /** Pointerlock and fullscreen */
  31758. /**
  31759. * Ask the browser to promote the current element to pointerlock mode
  31760. * @param element defines the DOM element to promote
  31761. */
  31762. static _RequestPointerlock(element: HTMLElement): void;
  31763. /**
  31764. * Asks the browser to exit pointerlock mode
  31765. */
  31766. static _ExitPointerlock(): void;
  31767. /**
  31768. * Ask the browser to promote the current element to fullscreen rendering mode
  31769. * @param element defines the DOM element to promote
  31770. */
  31771. static _RequestFullscreen(element: HTMLElement): void;
  31772. /**
  31773. * Asks the browser to exit fullscreen mode
  31774. */
  31775. static _ExitFullscreen(): void;
  31776. }
  31777. }
  31778. declare module BABYLON {
  31779. /**
  31780. * The engine store class is responsible to hold all the instances of Engine and Scene created
  31781. * during the life time of the application.
  31782. */
  31783. export class EngineStore {
  31784. /** Gets the list of created engines */
  31785. static Instances: Engine[];
  31786. /** @hidden */
  31787. static _LastCreatedScene: Nullable<Scene>;
  31788. /**
  31789. * Gets the latest created engine
  31790. */
  31791. static readonly LastCreatedEngine: Nullable<Engine>;
  31792. /**
  31793. * Gets the latest created scene
  31794. */
  31795. static readonly LastCreatedScene: Nullable<Scene>;
  31796. /**
  31797. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  31798. * @ignorenaming
  31799. */
  31800. static UseFallbackTexture: boolean;
  31801. /**
  31802. * Texture content used if a texture cannot loaded
  31803. * @ignorenaming
  31804. */
  31805. static FallbackTexture: string;
  31806. }
  31807. }
  31808. declare module BABYLON {
  31809. /**
  31810. * Helper class that provides a small promise polyfill
  31811. */
  31812. export class PromisePolyfill {
  31813. /**
  31814. * Static function used to check if the polyfill is required
  31815. * If this is the case then the function will inject the polyfill to window.Promise
  31816. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  31817. */
  31818. static Apply(force?: boolean): void;
  31819. }
  31820. }
  31821. declare module BABYLON {
  31822. /**
  31823. * Interface for screenshot methods with describe argument called `size` as object with options
  31824. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  31825. */
  31826. export interface IScreenshotSize {
  31827. /**
  31828. * number in pixels for canvas height
  31829. */
  31830. height?: number;
  31831. /**
  31832. * multiplier allowing render at a higher or lower resolution
  31833. * If value is defined then height and width will be ignored and taken from camera
  31834. */
  31835. precision?: number;
  31836. /**
  31837. * number in pixels for canvas width
  31838. */
  31839. width?: number;
  31840. }
  31841. }
  31842. declare module BABYLON {
  31843. interface IColor4Like {
  31844. r: float;
  31845. g: float;
  31846. b: float;
  31847. a: float;
  31848. }
  31849. /**
  31850. * Class containing a set of static utilities functions
  31851. */
  31852. export class Tools {
  31853. /**
  31854. * Gets or sets the base URL to use to load assets
  31855. */
  31856. static BaseUrl: string;
  31857. /**
  31858. * Enable/Disable Custom HTTP Request Headers globally.
  31859. * default = false
  31860. * @see CustomRequestHeaders
  31861. */
  31862. static UseCustomRequestHeaders: boolean;
  31863. /**
  31864. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  31865. * i.e. when loading files, where the server/service expects an Authorization header
  31866. */
  31867. static CustomRequestHeaders: {
  31868. [key: string]: string;
  31869. };
  31870. /**
  31871. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  31872. */
  31873. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  31874. /**
  31875. * Default behaviour for cors in the application.
  31876. * It can be a string if the expected behavior is identical in the entire app.
  31877. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  31878. */
  31879. static CorsBehavior: string | ((url: string | string[]) => string);
  31880. /**
  31881. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  31882. * @ignorenaming
  31883. */
  31884. static UseFallbackTexture: boolean;
  31885. /**
  31886. * Use this object to register external classes like custom textures or material
  31887. * to allow the laoders to instantiate them
  31888. */
  31889. static RegisteredExternalClasses: {
  31890. [key: string]: Object;
  31891. };
  31892. /**
  31893. * Texture content used if a texture cannot loaded
  31894. * @ignorenaming
  31895. */
  31896. static fallbackTexture: string;
  31897. /**
  31898. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  31899. * @param u defines the coordinate on X axis
  31900. * @param v defines the coordinate on Y axis
  31901. * @param width defines the width of the source data
  31902. * @param height defines the height of the source data
  31903. * @param pixels defines the source byte array
  31904. * @param color defines the output color
  31905. */
  31906. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  31907. /**
  31908. * Interpolates between a and b via alpha
  31909. * @param a The lower value (returned when alpha = 0)
  31910. * @param b The upper value (returned when alpha = 1)
  31911. * @param alpha The interpolation-factor
  31912. * @return The mixed value
  31913. */
  31914. static Mix(a: number, b: number, alpha: number): number;
  31915. /**
  31916. * Tries to instantiate a new object from a given class name
  31917. * @param className defines the class name to instantiate
  31918. * @returns the new object or null if the system was not able to do the instantiation
  31919. */
  31920. static Instantiate(className: string): any;
  31921. /**
  31922. * Provides a slice function that will work even on IE
  31923. * @param data defines the array to slice
  31924. * @param start defines the start of the data (optional)
  31925. * @param end defines the end of the data (optional)
  31926. * @returns the new sliced array
  31927. */
  31928. static Slice<T>(data: T, start?: number, end?: number): T;
  31929. /**
  31930. * Polyfill for setImmediate
  31931. * @param action defines the action to execute after the current execution block
  31932. */
  31933. static SetImmediate(action: () => void): void;
  31934. /**
  31935. * Function indicating if a number is an exponent of 2
  31936. * @param value defines the value to test
  31937. * @returns true if the value is an exponent of 2
  31938. */
  31939. static IsExponentOfTwo(value: number): boolean;
  31940. private static _tmpFloatArray;
  31941. /**
  31942. * Returns the nearest 32-bit single precision float representation of a Number
  31943. * @param value A Number. If the parameter is of a different type, it will get converted
  31944. * to a number or to NaN if it cannot be converted
  31945. * @returns number
  31946. */
  31947. static FloatRound(value: number): number;
  31948. /**
  31949. * Extracts the filename from a path
  31950. * @param path defines the path to use
  31951. * @returns the filename
  31952. */
  31953. static GetFilename(path: string): string;
  31954. /**
  31955. * Extracts the "folder" part of a path (everything before the filename).
  31956. * @param uri The URI to extract the info from
  31957. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  31958. * @returns The "folder" part of the path
  31959. */
  31960. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  31961. /**
  31962. * Extracts text content from a DOM element hierarchy
  31963. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  31964. */
  31965. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  31966. /**
  31967. * Convert an angle in radians to degrees
  31968. * @param angle defines the angle to convert
  31969. * @returns the angle in degrees
  31970. */
  31971. static ToDegrees(angle: number): number;
  31972. /**
  31973. * Convert an angle in degrees to radians
  31974. * @param angle defines the angle to convert
  31975. * @returns the angle in radians
  31976. */
  31977. static ToRadians(angle: number): number;
  31978. /**
  31979. * Encode a buffer to a base64 string
  31980. * @param buffer defines the buffer to encode
  31981. * @returns the encoded string
  31982. */
  31983. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  31984. /**
  31985. * Returns an array if obj is not an array
  31986. * @param obj defines the object to evaluate as an array
  31987. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  31988. * @returns either obj directly if obj is an array or a new array containing obj
  31989. */
  31990. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  31991. /**
  31992. * Gets the pointer prefix to use
  31993. * @returns "pointer" if touch is enabled. Else returns "mouse"
  31994. */
  31995. static GetPointerPrefix(): string;
  31996. /**
  31997. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  31998. * @param url define the url we are trying
  31999. * @param element define the dom element where to configure the cors policy
  32000. */
  32001. static SetCorsBehavior(url: string | string[], element: {
  32002. crossOrigin: string | null;
  32003. }): void;
  32004. /**
  32005. * Removes unwanted characters from an url
  32006. * @param url defines the url to clean
  32007. * @returns the cleaned url
  32008. */
  32009. static CleanUrl(url: string): string;
  32010. /**
  32011. * Gets or sets a function used to pre-process url before using them to load assets
  32012. */
  32013. static PreprocessUrl: (url: string) => string;
  32014. /**
  32015. * Loads an image as an HTMLImageElement.
  32016. * @param input url string, ArrayBuffer, or Blob to load
  32017. * @param onLoad callback called when the image successfully loads
  32018. * @param onError callback called when the image fails to load
  32019. * @param offlineProvider offline provider for caching
  32020. * @returns the HTMLImageElement of the loaded image
  32021. */
  32022. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  32023. /**
  32024. * Loads a file
  32025. * @param url url string, ArrayBuffer, or Blob to load
  32026. * @param onSuccess callback called when the file successfully loads
  32027. * @param onProgress callback called while file is loading (if the server supports this mode)
  32028. * @param offlineProvider defines the offline provider for caching
  32029. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  32030. * @param onError callback called when the file fails to load
  32031. * @returns a file request object
  32032. */
  32033. 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;
  32034. /**
  32035. * Loads a file from a url
  32036. * @param url the file url to load
  32037. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  32038. */
  32039. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  32040. /**
  32041. * Load a script (identified by an url). When the url returns, the
  32042. * content of this file is added into a new script element, attached to the DOM (body element)
  32043. * @param scriptUrl defines the url of the script to laod
  32044. * @param onSuccess defines the callback called when the script is loaded
  32045. * @param onError defines the callback to call if an error occurs
  32046. * @param scriptId defines the id of the script element
  32047. */
  32048. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  32049. /**
  32050. * Load an asynchronous script (identified by an url). When the url returns, the
  32051. * content of this file is added into a new script element, attached to the DOM (body element)
  32052. * @param scriptUrl defines the url of the script to laod
  32053. * @param scriptId defines the id of the script element
  32054. * @returns a promise request object
  32055. */
  32056. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  32057. /**
  32058. * Loads a file from a blob
  32059. * @param fileToLoad defines the blob to use
  32060. * @param callback defines the callback to call when data is loaded
  32061. * @param progressCallback defines the callback to call during loading process
  32062. * @returns a file request object
  32063. */
  32064. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  32065. /**
  32066. * Loads a file
  32067. * @param fileToLoad defines the file to load
  32068. * @param callback defines the callback to call when data is loaded
  32069. * @param progressCallBack defines the callback to call during loading process
  32070. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  32071. * @returns a file request object
  32072. */
  32073. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  32074. /**
  32075. * Creates a data url from a given string content
  32076. * @param content defines the content to convert
  32077. * @returns the new data url link
  32078. */
  32079. static FileAsURL(content: string): string;
  32080. /**
  32081. * Format the given number to a specific decimal format
  32082. * @param value defines the number to format
  32083. * @param decimals defines the number of decimals to use
  32084. * @returns the formatted string
  32085. */
  32086. static Format(value: number, decimals?: number): string;
  32087. /**
  32088. * Tries to copy an object by duplicating every property
  32089. * @param source defines the source object
  32090. * @param destination defines the target object
  32091. * @param doNotCopyList defines a list of properties to avoid
  32092. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  32093. */
  32094. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  32095. /**
  32096. * Gets a boolean indicating if the given object has no own property
  32097. * @param obj defines the object to test
  32098. * @returns true if object has no own property
  32099. */
  32100. static IsEmpty(obj: any): boolean;
  32101. /**
  32102. * Function used to register events at window level
  32103. * @param windowElement defines the Window object to use
  32104. * @param events defines the events to register
  32105. */
  32106. static RegisterTopRootEvents(windowElement: Window, events: {
  32107. name: string;
  32108. handler: Nullable<(e: FocusEvent) => any>;
  32109. }[]): void;
  32110. /**
  32111. * Function used to unregister events from window level
  32112. * @param windowElement defines the Window object to use
  32113. * @param events defines the events to unregister
  32114. */
  32115. static UnregisterTopRootEvents(windowElement: Window, events: {
  32116. name: string;
  32117. handler: Nullable<(e: FocusEvent) => any>;
  32118. }[]): void;
  32119. /**
  32120. * @ignore
  32121. */
  32122. static _ScreenshotCanvas: HTMLCanvasElement;
  32123. /**
  32124. * Dumps the current bound framebuffer
  32125. * @param width defines the rendering width
  32126. * @param height defines the rendering height
  32127. * @param engine defines the hosting engine
  32128. * @param successCallback defines the callback triggered once the data are available
  32129. * @param mimeType defines the mime type of the result
  32130. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  32131. */
  32132. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  32133. /**
  32134. * Converts the canvas data to blob.
  32135. * This acts as a polyfill for browsers not supporting the to blob function.
  32136. * @param canvas Defines the canvas to extract the data from
  32137. * @param successCallback Defines the callback triggered once the data are available
  32138. * @param mimeType Defines the mime type of the result
  32139. */
  32140. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  32141. /**
  32142. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  32143. * @param successCallback defines the callback triggered once the data are available
  32144. * @param mimeType defines the mime type of the result
  32145. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  32146. */
  32147. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  32148. /**
  32149. * Downloads a blob in the browser
  32150. * @param blob defines the blob to download
  32151. * @param fileName defines the name of the downloaded file
  32152. */
  32153. static Download(blob: Blob, fileName: string): void;
  32154. /**
  32155. * Captures a screenshot of the current rendering
  32156. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32157. * @param engine defines the rendering engine
  32158. * @param camera defines the source camera
  32159. * @param size This parameter can be set to a single number or to an object with the
  32160. * following (optional) properties: precision, width, height. If a single number is passed,
  32161. * it will be used for both width and height. If an object is passed, the screenshot size
  32162. * will be derived from the parameters. The precision property is a multiplier allowing
  32163. * rendering at a higher or lower resolution
  32164. * @param successCallback defines the callback receives a single parameter which contains the
  32165. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  32166. * src parameter of an <img> to display it
  32167. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  32168. * Check your browser for supported MIME types
  32169. */
  32170. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  32171. /**
  32172. * Captures a screenshot of the current rendering
  32173. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32174. * @param engine defines the rendering engine
  32175. * @param camera defines the source camera
  32176. * @param size This parameter can be set to a single number or to an object with the
  32177. * following (optional) properties: precision, width, height. If a single number is passed,
  32178. * it will be used for both width and height. If an object is passed, the screenshot size
  32179. * will be derived from the parameters. The precision property is a multiplier allowing
  32180. * rendering at a higher or lower resolution
  32181. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  32182. * Check your browser for supported MIME types
  32183. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  32184. * to the src parameter of an <img> to display it
  32185. */
  32186. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  32187. /**
  32188. * Generates an image screenshot from the specified camera.
  32189. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32190. * @param engine The engine to use for rendering
  32191. * @param camera The camera to use for rendering
  32192. * @param size This parameter can be set to a single number or to an object with the
  32193. * following (optional) properties: precision, width, height. If a single number is passed,
  32194. * it will be used for both width and height. If an object is passed, the screenshot size
  32195. * will be derived from the parameters. The precision property is a multiplier allowing
  32196. * rendering at a higher or lower resolution
  32197. * @param successCallback The callback receives a single parameter which contains the
  32198. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  32199. * src parameter of an <img> to display it
  32200. * @param mimeType The MIME type of the screenshot image (default: image/png).
  32201. * Check your browser for supported MIME types
  32202. * @param samples Texture samples (default: 1)
  32203. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  32204. * @param fileName A name for for the downloaded file.
  32205. */
  32206. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  32207. /**
  32208. * Generates an image screenshot from the specified camera.
  32209. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32210. * @param engine The engine to use for rendering
  32211. * @param camera The camera to use for rendering
  32212. * @param size This parameter can be set to a single number or to an object with the
  32213. * following (optional) properties: precision, width, height. If a single number is passed,
  32214. * it will be used for both width and height. If an object is passed, the screenshot size
  32215. * will be derived from the parameters. The precision property is a multiplier allowing
  32216. * rendering at a higher or lower resolution
  32217. * @param mimeType The MIME type of the screenshot image (default: image/png).
  32218. * Check your browser for supported MIME types
  32219. * @param samples Texture samples (default: 1)
  32220. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  32221. * @param fileName A name for for the downloaded file.
  32222. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  32223. * to the src parameter of an <img> to display it
  32224. */
  32225. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  32226. /**
  32227. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  32228. * Be aware Math.random() could cause collisions, but:
  32229. * "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"
  32230. * @returns a pseudo random id
  32231. */
  32232. static RandomId(): string;
  32233. /**
  32234. * Test if the given uri is a base64 string
  32235. * @param uri The uri to test
  32236. * @return True if the uri is a base64 string or false otherwise
  32237. */
  32238. static IsBase64(uri: string): boolean;
  32239. /**
  32240. * Decode the given base64 uri.
  32241. * @param uri The uri to decode
  32242. * @return The decoded base64 data.
  32243. */
  32244. static DecodeBase64(uri: string): ArrayBuffer;
  32245. /**
  32246. * Gets the absolute url.
  32247. * @param url the input url
  32248. * @return the absolute url
  32249. */
  32250. static GetAbsoluteUrl(url: string): string;
  32251. /**
  32252. * No log
  32253. */
  32254. static readonly NoneLogLevel: number;
  32255. /**
  32256. * Only message logs
  32257. */
  32258. static readonly MessageLogLevel: number;
  32259. /**
  32260. * Only warning logs
  32261. */
  32262. static readonly WarningLogLevel: number;
  32263. /**
  32264. * Only error logs
  32265. */
  32266. static readonly ErrorLogLevel: number;
  32267. /**
  32268. * All logs
  32269. */
  32270. static readonly AllLogLevel: number;
  32271. /**
  32272. * Gets a value indicating the number of loading errors
  32273. * @ignorenaming
  32274. */
  32275. static readonly errorsCount: number;
  32276. /**
  32277. * Callback called when a new log is added
  32278. */
  32279. static OnNewCacheEntry: (entry: string) => void;
  32280. /**
  32281. * Log a message to the console
  32282. * @param message defines the message to log
  32283. */
  32284. static Log(message: string): void;
  32285. /**
  32286. * Write a warning message to the console
  32287. * @param message defines the message to log
  32288. */
  32289. static Warn(message: string): void;
  32290. /**
  32291. * Write an error message to the console
  32292. * @param message defines the message to log
  32293. */
  32294. static Error(message: string): void;
  32295. /**
  32296. * Gets current log cache (list of logs)
  32297. */
  32298. static readonly LogCache: string;
  32299. /**
  32300. * Clears the log cache
  32301. */
  32302. static ClearLogCache(): void;
  32303. /**
  32304. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  32305. */
  32306. static LogLevels: number;
  32307. /**
  32308. * Checks if the window object exists
  32309. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  32310. */
  32311. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  32312. /**
  32313. * No performance log
  32314. */
  32315. static readonly PerformanceNoneLogLevel: number;
  32316. /**
  32317. * Use user marks to log performance
  32318. */
  32319. static readonly PerformanceUserMarkLogLevel: number;
  32320. /**
  32321. * Log performance to the console
  32322. */
  32323. static readonly PerformanceConsoleLogLevel: number;
  32324. private static _performance;
  32325. /**
  32326. * Sets the current performance log level
  32327. */
  32328. static PerformanceLogLevel: number;
  32329. private static _StartPerformanceCounterDisabled;
  32330. private static _EndPerformanceCounterDisabled;
  32331. private static _StartUserMark;
  32332. private static _EndUserMark;
  32333. private static _StartPerformanceConsole;
  32334. private static _EndPerformanceConsole;
  32335. /**
  32336. * Starts a performance counter
  32337. */
  32338. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  32339. /**
  32340. * Ends a specific performance coutner
  32341. */
  32342. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  32343. /**
  32344. * Gets either window.performance.now() if supported or Date.now() else
  32345. */
  32346. static readonly Now: number;
  32347. /**
  32348. * This method will return the name of the class used to create the instance of the given object.
  32349. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  32350. * @param object the object to get the class name from
  32351. * @param isType defines if the object is actually a type
  32352. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  32353. */
  32354. static GetClassName(object: any, isType?: boolean): string;
  32355. /**
  32356. * Gets the first element of an array satisfying a given predicate
  32357. * @param array defines the array to browse
  32358. * @param predicate defines the predicate to use
  32359. * @returns null if not found or the element
  32360. */
  32361. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  32362. /**
  32363. * This method will return the name of the full name of the class, including its owning module (if any).
  32364. * 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).
  32365. * @param object the object to get the class name from
  32366. * @param isType defines if the object is actually a type
  32367. * @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.
  32368. * @ignorenaming
  32369. */
  32370. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  32371. /**
  32372. * Returns a promise that resolves after the given amount of time.
  32373. * @param delay Number of milliseconds to delay
  32374. * @returns Promise that resolves after the given amount of time
  32375. */
  32376. static DelayAsync(delay: number): Promise<void>;
  32377. }
  32378. /**
  32379. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  32380. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  32381. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  32382. * @param name The name of the class, case should be preserved
  32383. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  32384. */
  32385. export function className(name: string, module?: string): (target: Object) => void;
  32386. /**
  32387. * An implementation of a loop for asynchronous functions.
  32388. */
  32389. export class AsyncLoop {
  32390. /**
  32391. * Defines the number of iterations for the loop
  32392. */
  32393. iterations: number;
  32394. /**
  32395. * Defines the current index of the loop.
  32396. */
  32397. index: number;
  32398. private _done;
  32399. private _fn;
  32400. private _successCallback;
  32401. /**
  32402. * Constructor.
  32403. * @param iterations the number of iterations.
  32404. * @param func the function to run each iteration
  32405. * @param successCallback the callback that will be called upon succesful execution
  32406. * @param offset starting offset.
  32407. */
  32408. constructor(
  32409. /**
  32410. * Defines the number of iterations for the loop
  32411. */
  32412. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  32413. /**
  32414. * Execute the next iteration. Must be called after the last iteration was finished.
  32415. */
  32416. executeNext(): void;
  32417. /**
  32418. * Break the loop and run the success callback.
  32419. */
  32420. breakLoop(): void;
  32421. /**
  32422. * Create and run an async loop.
  32423. * @param iterations the number of iterations.
  32424. * @param fn the function to run each iteration
  32425. * @param successCallback the callback that will be called upon succesful execution
  32426. * @param offset starting offset.
  32427. * @returns the created async loop object
  32428. */
  32429. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  32430. /**
  32431. * A for-loop that will run a given number of iterations synchronous and the rest async.
  32432. * @param iterations total number of iterations
  32433. * @param syncedIterations number of synchronous iterations in each async iteration.
  32434. * @param fn the function to call each iteration.
  32435. * @param callback a success call back that will be called when iterating stops.
  32436. * @param breakFunction a break condition (optional)
  32437. * @param timeout timeout settings for the setTimeout function. default - 0.
  32438. * @returns the created async loop object
  32439. */
  32440. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  32441. }
  32442. }
  32443. declare module BABYLON {
  32444. /**
  32445. * This class implement a typical dictionary using a string as key and the generic type T as value.
  32446. * The underlying implementation relies on an associative array to ensure the best performances.
  32447. * The value can be anything including 'null' but except 'undefined'
  32448. */
  32449. export class StringDictionary<T> {
  32450. /**
  32451. * This will clear this dictionary and copy the content from the 'source' one.
  32452. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  32453. * @param source the dictionary to take the content from and copy to this dictionary
  32454. */
  32455. copyFrom(source: StringDictionary<T>): void;
  32456. /**
  32457. * Get a value based from its key
  32458. * @param key the given key to get the matching value from
  32459. * @return the value if found, otherwise undefined is returned
  32460. */
  32461. get(key: string): T | undefined;
  32462. /**
  32463. * Get a value from its key or add it if it doesn't exist.
  32464. * This method will ensure you that a given key/data will be present in the dictionary.
  32465. * @param key the given key to get the matching value from
  32466. * @param factory the factory that will create the value if the key is not present in the dictionary.
  32467. * The factory will only be invoked if there's no data for the given key.
  32468. * @return the value corresponding to the key.
  32469. */
  32470. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  32471. /**
  32472. * Get a value from its key if present in the dictionary otherwise add it
  32473. * @param key the key to get the value from
  32474. * @param val if there's no such key/value pair in the dictionary add it with this value
  32475. * @return the value corresponding to the key
  32476. */
  32477. getOrAdd(key: string, val: T): T;
  32478. /**
  32479. * Check if there's a given key in the dictionary
  32480. * @param key the key to check for
  32481. * @return true if the key is present, false otherwise
  32482. */
  32483. contains(key: string): boolean;
  32484. /**
  32485. * Add a new key and its corresponding value
  32486. * @param key the key to add
  32487. * @param value the value corresponding to the key
  32488. * @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
  32489. */
  32490. add(key: string, value: T): boolean;
  32491. /**
  32492. * Update a specific value associated to a key
  32493. * @param key defines the key to use
  32494. * @param value defines the value to store
  32495. * @returns true if the value was updated (or false if the key was not found)
  32496. */
  32497. set(key: string, value: T): boolean;
  32498. /**
  32499. * Get the element of the given key and remove it from the dictionary
  32500. * @param key defines the key to search
  32501. * @returns the value associated with the key or null if not found
  32502. */
  32503. getAndRemove(key: string): Nullable<T>;
  32504. /**
  32505. * Remove a key/value from the dictionary.
  32506. * @param key the key to remove
  32507. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  32508. */
  32509. remove(key: string): boolean;
  32510. /**
  32511. * Clear the whole content of the dictionary
  32512. */
  32513. clear(): void;
  32514. /**
  32515. * Gets the current count
  32516. */
  32517. readonly count: number;
  32518. /**
  32519. * Execute a callback on each key/val of the dictionary.
  32520. * Note that you can remove any element in this dictionary in the callback implementation
  32521. * @param callback the callback to execute on a given key/value pair
  32522. */
  32523. forEach(callback: (key: string, val: T) => void): void;
  32524. /**
  32525. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  32526. * If the callback returns null or undefined the method will iterate to the next key/value pair
  32527. * Note that you can remove any element in this dictionary in the callback implementation
  32528. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  32529. * @returns the first item
  32530. */
  32531. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  32532. private _count;
  32533. private _data;
  32534. }
  32535. }
  32536. declare module BABYLON {
  32537. /** @hidden */
  32538. export interface ICollisionCoordinator {
  32539. createCollider(): Collider;
  32540. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  32541. init(scene: Scene): void;
  32542. }
  32543. /** @hidden */
  32544. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  32545. private _scene;
  32546. private _scaledPosition;
  32547. private _scaledVelocity;
  32548. private _finalPosition;
  32549. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  32550. createCollider(): Collider;
  32551. init(scene: Scene): void;
  32552. private _collideWithWorld;
  32553. }
  32554. }
  32555. declare module BABYLON {
  32556. /**
  32557. * Class used to manage all inputs for the scene.
  32558. */
  32559. export class InputManager {
  32560. /** The distance in pixel that you have to move to prevent some events */
  32561. static DragMovementThreshold: number;
  32562. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  32563. static LongPressDelay: number;
  32564. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  32565. static DoubleClickDelay: number;
  32566. /** If you need to check double click without raising a single click at first click, enable this flag */
  32567. static ExclusiveDoubleClickMode: boolean;
  32568. private _wheelEventName;
  32569. private _onPointerMove;
  32570. private _onPointerDown;
  32571. private _onPointerUp;
  32572. private _initClickEvent;
  32573. private _initActionManager;
  32574. private _delayedSimpleClick;
  32575. private _delayedSimpleClickTimeout;
  32576. private _previousDelayedSimpleClickTimeout;
  32577. private _meshPickProceed;
  32578. private _previousButtonPressed;
  32579. private _currentPickResult;
  32580. private _previousPickResult;
  32581. private _totalPointersPressed;
  32582. private _doubleClickOccured;
  32583. private _pointerOverMesh;
  32584. private _pickedDownMesh;
  32585. private _pickedUpMesh;
  32586. private _pointerX;
  32587. private _pointerY;
  32588. private _unTranslatedPointerX;
  32589. private _unTranslatedPointerY;
  32590. private _startingPointerPosition;
  32591. private _previousStartingPointerPosition;
  32592. private _startingPointerTime;
  32593. private _previousStartingPointerTime;
  32594. private _pointerCaptures;
  32595. private _onKeyDown;
  32596. private _onKeyUp;
  32597. private _onCanvasFocusObserver;
  32598. private _onCanvasBlurObserver;
  32599. private _scene;
  32600. /**
  32601. * Creates a new InputManager
  32602. * @param scene defines the hosting scene
  32603. */
  32604. constructor(scene: Scene);
  32605. /**
  32606. * Gets the mesh that is currently under the pointer
  32607. */
  32608. readonly meshUnderPointer: Nullable<AbstractMesh>;
  32609. /**
  32610. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  32611. */
  32612. readonly unTranslatedPointer: Vector2;
  32613. /**
  32614. * Gets or sets the current on-screen X position of the pointer
  32615. */
  32616. pointerX: number;
  32617. /**
  32618. * Gets or sets the current on-screen Y position of the pointer
  32619. */
  32620. pointerY: number;
  32621. private _updatePointerPosition;
  32622. private _processPointerMove;
  32623. private _setRayOnPointerInfo;
  32624. private _checkPrePointerObservable;
  32625. /**
  32626. * Use this method to simulate a pointer move on a mesh
  32627. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32628. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32629. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32630. */
  32631. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  32632. /**
  32633. * Use this method to simulate a pointer down on a mesh
  32634. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32635. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32636. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32637. */
  32638. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  32639. private _processPointerDown;
  32640. /** @hidden */
  32641. _isPointerSwiping(): boolean;
  32642. /**
  32643. * Use this method to simulate a pointer up on a mesh
  32644. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32645. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32646. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32647. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  32648. */
  32649. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  32650. private _processPointerUp;
  32651. /**
  32652. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  32653. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  32654. * @returns true if the pointer was captured
  32655. */
  32656. isPointerCaptured(pointerId?: number): boolean;
  32657. /**
  32658. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  32659. * @param attachUp defines if you want to attach events to pointerup
  32660. * @param attachDown defines if you want to attach events to pointerdown
  32661. * @param attachMove defines if you want to attach events to pointermove
  32662. */
  32663. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  32664. /**
  32665. * Detaches all event handlers
  32666. */
  32667. detachControl(): void;
  32668. /**
  32669. * Force the value of meshUnderPointer
  32670. * @param mesh defines the mesh to use
  32671. */
  32672. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  32673. /**
  32674. * Gets the mesh under the pointer
  32675. * @returns a Mesh or null if no mesh is under the pointer
  32676. */
  32677. getPointerOverMesh(): Nullable<AbstractMesh>;
  32678. }
  32679. }
  32680. declare module BABYLON {
  32681. /**
  32682. * Helper class used to generate session unique ID
  32683. */
  32684. export class UniqueIdGenerator {
  32685. private static _UniqueIdCounter;
  32686. /**
  32687. * Gets an unique (relatively to the current scene) Id
  32688. */
  32689. static readonly UniqueId: number;
  32690. }
  32691. }
  32692. declare module BABYLON {
  32693. /**
  32694. * This class defines the direct association between an animation and a target
  32695. */
  32696. export class TargetedAnimation {
  32697. /**
  32698. * Animation to perform
  32699. */
  32700. animation: Animation;
  32701. /**
  32702. * Target to animate
  32703. */
  32704. target: any;
  32705. /**
  32706. * Serialize the object
  32707. * @returns the JSON object representing the current entity
  32708. */
  32709. serialize(): any;
  32710. }
  32711. /**
  32712. * Use this class to create coordinated animations on multiple targets
  32713. */
  32714. export class AnimationGroup implements IDisposable {
  32715. /** The name of the animation group */
  32716. name: string;
  32717. private _scene;
  32718. private _targetedAnimations;
  32719. private _animatables;
  32720. private _from;
  32721. private _to;
  32722. private _isStarted;
  32723. private _isPaused;
  32724. private _speedRatio;
  32725. private _loopAnimation;
  32726. /**
  32727. * Gets or sets the unique id of the node
  32728. */
  32729. uniqueId: number;
  32730. /**
  32731. * This observable will notify when one animation have ended
  32732. */
  32733. onAnimationEndObservable: Observable<TargetedAnimation>;
  32734. /**
  32735. * Observer raised when one animation loops
  32736. */
  32737. onAnimationLoopObservable: Observable<TargetedAnimation>;
  32738. /**
  32739. * This observable will notify when all animations have ended.
  32740. */
  32741. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  32742. /**
  32743. * This observable will notify when all animations have paused.
  32744. */
  32745. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  32746. /**
  32747. * This observable will notify when all animations are playing.
  32748. */
  32749. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  32750. /**
  32751. * Gets the first frame
  32752. */
  32753. readonly from: number;
  32754. /**
  32755. * Gets the last frame
  32756. */
  32757. readonly to: number;
  32758. /**
  32759. * Define if the animations are started
  32760. */
  32761. readonly isStarted: boolean;
  32762. /**
  32763. * Gets a value indicating that the current group is playing
  32764. */
  32765. readonly isPlaying: boolean;
  32766. /**
  32767. * Gets or sets the speed ratio to use for all animations
  32768. */
  32769. /**
  32770. * Gets or sets the speed ratio to use for all animations
  32771. */
  32772. speedRatio: number;
  32773. /**
  32774. * Gets or sets if all animations should loop or not
  32775. */
  32776. loopAnimation: boolean;
  32777. /**
  32778. * Gets the targeted animations for this animation group
  32779. */
  32780. readonly targetedAnimations: Array<TargetedAnimation>;
  32781. /**
  32782. * returning the list of animatables controlled by this animation group.
  32783. */
  32784. readonly animatables: Array<Animatable>;
  32785. /**
  32786. * Instantiates a new Animation Group.
  32787. * This helps managing several animations at once.
  32788. * @see http://doc.babylonjs.com/how_to/group
  32789. * @param name Defines the name of the group
  32790. * @param scene Defines the scene the group belongs to
  32791. */
  32792. constructor(
  32793. /** The name of the animation group */
  32794. name: string, scene?: Nullable<Scene>);
  32795. /**
  32796. * Add an animation (with its target) in the group
  32797. * @param animation defines the animation we want to add
  32798. * @param target defines the target of the animation
  32799. * @returns the TargetedAnimation object
  32800. */
  32801. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  32802. /**
  32803. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  32804. * It can add constant keys at begin or end
  32805. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  32806. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  32807. * @returns the animation group
  32808. */
  32809. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  32810. /**
  32811. * Start all animations on given targets
  32812. * @param loop defines if animations must loop
  32813. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  32814. * @param from defines the from key (optional)
  32815. * @param to defines the to key (optional)
  32816. * @returns the current animation group
  32817. */
  32818. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  32819. /**
  32820. * Pause all animations
  32821. * @returns the animation group
  32822. */
  32823. pause(): AnimationGroup;
  32824. /**
  32825. * Play all animations to initial state
  32826. * This function will start() the animations if they were not started or will restart() them if they were paused
  32827. * @param loop defines if animations must loop
  32828. * @returns the animation group
  32829. */
  32830. play(loop?: boolean): AnimationGroup;
  32831. /**
  32832. * Reset all animations to initial state
  32833. * @returns the animation group
  32834. */
  32835. reset(): AnimationGroup;
  32836. /**
  32837. * Restart animations from key 0
  32838. * @returns the animation group
  32839. */
  32840. restart(): AnimationGroup;
  32841. /**
  32842. * Stop all animations
  32843. * @returns the animation group
  32844. */
  32845. stop(): AnimationGroup;
  32846. /**
  32847. * Set animation weight for all animatables
  32848. * @param weight defines the weight to use
  32849. * @return the animationGroup
  32850. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  32851. */
  32852. setWeightForAllAnimatables(weight: number): AnimationGroup;
  32853. /**
  32854. * Synchronize and normalize all animatables with a source animatable
  32855. * @param root defines the root animatable to synchronize with
  32856. * @return the animationGroup
  32857. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  32858. */
  32859. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  32860. /**
  32861. * Goes to a specific frame in this animation group
  32862. * @param frame the frame number to go to
  32863. * @return the animationGroup
  32864. */
  32865. goToFrame(frame: number): AnimationGroup;
  32866. /**
  32867. * Dispose all associated resources
  32868. */
  32869. dispose(): void;
  32870. private _checkAnimationGroupEnded;
  32871. /**
  32872. * Clone the current animation group and returns a copy
  32873. * @param newName defines the name of the new group
  32874. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  32875. * @returns the new aniamtion group
  32876. */
  32877. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  32878. /**
  32879. * Serializes the animationGroup to an object
  32880. * @returns Serialized object
  32881. */
  32882. serialize(): any;
  32883. /**
  32884. * Returns a new AnimationGroup object parsed from the source provided.
  32885. * @param parsedAnimationGroup defines the source
  32886. * @param scene defines the scene that will receive the animationGroup
  32887. * @returns a new AnimationGroup
  32888. */
  32889. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  32890. /**
  32891. * Returns the string "AnimationGroup"
  32892. * @returns "AnimationGroup"
  32893. */
  32894. getClassName(): string;
  32895. /**
  32896. * Creates a detailled string about the object
  32897. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  32898. * @returns a string representing the object
  32899. */
  32900. toString(fullDetails?: boolean): string;
  32901. }
  32902. }
  32903. declare module BABYLON {
  32904. /**
  32905. * Define an interface for all classes that will hold resources
  32906. */
  32907. export interface IDisposable {
  32908. /**
  32909. * Releases all held resources
  32910. */
  32911. dispose(): void;
  32912. }
  32913. /** Interface defining initialization parameters for Scene class */
  32914. export interface SceneOptions {
  32915. /**
  32916. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  32917. * It will improve performance when the number of geometries becomes important.
  32918. */
  32919. useGeometryUniqueIdsMap?: boolean;
  32920. /**
  32921. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  32922. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  32923. */
  32924. useMaterialMeshMap?: boolean;
  32925. /**
  32926. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  32927. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  32928. */
  32929. useClonedMeshhMap?: boolean;
  32930. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  32931. virtual?: boolean;
  32932. }
  32933. /**
  32934. * Represents a scene to be rendered by the engine.
  32935. * @see http://doc.babylonjs.com/features/scene
  32936. */
  32937. export class Scene extends AbstractScene implements IAnimatable {
  32938. /** The fog is deactivated */
  32939. static readonly FOGMODE_NONE: number;
  32940. /** The fog density is following an exponential function */
  32941. static readonly FOGMODE_EXP: number;
  32942. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  32943. static readonly FOGMODE_EXP2: number;
  32944. /** The fog density is following a linear function. */
  32945. static readonly FOGMODE_LINEAR: number;
  32946. /**
  32947. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  32948. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32949. */
  32950. static MinDeltaTime: number;
  32951. /**
  32952. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  32953. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32954. */
  32955. static MaxDeltaTime: number;
  32956. /**
  32957. * Factory used to create the default material.
  32958. * @param name The name of the material to create
  32959. * @param scene The scene to create the material for
  32960. * @returns The default material
  32961. */
  32962. static DefaultMaterialFactory(scene: Scene): Material;
  32963. /**
  32964. * Factory used to create the a collision coordinator.
  32965. * @returns The collision coordinator
  32966. */
  32967. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  32968. /** @hidden */
  32969. _inputManager: InputManager;
  32970. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  32971. cameraToUseForPointers: Nullable<Camera>;
  32972. /** @hidden */
  32973. readonly _isScene: boolean;
  32974. /**
  32975. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  32976. */
  32977. autoClear: boolean;
  32978. /**
  32979. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  32980. */
  32981. autoClearDepthAndStencil: boolean;
  32982. /**
  32983. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  32984. */
  32985. clearColor: Color4;
  32986. /**
  32987. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  32988. */
  32989. ambientColor: Color3;
  32990. /**
  32991. * This is use to store the default BRDF lookup for PBR materials in your scene.
  32992. * It should only be one of the following (if not the default embedded one):
  32993. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  32994. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  32995. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  32996. * The material properties need to be setup according to the type of texture in use.
  32997. */
  32998. environmentBRDFTexture: BaseTexture;
  32999. /** @hidden */
  33000. protected _environmentTexture: Nullable<BaseTexture>;
  33001. /**
  33002. * Texture used in all pbr material as the reflection texture.
  33003. * As in the majority of the scene they are the same (exception for multi room and so on),
  33004. * this is easier to reference from here than from all the materials.
  33005. */
  33006. /**
  33007. * Texture used in all pbr material as the reflection texture.
  33008. * As in the majority of the scene they are the same (exception for multi room and so on),
  33009. * this is easier to set here than in all the materials.
  33010. */
  33011. environmentTexture: Nullable<BaseTexture>;
  33012. /** @hidden */
  33013. protected _environmentIntensity: number;
  33014. /**
  33015. * Intensity of the environment in all pbr material.
  33016. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  33017. * As in the majority of the scene they are the same (exception for multi room and so on),
  33018. * this is easier to reference from here than from all the materials.
  33019. */
  33020. /**
  33021. * Intensity of the environment in all pbr material.
  33022. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  33023. * As in the majority of the scene they are the same (exception for multi room and so on),
  33024. * this is easier to set here than in all the materials.
  33025. */
  33026. environmentIntensity: number;
  33027. /** @hidden */
  33028. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  33029. /**
  33030. * Default image processing configuration used either in the rendering
  33031. * Forward main pass or through the imageProcessingPostProcess if present.
  33032. * As in the majority of the scene they are the same (exception for multi camera),
  33033. * this is easier to reference from here than from all the materials and post process.
  33034. *
  33035. * No setter as we it is a shared configuration, you can set the values instead.
  33036. */
  33037. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  33038. private _forceWireframe;
  33039. /**
  33040. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  33041. */
  33042. forceWireframe: boolean;
  33043. private _forcePointsCloud;
  33044. /**
  33045. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  33046. */
  33047. forcePointsCloud: boolean;
  33048. /**
  33049. * Gets or sets the active clipplane 1
  33050. */
  33051. clipPlane: Nullable<Plane>;
  33052. /**
  33053. * Gets or sets the active clipplane 2
  33054. */
  33055. clipPlane2: Nullable<Plane>;
  33056. /**
  33057. * Gets or sets the active clipplane 3
  33058. */
  33059. clipPlane3: Nullable<Plane>;
  33060. /**
  33061. * Gets or sets the active clipplane 4
  33062. */
  33063. clipPlane4: Nullable<Plane>;
  33064. /**
  33065. * Gets or sets a boolean indicating if animations are enabled
  33066. */
  33067. animationsEnabled: boolean;
  33068. private _animationPropertiesOverride;
  33069. /**
  33070. * Gets or sets the animation properties override
  33071. */
  33072. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  33073. /**
  33074. * Gets or sets a boolean indicating if a constant deltatime has to be used
  33075. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  33076. */
  33077. useConstantAnimationDeltaTime: boolean;
  33078. /**
  33079. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  33080. * Please note that it requires to run a ray cast through the scene on every frame
  33081. */
  33082. constantlyUpdateMeshUnderPointer: boolean;
  33083. /**
  33084. * Defines the HTML cursor to use when hovering over interactive elements
  33085. */
  33086. hoverCursor: string;
  33087. /**
  33088. * Defines the HTML default cursor to use (empty by default)
  33089. */
  33090. defaultCursor: string;
  33091. /**
  33092. * This is used to call preventDefault() on pointer down
  33093. * in order to block unwanted artifacts like system double clicks
  33094. */
  33095. preventDefaultOnPointerDown: boolean;
  33096. /**
  33097. * This is used to call preventDefault() on pointer up
  33098. * in order to block unwanted artifacts like system double clicks
  33099. */
  33100. preventDefaultOnPointerUp: boolean;
  33101. /**
  33102. * Gets or sets user defined metadata
  33103. */
  33104. metadata: any;
  33105. /**
  33106. * For internal use only. Please do not use.
  33107. */
  33108. reservedDataStore: any;
  33109. /**
  33110. * Gets the name of the plugin used to load this scene (null by default)
  33111. */
  33112. loadingPluginName: string;
  33113. /**
  33114. * Use this array to add regular expressions used to disable offline support for specific urls
  33115. */
  33116. disableOfflineSupportExceptionRules: RegExp[];
  33117. /**
  33118. * An event triggered when the scene is disposed.
  33119. */
  33120. onDisposeObservable: Observable<Scene>;
  33121. private _onDisposeObserver;
  33122. /** Sets a function to be executed when this scene is disposed. */
  33123. onDispose: () => void;
  33124. /**
  33125. * An event triggered before rendering the scene (right after animations and physics)
  33126. */
  33127. onBeforeRenderObservable: Observable<Scene>;
  33128. private _onBeforeRenderObserver;
  33129. /** Sets a function to be executed before rendering this scene */
  33130. beforeRender: Nullable<() => void>;
  33131. /**
  33132. * An event triggered after rendering the scene
  33133. */
  33134. onAfterRenderObservable: Observable<Scene>;
  33135. /**
  33136. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  33137. */
  33138. onAfterRenderCameraObservable: Observable<Camera>;
  33139. private _onAfterRenderObserver;
  33140. /** Sets a function to be executed after rendering this scene */
  33141. afterRender: Nullable<() => void>;
  33142. /**
  33143. * An event triggered before animating the scene
  33144. */
  33145. onBeforeAnimationsObservable: Observable<Scene>;
  33146. /**
  33147. * An event triggered after animations processing
  33148. */
  33149. onAfterAnimationsObservable: Observable<Scene>;
  33150. /**
  33151. * An event triggered before draw calls are ready to be sent
  33152. */
  33153. onBeforeDrawPhaseObservable: Observable<Scene>;
  33154. /**
  33155. * An event triggered after draw calls have been sent
  33156. */
  33157. onAfterDrawPhaseObservable: Observable<Scene>;
  33158. /**
  33159. * An event triggered when the scene is ready
  33160. */
  33161. onReadyObservable: Observable<Scene>;
  33162. /**
  33163. * An event triggered before rendering a camera
  33164. */
  33165. onBeforeCameraRenderObservable: Observable<Camera>;
  33166. private _onBeforeCameraRenderObserver;
  33167. /** Sets a function to be executed before rendering a camera*/
  33168. beforeCameraRender: () => void;
  33169. /**
  33170. * An event triggered after rendering a camera
  33171. */
  33172. onAfterCameraRenderObservable: Observable<Camera>;
  33173. private _onAfterCameraRenderObserver;
  33174. /** Sets a function to be executed after rendering a camera*/
  33175. afterCameraRender: () => void;
  33176. /**
  33177. * An event triggered when active meshes evaluation is about to start
  33178. */
  33179. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  33180. /**
  33181. * An event triggered when active meshes evaluation is done
  33182. */
  33183. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  33184. /**
  33185. * An event triggered when particles rendering is about to start
  33186. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  33187. */
  33188. onBeforeParticlesRenderingObservable: Observable<Scene>;
  33189. /**
  33190. * An event triggered when particles rendering is done
  33191. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  33192. */
  33193. onAfterParticlesRenderingObservable: Observable<Scene>;
  33194. /**
  33195. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  33196. */
  33197. onDataLoadedObservable: Observable<Scene>;
  33198. /**
  33199. * An event triggered when a camera is created
  33200. */
  33201. onNewCameraAddedObservable: Observable<Camera>;
  33202. /**
  33203. * An event triggered when a camera is removed
  33204. */
  33205. onCameraRemovedObservable: Observable<Camera>;
  33206. /**
  33207. * An event triggered when a light is created
  33208. */
  33209. onNewLightAddedObservable: Observable<Light>;
  33210. /**
  33211. * An event triggered when a light is removed
  33212. */
  33213. onLightRemovedObservable: Observable<Light>;
  33214. /**
  33215. * An event triggered when a geometry is created
  33216. */
  33217. onNewGeometryAddedObservable: Observable<Geometry>;
  33218. /**
  33219. * An event triggered when a geometry is removed
  33220. */
  33221. onGeometryRemovedObservable: Observable<Geometry>;
  33222. /**
  33223. * An event triggered when a transform node is created
  33224. */
  33225. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  33226. /**
  33227. * An event triggered when a transform node is removed
  33228. */
  33229. onTransformNodeRemovedObservable: Observable<TransformNode>;
  33230. /**
  33231. * An event triggered when a mesh is created
  33232. */
  33233. onNewMeshAddedObservable: Observable<AbstractMesh>;
  33234. /**
  33235. * An event triggered when a mesh is removed
  33236. */
  33237. onMeshRemovedObservable: Observable<AbstractMesh>;
  33238. /**
  33239. * An event triggered when a skeleton is created
  33240. */
  33241. onNewSkeletonAddedObservable: Observable<Skeleton>;
  33242. /**
  33243. * An event triggered when a skeleton is removed
  33244. */
  33245. onSkeletonRemovedObservable: Observable<Skeleton>;
  33246. /**
  33247. * An event triggered when a material is created
  33248. */
  33249. onNewMaterialAddedObservable: Observable<Material>;
  33250. /**
  33251. * An event triggered when a material is removed
  33252. */
  33253. onMaterialRemovedObservable: Observable<Material>;
  33254. /**
  33255. * An event triggered when a texture is created
  33256. */
  33257. onNewTextureAddedObservable: Observable<BaseTexture>;
  33258. /**
  33259. * An event triggered when a texture is removed
  33260. */
  33261. onTextureRemovedObservable: Observable<BaseTexture>;
  33262. /**
  33263. * An event triggered when render targets are about to be rendered
  33264. * Can happen multiple times per frame.
  33265. */
  33266. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  33267. /**
  33268. * An event triggered when render targets were rendered.
  33269. * Can happen multiple times per frame.
  33270. */
  33271. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  33272. /**
  33273. * An event triggered before calculating deterministic simulation step
  33274. */
  33275. onBeforeStepObservable: Observable<Scene>;
  33276. /**
  33277. * An event triggered after calculating deterministic simulation step
  33278. */
  33279. onAfterStepObservable: Observable<Scene>;
  33280. /**
  33281. * An event triggered when the activeCamera property is updated
  33282. */
  33283. onActiveCameraChanged: Observable<Scene>;
  33284. /**
  33285. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  33286. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  33287. * 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)
  33288. */
  33289. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  33290. /**
  33291. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  33292. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  33293. * 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)
  33294. */
  33295. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  33296. /**
  33297. * This Observable will when a mesh has been imported into the scene.
  33298. */
  33299. onMeshImportedObservable: Observable<AbstractMesh>;
  33300. /**
  33301. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  33302. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  33303. */
  33304. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  33305. /** @hidden */
  33306. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  33307. /**
  33308. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  33309. */
  33310. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  33311. /**
  33312. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  33313. */
  33314. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  33315. /**
  33316. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  33317. */
  33318. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  33319. /** Callback called when a pointer move is detected */
  33320. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  33321. /** Callback called when a pointer down is detected */
  33322. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  33323. /** Callback called when a pointer up is detected */
  33324. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  33325. /** Callback called when a pointer pick is detected */
  33326. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  33327. /**
  33328. * 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).
  33329. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  33330. */
  33331. onPrePointerObservable: Observable<PointerInfoPre>;
  33332. /**
  33333. * Observable event triggered each time an input event is received from the rendering canvas
  33334. */
  33335. onPointerObservable: Observable<PointerInfo>;
  33336. /**
  33337. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  33338. */
  33339. readonly unTranslatedPointer: Vector2;
  33340. /**
  33341. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  33342. */
  33343. static DragMovementThreshold: number;
  33344. /**
  33345. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  33346. */
  33347. static LongPressDelay: number;
  33348. /**
  33349. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  33350. */
  33351. static DoubleClickDelay: number;
  33352. /** If you need to check double click without raising a single click at first click, enable this flag */
  33353. static ExclusiveDoubleClickMode: boolean;
  33354. /** @hidden */
  33355. _mirroredCameraPosition: Nullable<Vector3>;
  33356. /**
  33357. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  33358. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  33359. */
  33360. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  33361. /**
  33362. * Observable event triggered each time an keyboard event is received from the hosting window
  33363. */
  33364. onKeyboardObservable: Observable<KeyboardInfo>;
  33365. private _useRightHandedSystem;
  33366. /**
  33367. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  33368. */
  33369. useRightHandedSystem: boolean;
  33370. private _timeAccumulator;
  33371. private _currentStepId;
  33372. private _currentInternalStep;
  33373. /**
  33374. * Sets the step Id used by deterministic lock step
  33375. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33376. * @param newStepId defines the step Id
  33377. */
  33378. setStepId(newStepId: number): void;
  33379. /**
  33380. * Gets the step Id used by deterministic lock step
  33381. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33382. * @returns the step Id
  33383. */
  33384. getStepId(): number;
  33385. /**
  33386. * Gets the internal step used by deterministic lock step
  33387. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33388. * @returns the internal step
  33389. */
  33390. getInternalStep(): number;
  33391. private _fogEnabled;
  33392. /**
  33393. * Gets or sets a boolean indicating if fog is enabled on this scene
  33394. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33395. * (Default is true)
  33396. */
  33397. fogEnabled: boolean;
  33398. private _fogMode;
  33399. /**
  33400. * Gets or sets the fog mode to use
  33401. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33402. * | mode | value |
  33403. * | --- | --- |
  33404. * | FOGMODE_NONE | 0 |
  33405. * | FOGMODE_EXP | 1 |
  33406. * | FOGMODE_EXP2 | 2 |
  33407. * | FOGMODE_LINEAR | 3 |
  33408. */
  33409. fogMode: number;
  33410. /**
  33411. * Gets or sets the fog color to use
  33412. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33413. * (Default is Color3(0.2, 0.2, 0.3))
  33414. */
  33415. fogColor: Color3;
  33416. /**
  33417. * Gets or sets the fog density to use
  33418. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33419. * (Default is 0.1)
  33420. */
  33421. fogDensity: number;
  33422. /**
  33423. * Gets or sets the fog start distance to use
  33424. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33425. * (Default is 0)
  33426. */
  33427. fogStart: number;
  33428. /**
  33429. * Gets or sets the fog end distance to use
  33430. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33431. * (Default is 1000)
  33432. */
  33433. fogEnd: number;
  33434. private _shadowsEnabled;
  33435. /**
  33436. * Gets or sets a boolean indicating if shadows are enabled on this scene
  33437. */
  33438. shadowsEnabled: boolean;
  33439. private _lightsEnabled;
  33440. /**
  33441. * Gets or sets a boolean indicating if lights are enabled on this scene
  33442. */
  33443. lightsEnabled: boolean;
  33444. /** All of the active cameras added to this scene. */
  33445. activeCameras: Camera[];
  33446. /** @hidden */
  33447. _activeCamera: Nullable<Camera>;
  33448. /** Gets or sets the current active camera */
  33449. activeCamera: Nullable<Camera>;
  33450. private _defaultMaterial;
  33451. /** The default material used on meshes when no material is affected */
  33452. /** The default material used on meshes when no material is affected */
  33453. defaultMaterial: Material;
  33454. private _texturesEnabled;
  33455. /**
  33456. * Gets or sets a boolean indicating if textures are enabled on this scene
  33457. */
  33458. texturesEnabled: boolean;
  33459. /**
  33460. * Gets or sets a boolean indicating if particles are enabled on this scene
  33461. */
  33462. particlesEnabled: boolean;
  33463. /**
  33464. * Gets or sets a boolean indicating if sprites are enabled on this scene
  33465. */
  33466. spritesEnabled: boolean;
  33467. private _skeletonsEnabled;
  33468. /**
  33469. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  33470. */
  33471. skeletonsEnabled: boolean;
  33472. /**
  33473. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  33474. */
  33475. lensFlaresEnabled: boolean;
  33476. /**
  33477. * Gets or sets a boolean indicating if collisions are enabled on this scene
  33478. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33479. */
  33480. collisionsEnabled: boolean;
  33481. private _collisionCoordinator;
  33482. /** @hidden */
  33483. readonly collisionCoordinator: ICollisionCoordinator;
  33484. /**
  33485. * Defines the gravity applied to this scene (used only for collisions)
  33486. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33487. */
  33488. gravity: Vector3;
  33489. /**
  33490. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  33491. */
  33492. postProcessesEnabled: boolean;
  33493. /**
  33494. * The list of postprocesses added to the scene
  33495. */
  33496. postProcesses: PostProcess[];
  33497. /**
  33498. * Gets the current postprocess manager
  33499. */
  33500. postProcessManager: PostProcessManager;
  33501. /**
  33502. * Gets or sets a boolean indicating if render targets are enabled on this scene
  33503. */
  33504. renderTargetsEnabled: boolean;
  33505. /**
  33506. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  33507. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  33508. */
  33509. dumpNextRenderTargets: boolean;
  33510. /**
  33511. * The list of user defined render targets added to the scene
  33512. */
  33513. customRenderTargets: RenderTargetTexture[];
  33514. /**
  33515. * Defines if texture loading must be delayed
  33516. * If true, textures will only be loaded when they need to be rendered
  33517. */
  33518. useDelayedTextureLoading: boolean;
  33519. /**
  33520. * Gets the list of meshes imported to the scene through SceneLoader
  33521. */
  33522. importedMeshesFiles: String[];
  33523. /**
  33524. * Gets or sets a boolean indicating if probes are enabled on this scene
  33525. */
  33526. probesEnabled: boolean;
  33527. /**
  33528. * Gets or sets the current offline provider to use to store scene data
  33529. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  33530. */
  33531. offlineProvider: IOfflineProvider;
  33532. /**
  33533. * Gets or sets the action manager associated with the scene
  33534. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  33535. */
  33536. actionManager: AbstractActionManager;
  33537. private _meshesForIntersections;
  33538. /**
  33539. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  33540. */
  33541. proceduralTexturesEnabled: boolean;
  33542. private _engine;
  33543. private _totalVertices;
  33544. /** @hidden */
  33545. _activeIndices: PerfCounter;
  33546. /** @hidden */
  33547. _activeParticles: PerfCounter;
  33548. /** @hidden */
  33549. _activeBones: PerfCounter;
  33550. private _animationRatio;
  33551. /** @hidden */
  33552. _animationTimeLast: number;
  33553. /** @hidden */
  33554. _animationTime: number;
  33555. /**
  33556. * Gets or sets a general scale for animation speed
  33557. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  33558. */
  33559. animationTimeScale: number;
  33560. /** @hidden */
  33561. _cachedMaterial: Nullable<Material>;
  33562. /** @hidden */
  33563. _cachedEffect: Nullable<Effect>;
  33564. /** @hidden */
  33565. _cachedVisibility: Nullable<number>;
  33566. private _renderId;
  33567. private _frameId;
  33568. private _executeWhenReadyTimeoutId;
  33569. private _intermediateRendering;
  33570. private _viewUpdateFlag;
  33571. private _projectionUpdateFlag;
  33572. /** @hidden */
  33573. _toBeDisposed: Nullable<IDisposable>[];
  33574. private _activeRequests;
  33575. /** @hidden */
  33576. _pendingData: any[];
  33577. private _isDisposed;
  33578. /**
  33579. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  33580. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  33581. */
  33582. dispatchAllSubMeshesOfActiveMeshes: boolean;
  33583. private _activeMeshes;
  33584. private _processedMaterials;
  33585. private _renderTargets;
  33586. /** @hidden */
  33587. _activeParticleSystems: SmartArray<IParticleSystem>;
  33588. private _activeSkeletons;
  33589. private _softwareSkinnedMeshes;
  33590. private _renderingManager;
  33591. /** @hidden */
  33592. _activeAnimatables: Animatable[];
  33593. private _transformMatrix;
  33594. private _sceneUbo;
  33595. /** @hidden */
  33596. _viewMatrix: Matrix;
  33597. private _projectionMatrix;
  33598. /** @hidden */
  33599. _forcedViewPosition: Nullable<Vector3>;
  33600. /** @hidden */
  33601. _frustumPlanes: Plane[];
  33602. /**
  33603. * Gets the list of frustum planes (built from the active camera)
  33604. */
  33605. readonly frustumPlanes: Plane[];
  33606. /**
  33607. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  33608. * This is useful if there are more lights that the maximum simulteanous authorized
  33609. */
  33610. requireLightSorting: boolean;
  33611. /** @hidden */
  33612. readonly useMaterialMeshMap: boolean;
  33613. /** @hidden */
  33614. readonly useClonedMeshhMap: boolean;
  33615. private _externalData;
  33616. private _uid;
  33617. /**
  33618. * @hidden
  33619. * Backing store of defined scene components.
  33620. */
  33621. _components: ISceneComponent[];
  33622. /**
  33623. * @hidden
  33624. * Backing store of defined scene components.
  33625. */
  33626. _serializableComponents: ISceneSerializableComponent[];
  33627. /**
  33628. * List of components to register on the next registration step.
  33629. */
  33630. private _transientComponents;
  33631. /**
  33632. * Registers the transient components if needed.
  33633. */
  33634. private _registerTransientComponents;
  33635. /**
  33636. * @hidden
  33637. * Add a component to the scene.
  33638. * Note that the ccomponent could be registered on th next frame if this is called after
  33639. * the register component stage.
  33640. * @param component Defines the component to add to the scene
  33641. */
  33642. _addComponent(component: ISceneComponent): void;
  33643. /**
  33644. * @hidden
  33645. * Gets a component from the scene.
  33646. * @param name defines the name of the component to retrieve
  33647. * @returns the component or null if not present
  33648. */
  33649. _getComponent(name: string): Nullable<ISceneComponent>;
  33650. /**
  33651. * @hidden
  33652. * Defines the actions happening before camera updates.
  33653. */
  33654. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  33655. /**
  33656. * @hidden
  33657. * Defines the actions happening before clear the canvas.
  33658. */
  33659. _beforeClearStage: Stage<SimpleStageAction>;
  33660. /**
  33661. * @hidden
  33662. * Defines the actions when collecting render targets for the frame.
  33663. */
  33664. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  33665. /**
  33666. * @hidden
  33667. * Defines the actions happening for one camera in the frame.
  33668. */
  33669. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  33670. /**
  33671. * @hidden
  33672. * Defines the actions happening during the per mesh ready checks.
  33673. */
  33674. _isReadyForMeshStage: Stage<MeshStageAction>;
  33675. /**
  33676. * @hidden
  33677. * Defines the actions happening before evaluate active mesh checks.
  33678. */
  33679. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  33680. /**
  33681. * @hidden
  33682. * Defines the actions happening during the evaluate sub mesh checks.
  33683. */
  33684. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  33685. /**
  33686. * @hidden
  33687. * Defines the actions happening during the active mesh stage.
  33688. */
  33689. _activeMeshStage: Stage<ActiveMeshStageAction>;
  33690. /**
  33691. * @hidden
  33692. * Defines the actions happening during the per camera render target step.
  33693. */
  33694. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  33695. /**
  33696. * @hidden
  33697. * Defines the actions happening just before the active camera is drawing.
  33698. */
  33699. _beforeCameraDrawStage: Stage<CameraStageAction>;
  33700. /**
  33701. * @hidden
  33702. * Defines the actions happening just before a render target is drawing.
  33703. */
  33704. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  33705. /**
  33706. * @hidden
  33707. * Defines the actions happening just before a rendering group is drawing.
  33708. */
  33709. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  33710. /**
  33711. * @hidden
  33712. * Defines the actions happening just before a mesh is drawing.
  33713. */
  33714. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  33715. /**
  33716. * @hidden
  33717. * Defines the actions happening just after a mesh has been drawn.
  33718. */
  33719. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  33720. /**
  33721. * @hidden
  33722. * Defines the actions happening just after a rendering group has been drawn.
  33723. */
  33724. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  33725. /**
  33726. * @hidden
  33727. * Defines the actions happening just after the active camera has been drawn.
  33728. */
  33729. _afterCameraDrawStage: Stage<CameraStageAction>;
  33730. /**
  33731. * @hidden
  33732. * Defines the actions happening just after a render target has been drawn.
  33733. */
  33734. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  33735. /**
  33736. * @hidden
  33737. * Defines the actions happening just after rendering all cameras and computing intersections.
  33738. */
  33739. _afterRenderStage: Stage<SimpleStageAction>;
  33740. /**
  33741. * @hidden
  33742. * Defines the actions happening when a pointer move event happens.
  33743. */
  33744. _pointerMoveStage: Stage<PointerMoveStageAction>;
  33745. /**
  33746. * @hidden
  33747. * Defines the actions happening when a pointer down event happens.
  33748. */
  33749. _pointerDownStage: Stage<PointerUpDownStageAction>;
  33750. /**
  33751. * @hidden
  33752. * Defines the actions happening when a pointer up event happens.
  33753. */
  33754. _pointerUpStage: Stage<PointerUpDownStageAction>;
  33755. /**
  33756. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  33757. */
  33758. private geometriesByUniqueId;
  33759. /**
  33760. * Creates a new Scene
  33761. * @param engine defines the engine to use to render this scene
  33762. * @param options defines the scene options
  33763. */
  33764. constructor(engine: Engine, options?: SceneOptions);
  33765. /**
  33766. * Gets a string idenfifying the name of the class
  33767. * @returns "Scene" string
  33768. */
  33769. getClassName(): string;
  33770. private _defaultMeshCandidates;
  33771. /**
  33772. * @hidden
  33773. */
  33774. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  33775. private _defaultSubMeshCandidates;
  33776. /**
  33777. * @hidden
  33778. */
  33779. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  33780. /**
  33781. * Sets the default candidate providers for the scene.
  33782. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  33783. * and getCollidingSubMeshCandidates to their default function
  33784. */
  33785. setDefaultCandidateProviders(): void;
  33786. /**
  33787. * Gets the mesh that is currently under the pointer
  33788. */
  33789. readonly meshUnderPointer: Nullable<AbstractMesh>;
  33790. /**
  33791. * Gets or sets the current on-screen X position of the pointer
  33792. */
  33793. pointerX: number;
  33794. /**
  33795. * Gets or sets the current on-screen Y position of the pointer
  33796. */
  33797. pointerY: number;
  33798. /**
  33799. * Gets the cached material (ie. the latest rendered one)
  33800. * @returns the cached material
  33801. */
  33802. getCachedMaterial(): Nullable<Material>;
  33803. /**
  33804. * Gets the cached effect (ie. the latest rendered one)
  33805. * @returns the cached effect
  33806. */
  33807. getCachedEffect(): Nullable<Effect>;
  33808. /**
  33809. * Gets the cached visibility state (ie. the latest rendered one)
  33810. * @returns the cached visibility state
  33811. */
  33812. getCachedVisibility(): Nullable<number>;
  33813. /**
  33814. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  33815. * @param material defines the current material
  33816. * @param effect defines the current effect
  33817. * @param visibility defines the current visibility state
  33818. * @returns true if one parameter is not cached
  33819. */
  33820. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  33821. /**
  33822. * Gets the engine associated with the scene
  33823. * @returns an Engine
  33824. */
  33825. getEngine(): Engine;
  33826. /**
  33827. * Gets the total number of vertices rendered per frame
  33828. * @returns the total number of vertices rendered per frame
  33829. */
  33830. getTotalVertices(): number;
  33831. /**
  33832. * Gets the performance counter for total vertices
  33833. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33834. */
  33835. readonly totalVerticesPerfCounter: PerfCounter;
  33836. /**
  33837. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  33838. * @returns the total number of active indices rendered per frame
  33839. */
  33840. getActiveIndices(): number;
  33841. /**
  33842. * Gets the performance counter for active indices
  33843. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33844. */
  33845. readonly totalActiveIndicesPerfCounter: PerfCounter;
  33846. /**
  33847. * Gets the total number of active particles rendered per frame
  33848. * @returns the total number of active particles rendered per frame
  33849. */
  33850. getActiveParticles(): number;
  33851. /**
  33852. * Gets the performance counter for active particles
  33853. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33854. */
  33855. readonly activeParticlesPerfCounter: PerfCounter;
  33856. /**
  33857. * Gets the total number of active bones rendered per frame
  33858. * @returns the total number of active bones rendered per frame
  33859. */
  33860. getActiveBones(): number;
  33861. /**
  33862. * Gets the performance counter for active bones
  33863. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33864. */
  33865. readonly activeBonesPerfCounter: PerfCounter;
  33866. /**
  33867. * Gets the array of active meshes
  33868. * @returns an array of AbstractMesh
  33869. */
  33870. getActiveMeshes(): SmartArray<AbstractMesh>;
  33871. /**
  33872. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  33873. * @returns a number
  33874. */
  33875. getAnimationRatio(): number;
  33876. /**
  33877. * Gets an unique Id for the current render phase
  33878. * @returns a number
  33879. */
  33880. getRenderId(): number;
  33881. /**
  33882. * Gets an unique Id for the current frame
  33883. * @returns a number
  33884. */
  33885. getFrameId(): number;
  33886. /** Call this function if you want to manually increment the render Id*/
  33887. incrementRenderId(): void;
  33888. private _createUbo;
  33889. /**
  33890. * Use this method to simulate a pointer move on a mesh
  33891. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33892. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33893. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33894. * @returns the current scene
  33895. */
  33896. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  33897. /**
  33898. * Use this method to simulate a pointer down on a mesh
  33899. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33900. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33901. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33902. * @returns the current scene
  33903. */
  33904. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  33905. /**
  33906. * Use this method to simulate a pointer up on a mesh
  33907. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33908. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33909. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33910. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  33911. * @returns the current scene
  33912. */
  33913. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  33914. /**
  33915. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  33916. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  33917. * @returns true if the pointer was captured
  33918. */
  33919. isPointerCaptured(pointerId?: number): boolean;
  33920. /**
  33921. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  33922. * @param attachUp defines if you want to attach events to pointerup
  33923. * @param attachDown defines if you want to attach events to pointerdown
  33924. * @param attachMove defines if you want to attach events to pointermove
  33925. */
  33926. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  33927. /** Detaches all event handlers*/
  33928. detachControl(): void;
  33929. /**
  33930. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  33931. * Delay loaded resources are not taking in account
  33932. * @return true if all required resources are ready
  33933. */
  33934. isReady(): boolean;
  33935. /** Resets all cached information relative to material (including effect and visibility) */
  33936. resetCachedMaterial(): void;
  33937. /**
  33938. * Registers a function to be called before every frame render
  33939. * @param func defines the function to register
  33940. */
  33941. registerBeforeRender(func: () => void): void;
  33942. /**
  33943. * Unregisters a function called before every frame render
  33944. * @param func defines the function to unregister
  33945. */
  33946. unregisterBeforeRender(func: () => void): void;
  33947. /**
  33948. * Registers a function to be called after every frame render
  33949. * @param func defines the function to register
  33950. */
  33951. registerAfterRender(func: () => void): void;
  33952. /**
  33953. * Unregisters a function called after every frame render
  33954. * @param func defines the function to unregister
  33955. */
  33956. unregisterAfterRender(func: () => void): void;
  33957. private _executeOnceBeforeRender;
  33958. /**
  33959. * The provided function will run before render once and will be disposed afterwards.
  33960. * A timeout delay can be provided so that the function will be executed in N ms.
  33961. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  33962. * @param func The function to be executed.
  33963. * @param timeout optional delay in ms
  33964. */
  33965. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  33966. /** @hidden */
  33967. _addPendingData(data: any): void;
  33968. /** @hidden */
  33969. _removePendingData(data: any): void;
  33970. /**
  33971. * Returns the number of items waiting to be loaded
  33972. * @returns the number of items waiting to be loaded
  33973. */
  33974. getWaitingItemsCount(): number;
  33975. /**
  33976. * Returns a boolean indicating if the scene is still loading data
  33977. */
  33978. readonly isLoading: boolean;
  33979. /**
  33980. * Registers a function to be executed when the scene is ready
  33981. * @param {Function} func - the function to be executed
  33982. */
  33983. executeWhenReady(func: () => void): void;
  33984. /**
  33985. * Returns a promise that resolves when the scene is ready
  33986. * @returns A promise that resolves when the scene is ready
  33987. */
  33988. whenReadyAsync(): Promise<void>;
  33989. /** @hidden */
  33990. _checkIsReady(): void;
  33991. /**
  33992. * Gets all animatable attached to the scene
  33993. */
  33994. readonly animatables: Animatable[];
  33995. /**
  33996. * Resets the last animation time frame.
  33997. * Useful to override when animations start running when loading a scene for the first time.
  33998. */
  33999. resetLastAnimationTimeFrame(): void;
  34000. /**
  34001. * Gets the current view matrix
  34002. * @returns a Matrix
  34003. */
  34004. getViewMatrix(): Matrix;
  34005. /**
  34006. * Gets the current projection matrix
  34007. * @returns a Matrix
  34008. */
  34009. getProjectionMatrix(): Matrix;
  34010. /**
  34011. * Gets the current transform matrix
  34012. * @returns a Matrix made of View * Projection
  34013. */
  34014. getTransformMatrix(): Matrix;
  34015. /**
  34016. * Sets the current transform matrix
  34017. * @param viewL defines the View matrix to use
  34018. * @param projectionL defines the Projection matrix to use
  34019. * @param viewR defines the right View matrix to use (if provided)
  34020. * @param projectionR defines the right Projection matrix to use (if provided)
  34021. */
  34022. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  34023. /**
  34024. * Gets the uniform buffer used to store scene data
  34025. * @returns a UniformBuffer
  34026. */
  34027. getSceneUniformBuffer(): UniformBuffer;
  34028. /**
  34029. * Gets an unique (relatively to the current scene) Id
  34030. * @returns an unique number for the scene
  34031. */
  34032. getUniqueId(): number;
  34033. /**
  34034. * Add a mesh to the list of scene's meshes
  34035. * @param newMesh defines the mesh to add
  34036. * @param recursive if all child meshes should also be added to the scene
  34037. */
  34038. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  34039. /**
  34040. * Remove a mesh for the list of scene's meshes
  34041. * @param toRemove defines the mesh to remove
  34042. * @param recursive if all child meshes should also be removed from the scene
  34043. * @returns the index where the mesh was in the mesh list
  34044. */
  34045. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  34046. /**
  34047. * Add a transform node to the list of scene's transform nodes
  34048. * @param newTransformNode defines the transform node to add
  34049. */
  34050. addTransformNode(newTransformNode: TransformNode): void;
  34051. /**
  34052. * Remove a transform node for the list of scene's transform nodes
  34053. * @param toRemove defines the transform node to remove
  34054. * @returns the index where the transform node was in the transform node list
  34055. */
  34056. removeTransformNode(toRemove: TransformNode): number;
  34057. /**
  34058. * Remove a skeleton for the list of scene's skeletons
  34059. * @param toRemove defines the skeleton to remove
  34060. * @returns the index where the skeleton was in the skeleton list
  34061. */
  34062. removeSkeleton(toRemove: Skeleton): number;
  34063. /**
  34064. * Remove a morph target for the list of scene's morph targets
  34065. * @param toRemove defines the morph target to remove
  34066. * @returns the index where the morph target was in the morph target list
  34067. */
  34068. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  34069. /**
  34070. * Remove a light for the list of scene's lights
  34071. * @param toRemove defines the light to remove
  34072. * @returns the index where the light was in the light list
  34073. */
  34074. removeLight(toRemove: Light): number;
  34075. /**
  34076. * Remove a camera for the list of scene's cameras
  34077. * @param toRemove defines the camera to remove
  34078. * @returns the index where the camera was in the camera list
  34079. */
  34080. removeCamera(toRemove: Camera): number;
  34081. /**
  34082. * Remove a particle system for the list of scene's particle systems
  34083. * @param toRemove defines the particle system to remove
  34084. * @returns the index where the particle system was in the particle system list
  34085. */
  34086. removeParticleSystem(toRemove: IParticleSystem): number;
  34087. /**
  34088. * Remove a animation for the list of scene's animations
  34089. * @param toRemove defines the animation to remove
  34090. * @returns the index where the animation was in the animation list
  34091. */
  34092. removeAnimation(toRemove: Animation): number;
  34093. /**
  34094. * Will stop the animation of the given target
  34095. * @param target - the target
  34096. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  34097. * @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)
  34098. */
  34099. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  34100. /**
  34101. * Removes the given animation group from this scene.
  34102. * @param toRemove The animation group to remove
  34103. * @returns The index of the removed animation group
  34104. */
  34105. removeAnimationGroup(toRemove: AnimationGroup): number;
  34106. /**
  34107. * Removes the given multi-material from this scene.
  34108. * @param toRemove The multi-material to remove
  34109. * @returns The index of the removed multi-material
  34110. */
  34111. removeMultiMaterial(toRemove: MultiMaterial): number;
  34112. /**
  34113. * Removes the given material from this scene.
  34114. * @param toRemove The material to remove
  34115. * @returns The index of the removed material
  34116. */
  34117. removeMaterial(toRemove: Material): number;
  34118. /**
  34119. * Removes the given action manager from this scene.
  34120. * @param toRemove The action manager to remove
  34121. * @returns The index of the removed action manager
  34122. */
  34123. removeActionManager(toRemove: AbstractActionManager): number;
  34124. /**
  34125. * Removes the given texture from this scene.
  34126. * @param toRemove The texture to remove
  34127. * @returns The index of the removed texture
  34128. */
  34129. removeTexture(toRemove: BaseTexture): number;
  34130. /**
  34131. * Adds the given light to this scene
  34132. * @param newLight The light to add
  34133. */
  34134. addLight(newLight: Light): void;
  34135. /**
  34136. * Sorts the list list based on light priorities
  34137. */
  34138. sortLightsByPriority(): void;
  34139. /**
  34140. * Adds the given camera to this scene
  34141. * @param newCamera The camera to add
  34142. */
  34143. addCamera(newCamera: Camera): void;
  34144. /**
  34145. * Adds the given skeleton to this scene
  34146. * @param newSkeleton The skeleton to add
  34147. */
  34148. addSkeleton(newSkeleton: Skeleton): void;
  34149. /**
  34150. * Adds the given particle system to this scene
  34151. * @param newParticleSystem The particle system to add
  34152. */
  34153. addParticleSystem(newParticleSystem: IParticleSystem): void;
  34154. /**
  34155. * Adds the given animation to this scene
  34156. * @param newAnimation The animation to add
  34157. */
  34158. addAnimation(newAnimation: Animation): void;
  34159. /**
  34160. * Adds the given animation group to this scene.
  34161. * @param newAnimationGroup The animation group to add
  34162. */
  34163. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  34164. /**
  34165. * Adds the given multi-material to this scene
  34166. * @param newMultiMaterial The multi-material to add
  34167. */
  34168. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  34169. /**
  34170. * Adds the given material to this scene
  34171. * @param newMaterial The material to add
  34172. */
  34173. addMaterial(newMaterial: Material): void;
  34174. /**
  34175. * Adds the given morph target to this scene
  34176. * @param newMorphTargetManager The morph target to add
  34177. */
  34178. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  34179. /**
  34180. * Adds the given geometry to this scene
  34181. * @param newGeometry The geometry to add
  34182. */
  34183. addGeometry(newGeometry: Geometry): void;
  34184. /**
  34185. * Adds the given action manager to this scene
  34186. * @param newActionManager The action manager to add
  34187. */
  34188. addActionManager(newActionManager: AbstractActionManager): void;
  34189. /**
  34190. * Adds the given texture to this scene.
  34191. * @param newTexture The texture to add
  34192. */
  34193. addTexture(newTexture: BaseTexture): void;
  34194. /**
  34195. * Switch active camera
  34196. * @param newCamera defines the new active camera
  34197. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  34198. */
  34199. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  34200. /**
  34201. * sets the active camera of the scene using its ID
  34202. * @param id defines the camera's ID
  34203. * @return the new active camera or null if none found.
  34204. */
  34205. setActiveCameraByID(id: string): Nullable<Camera>;
  34206. /**
  34207. * sets the active camera of the scene using its name
  34208. * @param name defines the camera's name
  34209. * @returns the new active camera or null if none found.
  34210. */
  34211. setActiveCameraByName(name: string): Nullable<Camera>;
  34212. /**
  34213. * get an animation group using its name
  34214. * @param name defines the material's name
  34215. * @return the animation group or null if none found.
  34216. */
  34217. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  34218. /**
  34219. * Get a material using its unique id
  34220. * @param uniqueId defines the material's unique id
  34221. * @return the material or null if none found.
  34222. */
  34223. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  34224. /**
  34225. * get a material using its id
  34226. * @param id defines the material's ID
  34227. * @return the material or null if none found.
  34228. */
  34229. getMaterialByID(id: string): Nullable<Material>;
  34230. /**
  34231. * Gets a the last added material using a given id
  34232. * @param id defines the material's ID
  34233. * @return the last material with the given id or null if none found.
  34234. */
  34235. getLastMaterialByID(id: string): Nullable<Material>;
  34236. /**
  34237. * Gets a material using its name
  34238. * @param name defines the material's name
  34239. * @return the material or null if none found.
  34240. */
  34241. getMaterialByName(name: string): Nullable<Material>;
  34242. /**
  34243. * Get a texture using its unique id
  34244. * @param uniqueId defines the texture's unique id
  34245. * @return the texture or null if none found.
  34246. */
  34247. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  34248. /**
  34249. * Gets a camera using its id
  34250. * @param id defines the id to look for
  34251. * @returns the camera or null if not found
  34252. */
  34253. getCameraByID(id: string): Nullable<Camera>;
  34254. /**
  34255. * Gets a camera using its unique id
  34256. * @param uniqueId defines the unique id to look for
  34257. * @returns the camera or null if not found
  34258. */
  34259. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  34260. /**
  34261. * Gets a camera using its name
  34262. * @param name defines the camera's name
  34263. * @return the camera or null if none found.
  34264. */
  34265. getCameraByName(name: string): Nullable<Camera>;
  34266. /**
  34267. * Gets a bone using its id
  34268. * @param id defines the bone's id
  34269. * @return the bone or null if not found
  34270. */
  34271. getBoneByID(id: string): Nullable<Bone>;
  34272. /**
  34273. * Gets a bone using its id
  34274. * @param name defines the bone's name
  34275. * @return the bone or null if not found
  34276. */
  34277. getBoneByName(name: string): Nullable<Bone>;
  34278. /**
  34279. * Gets a light node using its name
  34280. * @param name defines the the light's name
  34281. * @return the light or null if none found.
  34282. */
  34283. getLightByName(name: string): Nullable<Light>;
  34284. /**
  34285. * Gets a light node using its id
  34286. * @param id defines the light's id
  34287. * @return the light or null if none found.
  34288. */
  34289. getLightByID(id: string): Nullable<Light>;
  34290. /**
  34291. * Gets a light node using its scene-generated unique ID
  34292. * @param uniqueId defines the light's unique id
  34293. * @return the light or null if none found.
  34294. */
  34295. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  34296. /**
  34297. * Gets a particle system by id
  34298. * @param id defines the particle system id
  34299. * @return the corresponding system or null if none found
  34300. */
  34301. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  34302. /**
  34303. * Gets a geometry using its ID
  34304. * @param id defines the geometry's id
  34305. * @return the geometry or null if none found.
  34306. */
  34307. getGeometryByID(id: string): Nullable<Geometry>;
  34308. private _getGeometryByUniqueID;
  34309. /**
  34310. * Add a new geometry to this scene
  34311. * @param geometry defines the geometry to be added to the scene.
  34312. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  34313. * @return a boolean defining if the geometry was added or not
  34314. */
  34315. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  34316. /**
  34317. * Removes an existing geometry
  34318. * @param geometry defines the geometry to be removed from the scene
  34319. * @return a boolean defining if the geometry was removed or not
  34320. */
  34321. removeGeometry(geometry: Geometry): boolean;
  34322. /**
  34323. * Gets the list of geometries attached to the scene
  34324. * @returns an array of Geometry
  34325. */
  34326. getGeometries(): Geometry[];
  34327. /**
  34328. * Gets the first added mesh found of a given ID
  34329. * @param id defines the id to search for
  34330. * @return the mesh found or null if not found at all
  34331. */
  34332. getMeshByID(id: string): Nullable<AbstractMesh>;
  34333. /**
  34334. * Gets a list of meshes using their id
  34335. * @param id defines the id to search for
  34336. * @returns a list of meshes
  34337. */
  34338. getMeshesByID(id: string): Array<AbstractMesh>;
  34339. /**
  34340. * Gets the first added transform node found of a given ID
  34341. * @param id defines the id to search for
  34342. * @return the found transform node or null if not found at all.
  34343. */
  34344. getTransformNodeByID(id: string): Nullable<TransformNode>;
  34345. /**
  34346. * Gets a transform node with its auto-generated unique id
  34347. * @param uniqueId efines the unique id to search for
  34348. * @return the found transform node or null if not found at all.
  34349. */
  34350. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  34351. /**
  34352. * Gets a list of transform nodes using their id
  34353. * @param id defines the id to search for
  34354. * @returns a list of transform nodes
  34355. */
  34356. getTransformNodesByID(id: string): Array<TransformNode>;
  34357. /**
  34358. * Gets a mesh with its auto-generated unique id
  34359. * @param uniqueId defines the unique id to search for
  34360. * @return the found mesh or null if not found at all.
  34361. */
  34362. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  34363. /**
  34364. * Gets a the last added mesh using a given id
  34365. * @param id defines the id to search for
  34366. * @return the found mesh or null if not found at all.
  34367. */
  34368. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  34369. /**
  34370. * Gets a the last added node (Mesh, Camera, Light) using a given id
  34371. * @param id defines the id to search for
  34372. * @return the found node or null if not found at all
  34373. */
  34374. getLastEntryByID(id: string): Nullable<Node>;
  34375. /**
  34376. * Gets a node (Mesh, Camera, Light) using a given id
  34377. * @param id defines the id to search for
  34378. * @return the found node or null if not found at all
  34379. */
  34380. getNodeByID(id: string): Nullable<Node>;
  34381. /**
  34382. * Gets a node (Mesh, Camera, Light) using a given name
  34383. * @param name defines the name to search for
  34384. * @return the found node or null if not found at all.
  34385. */
  34386. getNodeByName(name: string): Nullable<Node>;
  34387. /**
  34388. * Gets a mesh using a given name
  34389. * @param name defines the name to search for
  34390. * @return the found mesh or null if not found at all.
  34391. */
  34392. getMeshByName(name: string): Nullable<AbstractMesh>;
  34393. /**
  34394. * Gets a transform node using a given name
  34395. * @param name defines the name to search for
  34396. * @return the found transform node or null if not found at all.
  34397. */
  34398. getTransformNodeByName(name: string): Nullable<TransformNode>;
  34399. /**
  34400. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  34401. * @param id defines the id to search for
  34402. * @return the found skeleton or null if not found at all.
  34403. */
  34404. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  34405. /**
  34406. * Gets a skeleton using a given auto generated unique id
  34407. * @param uniqueId defines the unique id to search for
  34408. * @return the found skeleton or null if not found at all.
  34409. */
  34410. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  34411. /**
  34412. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  34413. * @param id defines the id to search for
  34414. * @return the found skeleton or null if not found at all.
  34415. */
  34416. getSkeletonById(id: string): Nullable<Skeleton>;
  34417. /**
  34418. * Gets a skeleton using a given name
  34419. * @param name defines the name to search for
  34420. * @return the found skeleton or null if not found at all.
  34421. */
  34422. getSkeletonByName(name: string): Nullable<Skeleton>;
  34423. /**
  34424. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  34425. * @param id defines the id to search for
  34426. * @return the found morph target manager or null if not found at all.
  34427. */
  34428. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  34429. /**
  34430. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  34431. * @param id defines the id to search for
  34432. * @return the found morph target or null if not found at all.
  34433. */
  34434. getMorphTargetById(id: string): Nullable<MorphTarget>;
  34435. /**
  34436. * Gets a boolean indicating if the given mesh is active
  34437. * @param mesh defines the mesh to look for
  34438. * @returns true if the mesh is in the active list
  34439. */
  34440. isActiveMesh(mesh: AbstractMesh): boolean;
  34441. /**
  34442. * Return a unique id as a string which can serve as an identifier for the scene
  34443. */
  34444. readonly uid: string;
  34445. /**
  34446. * Add an externaly attached data from its key.
  34447. * This method call will fail and return false, if such key already exists.
  34448. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  34449. * @param key the unique key that identifies the data
  34450. * @param data the data object to associate to the key for this Engine instance
  34451. * @return true if no such key were already present and the data was added successfully, false otherwise
  34452. */
  34453. addExternalData<T>(key: string, data: T): boolean;
  34454. /**
  34455. * Get an externaly attached data from its key
  34456. * @param key the unique key that identifies the data
  34457. * @return the associated data, if present (can be null), or undefined if not present
  34458. */
  34459. getExternalData<T>(key: string): Nullable<T>;
  34460. /**
  34461. * Get an externaly attached data from its key, create it using a factory if it's not already present
  34462. * @param key the unique key that identifies the data
  34463. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  34464. * @return the associated data, can be null if the factory returned null.
  34465. */
  34466. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  34467. /**
  34468. * Remove an externaly attached data from the Engine instance
  34469. * @param key the unique key that identifies the data
  34470. * @return true if the data was successfully removed, false if it doesn't exist
  34471. */
  34472. removeExternalData(key: string): boolean;
  34473. private _evaluateSubMesh;
  34474. /**
  34475. * Clear the processed materials smart array preventing retention point in material dispose.
  34476. */
  34477. freeProcessedMaterials(): void;
  34478. private _preventFreeActiveMeshesAndRenderingGroups;
  34479. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  34480. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  34481. * when disposing several meshes in a row or a hierarchy of meshes.
  34482. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  34483. */
  34484. blockfreeActiveMeshesAndRenderingGroups: boolean;
  34485. /**
  34486. * Clear the active meshes smart array preventing retention point in mesh dispose.
  34487. */
  34488. freeActiveMeshes(): void;
  34489. /**
  34490. * Clear the info related to rendering groups preventing retention points during dispose.
  34491. */
  34492. freeRenderingGroups(): void;
  34493. /** @hidden */
  34494. _isInIntermediateRendering(): boolean;
  34495. /**
  34496. * Lambda returning the list of potentially active meshes.
  34497. */
  34498. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  34499. /**
  34500. * Lambda returning the list of potentially active sub meshes.
  34501. */
  34502. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  34503. /**
  34504. * Lambda returning the list of potentially intersecting sub meshes.
  34505. */
  34506. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  34507. /**
  34508. * Lambda returning the list of potentially colliding sub meshes.
  34509. */
  34510. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  34511. private _activeMeshesFrozen;
  34512. /**
  34513. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  34514. * @returns the current scene
  34515. */
  34516. freezeActiveMeshes(): Scene;
  34517. /**
  34518. * Use this function to restart evaluating active meshes on every frame
  34519. * @returns the current scene
  34520. */
  34521. unfreezeActiveMeshes(): Scene;
  34522. private _evaluateActiveMeshes;
  34523. private _activeMesh;
  34524. /**
  34525. * Update the transform matrix to update from the current active camera
  34526. * @param force defines a boolean used to force the update even if cache is up to date
  34527. */
  34528. updateTransformMatrix(force?: boolean): void;
  34529. private _bindFrameBuffer;
  34530. /** @hidden */
  34531. _allowPostProcessClearColor: boolean;
  34532. /** @hidden */
  34533. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  34534. private _processSubCameras;
  34535. private _checkIntersections;
  34536. /** @hidden */
  34537. _advancePhysicsEngineStep(step: number): void;
  34538. /**
  34539. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  34540. */
  34541. getDeterministicFrameTime: () => number;
  34542. /** @hidden */
  34543. _animate(): void;
  34544. /** Execute all animations (for a frame) */
  34545. animate(): void;
  34546. /**
  34547. * Render the scene
  34548. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  34549. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  34550. */
  34551. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  34552. /**
  34553. * Freeze all materials
  34554. * A frozen material will not be updatable but should be faster to render
  34555. */
  34556. freezeMaterials(): void;
  34557. /**
  34558. * Unfreeze all materials
  34559. * A frozen material will not be updatable but should be faster to render
  34560. */
  34561. unfreezeMaterials(): void;
  34562. /**
  34563. * Releases all held ressources
  34564. */
  34565. dispose(): void;
  34566. /**
  34567. * Gets if the scene is already disposed
  34568. */
  34569. readonly isDisposed: boolean;
  34570. /**
  34571. * Call this function to reduce memory footprint of the scene.
  34572. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  34573. */
  34574. clearCachedVertexData(): void;
  34575. /**
  34576. * This function will remove the local cached buffer data from texture.
  34577. * It will save memory but will prevent the texture from being rebuilt
  34578. */
  34579. cleanCachedTextureBuffer(): void;
  34580. /**
  34581. * Get the world extend vectors with an optional filter
  34582. *
  34583. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  34584. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  34585. */
  34586. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  34587. min: Vector3;
  34588. max: Vector3;
  34589. };
  34590. /**
  34591. * Creates a ray that can be used to pick in the scene
  34592. * @param x defines the x coordinate of the origin (on-screen)
  34593. * @param y defines the y coordinate of the origin (on-screen)
  34594. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  34595. * @param camera defines the camera to use for the picking
  34596. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  34597. * @returns a Ray
  34598. */
  34599. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  34600. /**
  34601. * Creates a ray that can be used to pick in the scene
  34602. * @param x defines the x coordinate of the origin (on-screen)
  34603. * @param y defines the y coordinate of the origin (on-screen)
  34604. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  34605. * @param result defines the ray where to store the picking ray
  34606. * @param camera defines the camera to use for the picking
  34607. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  34608. * @returns the current scene
  34609. */
  34610. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  34611. /**
  34612. * Creates a ray that can be used to pick in the scene
  34613. * @param x defines the x coordinate of the origin (on-screen)
  34614. * @param y defines the y coordinate of the origin (on-screen)
  34615. * @param camera defines the camera to use for the picking
  34616. * @returns a Ray
  34617. */
  34618. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  34619. /**
  34620. * Creates a ray that can be used to pick in the scene
  34621. * @param x defines the x coordinate of the origin (on-screen)
  34622. * @param y defines the y coordinate of the origin (on-screen)
  34623. * @param result defines the ray where to store the picking ray
  34624. * @param camera defines the camera to use for the picking
  34625. * @returns the current scene
  34626. */
  34627. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  34628. /** Launch a ray to try to pick a mesh in the scene
  34629. * @param x position on screen
  34630. * @param y position on screen
  34631. * @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
  34632. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  34633. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  34634. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34635. * @returns a PickingInfo
  34636. */
  34637. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  34638. /** Use the given ray to pick a mesh in the scene
  34639. * @param ray The ray to use to pick meshes
  34640. * @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
  34641. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  34642. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34643. * @returns a PickingInfo
  34644. */
  34645. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  34646. /**
  34647. * Launch a ray to try to pick a mesh in the scene
  34648. * @param x X position on screen
  34649. * @param y Y position on screen
  34650. * @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
  34651. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  34652. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34653. * @returns an array of PickingInfo
  34654. */
  34655. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  34656. /**
  34657. * Launch a ray to try to pick a mesh in the scene
  34658. * @param ray Ray to use
  34659. * @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
  34660. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34661. * @returns an array of PickingInfo
  34662. */
  34663. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  34664. /**
  34665. * Force the value of meshUnderPointer
  34666. * @param mesh defines the mesh to use
  34667. */
  34668. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  34669. /**
  34670. * Gets the mesh under the pointer
  34671. * @returns a Mesh or null if no mesh is under the pointer
  34672. */
  34673. getPointerOverMesh(): Nullable<AbstractMesh>;
  34674. /** @hidden */
  34675. _rebuildGeometries(): void;
  34676. /** @hidden */
  34677. _rebuildTextures(): void;
  34678. private _getByTags;
  34679. /**
  34680. * Get a list of meshes by tags
  34681. * @param tagsQuery defines the tags query to use
  34682. * @param forEach defines a predicate used to filter results
  34683. * @returns an array of Mesh
  34684. */
  34685. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  34686. /**
  34687. * Get a list of cameras by tags
  34688. * @param tagsQuery defines the tags query to use
  34689. * @param forEach defines a predicate used to filter results
  34690. * @returns an array of Camera
  34691. */
  34692. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  34693. /**
  34694. * Get a list of lights by tags
  34695. * @param tagsQuery defines the tags query to use
  34696. * @param forEach defines a predicate used to filter results
  34697. * @returns an array of Light
  34698. */
  34699. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  34700. /**
  34701. * Get a list of materials by tags
  34702. * @param tagsQuery defines the tags query to use
  34703. * @param forEach defines a predicate used to filter results
  34704. * @returns an array of Material
  34705. */
  34706. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  34707. /**
  34708. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  34709. * This allowed control for front to back rendering or reversly depending of the special needs.
  34710. *
  34711. * @param renderingGroupId The rendering group id corresponding to its index
  34712. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  34713. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  34714. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  34715. */
  34716. 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;
  34717. /**
  34718. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  34719. *
  34720. * @param renderingGroupId The rendering group id corresponding to its index
  34721. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  34722. * @param depth Automatically clears depth between groups if true and autoClear is true.
  34723. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  34724. */
  34725. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  34726. /**
  34727. * Gets the current auto clear configuration for one rendering group of the rendering
  34728. * manager.
  34729. * @param index the rendering group index to get the information for
  34730. * @returns The auto clear setup for the requested rendering group
  34731. */
  34732. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  34733. private _blockMaterialDirtyMechanism;
  34734. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  34735. blockMaterialDirtyMechanism: boolean;
  34736. /**
  34737. * Will flag all materials as dirty to trigger new shader compilation
  34738. * @param flag defines the flag used to specify which material part must be marked as dirty
  34739. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  34740. */
  34741. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  34742. /** @hidden */
  34743. _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;
  34744. /** @hidden */
  34745. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  34746. }
  34747. }
  34748. declare module BABYLON {
  34749. /**
  34750. * Set of assets to keep when moving a scene into an asset container.
  34751. */
  34752. export class KeepAssets extends AbstractScene {
  34753. }
  34754. /**
  34755. * Container with a set of assets that can be added or removed from a scene.
  34756. */
  34757. export class AssetContainer extends AbstractScene {
  34758. /**
  34759. * The scene the AssetContainer belongs to.
  34760. */
  34761. scene: Scene;
  34762. /**
  34763. * Instantiates an AssetContainer.
  34764. * @param scene The scene the AssetContainer belongs to.
  34765. */
  34766. constructor(scene: Scene);
  34767. /**
  34768. * Adds all the assets from the container to the scene.
  34769. */
  34770. addAllToScene(): void;
  34771. /**
  34772. * Removes all the assets in the container from the scene
  34773. */
  34774. removeAllFromScene(): void;
  34775. /**
  34776. * Disposes all the assets in the container
  34777. */
  34778. dispose(): void;
  34779. private _moveAssets;
  34780. /**
  34781. * Removes all the assets contained in the scene and adds them to the container.
  34782. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  34783. */
  34784. moveAllFromScene(keepAssets?: KeepAssets): void;
  34785. /**
  34786. * 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.
  34787. * @returns the root mesh
  34788. */
  34789. createRootMesh(): Mesh;
  34790. }
  34791. }
  34792. declare module BABYLON {
  34793. /**
  34794. * Defines how the parser contract is defined.
  34795. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  34796. */
  34797. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  34798. /**
  34799. * Defines how the individual parser contract is defined.
  34800. * These parser can parse an individual asset
  34801. */
  34802. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  34803. /**
  34804. * Base class of the scene acting as a container for the different elements composing a scene.
  34805. * This class is dynamically extended by the different components of the scene increasing
  34806. * flexibility and reducing coupling
  34807. */
  34808. export abstract class AbstractScene {
  34809. /**
  34810. * Stores the list of available parsers in the application.
  34811. */
  34812. private static _BabylonFileParsers;
  34813. /**
  34814. * Stores the list of available individual parsers in the application.
  34815. */
  34816. private static _IndividualBabylonFileParsers;
  34817. /**
  34818. * Adds a parser in the list of available ones
  34819. * @param name Defines the name of the parser
  34820. * @param parser Defines the parser to add
  34821. */
  34822. static AddParser(name: string, parser: BabylonFileParser): void;
  34823. /**
  34824. * Gets a general parser from the list of avaialble ones
  34825. * @param name Defines the name of the parser
  34826. * @returns the requested parser or null
  34827. */
  34828. static GetParser(name: string): Nullable<BabylonFileParser>;
  34829. /**
  34830. * Adds n individual parser in the list of available ones
  34831. * @param name Defines the name of the parser
  34832. * @param parser Defines the parser to add
  34833. */
  34834. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  34835. /**
  34836. * Gets an individual parser from the list of avaialble ones
  34837. * @param name Defines the name of the parser
  34838. * @returns the requested parser or null
  34839. */
  34840. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  34841. /**
  34842. * Parser json data and populate both a scene and its associated container object
  34843. * @param jsonData Defines the data to parse
  34844. * @param scene Defines the scene to parse the data for
  34845. * @param container Defines the container attached to the parsing sequence
  34846. * @param rootUrl Defines the root url of the data
  34847. */
  34848. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  34849. /**
  34850. * Gets the list of root nodes (ie. nodes with no parent)
  34851. */
  34852. rootNodes: Node[];
  34853. /** All of the cameras added to this scene
  34854. * @see http://doc.babylonjs.com/babylon101/cameras
  34855. */
  34856. cameras: Camera[];
  34857. /**
  34858. * All of the lights added to this scene
  34859. * @see http://doc.babylonjs.com/babylon101/lights
  34860. */
  34861. lights: Light[];
  34862. /**
  34863. * All of the (abstract) meshes added to this scene
  34864. */
  34865. meshes: AbstractMesh[];
  34866. /**
  34867. * The list of skeletons added to the scene
  34868. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  34869. */
  34870. skeletons: Skeleton[];
  34871. /**
  34872. * All of the particle systems added to this scene
  34873. * @see http://doc.babylonjs.com/babylon101/particles
  34874. */
  34875. particleSystems: IParticleSystem[];
  34876. /**
  34877. * Gets a list of Animations associated with the scene
  34878. */
  34879. animations: Animation[];
  34880. /**
  34881. * All of the animation groups added to this scene
  34882. * @see http://doc.babylonjs.com/how_to/group
  34883. */
  34884. animationGroups: AnimationGroup[];
  34885. /**
  34886. * All of the multi-materials added to this scene
  34887. * @see http://doc.babylonjs.com/how_to/multi_materials
  34888. */
  34889. multiMaterials: MultiMaterial[];
  34890. /**
  34891. * All of the materials added to this scene
  34892. * In the context of a Scene, it is not supposed to be modified manually.
  34893. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  34894. * Note also that the order of the Material wihin the array is not significant and might change.
  34895. * @see http://doc.babylonjs.com/babylon101/materials
  34896. */
  34897. materials: Material[];
  34898. /**
  34899. * The list of morph target managers added to the scene
  34900. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  34901. */
  34902. morphTargetManagers: MorphTargetManager[];
  34903. /**
  34904. * The list of geometries used in the scene.
  34905. */
  34906. geometries: Geometry[];
  34907. /**
  34908. * All of the tranform nodes added to this scene
  34909. * In the context of a Scene, it is not supposed to be modified manually.
  34910. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  34911. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  34912. * @see http://doc.babylonjs.com/how_to/transformnode
  34913. */
  34914. transformNodes: TransformNode[];
  34915. /**
  34916. * ActionManagers available on the scene.
  34917. */
  34918. actionManagers: AbstractActionManager[];
  34919. /**
  34920. * Textures to keep.
  34921. */
  34922. textures: BaseTexture[];
  34923. /**
  34924. * Environment texture for the scene
  34925. */
  34926. environmentTexture: Nullable<BaseTexture>;
  34927. }
  34928. }
  34929. declare module BABYLON {
  34930. /**
  34931. * Interface used to define options for Sound class
  34932. */
  34933. export interface ISoundOptions {
  34934. /**
  34935. * Does the sound autoplay once loaded.
  34936. */
  34937. autoplay?: boolean;
  34938. /**
  34939. * Does the sound loop after it finishes playing once.
  34940. */
  34941. loop?: boolean;
  34942. /**
  34943. * Sound's volume
  34944. */
  34945. volume?: number;
  34946. /**
  34947. * Is it a spatial sound?
  34948. */
  34949. spatialSound?: boolean;
  34950. /**
  34951. * Maximum distance to hear that sound
  34952. */
  34953. maxDistance?: number;
  34954. /**
  34955. * Uses user defined attenuation function
  34956. */
  34957. useCustomAttenuation?: boolean;
  34958. /**
  34959. * Define the roll off factor of spatial sounds.
  34960. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34961. */
  34962. rolloffFactor?: number;
  34963. /**
  34964. * Define the reference distance the sound should be heard perfectly.
  34965. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34966. */
  34967. refDistance?: number;
  34968. /**
  34969. * Define the distance attenuation model the sound will follow.
  34970. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34971. */
  34972. distanceModel?: string;
  34973. /**
  34974. * Defines the playback speed (1 by default)
  34975. */
  34976. playbackRate?: number;
  34977. /**
  34978. * Defines if the sound is from a streaming source
  34979. */
  34980. streaming?: boolean;
  34981. /**
  34982. * Defines an optional length (in seconds) inside the sound file
  34983. */
  34984. length?: number;
  34985. /**
  34986. * Defines an optional offset (in seconds) inside the sound file
  34987. */
  34988. offset?: number;
  34989. /**
  34990. * If true, URLs will not be required to state the audio file codec to use.
  34991. */
  34992. skipCodecCheck?: boolean;
  34993. }
  34994. /**
  34995. * Defines a sound that can be played in the application.
  34996. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  34997. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34998. */
  34999. export class Sound {
  35000. /**
  35001. * The name of the sound in the scene.
  35002. */
  35003. name: string;
  35004. /**
  35005. * Does the sound autoplay once loaded.
  35006. */
  35007. autoplay: boolean;
  35008. /**
  35009. * Does the sound loop after it finishes playing once.
  35010. */
  35011. loop: boolean;
  35012. /**
  35013. * Does the sound use a custom attenuation curve to simulate the falloff
  35014. * happening when the source gets further away from the camera.
  35015. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  35016. */
  35017. useCustomAttenuation: boolean;
  35018. /**
  35019. * The sound track id this sound belongs to.
  35020. */
  35021. soundTrackId: number;
  35022. /**
  35023. * Is this sound currently played.
  35024. */
  35025. isPlaying: boolean;
  35026. /**
  35027. * Is this sound currently paused.
  35028. */
  35029. isPaused: boolean;
  35030. /**
  35031. * Does this sound enables spatial sound.
  35032. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35033. */
  35034. spatialSound: boolean;
  35035. /**
  35036. * Define the reference distance the sound should be heard perfectly.
  35037. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35038. */
  35039. refDistance: number;
  35040. /**
  35041. * Define the roll off factor of spatial sounds.
  35042. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35043. */
  35044. rolloffFactor: number;
  35045. /**
  35046. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  35047. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35048. */
  35049. maxDistance: number;
  35050. /**
  35051. * Define the distance attenuation model the sound will follow.
  35052. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35053. */
  35054. distanceModel: string;
  35055. /**
  35056. * @hidden
  35057. * Back Compat
  35058. **/
  35059. onended: () => any;
  35060. /**
  35061. * Observable event when the current playing sound finishes.
  35062. */
  35063. onEndedObservable: Observable<Sound>;
  35064. private _panningModel;
  35065. private _playbackRate;
  35066. private _streaming;
  35067. private _startTime;
  35068. private _startOffset;
  35069. private _position;
  35070. /** @hidden */
  35071. _positionInEmitterSpace: boolean;
  35072. private _localDirection;
  35073. private _volume;
  35074. private _isReadyToPlay;
  35075. private _isDirectional;
  35076. private _readyToPlayCallback;
  35077. private _audioBuffer;
  35078. private _soundSource;
  35079. private _streamingSource;
  35080. private _soundPanner;
  35081. private _soundGain;
  35082. private _inputAudioNode;
  35083. private _outputAudioNode;
  35084. private _coneInnerAngle;
  35085. private _coneOuterAngle;
  35086. private _coneOuterGain;
  35087. private _scene;
  35088. private _connectedTransformNode;
  35089. private _customAttenuationFunction;
  35090. private _registerFunc;
  35091. private _isOutputConnected;
  35092. private _htmlAudioElement;
  35093. private _urlType;
  35094. private _length?;
  35095. private _offset?;
  35096. /** @hidden */
  35097. static _SceneComponentInitialization: (scene: Scene) => void;
  35098. /**
  35099. * Create a sound and attach it to a scene
  35100. * @param name Name of your sound
  35101. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  35102. * @param scene defines the scene the sound belongs to
  35103. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  35104. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  35105. */
  35106. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  35107. /**
  35108. * Release the sound and its associated resources
  35109. */
  35110. dispose(): void;
  35111. /**
  35112. * Gets if the sounds is ready to be played or not.
  35113. * @returns true if ready, otherwise false
  35114. */
  35115. isReady(): boolean;
  35116. private _soundLoaded;
  35117. /**
  35118. * Sets the data of the sound from an audiobuffer
  35119. * @param audioBuffer The audioBuffer containing the data
  35120. */
  35121. setAudioBuffer(audioBuffer: AudioBuffer): void;
  35122. /**
  35123. * Updates the current sounds options such as maxdistance, loop...
  35124. * @param options A JSON object containing values named as the object properties
  35125. */
  35126. updateOptions(options: ISoundOptions): void;
  35127. private _createSpatialParameters;
  35128. private _updateSpatialParameters;
  35129. /**
  35130. * Switch the panning model to HRTF:
  35131. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  35132. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35133. */
  35134. switchPanningModelToHRTF(): void;
  35135. /**
  35136. * Switch the panning model to Equal Power:
  35137. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  35138. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35139. */
  35140. switchPanningModelToEqualPower(): void;
  35141. private _switchPanningModel;
  35142. /**
  35143. * Connect this sound to a sound track audio node like gain...
  35144. * @param soundTrackAudioNode the sound track audio node to connect to
  35145. */
  35146. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  35147. /**
  35148. * Transform this sound into a directional source
  35149. * @param coneInnerAngle Size of the inner cone in degree
  35150. * @param coneOuterAngle Size of the outer cone in degree
  35151. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  35152. */
  35153. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  35154. /**
  35155. * Gets or sets the inner angle for the directional cone.
  35156. */
  35157. /**
  35158. * Gets or sets the inner angle for the directional cone.
  35159. */
  35160. directionalConeInnerAngle: number;
  35161. /**
  35162. * Gets or sets the outer angle for the directional cone.
  35163. */
  35164. /**
  35165. * Gets or sets the outer angle for the directional cone.
  35166. */
  35167. directionalConeOuterAngle: number;
  35168. /**
  35169. * Sets the position of the emitter if spatial sound is enabled
  35170. * @param newPosition Defines the new posisiton
  35171. */
  35172. setPosition(newPosition: Vector3): void;
  35173. /**
  35174. * Sets the local direction of the emitter if spatial sound is enabled
  35175. * @param newLocalDirection Defines the new local direction
  35176. */
  35177. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  35178. private _updateDirection;
  35179. /** @hidden */
  35180. updateDistanceFromListener(): void;
  35181. /**
  35182. * Sets a new custom attenuation function for the sound.
  35183. * @param callback Defines the function used for the attenuation
  35184. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  35185. */
  35186. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  35187. /**
  35188. * Play the sound
  35189. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  35190. * @param offset (optional) Start the sound at a specific time in seconds
  35191. * @param length (optional) Sound duration (in seconds)
  35192. */
  35193. play(time?: number, offset?: number, length?: number): void;
  35194. private _onended;
  35195. /**
  35196. * Stop the sound
  35197. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  35198. */
  35199. stop(time?: number): void;
  35200. /**
  35201. * Put the sound in pause
  35202. */
  35203. pause(): void;
  35204. /**
  35205. * Sets a dedicated volume for this sounds
  35206. * @param newVolume Define the new volume of the sound
  35207. * @param time Define time for gradual change to new volume
  35208. */
  35209. setVolume(newVolume: number, time?: number): void;
  35210. /**
  35211. * Set the sound play back rate
  35212. * @param newPlaybackRate Define the playback rate the sound should be played at
  35213. */
  35214. setPlaybackRate(newPlaybackRate: number): void;
  35215. /**
  35216. * Gets the volume of the sound.
  35217. * @returns the volume of the sound
  35218. */
  35219. getVolume(): number;
  35220. /**
  35221. * Attach the sound to a dedicated mesh
  35222. * @param transformNode The transform node to connect the sound with
  35223. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  35224. */
  35225. attachToMesh(transformNode: TransformNode): void;
  35226. /**
  35227. * Detach the sound from the previously attached mesh
  35228. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  35229. */
  35230. detachFromMesh(): void;
  35231. private _onRegisterAfterWorldMatrixUpdate;
  35232. /**
  35233. * Clone the current sound in the scene.
  35234. * @returns the new sound clone
  35235. */
  35236. clone(): Nullable<Sound>;
  35237. /**
  35238. * Gets the current underlying audio buffer containing the data
  35239. * @returns the audio buffer
  35240. */
  35241. getAudioBuffer(): Nullable<AudioBuffer>;
  35242. /**
  35243. * Serializes the Sound in a JSON representation
  35244. * @returns the JSON representation of the sound
  35245. */
  35246. serialize(): any;
  35247. /**
  35248. * Parse a JSON representation of a sound to innstantiate in a given scene
  35249. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  35250. * @param scene Define the scene the new parsed sound should be created in
  35251. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  35252. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  35253. * @returns the newly parsed sound
  35254. */
  35255. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  35256. }
  35257. }
  35258. declare module BABYLON {
  35259. /**
  35260. * This defines an action helpful to play a defined sound on a triggered action.
  35261. */
  35262. export class PlaySoundAction extends Action {
  35263. private _sound;
  35264. /**
  35265. * Instantiate the action
  35266. * @param triggerOptions defines the trigger options
  35267. * @param sound defines the sound to play
  35268. * @param condition defines the trigger related conditions
  35269. */
  35270. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  35271. /** @hidden */
  35272. _prepare(): void;
  35273. /**
  35274. * Execute the action and play the sound.
  35275. */
  35276. execute(): void;
  35277. /**
  35278. * Serializes the actions and its related information.
  35279. * @param parent defines the object to serialize in
  35280. * @returns the serialized object
  35281. */
  35282. serialize(parent: any): any;
  35283. }
  35284. /**
  35285. * This defines an action helpful to stop a defined sound on a triggered action.
  35286. */
  35287. export class StopSoundAction extends Action {
  35288. private _sound;
  35289. /**
  35290. * Instantiate the action
  35291. * @param triggerOptions defines the trigger options
  35292. * @param sound defines the sound to stop
  35293. * @param condition defines the trigger related conditions
  35294. */
  35295. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  35296. /** @hidden */
  35297. _prepare(): void;
  35298. /**
  35299. * Execute the action and stop the sound.
  35300. */
  35301. execute(): void;
  35302. /**
  35303. * Serializes the actions and its related information.
  35304. * @param parent defines the object to serialize in
  35305. * @returns the serialized object
  35306. */
  35307. serialize(parent: any): any;
  35308. }
  35309. }
  35310. declare module BABYLON {
  35311. /**
  35312. * This defines an action responsible to change the value of a property
  35313. * by interpolating between its current value and the newly set one once triggered.
  35314. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  35315. */
  35316. export class InterpolateValueAction extends Action {
  35317. /**
  35318. * Defines the path of the property where the value should be interpolated
  35319. */
  35320. propertyPath: string;
  35321. /**
  35322. * Defines the target value at the end of the interpolation.
  35323. */
  35324. value: any;
  35325. /**
  35326. * Defines the time it will take for the property to interpolate to the value.
  35327. */
  35328. duration: number;
  35329. /**
  35330. * Defines if the other scene animations should be stopped when the action has been triggered
  35331. */
  35332. stopOtherAnimations?: boolean;
  35333. /**
  35334. * Defines a callback raised once the interpolation animation has been done.
  35335. */
  35336. onInterpolationDone?: () => void;
  35337. /**
  35338. * Observable triggered once the interpolation animation has been done.
  35339. */
  35340. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  35341. private _target;
  35342. private _effectiveTarget;
  35343. private _property;
  35344. /**
  35345. * Instantiate the action
  35346. * @param triggerOptions defines the trigger options
  35347. * @param target defines the object containing the value to interpolate
  35348. * @param propertyPath defines the path to the property in the target object
  35349. * @param value defines the target value at the end of the interpolation
  35350. * @param duration deines the time it will take for the property to interpolate to the value.
  35351. * @param condition defines the trigger related conditions
  35352. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  35353. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  35354. */
  35355. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  35356. /** @hidden */
  35357. _prepare(): void;
  35358. /**
  35359. * Execute the action starts the value interpolation.
  35360. */
  35361. execute(): void;
  35362. /**
  35363. * Serializes the actions and its related information.
  35364. * @param parent defines the object to serialize in
  35365. * @returns the serialized object
  35366. */
  35367. serialize(parent: any): any;
  35368. }
  35369. }
  35370. declare module BABYLON {
  35371. /**
  35372. * Options allowed during the creation of a sound track.
  35373. */
  35374. export interface ISoundTrackOptions {
  35375. /**
  35376. * The volume the sound track should take during creation
  35377. */
  35378. volume?: number;
  35379. /**
  35380. * Define if the sound track is the main sound track of the scene
  35381. */
  35382. mainTrack?: boolean;
  35383. }
  35384. /**
  35385. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  35386. * It will be also used in a future release to apply effects on a specific track.
  35387. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  35388. */
  35389. export class SoundTrack {
  35390. /**
  35391. * The unique identifier of the sound track in the scene.
  35392. */
  35393. id: number;
  35394. /**
  35395. * The list of sounds included in the sound track.
  35396. */
  35397. soundCollection: Array<Sound>;
  35398. private _outputAudioNode;
  35399. private _scene;
  35400. private _isMainTrack;
  35401. private _connectedAnalyser;
  35402. private _options;
  35403. private _isInitialized;
  35404. /**
  35405. * Creates a new sound track.
  35406. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  35407. * @param scene Define the scene the sound track belongs to
  35408. * @param options
  35409. */
  35410. constructor(scene: Scene, options?: ISoundTrackOptions);
  35411. private _initializeSoundTrackAudioGraph;
  35412. /**
  35413. * Release the sound track and its associated resources
  35414. */
  35415. dispose(): void;
  35416. /**
  35417. * Adds a sound to this sound track
  35418. * @param sound define the cound to add
  35419. * @ignoreNaming
  35420. */
  35421. AddSound(sound: Sound): void;
  35422. /**
  35423. * Removes a sound to this sound track
  35424. * @param sound define the cound to remove
  35425. * @ignoreNaming
  35426. */
  35427. RemoveSound(sound: Sound): void;
  35428. /**
  35429. * Set a global volume for the full sound track.
  35430. * @param newVolume Define the new volume of the sound track
  35431. */
  35432. setVolume(newVolume: number): void;
  35433. /**
  35434. * Switch the panning model to HRTF:
  35435. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  35436. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35437. */
  35438. switchPanningModelToHRTF(): void;
  35439. /**
  35440. * Switch the panning model to Equal Power:
  35441. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  35442. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35443. */
  35444. switchPanningModelToEqualPower(): void;
  35445. /**
  35446. * Connect the sound track to an audio analyser allowing some amazing
  35447. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  35448. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  35449. * @param analyser The analyser to connect to the engine
  35450. */
  35451. connectToAnalyser(analyser: Analyser): void;
  35452. }
  35453. }
  35454. declare module BABYLON {
  35455. interface AbstractScene {
  35456. /**
  35457. * The list of sounds used in the scene.
  35458. */
  35459. sounds: Nullable<Array<Sound>>;
  35460. }
  35461. interface Scene {
  35462. /**
  35463. * @hidden
  35464. * Backing field
  35465. */
  35466. _mainSoundTrack: SoundTrack;
  35467. /**
  35468. * The main sound track played by the scene.
  35469. * It cotains your primary collection of sounds.
  35470. */
  35471. mainSoundTrack: SoundTrack;
  35472. /**
  35473. * The list of sound tracks added to the scene
  35474. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35475. */
  35476. soundTracks: Nullable<Array<SoundTrack>>;
  35477. /**
  35478. * Gets a sound using a given name
  35479. * @param name defines the name to search for
  35480. * @return the found sound or null if not found at all.
  35481. */
  35482. getSoundByName(name: string): Nullable<Sound>;
  35483. /**
  35484. * Gets or sets if audio support is enabled
  35485. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35486. */
  35487. audioEnabled: boolean;
  35488. /**
  35489. * Gets or sets if audio will be output to headphones
  35490. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35491. */
  35492. headphone: boolean;
  35493. /**
  35494. * Gets or sets custom audio listener position provider
  35495. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35496. */
  35497. audioListenerPositionProvider: Nullable<() => Vector3>;
  35498. }
  35499. /**
  35500. * Defines the sound scene component responsible to manage any sounds
  35501. * in a given scene.
  35502. */
  35503. export class AudioSceneComponent implements ISceneSerializableComponent {
  35504. /**
  35505. * The component name helpfull to identify the component in the list of scene components.
  35506. */
  35507. readonly name: string;
  35508. /**
  35509. * The scene the component belongs to.
  35510. */
  35511. scene: Scene;
  35512. private _audioEnabled;
  35513. /**
  35514. * Gets whether audio is enabled or not.
  35515. * Please use related enable/disable method to switch state.
  35516. */
  35517. readonly audioEnabled: boolean;
  35518. private _headphone;
  35519. /**
  35520. * Gets whether audio is outputing to headphone or not.
  35521. * Please use the according Switch methods to change output.
  35522. */
  35523. readonly headphone: boolean;
  35524. private _audioListenerPositionProvider;
  35525. /**
  35526. * Gets the current audio listener position provider
  35527. */
  35528. /**
  35529. * Sets a custom listener position for all sounds in the scene
  35530. * By default, this is the position of the first active camera
  35531. */
  35532. audioListenerPositionProvider: Nullable<() => Vector3>;
  35533. /**
  35534. * Creates a new instance of the component for the given scene
  35535. * @param scene Defines the scene to register the component in
  35536. */
  35537. constructor(scene: Scene);
  35538. /**
  35539. * Registers the component in a given scene
  35540. */
  35541. register(): void;
  35542. /**
  35543. * Rebuilds the elements related to this component in case of
  35544. * context lost for instance.
  35545. */
  35546. rebuild(): void;
  35547. /**
  35548. * Serializes the component data to the specified json object
  35549. * @param serializationObject The object to serialize to
  35550. */
  35551. serialize(serializationObject: any): void;
  35552. /**
  35553. * Adds all the elements from the container to the scene
  35554. * @param container the container holding the elements
  35555. */
  35556. addFromContainer(container: AbstractScene): void;
  35557. /**
  35558. * Removes all the elements in the container from the scene
  35559. * @param container contains the elements to remove
  35560. * @param dispose if the removed element should be disposed (default: false)
  35561. */
  35562. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  35563. /**
  35564. * Disposes the component and the associated ressources.
  35565. */
  35566. dispose(): void;
  35567. /**
  35568. * Disables audio in the associated scene.
  35569. */
  35570. disableAudio(): void;
  35571. /**
  35572. * Enables audio in the associated scene.
  35573. */
  35574. enableAudio(): void;
  35575. /**
  35576. * Switch audio to headphone output.
  35577. */
  35578. switchAudioModeForHeadphones(): void;
  35579. /**
  35580. * Switch audio to normal speakers.
  35581. */
  35582. switchAudioModeForNormalSpeakers(): void;
  35583. private _afterRender;
  35584. }
  35585. }
  35586. declare module BABYLON {
  35587. /**
  35588. * Wraps one or more Sound objects and selects one with random weight for playback.
  35589. */
  35590. export class WeightedSound {
  35591. /** When true a Sound will be selected and played when the current playing Sound completes. */
  35592. loop: boolean;
  35593. private _coneInnerAngle;
  35594. private _coneOuterAngle;
  35595. private _volume;
  35596. /** A Sound is currently playing. */
  35597. isPlaying: boolean;
  35598. /** A Sound is currently paused. */
  35599. isPaused: boolean;
  35600. private _sounds;
  35601. private _weights;
  35602. private _currentIndex?;
  35603. /**
  35604. * Creates a new WeightedSound from the list of sounds given.
  35605. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  35606. * @param sounds Array of Sounds that will be selected from.
  35607. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  35608. */
  35609. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  35610. /**
  35611. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  35612. */
  35613. /**
  35614. * The size of cone in degress for a directional sound in which there will be no attenuation.
  35615. */
  35616. directionalConeInnerAngle: number;
  35617. /**
  35618. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  35619. * Listener angles between innerAngle and outerAngle will falloff linearly.
  35620. */
  35621. /**
  35622. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  35623. * Listener angles between innerAngle and outerAngle will falloff linearly.
  35624. */
  35625. directionalConeOuterAngle: number;
  35626. /**
  35627. * Playback volume.
  35628. */
  35629. /**
  35630. * Playback volume.
  35631. */
  35632. volume: number;
  35633. private _onended;
  35634. /**
  35635. * Suspend playback
  35636. */
  35637. pause(): void;
  35638. /**
  35639. * Stop playback
  35640. */
  35641. stop(): void;
  35642. /**
  35643. * Start playback.
  35644. * @param startOffset Position the clip head at a specific time in seconds.
  35645. */
  35646. play(startOffset?: number): void;
  35647. }
  35648. }
  35649. declare module BABYLON {
  35650. /**
  35651. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  35652. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35653. */
  35654. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  35655. /**
  35656. * Gets the name of the behavior.
  35657. */
  35658. readonly name: string;
  35659. /**
  35660. * The easing function used by animations
  35661. */
  35662. static EasingFunction: BackEase;
  35663. /**
  35664. * The easing mode used by animations
  35665. */
  35666. static EasingMode: number;
  35667. /**
  35668. * The duration of the animation, in milliseconds
  35669. */
  35670. transitionDuration: number;
  35671. /**
  35672. * Length of the distance animated by the transition when lower radius is reached
  35673. */
  35674. lowerRadiusTransitionRange: number;
  35675. /**
  35676. * Length of the distance animated by the transition when upper radius is reached
  35677. */
  35678. upperRadiusTransitionRange: number;
  35679. private _autoTransitionRange;
  35680. /**
  35681. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  35682. */
  35683. /**
  35684. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  35685. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  35686. */
  35687. autoTransitionRange: boolean;
  35688. private _attachedCamera;
  35689. private _onAfterCheckInputsObserver;
  35690. private _onMeshTargetChangedObserver;
  35691. /**
  35692. * Initializes the behavior.
  35693. */
  35694. init(): void;
  35695. /**
  35696. * Attaches the behavior to its arc rotate camera.
  35697. * @param camera Defines the camera to attach the behavior to
  35698. */
  35699. attach(camera: ArcRotateCamera): void;
  35700. /**
  35701. * Detaches the behavior from its current arc rotate camera.
  35702. */
  35703. detach(): void;
  35704. private _radiusIsAnimating;
  35705. private _radiusBounceTransition;
  35706. private _animatables;
  35707. private _cachedWheelPrecision;
  35708. /**
  35709. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  35710. * @param radiusLimit The limit to check against.
  35711. * @return Bool to indicate if at limit.
  35712. */
  35713. private _isRadiusAtLimit;
  35714. /**
  35715. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  35716. * @param radiusDelta The delta by which to animate to. Can be negative.
  35717. */
  35718. private _applyBoundRadiusAnimation;
  35719. /**
  35720. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  35721. */
  35722. protected _clearAnimationLocks(): void;
  35723. /**
  35724. * Stops and removes all animations that have been applied to the camera
  35725. */
  35726. stopAllAnimations(): void;
  35727. }
  35728. }
  35729. declare module BABYLON {
  35730. /**
  35731. * 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.
  35732. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35733. */
  35734. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  35735. /**
  35736. * Gets the name of the behavior.
  35737. */
  35738. readonly name: string;
  35739. private _mode;
  35740. private _radiusScale;
  35741. private _positionScale;
  35742. private _defaultElevation;
  35743. private _elevationReturnTime;
  35744. private _elevationReturnWaitTime;
  35745. private _zoomStopsAnimation;
  35746. private _framingTime;
  35747. /**
  35748. * The easing function used by animations
  35749. */
  35750. static EasingFunction: ExponentialEase;
  35751. /**
  35752. * The easing mode used by animations
  35753. */
  35754. static EasingMode: number;
  35755. /**
  35756. * Sets the current mode used by the behavior
  35757. */
  35758. /**
  35759. * Gets current mode used by the behavior.
  35760. */
  35761. mode: number;
  35762. /**
  35763. * Sets the scale applied to the radius (1 by default)
  35764. */
  35765. /**
  35766. * Gets the scale applied to the radius
  35767. */
  35768. radiusScale: number;
  35769. /**
  35770. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  35771. */
  35772. /**
  35773. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  35774. */
  35775. positionScale: number;
  35776. /**
  35777. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  35778. * behaviour is triggered, in radians.
  35779. */
  35780. /**
  35781. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  35782. * behaviour is triggered, in radians.
  35783. */
  35784. defaultElevation: number;
  35785. /**
  35786. * Sets the time (in milliseconds) taken to return to the default beta position.
  35787. * Negative value indicates camera should not return to default.
  35788. */
  35789. /**
  35790. * Gets the time (in milliseconds) taken to return to the default beta position.
  35791. * Negative value indicates camera should not return to default.
  35792. */
  35793. elevationReturnTime: number;
  35794. /**
  35795. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  35796. */
  35797. /**
  35798. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  35799. */
  35800. elevationReturnWaitTime: number;
  35801. /**
  35802. * Sets the flag that indicates if user zooming should stop animation.
  35803. */
  35804. /**
  35805. * Gets the flag that indicates if user zooming should stop animation.
  35806. */
  35807. zoomStopsAnimation: boolean;
  35808. /**
  35809. * Sets the transition time when framing the mesh, in milliseconds
  35810. */
  35811. /**
  35812. * Gets the transition time when framing the mesh, in milliseconds
  35813. */
  35814. framingTime: number;
  35815. /**
  35816. * Define if the behavior should automatically change the configured
  35817. * camera limits and sensibilities.
  35818. */
  35819. autoCorrectCameraLimitsAndSensibility: boolean;
  35820. private _onPrePointerObservableObserver;
  35821. private _onAfterCheckInputsObserver;
  35822. private _onMeshTargetChangedObserver;
  35823. private _attachedCamera;
  35824. private _isPointerDown;
  35825. private _lastInteractionTime;
  35826. /**
  35827. * Initializes the behavior.
  35828. */
  35829. init(): void;
  35830. /**
  35831. * Attaches the behavior to its arc rotate camera.
  35832. * @param camera Defines the camera to attach the behavior to
  35833. */
  35834. attach(camera: ArcRotateCamera): void;
  35835. /**
  35836. * Detaches the behavior from its current arc rotate camera.
  35837. */
  35838. detach(): void;
  35839. private _animatables;
  35840. private _betaIsAnimating;
  35841. private _betaTransition;
  35842. private _radiusTransition;
  35843. private _vectorTransition;
  35844. /**
  35845. * Targets the given mesh and updates zoom level accordingly.
  35846. * @param mesh The mesh to target.
  35847. * @param radius Optional. If a cached radius position already exists, overrides default.
  35848. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35849. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35850. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35851. */
  35852. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35853. /**
  35854. * Targets the given mesh with its children and updates zoom level accordingly.
  35855. * @param mesh The mesh to target.
  35856. * @param radius Optional. If a cached radius position already exists, overrides default.
  35857. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35858. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35859. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35860. */
  35861. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35862. /**
  35863. * Targets the given meshes with their children and updates zoom level accordingly.
  35864. * @param meshes The mesh to target.
  35865. * @param radius Optional. If a cached radius position already exists, overrides default.
  35866. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35867. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35868. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35869. */
  35870. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35871. /**
  35872. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  35873. * @param minimumWorld Determines the smaller position of the bounding box extend
  35874. * @param maximumWorld Determines the bigger position of the bounding box extend
  35875. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35876. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35877. */
  35878. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35879. /**
  35880. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  35881. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  35882. * frustum width.
  35883. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  35884. * to fully enclose the mesh in the viewing frustum.
  35885. */
  35886. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  35887. /**
  35888. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  35889. * is automatically returned to its default position (expected to be above ground plane).
  35890. */
  35891. private _maintainCameraAboveGround;
  35892. /**
  35893. * Returns the frustum slope based on the canvas ratio and camera FOV
  35894. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  35895. */
  35896. private _getFrustumSlope;
  35897. /**
  35898. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  35899. */
  35900. private _clearAnimationLocks;
  35901. /**
  35902. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  35903. */
  35904. private _applyUserInteraction;
  35905. /**
  35906. * Stops and removes all animations that have been applied to the camera
  35907. */
  35908. stopAllAnimations(): void;
  35909. /**
  35910. * Gets a value indicating if the user is moving the camera
  35911. */
  35912. readonly isUserIsMoving: boolean;
  35913. /**
  35914. * The camera can move all the way towards the mesh.
  35915. */
  35916. static IgnoreBoundsSizeMode: number;
  35917. /**
  35918. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  35919. */
  35920. static FitFrustumSidesMode: number;
  35921. }
  35922. }
  35923. declare module BABYLON {
  35924. /**
  35925. * Base class for Camera Pointer Inputs.
  35926. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  35927. * for example usage.
  35928. */
  35929. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  35930. /**
  35931. * Defines the camera the input is attached to.
  35932. */
  35933. abstract camera: Camera;
  35934. /**
  35935. * Whether keyboard modifier keys are pressed at time of last mouse event.
  35936. */
  35937. protected _altKey: boolean;
  35938. protected _ctrlKey: boolean;
  35939. protected _metaKey: boolean;
  35940. protected _shiftKey: boolean;
  35941. /**
  35942. * Which mouse buttons were pressed at time of last mouse event.
  35943. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  35944. */
  35945. protected _buttonsPressed: number;
  35946. /**
  35947. * Defines the buttons associated with the input to handle camera move.
  35948. */
  35949. buttons: number[];
  35950. /**
  35951. * Attach the input controls to a specific dom element to get the input from.
  35952. * @param element Defines the element the controls should be listened from
  35953. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35954. */
  35955. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35956. /**
  35957. * Detach the current controls from the specified dom element.
  35958. * @param element Defines the element to stop listening the inputs from
  35959. */
  35960. detachControl(element: Nullable<HTMLElement>): void;
  35961. /**
  35962. * Gets the class name of the current input.
  35963. * @returns the class name
  35964. */
  35965. getClassName(): string;
  35966. /**
  35967. * Get the friendly name associated with the input class.
  35968. * @returns the input friendly name
  35969. */
  35970. getSimpleName(): string;
  35971. /**
  35972. * Called on pointer POINTERDOUBLETAP event.
  35973. * Override this method to provide functionality on POINTERDOUBLETAP event.
  35974. */
  35975. protected onDoubleTap(type: string): void;
  35976. /**
  35977. * Called on pointer POINTERMOVE event if only a single touch is active.
  35978. * Override this method to provide functionality.
  35979. */
  35980. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  35981. /**
  35982. * Called on pointer POINTERMOVE event if multiple touches are active.
  35983. * Override this method to provide functionality.
  35984. */
  35985. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  35986. /**
  35987. * Called on JS contextmenu event.
  35988. * Override this method to provide functionality.
  35989. */
  35990. protected onContextMenu(evt: PointerEvent): void;
  35991. /**
  35992. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  35993. * press.
  35994. * Override this method to provide functionality.
  35995. */
  35996. protected onButtonDown(evt: PointerEvent): void;
  35997. /**
  35998. * Called each time a new POINTERUP event occurs. Ie, for each button
  35999. * release.
  36000. * Override this method to provide functionality.
  36001. */
  36002. protected onButtonUp(evt: PointerEvent): void;
  36003. /**
  36004. * Called when window becomes inactive.
  36005. * Override this method to provide functionality.
  36006. */
  36007. protected onLostFocus(): void;
  36008. private _pointerInput;
  36009. private _observer;
  36010. private _onLostFocus;
  36011. private pointA;
  36012. private pointB;
  36013. }
  36014. }
  36015. declare module BABYLON {
  36016. /**
  36017. * Manage the pointers inputs to control an arc rotate camera.
  36018. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36019. */
  36020. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  36021. /**
  36022. * Defines the camera the input is attached to.
  36023. */
  36024. camera: ArcRotateCamera;
  36025. /**
  36026. * Gets the class name of the current input.
  36027. * @returns the class name
  36028. */
  36029. getClassName(): string;
  36030. /**
  36031. * Defines the buttons associated with the input to handle camera move.
  36032. */
  36033. buttons: number[];
  36034. /**
  36035. * Defines the pointer angular sensibility along the X axis or how fast is
  36036. * the camera rotating.
  36037. */
  36038. angularSensibilityX: number;
  36039. /**
  36040. * Defines the pointer angular sensibility along the Y axis or how fast is
  36041. * the camera rotating.
  36042. */
  36043. angularSensibilityY: number;
  36044. /**
  36045. * Defines the pointer pinch precision or how fast is the camera zooming.
  36046. */
  36047. pinchPrecision: number;
  36048. /**
  36049. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  36050. * from 0.
  36051. * It defines the percentage of current camera.radius to use as delta when
  36052. * pinch zoom is used.
  36053. */
  36054. pinchDeltaPercentage: number;
  36055. /**
  36056. * Defines the pointer panning sensibility or how fast is the camera moving.
  36057. */
  36058. panningSensibility: number;
  36059. /**
  36060. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  36061. */
  36062. multiTouchPanning: boolean;
  36063. /**
  36064. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  36065. * zoom (pinch) through multitouch.
  36066. */
  36067. multiTouchPanAndZoom: boolean;
  36068. /**
  36069. * Revers pinch action direction.
  36070. */
  36071. pinchInwards: boolean;
  36072. private _isPanClick;
  36073. private _twoFingerActivityCount;
  36074. private _isPinching;
  36075. /**
  36076. * Called on pointer POINTERMOVE event if only a single touch is active.
  36077. */
  36078. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  36079. /**
  36080. * Called on pointer POINTERDOUBLETAP event.
  36081. */
  36082. protected onDoubleTap(type: string): void;
  36083. /**
  36084. * Called on pointer POINTERMOVE event if multiple touches are active.
  36085. */
  36086. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  36087. /**
  36088. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  36089. * press.
  36090. */
  36091. protected onButtonDown(evt: PointerEvent): void;
  36092. /**
  36093. * Called each time a new POINTERUP event occurs. Ie, for each button
  36094. * release.
  36095. */
  36096. protected onButtonUp(evt: PointerEvent): void;
  36097. /**
  36098. * Called when window becomes inactive.
  36099. */
  36100. protected onLostFocus(): void;
  36101. }
  36102. }
  36103. declare module BABYLON {
  36104. /**
  36105. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  36106. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36107. */
  36108. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  36109. /**
  36110. * Defines the camera the input is attached to.
  36111. */
  36112. camera: ArcRotateCamera;
  36113. /**
  36114. * Defines the list of key codes associated with the up action (increase alpha)
  36115. */
  36116. keysUp: number[];
  36117. /**
  36118. * Defines the list of key codes associated with the down action (decrease alpha)
  36119. */
  36120. keysDown: number[];
  36121. /**
  36122. * Defines the list of key codes associated with the left action (increase beta)
  36123. */
  36124. keysLeft: number[];
  36125. /**
  36126. * Defines the list of key codes associated with the right action (decrease beta)
  36127. */
  36128. keysRight: number[];
  36129. /**
  36130. * Defines the list of key codes associated with the reset action.
  36131. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  36132. */
  36133. keysReset: number[];
  36134. /**
  36135. * Defines the panning sensibility of the inputs.
  36136. * (How fast is the camera paning)
  36137. */
  36138. panningSensibility: number;
  36139. /**
  36140. * Defines the zooming sensibility of the inputs.
  36141. * (How fast is the camera zooming)
  36142. */
  36143. zoomingSensibility: number;
  36144. /**
  36145. * Defines wether maintaining the alt key down switch the movement mode from
  36146. * orientation to zoom.
  36147. */
  36148. useAltToZoom: boolean;
  36149. /**
  36150. * Rotation speed of the camera
  36151. */
  36152. angularSpeed: number;
  36153. private _keys;
  36154. private _ctrlPressed;
  36155. private _altPressed;
  36156. private _onCanvasBlurObserver;
  36157. private _onKeyboardObserver;
  36158. private _engine;
  36159. private _scene;
  36160. /**
  36161. * Attach the input controls to a specific dom element to get the input from.
  36162. * @param element Defines the element the controls should be listened from
  36163. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36164. */
  36165. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36166. /**
  36167. * Detach the current controls from the specified dom element.
  36168. * @param element Defines the element to stop listening the inputs from
  36169. */
  36170. detachControl(element: Nullable<HTMLElement>): void;
  36171. /**
  36172. * Update the current camera state depending on the inputs that have been used this frame.
  36173. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36174. */
  36175. checkInputs(): void;
  36176. /**
  36177. * Gets the class name of the current intput.
  36178. * @returns the class name
  36179. */
  36180. getClassName(): string;
  36181. /**
  36182. * Get the friendly name associated with the input class.
  36183. * @returns the input friendly name
  36184. */
  36185. getSimpleName(): string;
  36186. }
  36187. }
  36188. declare module BABYLON {
  36189. /**
  36190. * Manage the mouse wheel inputs to control an arc rotate camera.
  36191. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36192. */
  36193. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  36194. /**
  36195. * Defines the camera the input is attached to.
  36196. */
  36197. camera: ArcRotateCamera;
  36198. /**
  36199. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  36200. */
  36201. wheelPrecision: number;
  36202. /**
  36203. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  36204. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  36205. */
  36206. wheelDeltaPercentage: number;
  36207. private _wheel;
  36208. private _observer;
  36209. private computeDeltaFromMouseWheelLegacyEvent;
  36210. /**
  36211. * Attach the input controls to a specific dom element to get the input from.
  36212. * @param element Defines the element the controls should be listened from
  36213. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36214. */
  36215. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36216. /**
  36217. * Detach the current controls from the specified dom element.
  36218. * @param element Defines the element to stop listening the inputs from
  36219. */
  36220. detachControl(element: Nullable<HTMLElement>): void;
  36221. /**
  36222. * Gets the class name of the current intput.
  36223. * @returns the class name
  36224. */
  36225. getClassName(): string;
  36226. /**
  36227. * Get the friendly name associated with the input class.
  36228. * @returns the input friendly name
  36229. */
  36230. getSimpleName(): string;
  36231. }
  36232. }
  36233. declare module BABYLON {
  36234. /**
  36235. * Default Inputs manager for the ArcRotateCamera.
  36236. * It groups all the default supported inputs for ease of use.
  36237. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36238. */
  36239. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  36240. /**
  36241. * Instantiates a new ArcRotateCameraInputsManager.
  36242. * @param camera Defines the camera the inputs belong to
  36243. */
  36244. constructor(camera: ArcRotateCamera);
  36245. /**
  36246. * Add mouse wheel input support to the input manager.
  36247. * @returns the current input manager
  36248. */
  36249. addMouseWheel(): ArcRotateCameraInputsManager;
  36250. /**
  36251. * Add pointers input support to the input manager.
  36252. * @returns the current input manager
  36253. */
  36254. addPointers(): ArcRotateCameraInputsManager;
  36255. /**
  36256. * Add keyboard input support to the input manager.
  36257. * @returns the current input manager
  36258. */
  36259. addKeyboard(): ArcRotateCameraInputsManager;
  36260. }
  36261. }
  36262. declare module BABYLON {
  36263. /**
  36264. * This represents an orbital type of camera.
  36265. *
  36266. * 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.
  36267. * 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.
  36268. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  36269. */
  36270. export class ArcRotateCamera extends TargetCamera {
  36271. /**
  36272. * Defines the rotation angle of the camera along the longitudinal axis.
  36273. */
  36274. alpha: number;
  36275. /**
  36276. * Defines the rotation angle of the camera along the latitudinal axis.
  36277. */
  36278. beta: number;
  36279. /**
  36280. * Defines the radius of the camera from it s target point.
  36281. */
  36282. radius: number;
  36283. protected _target: Vector3;
  36284. protected _targetHost: Nullable<AbstractMesh>;
  36285. /**
  36286. * Defines the target point of the camera.
  36287. * The camera looks towards it form the radius distance.
  36288. */
  36289. target: Vector3;
  36290. /**
  36291. * Define the current local position of the camera in the scene
  36292. */
  36293. position: Vector3;
  36294. protected _upVector: Vector3;
  36295. protected _upToYMatrix: Matrix;
  36296. protected _YToUpMatrix: Matrix;
  36297. /**
  36298. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  36299. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  36300. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  36301. */
  36302. upVector: Vector3;
  36303. /**
  36304. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  36305. */
  36306. setMatUp(): void;
  36307. /**
  36308. * Current inertia value on the longitudinal axis.
  36309. * The bigger this number the longer it will take for the camera to stop.
  36310. */
  36311. inertialAlphaOffset: number;
  36312. /**
  36313. * Current inertia value on the latitudinal axis.
  36314. * The bigger this number the longer it will take for the camera to stop.
  36315. */
  36316. inertialBetaOffset: number;
  36317. /**
  36318. * Current inertia value on the radius axis.
  36319. * The bigger this number the longer it will take for the camera to stop.
  36320. */
  36321. inertialRadiusOffset: number;
  36322. /**
  36323. * Minimum allowed angle on the longitudinal axis.
  36324. * This can help limiting how the Camera is able to move in the scene.
  36325. */
  36326. lowerAlphaLimit: Nullable<number>;
  36327. /**
  36328. * Maximum allowed angle on the longitudinal axis.
  36329. * This can help limiting how the Camera is able to move in the scene.
  36330. */
  36331. upperAlphaLimit: Nullable<number>;
  36332. /**
  36333. * Minimum allowed angle on the latitudinal axis.
  36334. * This can help limiting how the Camera is able to move in the scene.
  36335. */
  36336. lowerBetaLimit: number;
  36337. /**
  36338. * Maximum allowed angle on the latitudinal axis.
  36339. * This can help limiting how the Camera is able to move in the scene.
  36340. */
  36341. upperBetaLimit: number;
  36342. /**
  36343. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  36344. * This can help limiting how the Camera is able to move in the scene.
  36345. */
  36346. lowerRadiusLimit: Nullable<number>;
  36347. /**
  36348. * Maximum allowed distance of the camera to the target (The camera can not get further).
  36349. * This can help limiting how the Camera is able to move in the scene.
  36350. */
  36351. upperRadiusLimit: Nullable<number>;
  36352. /**
  36353. * Defines the current inertia value used during panning of the camera along the X axis.
  36354. */
  36355. inertialPanningX: number;
  36356. /**
  36357. * Defines the current inertia value used during panning of the camera along the Y axis.
  36358. */
  36359. inertialPanningY: number;
  36360. /**
  36361. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  36362. * Basically if your fingers moves away from more than this distance you will be considered
  36363. * in pinch mode.
  36364. */
  36365. pinchToPanMaxDistance: number;
  36366. /**
  36367. * Defines the maximum distance the camera can pan.
  36368. * This could help keeping the cammera always in your scene.
  36369. */
  36370. panningDistanceLimit: Nullable<number>;
  36371. /**
  36372. * Defines the target of the camera before paning.
  36373. */
  36374. panningOriginTarget: Vector3;
  36375. /**
  36376. * Defines the value of the inertia used during panning.
  36377. * 0 would mean stop inertia and one would mean no decelleration at all.
  36378. */
  36379. panningInertia: number;
  36380. /**
  36381. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  36382. */
  36383. angularSensibilityX: number;
  36384. /**
  36385. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  36386. */
  36387. angularSensibilityY: number;
  36388. /**
  36389. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  36390. */
  36391. pinchPrecision: number;
  36392. /**
  36393. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  36394. * It will be used instead of pinchDeltaPrecision if different from 0.
  36395. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  36396. */
  36397. pinchDeltaPercentage: number;
  36398. /**
  36399. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  36400. */
  36401. panningSensibility: number;
  36402. /**
  36403. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  36404. */
  36405. keysUp: number[];
  36406. /**
  36407. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  36408. */
  36409. keysDown: number[];
  36410. /**
  36411. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  36412. */
  36413. keysLeft: number[];
  36414. /**
  36415. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  36416. */
  36417. keysRight: number[];
  36418. /**
  36419. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  36420. */
  36421. wheelPrecision: number;
  36422. /**
  36423. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  36424. * It will be used instead of pinchDeltaPrecision if different from 0.
  36425. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  36426. */
  36427. wheelDeltaPercentage: number;
  36428. /**
  36429. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  36430. */
  36431. zoomOnFactor: number;
  36432. /**
  36433. * Defines a screen offset for the camera position.
  36434. */
  36435. targetScreenOffset: Vector2;
  36436. /**
  36437. * Allows the camera to be completely reversed.
  36438. * If false the camera can not arrive upside down.
  36439. */
  36440. allowUpsideDown: boolean;
  36441. /**
  36442. * Define if double tap/click is used to restore the previously saved state of the camera.
  36443. */
  36444. useInputToRestoreState: boolean;
  36445. /** @hidden */
  36446. _viewMatrix: Matrix;
  36447. /** @hidden */
  36448. _useCtrlForPanning: boolean;
  36449. /** @hidden */
  36450. _panningMouseButton: number;
  36451. /**
  36452. * Defines the input associated to the camera.
  36453. */
  36454. inputs: ArcRotateCameraInputsManager;
  36455. /** @hidden */
  36456. _reset: () => void;
  36457. /**
  36458. * Defines the allowed panning axis.
  36459. */
  36460. panningAxis: Vector3;
  36461. protected _localDirection: Vector3;
  36462. protected _transformedDirection: Vector3;
  36463. private _bouncingBehavior;
  36464. /**
  36465. * Gets the bouncing behavior of the camera if it has been enabled.
  36466. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  36467. */
  36468. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  36469. /**
  36470. * Defines if the bouncing behavior of the camera is enabled on the camera.
  36471. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  36472. */
  36473. useBouncingBehavior: boolean;
  36474. private _framingBehavior;
  36475. /**
  36476. * Gets the framing behavior of the camera if it has been enabled.
  36477. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  36478. */
  36479. readonly framingBehavior: Nullable<FramingBehavior>;
  36480. /**
  36481. * Defines if the framing behavior of the camera is enabled on the camera.
  36482. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  36483. */
  36484. useFramingBehavior: boolean;
  36485. private _autoRotationBehavior;
  36486. /**
  36487. * Gets the auto rotation behavior of the camera if it has been enabled.
  36488. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36489. */
  36490. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  36491. /**
  36492. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  36493. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36494. */
  36495. useAutoRotationBehavior: boolean;
  36496. /**
  36497. * Observable triggered when the mesh target has been changed on the camera.
  36498. */
  36499. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  36500. /**
  36501. * Event raised when the camera is colliding with a mesh.
  36502. */
  36503. onCollide: (collidedMesh: AbstractMesh) => void;
  36504. /**
  36505. * Defines whether the camera should check collision with the objects oh the scene.
  36506. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  36507. */
  36508. checkCollisions: boolean;
  36509. /**
  36510. * Defines the collision radius of the camera.
  36511. * This simulates a sphere around the camera.
  36512. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  36513. */
  36514. collisionRadius: Vector3;
  36515. protected _collider: Collider;
  36516. protected _previousPosition: Vector3;
  36517. protected _collisionVelocity: Vector3;
  36518. protected _newPosition: Vector3;
  36519. protected _previousAlpha: number;
  36520. protected _previousBeta: number;
  36521. protected _previousRadius: number;
  36522. protected _collisionTriggered: boolean;
  36523. protected _targetBoundingCenter: Nullable<Vector3>;
  36524. private _computationVector;
  36525. /**
  36526. * Instantiates a new ArcRotateCamera in a given scene
  36527. * @param name Defines the name of the camera
  36528. * @param alpha Defines the camera rotation along the logitudinal axis
  36529. * @param beta Defines the camera rotation along the latitudinal axis
  36530. * @param radius Defines the camera distance from its target
  36531. * @param target Defines the camera target
  36532. * @param scene Defines the scene the camera belongs to
  36533. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  36534. */
  36535. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  36536. /** @hidden */
  36537. _initCache(): void;
  36538. /** @hidden */
  36539. _updateCache(ignoreParentClass?: boolean): void;
  36540. protected _getTargetPosition(): Vector3;
  36541. private _storedAlpha;
  36542. private _storedBeta;
  36543. private _storedRadius;
  36544. private _storedTarget;
  36545. private _storedTargetScreenOffset;
  36546. /**
  36547. * Stores the current state of the camera (alpha, beta, radius and target)
  36548. * @returns the camera itself
  36549. */
  36550. storeState(): Camera;
  36551. /**
  36552. * @hidden
  36553. * Restored camera state. You must call storeState() first
  36554. */
  36555. _restoreStateValues(): boolean;
  36556. /** @hidden */
  36557. _isSynchronizedViewMatrix(): boolean;
  36558. /**
  36559. * Attached controls to the current camera.
  36560. * @param element Defines the element the controls should be listened from
  36561. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36562. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  36563. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  36564. */
  36565. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  36566. /**
  36567. * Detach the current controls from the camera.
  36568. * The camera will stop reacting to inputs.
  36569. * @param element Defines the element to stop listening the inputs from
  36570. */
  36571. detachControl(element: HTMLElement): void;
  36572. /** @hidden */
  36573. _checkInputs(): void;
  36574. protected _checkLimits(): void;
  36575. /**
  36576. * Rebuilds angles (alpha, beta) and radius from the give position and target
  36577. */
  36578. rebuildAnglesAndRadius(): void;
  36579. /**
  36580. * Use a position to define the current camera related information like alpha, beta and radius
  36581. * @param position Defines the position to set the camera at
  36582. */
  36583. setPosition(position: Vector3): void;
  36584. /**
  36585. * Defines the target the camera should look at.
  36586. * This will automatically adapt alpha beta and radius to fit within the new target.
  36587. * @param target Defines the new target as a Vector or a mesh
  36588. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  36589. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  36590. */
  36591. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  36592. /** @hidden */
  36593. _getViewMatrix(): Matrix;
  36594. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  36595. /**
  36596. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  36597. * @param meshes Defines the mesh to zoom on
  36598. * @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)
  36599. */
  36600. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  36601. /**
  36602. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  36603. * The target will be changed but the radius
  36604. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  36605. * @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)
  36606. */
  36607. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  36608. min: Vector3;
  36609. max: Vector3;
  36610. distance: number;
  36611. }, doNotUpdateMaxZ?: boolean): void;
  36612. /**
  36613. * @override
  36614. * Override Camera.createRigCamera
  36615. */
  36616. createRigCamera(name: string, cameraIndex: number): Camera;
  36617. /**
  36618. * @hidden
  36619. * @override
  36620. * Override Camera._updateRigCameras
  36621. */
  36622. _updateRigCameras(): void;
  36623. /**
  36624. * Destroy the camera and release the current resources hold by it.
  36625. */
  36626. dispose(): void;
  36627. /**
  36628. * Gets the current object class name.
  36629. * @return the class name
  36630. */
  36631. getClassName(): string;
  36632. }
  36633. }
  36634. declare module BABYLON {
  36635. /**
  36636. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  36637. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36638. */
  36639. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  36640. /**
  36641. * Gets the name of the behavior.
  36642. */
  36643. readonly name: string;
  36644. private _zoomStopsAnimation;
  36645. private _idleRotationSpeed;
  36646. private _idleRotationWaitTime;
  36647. private _idleRotationSpinupTime;
  36648. /**
  36649. * Sets the flag that indicates if user zooming should stop animation.
  36650. */
  36651. /**
  36652. * Gets the flag that indicates if user zooming should stop animation.
  36653. */
  36654. zoomStopsAnimation: boolean;
  36655. /**
  36656. * Sets the default speed at which the camera rotates around the model.
  36657. */
  36658. /**
  36659. * Gets the default speed at which the camera rotates around the model.
  36660. */
  36661. idleRotationSpeed: number;
  36662. /**
  36663. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  36664. */
  36665. /**
  36666. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  36667. */
  36668. idleRotationWaitTime: number;
  36669. /**
  36670. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  36671. */
  36672. /**
  36673. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  36674. */
  36675. idleRotationSpinupTime: number;
  36676. /**
  36677. * Gets a value indicating if the camera is currently rotating because of this behavior
  36678. */
  36679. readonly rotationInProgress: boolean;
  36680. private _onPrePointerObservableObserver;
  36681. private _onAfterCheckInputsObserver;
  36682. private _attachedCamera;
  36683. private _isPointerDown;
  36684. private _lastFrameTime;
  36685. private _lastInteractionTime;
  36686. private _cameraRotationSpeed;
  36687. /**
  36688. * Initializes the behavior.
  36689. */
  36690. init(): void;
  36691. /**
  36692. * Attaches the behavior to its arc rotate camera.
  36693. * @param camera Defines the camera to attach the behavior to
  36694. */
  36695. attach(camera: ArcRotateCamera): void;
  36696. /**
  36697. * Detaches the behavior from its current arc rotate camera.
  36698. */
  36699. detach(): void;
  36700. /**
  36701. * Returns true if user is scrolling.
  36702. * @return true if user is scrolling.
  36703. */
  36704. private _userIsZooming;
  36705. private _lastFrameRadius;
  36706. private _shouldAnimationStopForInteraction;
  36707. /**
  36708. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  36709. */
  36710. private _applyUserInteraction;
  36711. private _userIsMoving;
  36712. }
  36713. }
  36714. declare module BABYLON {
  36715. /**
  36716. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  36717. */
  36718. export class AttachToBoxBehavior implements Behavior<Mesh> {
  36719. private ui;
  36720. /**
  36721. * The name of the behavior
  36722. */
  36723. name: string;
  36724. /**
  36725. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  36726. */
  36727. distanceAwayFromFace: number;
  36728. /**
  36729. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  36730. */
  36731. distanceAwayFromBottomOfFace: number;
  36732. private _faceVectors;
  36733. private _target;
  36734. private _scene;
  36735. private _onRenderObserver;
  36736. private _tmpMatrix;
  36737. private _tmpVector;
  36738. /**
  36739. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  36740. * @param ui The transform node that should be attched to the mesh
  36741. */
  36742. constructor(ui: TransformNode);
  36743. /**
  36744. * Initializes the behavior
  36745. */
  36746. init(): void;
  36747. private _closestFace;
  36748. private _zeroVector;
  36749. private _lookAtTmpMatrix;
  36750. private _lookAtToRef;
  36751. /**
  36752. * Attaches the AttachToBoxBehavior to the passed in mesh
  36753. * @param target The mesh that the specified node will be attached to
  36754. */
  36755. attach(target: Mesh): void;
  36756. /**
  36757. * Detaches the behavior from the mesh
  36758. */
  36759. detach(): void;
  36760. }
  36761. }
  36762. declare module BABYLON {
  36763. /**
  36764. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  36765. */
  36766. export class FadeInOutBehavior implements Behavior<Mesh> {
  36767. /**
  36768. * Time in milliseconds to delay before fading in (Default: 0)
  36769. */
  36770. delay: number;
  36771. /**
  36772. * Time in milliseconds for the mesh to fade in (Default: 300)
  36773. */
  36774. fadeInTime: number;
  36775. private _millisecondsPerFrame;
  36776. private _hovered;
  36777. private _hoverValue;
  36778. private _ownerNode;
  36779. /**
  36780. * Instatiates the FadeInOutBehavior
  36781. */
  36782. constructor();
  36783. /**
  36784. * The name of the behavior
  36785. */
  36786. readonly name: string;
  36787. /**
  36788. * Initializes the behavior
  36789. */
  36790. init(): void;
  36791. /**
  36792. * Attaches the fade behavior on the passed in mesh
  36793. * @param ownerNode The mesh that will be faded in/out once attached
  36794. */
  36795. attach(ownerNode: Mesh): void;
  36796. /**
  36797. * Detaches the behavior from the mesh
  36798. */
  36799. detach(): void;
  36800. /**
  36801. * Triggers the mesh to begin fading in or out
  36802. * @param value if the object should fade in or out (true to fade in)
  36803. */
  36804. fadeIn(value: boolean): void;
  36805. private _update;
  36806. private _setAllVisibility;
  36807. }
  36808. }
  36809. declare module BABYLON {
  36810. /**
  36811. * Class containing a set of static utilities functions for managing Pivots
  36812. * @hidden
  36813. */
  36814. export class PivotTools {
  36815. private static _PivotCached;
  36816. private static _OldPivotPoint;
  36817. private static _PivotTranslation;
  36818. private static _PivotTmpVector;
  36819. /** @hidden */
  36820. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  36821. /** @hidden */
  36822. static _RestorePivotPoint(mesh: AbstractMesh): void;
  36823. }
  36824. }
  36825. declare module BABYLON {
  36826. /**
  36827. * Class containing static functions to help procedurally build meshes
  36828. */
  36829. export class PlaneBuilder {
  36830. /**
  36831. * Creates a plane mesh
  36832. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  36833. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  36834. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  36835. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  36836. * * 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
  36837. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  36838. * @param name defines the name of the mesh
  36839. * @param options defines the options used to create the mesh
  36840. * @param scene defines the hosting scene
  36841. * @returns the plane mesh
  36842. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  36843. */
  36844. static CreatePlane(name: string, options: {
  36845. size?: number;
  36846. width?: number;
  36847. height?: number;
  36848. sideOrientation?: number;
  36849. frontUVs?: Vector4;
  36850. backUVs?: Vector4;
  36851. updatable?: boolean;
  36852. sourcePlane?: Plane;
  36853. }, scene?: Nullable<Scene>): Mesh;
  36854. }
  36855. }
  36856. declare module BABYLON {
  36857. /**
  36858. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  36859. */
  36860. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  36861. private static _AnyMouseID;
  36862. /**
  36863. * Abstract mesh the behavior is set on
  36864. */
  36865. attachedNode: AbstractMesh;
  36866. private _dragPlane;
  36867. private _scene;
  36868. private _pointerObserver;
  36869. private _beforeRenderObserver;
  36870. private static _planeScene;
  36871. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  36872. /**
  36873. * 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)
  36874. */
  36875. maxDragAngle: number;
  36876. /**
  36877. * @hidden
  36878. */
  36879. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  36880. /**
  36881. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  36882. */
  36883. currentDraggingPointerID: number;
  36884. /**
  36885. * The last position where the pointer hit the drag plane in world space
  36886. */
  36887. lastDragPosition: Vector3;
  36888. /**
  36889. * If the behavior is currently in a dragging state
  36890. */
  36891. dragging: boolean;
  36892. /**
  36893. * 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)
  36894. */
  36895. dragDeltaRatio: number;
  36896. /**
  36897. * If the drag plane orientation should be updated during the dragging (Default: true)
  36898. */
  36899. updateDragPlane: boolean;
  36900. private _debugMode;
  36901. private _moving;
  36902. /**
  36903. * Fires each time the attached mesh is dragged with the pointer
  36904. * * delta between last drag position and current drag position in world space
  36905. * * dragDistance along the drag axis
  36906. * * dragPlaneNormal normal of the current drag plane used during the drag
  36907. * * dragPlanePoint in world space where the drag intersects the drag plane
  36908. */
  36909. onDragObservable: Observable<{
  36910. delta: Vector3;
  36911. dragPlanePoint: Vector3;
  36912. dragPlaneNormal: Vector3;
  36913. dragDistance: number;
  36914. pointerId: number;
  36915. }>;
  36916. /**
  36917. * Fires each time a drag begins (eg. mouse down on mesh)
  36918. */
  36919. onDragStartObservable: Observable<{
  36920. dragPlanePoint: Vector3;
  36921. pointerId: number;
  36922. }>;
  36923. /**
  36924. * Fires each time a drag ends (eg. mouse release after drag)
  36925. */
  36926. onDragEndObservable: Observable<{
  36927. dragPlanePoint: Vector3;
  36928. pointerId: number;
  36929. }>;
  36930. /**
  36931. * If the attached mesh should be moved when dragged
  36932. */
  36933. moveAttached: boolean;
  36934. /**
  36935. * If the drag behavior will react to drag events (Default: true)
  36936. */
  36937. enabled: boolean;
  36938. /**
  36939. * If pointer events should start and release the drag (Default: true)
  36940. */
  36941. startAndReleaseDragOnPointerEvents: boolean;
  36942. /**
  36943. * If camera controls should be detached during the drag
  36944. */
  36945. detachCameraControls: boolean;
  36946. /**
  36947. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  36948. */
  36949. useObjectOrienationForDragging: boolean;
  36950. private _options;
  36951. /**
  36952. * Creates a pointer drag behavior that can be attached to a mesh
  36953. * @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)
  36954. */
  36955. constructor(options?: {
  36956. dragAxis?: Vector3;
  36957. dragPlaneNormal?: Vector3;
  36958. });
  36959. /**
  36960. * Predicate to determine if it is valid to move the object to a new position when it is moved
  36961. */
  36962. validateDrag: (targetPosition: Vector3) => boolean;
  36963. /**
  36964. * The name of the behavior
  36965. */
  36966. readonly name: string;
  36967. /**
  36968. * Initializes the behavior
  36969. */
  36970. init(): void;
  36971. private _tmpVector;
  36972. private _alternatePickedPoint;
  36973. private _worldDragAxis;
  36974. private _targetPosition;
  36975. private _attachedElement;
  36976. /**
  36977. * Attaches the drag behavior the passed in mesh
  36978. * @param ownerNode The mesh that will be dragged around once attached
  36979. * @param predicate Predicate to use for pick filtering
  36980. */
  36981. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  36982. /**
  36983. * Force relase the drag action by code.
  36984. */
  36985. releaseDrag(): void;
  36986. private _startDragRay;
  36987. private _lastPointerRay;
  36988. /**
  36989. * Simulates the start of a pointer drag event on the behavior
  36990. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  36991. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  36992. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  36993. */
  36994. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  36995. private _startDrag;
  36996. private _dragDelta;
  36997. private _moveDrag;
  36998. private _pickWithRayOnDragPlane;
  36999. private _pointA;
  37000. private _pointB;
  37001. private _pointC;
  37002. private _lineA;
  37003. private _lineB;
  37004. private _localAxis;
  37005. private _lookAt;
  37006. private _updateDragPlanePosition;
  37007. /**
  37008. * Detaches the behavior from the mesh
  37009. */
  37010. detach(): void;
  37011. }
  37012. }
  37013. declare module BABYLON {
  37014. /**
  37015. * A behavior that when attached to a mesh will allow the mesh to be scaled
  37016. */
  37017. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  37018. private _dragBehaviorA;
  37019. private _dragBehaviorB;
  37020. private _startDistance;
  37021. private _initialScale;
  37022. private _targetScale;
  37023. private _ownerNode;
  37024. private _sceneRenderObserver;
  37025. /**
  37026. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  37027. */
  37028. constructor();
  37029. /**
  37030. * The name of the behavior
  37031. */
  37032. readonly name: string;
  37033. /**
  37034. * Initializes the behavior
  37035. */
  37036. init(): void;
  37037. private _getCurrentDistance;
  37038. /**
  37039. * Attaches the scale behavior the passed in mesh
  37040. * @param ownerNode The mesh that will be scaled around once attached
  37041. */
  37042. attach(ownerNode: Mesh): void;
  37043. /**
  37044. * Detaches the behavior from the mesh
  37045. */
  37046. detach(): void;
  37047. }
  37048. }
  37049. declare module BABYLON {
  37050. /**
  37051. * 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
  37052. */
  37053. export class SixDofDragBehavior implements Behavior<Mesh> {
  37054. private static _virtualScene;
  37055. private _ownerNode;
  37056. private _sceneRenderObserver;
  37057. private _scene;
  37058. private _targetPosition;
  37059. private _virtualOriginMesh;
  37060. private _virtualDragMesh;
  37061. private _pointerObserver;
  37062. private _moving;
  37063. private _startingOrientation;
  37064. /**
  37065. * 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)
  37066. */
  37067. private zDragFactor;
  37068. /**
  37069. * If the object should rotate to face the drag origin
  37070. */
  37071. rotateDraggedObject: boolean;
  37072. /**
  37073. * If the behavior is currently in a dragging state
  37074. */
  37075. dragging: boolean;
  37076. /**
  37077. * 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)
  37078. */
  37079. dragDeltaRatio: number;
  37080. /**
  37081. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  37082. */
  37083. currentDraggingPointerID: number;
  37084. /**
  37085. * If camera controls should be detached during the drag
  37086. */
  37087. detachCameraControls: boolean;
  37088. /**
  37089. * Fires each time a drag starts
  37090. */
  37091. onDragStartObservable: Observable<{}>;
  37092. /**
  37093. * Fires each time a drag ends (eg. mouse release after drag)
  37094. */
  37095. onDragEndObservable: Observable<{}>;
  37096. /**
  37097. * 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
  37098. */
  37099. constructor();
  37100. /**
  37101. * The name of the behavior
  37102. */
  37103. readonly name: string;
  37104. /**
  37105. * Initializes the behavior
  37106. */
  37107. init(): void;
  37108. /**
  37109. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  37110. */
  37111. private readonly _pointerCamera;
  37112. /**
  37113. * Attaches the scale behavior the passed in mesh
  37114. * @param ownerNode The mesh that will be scaled around once attached
  37115. */
  37116. attach(ownerNode: Mesh): void;
  37117. /**
  37118. * Detaches the behavior from the mesh
  37119. */
  37120. detach(): void;
  37121. }
  37122. }
  37123. declare module BABYLON {
  37124. /**
  37125. * Class used to apply inverse kinematics to bones
  37126. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  37127. */
  37128. export class BoneIKController {
  37129. private static _tmpVecs;
  37130. private static _tmpQuat;
  37131. private static _tmpMats;
  37132. /**
  37133. * Gets or sets the target mesh
  37134. */
  37135. targetMesh: AbstractMesh;
  37136. /** Gets or sets the mesh used as pole */
  37137. poleTargetMesh: AbstractMesh;
  37138. /**
  37139. * Gets or sets the bone used as pole
  37140. */
  37141. poleTargetBone: Nullable<Bone>;
  37142. /**
  37143. * Gets or sets the target position
  37144. */
  37145. targetPosition: Vector3;
  37146. /**
  37147. * Gets or sets the pole target position
  37148. */
  37149. poleTargetPosition: Vector3;
  37150. /**
  37151. * Gets or sets the pole target local offset
  37152. */
  37153. poleTargetLocalOffset: Vector3;
  37154. /**
  37155. * Gets or sets the pole angle
  37156. */
  37157. poleAngle: number;
  37158. /**
  37159. * Gets or sets the mesh associated with the controller
  37160. */
  37161. mesh: AbstractMesh;
  37162. /**
  37163. * 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)
  37164. */
  37165. slerpAmount: number;
  37166. private _bone1Quat;
  37167. private _bone1Mat;
  37168. private _bone2Ang;
  37169. private _bone1;
  37170. private _bone2;
  37171. private _bone1Length;
  37172. private _bone2Length;
  37173. private _maxAngle;
  37174. private _maxReach;
  37175. private _rightHandedSystem;
  37176. private _bendAxis;
  37177. private _slerping;
  37178. private _adjustRoll;
  37179. /**
  37180. * Gets or sets maximum allowed angle
  37181. */
  37182. maxAngle: number;
  37183. /**
  37184. * Creates a new BoneIKController
  37185. * @param mesh defines the mesh to control
  37186. * @param bone defines the bone to control
  37187. * @param options defines options to set up the controller
  37188. */
  37189. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  37190. targetMesh?: AbstractMesh;
  37191. poleTargetMesh?: AbstractMesh;
  37192. poleTargetBone?: Bone;
  37193. poleTargetLocalOffset?: Vector3;
  37194. poleAngle?: number;
  37195. bendAxis?: Vector3;
  37196. maxAngle?: number;
  37197. slerpAmount?: number;
  37198. });
  37199. private _setMaxAngle;
  37200. /**
  37201. * Force the controller to update the bones
  37202. */
  37203. update(): void;
  37204. }
  37205. }
  37206. declare module BABYLON {
  37207. /**
  37208. * Class used to make a bone look toward a point in space
  37209. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  37210. */
  37211. export class BoneLookController {
  37212. private static _tmpVecs;
  37213. private static _tmpQuat;
  37214. private static _tmpMats;
  37215. /**
  37216. * The target Vector3 that the bone will look at
  37217. */
  37218. target: Vector3;
  37219. /**
  37220. * The mesh that the bone is attached to
  37221. */
  37222. mesh: AbstractMesh;
  37223. /**
  37224. * The bone that will be looking to the target
  37225. */
  37226. bone: Bone;
  37227. /**
  37228. * The up axis of the coordinate system that is used when the bone is rotated
  37229. */
  37230. upAxis: Vector3;
  37231. /**
  37232. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  37233. */
  37234. upAxisSpace: Space;
  37235. /**
  37236. * Used to make an adjustment to the yaw of the bone
  37237. */
  37238. adjustYaw: number;
  37239. /**
  37240. * Used to make an adjustment to the pitch of the bone
  37241. */
  37242. adjustPitch: number;
  37243. /**
  37244. * Used to make an adjustment to the roll of the bone
  37245. */
  37246. adjustRoll: number;
  37247. /**
  37248. * 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)
  37249. */
  37250. slerpAmount: number;
  37251. private _minYaw;
  37252. private _maxYaw;
  37253. private _minPitch;
  37254. private _maxPitch;
  37255. private _minYawSin;
  37256. private _minYawCos;
  37257. private _maxYawSin;
  37258. private _maxYawCos;
  37259. private _midYawConstraint;
  37260. private _minPitchTan;
  37261. private _maxPitchTan;
  37262. private _boneQuat;
  37263. private _slerping;
  37264. private _transformYawPitch;
  37265. private _transformYawPitchInv;
  37266. private _firstFrameSkipped;
  37267. private _yawRange;
  37268. private _fowardAxis;
  37269. /**
  37270. * Gets or sets the minimum yaw angle that the bone can look to
  37271. */
  37272. minYaw: number;
  37273. /**
  37274. * Gets or sets the maximum yaw angle that the bone can look to
  37275. */
  37276. maxYaw: number;
  37277. /**
  37278. * Gets or sets the minimum pitch angle that the bone can look to
  37279. */
  37280. minPitch: number;
  37281. /**
  37282. * Gets or sets the maximum pitch angle that the bone can look to
  37283. */
  37284. maxPitch: number;
  37285. /**
  37286. * Create a BoneLookController
  37287. * @param mesh the mesh that the bone belongs to
  37288. * @param bone the bone that will be looking to the target
  37289. * @param target the target Vector3 to look at
  37290. * @param options optional settings:
  37291. * * maxYaw: the maximum angle the bone will yaw to
  37292. * * minYaw: the minimum angle the bone will yaw to
  37293. * * maxPitch: the maximum angle the bone will pitch to
  37294. * * minPitch: the minimum angle the bone will yaw to
  37295. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  37296. * * upAxis: the up axis of the coordinate system
  37297. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  37298. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  37299. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  37300. * * adjustYaw: used to make an adjustment to the yaw of the bone
  37301. * * adjustPitch: used to make an adjustment to the pitch of the bone
  37302. * * adjustRoll: used to make an adjustment to the roll of the bone
  37303. **/
  37304. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  37305. maxYaw?: number;
  37306. minYaw?: number;
  37307. maxPitch?: number;
  37308. minPitch?: number;
  37309. slerpAmount?: number;
  37310. upAxis?: Vector3;
  37311. upAxisSpace?: Space;
  37312. yawAxis?: Vector3;
  37313. pitchAxis?: Vector3;
  37314. adjustYaw?: number;
  37315. adjustPitch?: number;
  37316. adjustRoll?: number;
  37317. });
  37318. /**
  37319. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  37320. */
  37321. update(): void;
  37322. private _getAngleDiff;
  37323. private _getAngleBetween;
  37324. private _isAngleBetween;
  37325. }
  37326. }
  37327. declare module BABYLON {
  37328. /**
  37329. * Manage the gamepad inputs to control an arc rotate camera.
  37330. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37331. */
  37332. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  37333. /**
  37334. * Defines the camera the input is attached to.
  37335. */
  37336. camera: ArcRotateCamera;
  37337. /**
  37338. * Defines the gamepad the input is gathering event from.
  37339. */
  37340. gamepad: Nullable<Gamepad>;
  37341. /**
  37342. * Defines the gamepad rotation sensiblity.
  37343. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  37344. */
  37345. gamepadRotationSensibility: number;
  37346. /**
  37347. * Defines the gamepad move sensiblity.
  37348. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  37349. */
  37350. gamepadMoveSensibility: number;
  37351. private _yAxisScale;
  37352. /**
  37353. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  37354. */
  37355. invertYAxis: boolean;
  37356. private _onGamepadConnectedObserver;
  37357. private _onGamepadDisconnectedObserver;
  37358. /**
  37359. * Attach the input controls to a specific dom element to get the input from.
  37360. * @param element Defines the element the controls should be listened from
  37361. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37362. */
  37363. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37364. /**
  37365. * Detach the current controls from the specified dom element.
  37366. * @param element Defines the element to stop listening the inputs from
  37367. */
  37368. detachControl(element: Nullable<HTMLElement>): void;
  37369. /**
  37370. * Update the current camera state depending on the inputs that have been used this frame.
  37371. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37372. */
  37373. checkInputs(): void;
  37374. /**
  37375. * Gets the class name of the current intput.
  37376. * @returns the class name
  37377. */
  37378. getClassName(): string;
  37379. /**
  37380. * Get the friendly name associated with the input class.
  37381. * @returns the input friendly name
  37382. */
  37383. getSimpleName(): string;
  37384. }
  37385. }
  37386. declare module BABYLON {
  37387. interface ArcRotateCameraInputsManager {
  37388. /**
  37389. * Add orientation input support to the input manager.
  37390. * @returns the current input manager
  37391. */
  37392. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  37393. }
  37394. /**
  37395. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  37396. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37397. */
  37398. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  37399. /**
  37400. * Defines the camera the input is attached to.
  37401. */
  37402. camera: ArcRotateCamera;
  37403. /**
  37404. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  37405. */
  37406. alphaCorrection: number;
  37407. /**
  37408. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  37409. */
  37410. gammaCorrection: number;
  37411. private _alpha;
  37412. private _gamma;
  37413. private _dirty;
  37414. private _deviceOrientationHandler;
  37415. /**
  37416. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  37417. */
  37418. constructor();
  37419. /**
  37420. * Attach the input controls to a specific dom element to get the input from.
  37421. * @param element Defines the element the controls should be listened from
  37422. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37423. */
  37424. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37425. /** @hidden */
  37426. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  37427. /**
  37428. * Update the current camera state depending on the inputs that have been used this frame.
  37429. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37430. */
  37431. checkInputs(): void;
  37432. /**
  37433. * Detach the current controls from the specified dom element.
  37434. * @param element Defines the element to stop listening the inputs from
  37435. */
  37436. detachControl(element: Nullable<HTMLElement>): void;
  37437. /**
  37438. * Gets the class name of the current intput.
  37439. * @returns the class name
  37440. */
  37441. getClassName(): string;
  37442. /**
  37443. * Get the friendly name associated with the input class.
  37444. * @returns the input friendly name
  37445. */
  37446. getSimpleName(): string;
  37447. }
  37448. }
  37449. declare module BABYLON {
  37450. /**
  37451. * Listen to mouse events to control the camera.
  37452. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37453. */
  37454. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  37455. /**
  37456. * Defines the camera the input is attached to.
  37457. */
  37458. camera: FlyCamera;
  37459. /**
  37460. * Defines if touch is enabled. (Default is true.)
  37461. */
  37462. touchEnabled: boolean;
  37463. /**
  37464. * Defines the buttons associated with the input to handle camera rotation.
  37465. */
  37466. buttons: number[];
  37467. /**
  37468. * Assign buttons for Yaw control.
  37469. */
  37470. buttonsYaw: number[];
  37471. /**
  37472. * Assign buttons for Pitch control.
  37473. */
  37474. buttonsPitch: number[];
  37475. /**
  37476. * Assign buttons for Roll control.
  37477. */
  37478. buttonsRoll: number[];
  37479. /**
  37480. * Detect if any button is being pressed while mouse is moved.
  37481. * -1 = Mouse locked.
  37482. * 0 = Left button.
  37483. * 1 = Middle Button.
  37484. * 2 = Right Button.
  37485. */
  37486. activeButton: number;
  37487. /**
  37488. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  37489. * Higher values reduce its sensitivity.
  37490. */
  37491. angularSensibility: number;
  37492. private _mousemoveCallback;
  37493. private _observer;
  37494. private _rollObserver;
  37495. private previousPosition;
  37496. private noPreventDefault;
  37497. private element;
  37498. /**
  37499. * Listen to mouse events to control the camera.
  37500. * @param touchEnabled Define if touch is enabled. (Default is true.)
  37501. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37502. */
  37503. constructor(touchEnabled?: boolean);
  37504. /**
  37505. * Attach the mouse control to the HTML DOM element.
  37506. * @param element Defines the element that listens to the input events.
  37507. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  37508. */
  37509. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37510. /**
  37511. * Detach the current controls from the specified dom element.
  37512. * @param element Defines the element to stop listening the inputs from
  37513. */
  37514. detachControl(element: Nullable<HTMLElement>): void;
  37515. /**
  37516. * Gets the class name of the current input.
  37517. * @returns the class name.
  37518. */
  37519. getClassName(): string;
  37520. /**
  37521. * Get the friendly name associated with the input class.
  37522. * @returns the input's friendly name.
  37523. */
  37524. getSimpleName(): string;
  37525. private _pointerInput;
  37526. private _onMouseMove;
  37527. /**
  37528. * Rotate camera by mouse offset.
  37529. */
  37530. private rotateCamera;
  37531. }
  37532. }
  37533. declare module BABYLON {
  37534. /**
  37535. * Default Inputs manager for the FlyCamera.
  37536. * It groups all the default supported inputs for ease of use.
  37537. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37538. */
  37539. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  37540. /**
  37541. * Instantiates a new FlyCameraInputsManager.
  37542. * @param camera Defines the camera the inputs belong to.
  37543. */
  37544. constructor(camera: FlyCamera);
  37545. /**
  37546. * Add keyboard input support to the input manager.
  37547. * @returns the new FlyCameraKeyboardMoveInput().
  37548. */
  37549. addKeyboard(): FlyCameraInputsManager;
  37550. /**
  37551. * Add mouse input support to the input manager.
  37552. * @param touchEnabled Enable touch screen support.
  37553. * @returns the new FlyCameraMouseInput().
  37554. */
  37555. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  37556. }
  37557. }
  37558. declare module BABYLON {
  37559. /**
  37560. * This is a flying camera, designed for 3D movement and rotation in all directions,
  37561. * such as in a 3D Space Shooter or a Flight Simulator.
  37562. */
  37563. export class FlyCamera extends TargetCamera {
  37564. /**
  37565. * Define the collision ellipsoid of the camera.
  37566. * This is helpful for simulating a camera body, like a player's body.
  37567. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  37568. */
  37569. ellipsoid: Vector3;
  37570. /**
  37571. * Define an offset for the position of the ellipsoid around the camera.
  37572. * This can be helpful if the camera is attached away from the player's body center,
  37573. * such as at its head.
  37574. */
  37575. ellipsoidOffset: Vector3;
  37576. /**
  37577. * Enable or disable collisions of the camera with the rest of the scene objects.
  37578. */
  37579. checkCollisions: boolean;
  37580. /**
  37581. * Enable or disable gravity on the camera.
  37582. */
  37583. applyGravity: boolean;
  37584. /**
  37585. * Define the current direction the camera is moving to.
  37586. */
  37587. cameraDirection: Vector3;
  37588. /**
  37589. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  37590. * This overrides and empties cameraRotation.
  37591. */
  37592. rotationQuaternion: Quaternion;
  37593. /**
  37594. * Track Roll to maintain the wanted Rolling when looking around.
  37595. */
  37596. _trackRoll: number;
  37597. /**
  37598. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  37599. */
  37600. rollCorrect: number;
  37601. /**
  37602. * Mimic a banked turn, Rolling the camera when Yawing.
  37603. * It's recommended to use rollCorrect = 10 for faster banking correction.
  37604. */
  37605. bankedTurn: boolean;
  37606. /**
  37607. * Limit in radians for how much Roll banking will add. (Default: 90°)
  37608. */
  37609. bankedTurnLimit: number;
  37610. /**
  37611. * Value of 0 disables the banked Roll.
  37612. * Value of 1 is equal to the Yaw angle in radians.
  37613. */
  37614. bankedTurnMultiplier: number;
  37615. /**
  37616. * The inputs manager loads all the input sources, such as keyboard and mouse.
  37617. */
  37618. inputs: FlyCameraInputsManager;
  37619. /**
  37620. * Gets the input sensibility for mouse input.
  37621. * Higher values reduce sensitivity.
  37622. */
  37623. /**
  37624. * Sets the input sensibility for a mouse input.
  37625. * Higher values reduce sensitivity.
  37626. */
  37627. angularSensibility: number;
  37628. /**
  37629. * Get the keys for camera movement forward.
  37630. */
  37631. /**
  37632. * Set the keys for camera movement forward.
  37633. */
  37634. keysForward: number[];
  37635. /**
  37636. * Get the keys for camera movement backward.
  37637. */
  37638. keysBackward: number[];
  37639. /**
  37640. * Get the keys for camera movement up.
  37641. */
  37642. /**
  37643. * Set the keys for camera movement up.
  37644. */
  37645. keysUp: number[];
  37646. /**
  37647. * Get the keys for camera movement down.
  37648. */
  37649. /**
  37650. * Set the keys for camera movement down.
  37651. */
  37652. keysDown: number[];
  37653. /**
  37654. * Get the keys for camera movement left.
  37655. */
  37656. /**
  37657. * Set the keys for camera movement left.
  37658. */
  37659. keysLeft: number[];
  37660. /**
  37661. * Set the keys for camera movement right.
  37662. */
  37663. /**
  37664. * Set the keys for camera movement right.
  37665. */
  37666. keysRight: number[];
  37667. /**
  37668. * Event raised when the camera collides with a mesh in the scene.
  37669. */
  37670. onCollide: (collidedMesh: AbstractMesh) => void;
  37671. private _collider;
  37672. private _needMoveForGravity;
  37673. private _oldPosition;
  37674. private _diffPosition;
  37675. private _newPosition;
  37676. /** @hidden */
  37677. _localDirection: Vector3;
  37678. /** @hidden */
  37679. _transformedDirection: Vector3;
  37680. /**
  37681. * Instantiates a FlyCamera.
  37682. * This is a flying camera, designed for 3D movement and rotation in all directions,
  37683. * such as in a 3D Space Shooter or a Flight Simulator.
  37684. * @param name Define the name of the camera in the scene.
  37685. * @param position Define the starting position of the camera in the scene.
  37686. * @param scene Define the scene the camera belongs to.
  37687. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  37688. */
  37689. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  37690. /**
  37691. * Attach a control to the HTML DOM element.
  37692. * @param element Defines the element that listens to the input events.
  37693. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  37694. */
  37695. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37696. /**
  37697. * Detach a control from the HTML DOM element.
  37698. * The camera will stop reacting to that input.
  37699. * @param element Defines the element that listens to the input events.
  37700. */
  37701. detachControl(element: HTMLElement): void;
  37702. private _collisionMask;
  37703. /**
  37704. * Get the mask that the camera ignores in collision events.
  37705. */
  37706. /**
  37707. * Set the mask that the camera ignores in collision events.
  37708. */
  37709. collisionMask: number;
  37710. /** @hidden */
  37711. _collideWithWorld(displacement: Vector3): void;
  37712. /** @hidden */
  37713. private _onCollisionPositionChange;
  37714. /** @hidden */
  37715. _checkInputs(): void;
  37716. /** @hidden */
  37717. _decideIfNeedsToMove(): boolean;
  37718. /** @hidden */
  37719. _updatePosition(): void;
  37720. /**
  37721. * Restore the Roll to its target value at the rate specified.
  37722. * @param rate - Higher means slower restoring.
  37723. * @hidden
  37724. */
  37725. restoreRoll(rate: number): void;
  37726. /**
  37727. * Destroy the camera and release the current resources held by it.
  37728. */
  37729. dispose(): void;
  37730. /**
  37731. * Get the current object class name.
  37732. * @returns the class name.
  37733. */
  37734. getClassName(): string;
  37735. }
  37736. }
  37737. declare module BABYLON {
  37738. /**
  37739. * Listen to keyboard events to control the camera.
  37740. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37741. */
  37742. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  37743. /**
  37744. * Defines the camera the input is attached to.
  37745. */
  37746. camera: FlyCamera;
  37747. /**
  37748. * The list of keyboard keys used to control the forward move of the camera.
  37749. */
  37750. keysForward: number[];
  37751. /**
  37752. * The list of keyboard keys used to control the backward move of the camera.
  37753. */
  37754. keysBackward: number[];
  37755. /**
  37756. * The list of keyboard keys used to control the forward move of the camera.
  37757. */
  37758. keysUp: number[];
  37759. /**
  37760. * The list of keyboard keys used to control the backward move of the camera.
  37761. */
  37762. keysDown: number[];
  37763. /**
  37764. * The list of keyboard keys used to control the right strafe move of the camera.
  37765. */
  37766. keysRight: number[];
  37767. /**
  37768. * The list of keyboard keys used to control the left strafe move of the camera.
  37769. */
  37770. keysLeft: number[];
  37771. private _keys;
  37772. private _onCanvasBlurObserver;
  37773. private _onKeyboardObserver;
  37774. private _engine;
  37775. private _scene;
  37776. /**
  37777. * Attach the input controls to a specific dom element to get the input from.
  37778. * @param element Defines the element the controls should be listened from
  37779. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37780. */
  37781. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37782. /**
  37783. * Detach the current controls from the specified dom element.
  37784. * @param element Defines the element to stop listening the inputs from
  37785. */
  37786. detachControl(element: Nullable<HTMLElement>): void;
  37787. /**
  37788. * Gets the class name of the current intput.
  37789. * @returns the class name
  37790. */
  37791. getClassName(): string;
  37792. /** @hidden */
  37793. _onLostFocus(e: FocusEvent): void;
  37794. /**
  37795. * Get the friendly name associated with the input class.
  37796. * @returns the input friendly name
  37797. */
  37798. getSimpleName(): string;
  37799. /**
  37800. * Update the current camera state depending on the inputs that have been used this frame.
  37801. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37802. */
  37803. checkInputs(): void;
  37804. }
  37805. }
  37806. declare module BABYLON {
  37807. /**
  37808. * Manage the mouse wheel inputs to control a follow camera.
  37809. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37810. */
  37811. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  37812. /**
  37813. * Defines the camera the input is attached to.
  37814. */
  37815. camera: FollowCamera;
  37816. /**
  37817. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  37818. */
  37819. axisControlRadius: boolean;
  37820. /**
  37821. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  37822. */
  37823. axisControlHeight: boolean;
  37824. /**
  37825. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  37826. */
  37827. axisControlRotation: boolean;
  37828. /**
  37829. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  37830. * relation to mouseWheel events.
  37831. */
  37832. wheelPrecision: number;
  37833. /**
  37834. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  37835. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  37836. */
  37837. wheelDeltaPercentage: number;
  37838. private _wheel;
  37839. private _observer;
  37840. /**
  37841. * Attach the input controls to a specific dom element to get the input from.
  37842. * @param element Defines the element the controls should be listened from
  37843. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37844. */
  37845. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37846. /**
  37847. * Detach the current controls from the specified dom element.
  37848. * @param element Defines the element to stop listening the inputs from
  37849. */
  37850. detachControl(element: Nullable<HTMLElement>): void;
  37851. /**
  37852. * Gets the class name of the current intput.
  37853. * @returns the class name
  37854. */
  37855. getClassName(): string;
  37856. /**
  37857. * Get the friendly name associated with the input class.
  37858. * @returns the input friendly name
  37859. */
  37860. getSimpleName(): string;
  37861. }
  37862. }
  37863. declare module BABYLON {
  37864. /**
  37865. * Manage the pointers inputs to control an follow camera.
  37866. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37867. */
  37868. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  37869. /**
  37870. * Defines the camera the input is attached to.
  37871. */
  37872. camera: FollowCamera;
  37873. /**
  37874. * Gets the class name of the current input.
  37875. * @returns the class name
  37876. */
  37877. getClassName(): string;
  37878. /**
  37879. * Defines the pointer angular sensibility along the X axis or how fast is
  37880. * the camera rotating.
  37881. * A negative number will reverse the axis direction.
  37882. */
  37883. angularSensibilityX: number;
  37884. /**
  37885. * Defines the pointer angular sensibility along the Y axis or how fast is
  37886. * the camera rotating.
  37887. * A negative number will reverse the axis direction.
  37888. */
  37889. angularSensibilityY: number;
  37890. /**
  37891. * Defines the pointer pinch precision or how fast is the camera zooming.
  37892. * A negative number will reverse the axis direction.
  37893. */
  37894. pinchPrecision: number;
  37895. /**
  37896. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  37897. * from 0.
  37898. * It defines the percentage of current camera.radius to use as delta when
  37899. * pinch zoom is used.
  37900. */
  37901. pinchDeltaPercentage: number;
  37902. /**
  37903. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  37904. */
  37905. axisXControlRadius: boolean;
  37906. /**
  37907. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  37908. */
  37909. axisXControlHeight: boolean;
  37910. /**
  37911. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  37912. */
  37913. axisXControlRotation: boolean;
  37914. /**
  37915. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  37916. */
  37917. axisYControlRadius: boolean;
  37918. /**
  37919. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  37920. */
  37921. axisYControlHeight: boolean;
  37922. /**
  37923. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  37924. */
  37925. axisYControlRotation: boolean;
  37926. /**
  37927. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  37928. */
  37929. axisPinchControlRadius: boolean;
  37930. /**
  37931. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  37932. */
  37933. axisPinchControlHeight: boolean;
  37934. /**
  37935. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  37936. */
  37937. axisPinchControlRotation: boolean;
  37938. /**
  37939. * Log error messages if basic misconfiguration has occurred.
  37940. */
  37941. warningEnable: boolean;
  37942. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  37943. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  37944. private _warningCounter;
  37945. private _warning;
  37946. }
  37947. }
  37948. declare module BABYLON {
  37949. /**
  37950. * Default Inputs manager for the FollowCamera.
  37951. * It groups all the default supported inputs for ease of use.
  37952. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37953. */
  37954. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  37955. /**
  37956. * Instantiates a new FollowCameraInputsManager.
  37957. * @param camera Defines the camera the inputs belong to
  37958. */
  37959. constructor(camera: FollowCamera);
  37960. /**
  37961. * Add keyboard input support to the input manager.
  37962. * @returns the current input manager
  37963. */
  37964. addKeyboard(): FollowCameraInputsManager;
  37965. /**
  37966. * Add mouse wheel input support to the input manager.
  37967. * @returns the current input manager
  37968. */
  37969. addMouseWheel(): FollowCameraInputsManager;
  37970. /**
  37971. * Add pointers input support to the input manager.
  37972. * @returns the current input manager
  37973. */
  37974. addPointers(): FollowCameraInputsManager;
  37975. /**
  37976. * Add orientation input support to the input manager.
  37977. * @returns the current input manager
  37978. */
  37979. addVRDeviceOrientation(): FollowCameraInputsManager;
  37980. }
  37981. }
  37982. declare module BABYLON {
  37983. /**
  37984. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  37985. * an arc rotate version arcFollowCamera are available.
  37986. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37987. */
  37988. export class FollowCamera extends TargetCamera {
  37989. /**
  37990. * Distance the follow camera should follow an object at
  37991. */
  37992. radius: number;
  37993. /**
  37994. * Minimum allowed distance of the camera to the axis of rotation
  37995. * (The camera can not get closer).
  37996. * This can help limiting how the Camera is able to move in the scene.
  37997. */
  37998. lowerRadiusLimit: Nullable<number>;
  37999. /**
  38000. * Maximum allowed distance of the camera to the axis of rotation
  38001. * (The camera can not get further).
  38002. * This can help limiting how the Camera is able to move in the scene.
  38003. */
  38004. upperRadiusLimit: Nullable<number>;
  38005. /**
  38006. * Define a rotation offset between the camera and the object it follows
  38007. */
  38008. rotationOffset: number;
  38009. /**
  38010. * Minimum allowed angle to camera position relative to target object.
  38011. * This can help limiting how the Camera is able to move in the scene.
  38012. */
  38013. lowerRotationOffsetLimit: Nullable<number>;
  38014. /**
  38015. * Maximum allowed angle to camera position relative to target object.
  38016. * This can help limiting how the Camera is able to move in the scene.
  38017. */
  38018. upperRotationOffsetLimit: Nullable<number>;
  38019. /**
  38020. * Define a height offset between the camera and the object it follows.
  38021. * It can help following an object from the top (like a car chaing a plane)
  38022. */
  38023. heightOffset: number;
  38024. /**
  38025. * Minimum allowed height of camera position relative to target object.
  38026. * This can help limiting how the Camera is able to move in the scene.
  38027. */
  38028. lowerHeightOffsetLimit: Nullable<number>;
  38029. /**
  38030. * Maximum allowed height of camera position relative to target object.
  38031. * This can help limiting how the Camera is able to move in the scene.
  38032. */
  38033. upperHeightOffsetLimit: Nullable<number>;
  38034. /**
  38035. * Define how fast the camera can accelerate to follow it s target.
  38036. */
  38037. cameraAcceleration: number;
  38038. /**
  38039. * Define the speed limit of the camera following an object.
  38040. */
  38041. maxCameraSpeed: number;
  38042. /**
  38043. * Define the target of the camera.
  38044. */
  38045. lockedTarget: Nullable<AbstractMesh>;
  38046. /**
  38047. * Defines the input associated with the camera.
  38048. */
  38049. inputs: FollowCameraInputsManager;
  38050. /**
  38051. * Instantiates the follow camera.
  38052. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38053. * @param name Define the name of the camera in the scene
  38054. * @param position Define the position of the camera
  38055. * @param scene Define the scene the camera belong to
  38056. * @param lockedTarget Define the target of the camera
  38057. */
  38058. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  38059. private _follow;
  38060. /**
  38061. * Attached controls to the current camera.
  38062. * @param element Defines the element the controls should be listened from
  38063. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38064. */
  38065. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38066. /**
  38067. * Detach the current controls from the camera.
  38068. * The camera will stop reacting to inputs.
  38069. * @param element Defines the element to stop listening the inputs from
  38070. */
  38071. detachControl(element: HTMLElement): void;
  38072. /** @hidden */
  38073. _checkInputs(): void;
  38074. private _checkLimits;
  38075. /**
  38076. * Gets the camera class name.
  38077. * @returns the class name
  38078. */
  38079. getClassName(): string;
  38080. }
  38081. /**
  38082. * Arc Rotate version of the follow camera.
  38083. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  38084. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38085. */
  38086. export class ArcFollowCamera extends TargetCamera {
  38087. /** The longitudinal angle of the camera */
  38088. alpha: number;
  38089. /** The latitudinal angle of the camera */
  38090. beta: number;
  38091. /** The radius of the camera from its target */
  38092. radius: number;
  38093. /** Define the camera target (the messh it should follow) */
  38094. target: Nullable<AbstractMesh>;
  38095. private _cartesianCoordinates;
  38096. /**
  38097. * Instantiates a new ArcFollowCamera
  38098. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38099. * @param name Define the name of the camera
  38100. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  38101. * @param beta Define the rotation angle of the camera around the elevation axis
  38102. * @param radius Define the radius of the camera from its target point
  38103. * @param target Define the target of the camera
  38104. * @param scene Define the scene the camera belongs to
  38105. */
  38106. constructor(name: string,
  38107. /** The longitudinal angle of the camera */
  38108. alpha: number,
  38109. /** The latitudinal angle of the camera */
  38110. beta: number,
  38111. /** The radius of the camera from its target */
  38112. radius: number,
  38113. /** Define the camera target (the messh it should follow) */
  38114. target: Nullable<AbstractMesh>, scene: Scene);
  38115. private _follow;
  38116. /** @hidden */
  38117. _checkInputs(): void;
  38118. /**
  38119. * Returns the class name of the object.
  38120. * It is mostly used internally for serialization purposes.
  38121. */
  38122. getClassName(): string;
  38123. }
  38124. }
  38125. declare module BABYLON {
  38126. /**
  38127. * Manage the keyboard inputs to control the movement of a follow camera.
  38128. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38129. */
  38130. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  38131. /**
  38132. * Defines the camera the input is attached to.
  38133. */
  38134. camera: FollowCamera;
  38135. /**
  38136. * Defines the list of key codes associated with the up action (increase heightOffset)
  38137. */
  38138. keysHeightOffsetIncr: number[];
  38139. /**
  38140. * Defines the list of key codes associated with the down action (decrease heightOffset)
  38141. */
  38142. keysHeightOffsetDecr: number[];
  38143. /**
  38144. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  38145. */
  38146. keysHeightOffsetModifierAlt: boolean;
  38147. /**
  38148. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  38149. */
  38150. keysHeightOffsetModifierCtrl: boolean;
  38151. /**
  38152. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  38153. */
  38154. keysHeightOffsetModifierShift: boolean;
  38155. /**
  38156. * Defines the list of key codes associated with the left action (increase rotationOffset)
  38157. */
  38158. keysRotationOffsetIncr: number[];
  38159. /**
  38160. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  38161. */
  38162. keysRotationOffsetDecr: number[];
  38163. /**
  38164. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  38165. */
  38166. keysRotationOffsetModifierAlt: boolean;
  38167. /**
  38168. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  38169. */
  38170. keysRotationOffsetModifierCtrl: boolean;
  38171. /**
  38172. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  38173. */
  38174. keysRotationOffsetModifierShift: boolean;
  38175. /**
  38176. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  38177. */
  38178. keysRadiusIncr: number[];
  38179. /**
  38180. * Defines the list of key codes associated with the zoom-out action (increase radius)
  38181. */
  38182. keysRadiusDecr: number[];
  38183. /**
  38184. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  38185. */
  38186. keysRadiusModifierAlt: boolean;
  38187. /**
  38188. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  38189. */
  38190. keysRadiusModifierCtrl: boolean;
  38191. /**
  38192. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  38193. */
  38194. keysRadiusModifierShift: boolean;
  38195. /**
  38196. * Defines the rate of change of heightOffset.
  38197. */
  38198. heightSensibility: number;
  38199. /**
  38200. * Defines the rate of change of rotationOffset.
  38201. */
  38202. rotationSensibility: number;
  38203. /**
  38204. * Defines the rate of change of radius.
  38205. */
  38206. radiusSensibility: number;
  38207. private _keys;
  38208. private _ctrlPressed;
  38209. private _altPressed;
  38210. private _shiftPressed;
  38211. private _onCanvasBlurObserver;
  38212. private _onKeyboardObserver;
  38213. private _engine;
  38214. private _scene;
  38215. /**
  38216. * Attach the input controls to a specific dom element to get the input from.
  38217. * @param element Defines the element the controls should be listened from
  38218. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38219. */
  38220. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38221. /**
  38222. * Detach the current controls from the specified dom element.
  38223. * @param element Defines the element to stop listening the inputs from
  38224. */
  38225. detachControl(element: Nullable<HTMLElement>): void;
  38226. /**
  38227. * Update the current camera state depending on the inputs that have been used this frame.
  38228. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38229. */
  38230. checkInputs(): void;
  38231. /**
  38232. * Gets the class name of the current input.
  38233. * @returns the class name
  38234. */
  38235. getClassName(): string;
  38236. /**
  38237. * Get the friendly name associated with the input class.
  38238. * @returns the input friendly name
  38239. */
  38240. getSimpleName(): string;
  38241. /**
  38242. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  38243. * allow modification of the heightOffset value.
  38244. */
  38245. private _modifierHeightOffset;
  38246. /**
  38247. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  38248. * allow modification of the rotationOffset value.
  38249. */
  38250. private _modifierRotationOffset;
  38251. /**
  38252. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  38253. * allow modification of the radius value.
  38254. */
  38255. private _modifierRadius;
  38256. }
  38257. }
  38258. declare module BABYLON {
  38259. interface FreeCameraInputsManager {
  38260. /**
  38261. * @hidden
  38262. */
  38263. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  38264. /**
  38265. * Add orientation input support to the input manager.
  38266. * @returns the current input manager
  38267. */
  38268. addDeviceOrientation(): FreeCameraInputsManager;
  38269. }
  38270. /**
  38271. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  38272. * Screen rotation is taken into account.
  38273. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38274. */
  38275. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  38276. private _camera;
  38277. private _screenOrientationAngle;
  38278. private _constantTranform;
  38279. private _screenQuaternion;
  38280. private _alpha;
  38281. private _beta;
  38282. private _gamma;
  38283. /**
  38284. * Can be used to detect if a device orientation sensor is availible on a device
  38285. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  38286. * @returns a promise that will resolve on orientation change
  38287. */
  38288. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  38289. /**
  38290. * @hidden
  38291. */
  38292. _onDeviceOrientationChangedObservable: Observable<void>;
  38293. /**
  38294. * Instantiates a new input
  38295. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38296. */
  38297. constructor();
  38298. /**
  38299. * Define the camera controlled by the input.
  38300. */
  38301. camera: FreeCamera;
  38302. /**
  38303. * Attach the input controls to a specific dom element to get the input from.
  38304. * @param element Defines the element the controls should be listened from
  38305. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38306. */
  38307. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38308. private _orientationChanged;
  38309. private _deviceOrientation;
  38310. /**
  38311. * Detach the current controls from the specified dom element.
  38312. * @param element Defines the element to stop listening the inputs from
  38313. */
  38314. detachControl(element: Nullable<HTMLElement>): void;
  38315. /**
  38316. * Update the current camera state depending on the inputs that have been used this frame.
  38317. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38318. */
  38319. checkInputs(): void;
  38320. /**
  38321. * Gets the class name of the current intput.
  38322. * @returns the class name
  38323. */
  38324. getClassName(): string;
  38325. /**
  38326. * Get the friendly name associated with the input class.
  38327. * @returns the input friendly name
  38328. */
  38329. getSimpleName(): string;
  38330. }
  38331. }
  38332. declare module BABYLON {
  38333. /**
  38334. * Manage the gamepad inputs to control a free camera.
  38335. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38336. */
  38337. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  38338. /**
  38339. * Define the camera the input is attached to.
  38340. */
  38341. camera: FreeCamera;
  38342. /**
  38343. * Define the Gamepad controlling the input
  38344. */
  38345. gamepad: Nullable<Gamepad>;
  38346. /**
  38347. * Defines the gamepad rotation sensiblity.
  38348. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  38349. */
  38350. gamepadAngularSensibility: number;
  38351. /**
  38352. * Defines the gamepad move sensiblity.
  38353. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  38354. */
  38355. gamepadMoveSensibility: number;
  38356. private _yAxisScale;
  38357. /**
  38358. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  38359. */
  38360. invertYAxis: boolean;
  38361. private _onGamepadConnectedObserver;
  38362. private _onGamepadDisconnectedObserver;
  38363. private _cameraTransform;
  38364. private _deltaTransform;
  38365. private _vector3;
  38366. private _vector2;
  38367. /**
  38368. * Attach the input controls to a specific dom element to get the input from.
  38369. * @param element Defines the element the controls should be listened from
  38370. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38371. */
  38372. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38373. /**
  38374. * Detach the current controls from the specified dom element.
  38375. * @param element Defines the element to stop listening the inputs from
  38376. */
  38377. detachControl(element: Nullable<HTMLElement>): void;
  38378. /**
  38379. * Update the current camera state depending on the inputs that have been used this frame.
  38380. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38381. */
  38382. checkInputs(): void;
  38383. /**
  38384. * Gets the class name of the current intput.
  38385. * @returns the class name
  38386. */
  38387. getClassName(): string;
  38388. /**
  38389. * Get the friendly name associated with the input class.
  38390. * @returns the input friendly name
  38391. */
  38392. getSimpleName(): string;
  38393. }
  38394. }
  38395. declare module BABYLON {
  38396. /**
  38397. * Defines the potential axis of a Joystick
  38398. */
  38399. export enum JoystickAxis {
  38400. /** X axis */
  38401. X = 0,
  38402. /** Y axis */
  38403. Y = 1,
  38404. /** Z axis */
  38405. Z = 2
  38406. }
  38407. /**
  38408. * Class used to define virtual joystick (used in touch mode)
  38409. */
  38410. export class VirtualJoystick {
  38411. /**
  38412. * Gets or sets a boolean indicating that left and right values must be inverted
  38413. */
  38414. reverseLeftRight: boolean;
  38415. /**
  38416. * Gets or sets a boolean indicating that up and down values must be inverted
  38417. */
  38418. reverseUpDown: boolean;
  38419. /**
  38420. * Gets the offset value for the position (ie. the change of the position value)
  38421. */
  38422. deltaPosition: Vector3;
  38423. /**
  38424. * Gets a boolean indicating if the virtual joystick was pressed
  38425. */
  38426. pressed: boolean;
  38427. /**
  38428. * Canvas the virtual joystick will render onto, default z-index of this is 5
  38429. */
  38430. static Canvas: Nullable<HTMLCanvasElement>;
  38431. private static _globalJoystickIndex;
  38432. private static vjCanvasContext;
  38433. private static vjCanvasWidth;
  38434. private static vjCanvasHeight;
  38435. private static halfWidth;
  38436. private _action;
  38437. private _axisTargetedByLeftAndRight;
  38438. private _axisTargetedByUpAndDown;
  38439. private _joystickSensibility;
  38440. private _inversedSensibility;
  38441. private _joystickPointerID;
  38442. private _joystickColor;
  38443. private _joystickPointerPos;
  38444. private _joystickPreviousPointerPos;
  38445. private _joystickPointerStartPos;
  38446. private _deltaJoystickVector;
  38447. private _leftJoystick;
  38448. private _touches;
  38449. private _onPointerDownHandlerRef;
  38450. private _onPointerMoveHandlerRef;
  38451. private _onPointerUpHandlerRef;
  38452. private _onResize;
  38453. /**
  38454. * Creates a new virtual joystick
  38455. * @param leftJoystick defines that the joystick is for left hand (false by default)
  38456. */
  38457. constructor(leftJoystick?: boolean);
  38458. /**
  38459. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  38460. * @param newJoystickSensibility defines the new sensibility
  38461. */
  38462. setJoystickSensibility(newJoystickSensibility: number): void;
  38463. private _onPointerDown;
  38464. private _onPointerMove;
  38465. private _onPointerUp;
  38466. /**
  38467. * Change the color of the virtual joystick
  38468. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  38469. */
  38470. setJoystickColor(newColor: string): void;
  38471. /**
  38472. * Defines a callback to call when the joystick is touched
  38473. * @param action defines the callback
  38474. */
  38475. setActionOnTouch(action: () => any): void;
  38476. /**
  38477. * Defines which axis you'd like to control for left & right
  38478. * @param axis defines the axis to use
  38479. */
  38480. setAxisForLeftRight(axis: JoystickAxis): void;
  38481. /**
  38482. * Defines which axis you'd like to control for up & down
  38483. * @param axis defines the axis to use
  38484. */
  38485. setAxisForUpDown(axis: JoystickAxis): void;
  38486. private _drawVirtualJoystick;
  38487. /**
  38488. * Release internal HTML canvas
  38489. */
  38490. releaseCanvas(): void;
  38491. }
  38492. }
  38493. declare module BABYLON {
  38494. interface FreeCameraInputsManager {
  38495. /**
  38496. * Add virtual joystick input support to the input manager.
  38497. * @returns the current input manager
  38498. */
  38499. addVirtualJoystick(): FreeCameraInputsManager;
  38500. }
  38501. /**
  38502. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  38503. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38504. */
  38505. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  38506. /**
  38507. * Defines the camera the input is attached to.
  38508. */
  38509. camera: FreeCamera;
  38510. private _leftjoystick;
  38511. private _rightjoystick;
  38512. /**
  38513. * Gets the left stick of the virtual joystick.
  38514. * @returns The virtual Joystick
  38515. */
  38516. getLeftJoystick(): VirtualJoystick;
  38517. /**
  38518. * Gets the right stick of the virtual joystick.
  38519. * @returns The virtual Joystick
  38520. */
  38521. getRightJoystick(): VirtualJoystick;
  38522. /**
  38523. * Update the current camera state depending on the inputs that have been used this frame.
  38524. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38525. */
  38526. checkInputs(): void;
  38527. /**
  38528. * Attach the input controls to a specific dom element to get the input from.
  38529. * @param element Defines the element the controls should be listened from
  38530. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38531. */
  38532. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38533. /**
  38534. * Detach the current controls from the specified dom element.
  38535. * @param element Defines the element to stop listening the inputs from
  38536. */
  38537. detachControl(element: Nullable<HTMLElement>): void;
  38538. /**
  38539. * Gets the class name of the current intput.
  38540. * @returns the class name
  38541. */
  38542. getClassName(): string;
  38543. /**
  38544. * Get the friendly name associated with the input class.
  38545. * @returns the input friendly name
  38546. */
  38547. getSimpleName(): string;
  38548. }
  38549. }
  38550. declare module BABYLON {
  38551. /**
  38552. * This represents a FPS type of camera controlled by touch.
  38553. * This is like a universal camera minus the Gamepad controls.
  38554. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38555. */
  38556. export class TouchCamera extends FreeCamera {
  38557. /**
  38558. * Defines the touch sensibility for rotation.
  38559. * The higher the faster.
  38560. */
  38561. touchAngularSensibility: number;
  38562. /**
  38563. * Defines the touch sensibility for move.
  38564. * The higher the faster.
  38565. */
  38566. touchMoveSensibility: number;
  38567. /**
  38568. * Instantiates a new touch camera.
  38569. * This represents a FPS type of camera controlled by touch.
  38570. * This is like a universal camera minus the Gamepad controls.
  38571. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38572. * @param name Define the name of the camera in the scene
  38573. * @param position Define the start position of the camera in the scene
  38574. * @param scene Define the scene the camera belongs to
  38575. */
  38576. constructor(name: string, position: Vector3, scene: Scene);
  38577. /**
  38578. * Gets the current object class name.
  38579. * @return the class name
  38580. */
  38581. getClassName(): string;
  38582. /** @hidden */
  38583. _setupInputs(): void;
  38584. }
  38585. }
  38586. declare module BABYLON {
  38587. /**
  38588. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  38589. * being tilted forward or back and left or right.
  38590. */
  38591. export class DeviceOrientationCamera extends FreeCamera {
  38592. private _initialQuaternion;
  38593. private _quaternionCache;
  38594. private _tmpDragQuaternion;
  38595. private _disablePointerInputWhenUsingDeviceOrientation;
  38596. /**
  38597. * Creates a new device orientation camera
  38598. * @param name The name of the camera
  38599. * @param position The start position camera
  38600. * @param scene The scene the camera belongs to
  38601. */
  38602. constructor(name: string, position: Vector3, scene: Scene);
  38603. /**
  38604. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  38605. */
  38606. disablePointerInputWhenUsingDeviceOrientation: boolean;
  38607. private _dragFactor;
  38608. /**
  38609. * Enabled turning on the y axis when the orientation sensor is active
  38610. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  38611. */
  38612. enableHorizontalDragging(dragFactor?: number): void;
  38613. /**
  38614. * Gets the current instance class name ("DeviceOrientationCamera").
  38615. * This helps avoiding instanceof at run time.
  38616. * @returns the class name
  38617. */
  38618. getClassName(): string;
  38619. /**
  38620. * @hidden
  38621. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  38622. */
  38623. _checkInputs(): void;
  38624. /**
  38625. * Reset the camera to its default orientation on the specified axis only.
  38626. * @param axis The axis to reset
  38627. */
  38628. resetToCurrentRotation(axis?: Axis): void;
  38629. }
  38630. }
  38631. declare module BABYLON {
  38632. /**
  38633. * Defines supported buttons for XBox360 compatible gamepads
  38634. */
  38635. export enum Xbox360Button {
  38636. /** A */
  38637. A = 0,
  38638. /** B */
  38639. B = 1,
  38640. /** X */
  38641. X = 2,
  38642. /** Y */
  38643. Y = 3,
  38644. /** Start */
  38645. Start = 4,
  38646. /** Back */
  38647. Back = 5,
  38648. /** Left button */
  38649. LB = 6,
  38650. /** Right button */
  38651. RB = 7,
  38652. /** Left stick */
  38653. LeftStick = 8,
  38654. /** Right stick */
  38655. RightStick = 9
  38656. }
  38657. /** Defines values for XBox360 DPad */
  38658. export enum Xbox360Dpad {
  38659. /** Up */
  38660. Up = 0,
  38661. /** Down */
  38662. Down = 1,
  38663. /** Left */
  38664. Left = 2,
  38665. /** Right */
  38666. Right = 3
  38667. }
  38668. /**
  38669. * Defines a XBox360 gamepad
  38670. */
  38671. export class Xbox360Pad extends Gamepad {
  38672. private _leftTrigger;
  38673. private _rightTrigger;
  38674. private _onlefttriggerchanged;
  38675. private _onrighttriggerchanged;
  38676. private _onbuttondown;
  38677. private _onbuttonup;
  38678. private _ondpaddown;
  38679. private _ondpadup;
  38680. /** Observable raised when a button is pressed */
  38681. onButtonDownObservable: Observable<Xbox360Button>;
  38682. /** Observable raised when a button is released */
  38683. onButtonUpObservable: Observable<Xbox360Button>;
  38684. /** Observable raised when a pad is pressed */
  38685. onPadDownObservable: Observable<Xbox360Dpad>;
  38686. /** Observable raised when a pad is released */
  38687. onPadUpObservable: Observable<Xbox360Dpad>;
  38688. private _buttonA;
  38689. private _buttonB;
  38690. private _buttonX;
  38691. private _buttonY;
  38692. private _buttonBack;
  38693. private _buttonStart;
  38694. private _buttonLB;
  38695. private _buttonRB;
  38696. private _buttonLeftStick;
  38697. private _buttonRightStick;
  38698. private _dPadUp;
  38699. private _dPadDown;
  38700. private _dPadLeft;
  38701. private _dPadRight;
  38702. private _isXboxOnePad;
  38703. /**
  38704. * Creates a new XBox360 gamepad object
  38705. * @param id defines the id of this gamepad
  38706. * @param index defines its index
  38707. * @param gamepad defines the internal HTML gamepad object
  38708. * @param xboxOne defines if it is a XBox One gamepad
  38709. */
  38710. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  38711. /**
  38712. * Defines the callback to call when left trigger is pressed
  38713. * @param callback defines the callback to use
  38714. */
  38715. onlefttriggerchanged(callback: (value: number) => void): void;
  38716. /**
  38717. * Defines the callback to call when right trigger is pressed
  38718. * @param callback defines the callback to use
  38719. */
  38720. onrighttriggerchanged(callback: (value: number) => void): void;
  38721. /**
  38722. * Gets the left trigger value
  38723. */
  38724. /**
  38725. * Sets the left trigger value
  38726. */
  38727. leftTrigger: number;
  38728. /**
  38729. * Gets the right trigger value
  38730. */
  38731. /**
  38732. * Sets the right trigger value
  38733. */
  38734. rightTrigger: number;
  38735. /**
  38736. * Defines the callback to call when a button is pressed
  38737. * @param callback defines the callback to use
  38738. */
  38739. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  38740. /**
  38741. * Defines the callback to call when a button is released
  38742. * @param callback defines the callback to use
  38743. */
  38744. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  38745. /**
  38746. * Defines the callback to call when a pad is pressed
  38747. * @param callback defines the callback to use
  38748. */
  38749. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  38750. /**
  38751. * Defines the callback to call when a pad is released
  38752. * @param callback defines the callback to use
  38753. */
  38754. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  38755. private _setButtonValue;
  38756. private _setDPadValue;
  38757. /**
  38758. * Gets the value of the `A` button
  38759. */
  38760. /**
  38761. * Sets the value of the `A` button
  38762. */
  38763. buttonA: number;
  38764. /**
  38765. * Gets the value of the `B` button
  38766. */
  38767. /**
  38768. * Sets the value of the `B` button
  38769. */
  38770. buttonB: number;
  38771. /**
  38772. * Gets the value of the `X` button
  38773. */
  38774. /**
  38775. * Sets the value of the `X` button
  38776. */
  38777. buttonX: number;
  38778. /**
  38779. * Gets the value of the `Y` button
  38780. */
  38781. /**
  38782. * Sets the value of the `Y` button
  38783. */
  38784. buttonY: number;
  38785. /**
  38786. * Gets the value of the `Start` button
  38787. */
  38788. /**
  38789. * Sets the value of the `Start` button
  38790. */
  38791. buttonStart: number;
  38792. /**
  38793. * Gets the value of the `Back` button
  38794. */
  38795. /**
  38796. * Sets the value of the `Back` button
  38797. */
  38798. buttonBack: number;
  38799. /**
  38800. * Gets the value of the `Left` button
  38801. */
  38802. /**
  38803. * Sets the value of the `Left` button
  38804. */
  38805. buttonLB: number;
  38806. /**
  38807. * Gets the value of the `Right` button
  38808. */
  38809. /**
  38810. * Sets the value of the `Right` button
  38811. */
  38812. buttonRB: number;
  38813. /**
  38814. * Gets the value of the Left joystick
  38815. */
  38816. /**
  38817. * Sets the value of the Left joystick
  38818. */
  38819. buttonLeftStick: number;
  38820. /**
  38821. * Gets the value of the Right joystick
  38822. */
  38823. /**
  38824. * Sets the value of the Right joystick
  38825. */
  38826. buttonRightStick: number;
  38827. /**
  38828. * Gets the value of D-pad up
  38829. */
  38830. /**
  38831. * Sets the value of D-pad up
  38832. */
  38833. dPadUp: number;
  38834. /**
  38835. * Gets the value of D-pad down
  38836. */
  38837. /**
  38838. * Sets the value of D-pad down
  38839. */
  38840. dPadDown: number;
  38841. /**
  38842. * Gets the value of D-pad left
  38843. */
  38844. /**
  38845. * Sets the value of D-pad left
  38846. */
  38847. dPadLeft: number;
  38848. /**
  38849. * Gets the value of D-pad right
  38850. */
  38851. /**
  38852. * Sets the value of D-pad right
  38853. */
  38854. dPadRight: number;
  38855. /**
  38856. * Force the gamepad to synchronize with device values
  38857. */
  38858. update(): void;
  38859. /**
  38860. * Disposes the gamepad
  38861. */
  38862. dispose(): void;
  38863. }
  38864. }
  38865. declare module BABYLON {
  38866. /**
  38867. * Defines supported buttons for DualShock compatible gamepads
  38868. */
  38869. export enum DualShockButton {
  38870. /** Cross */
  38871. Cross = 0,
  38872. /** Circle */
  38873. Circle = 1,
  38874. /** Square */
  38875. Square = 2,
  38876. /** Triangle */
  38877. Triangle = 3,
  38878. /** Options */
  38879. Options = 4,
  38880. /** Share */
  38881. Share = 5,
  38882. /** L1 */
  38883. L1 = 6,
  38884. /** R1 */
  38885. R1 = 7,
  38886. /** Left stick */
  38887. LeftStick = 8,
  38888. /** Right stick */
  38889. RightStick = 9
  38890. }
  38891. /** Defines values for DualShock DPad */
  38892. export enum DualShockDpad {
  38893. /** Up */
  38894. Up = 0,
  38895. /** Down */
  38896. Down = 1,
  38897. /** Left */
  38898. Left = 2,
  38899. /** Right */
  38900. Right = 3
  38901. }
  38902. /**
  38903. * Defines a DualShock gamepad
  38904. */
  38905. export class DualShockPad extends Gamepad {
  38906. private _leftTrigger;
  38907. private _rightTrigger;
  38908. private _onlefttriggerchanged;
  38909. private _onrighttriggerchanged;
  38910. private _onbuttondown;
  38911. private _onbuttonup;
  38912. private _ondpaddown;
  38913. private _ondpadup;
  38914. /** Observable raised when a button is pressed */
  38915. onButtonDownObservable: Observable<DualShockButton>;
  38916. /** Observable raised when a button is released */
  38917. onButtonUpObservable: Observable<DualShockButton>;
  38918. /** Observable raised when a pad is pressed */
  38919. onPadDownObservable: Observable<DualShockDpad>;
  38920. /** Observable raised when a pad is released */
  38921. onPadUpObservable: Observable<DualShockDpad>;
  38922. private _buttonCross;
  38923. private _buttonCircle;
  38924. private _buttonSquare;
  38925. private _buttonTriangle;
  38926. private _buttonShare;
  38927. private _buttonOptions;
  38928. private _buttonL1;
  38929. private _buttonR1;
  38930. private _buttonLeftStick;
  38931. private _buttonRightStick;
  38932. private _dPadUp;
  38933. private _dPadDown;
  38934. private _dPadLeft;
  38935. private _dPadRight;
  38936. /**
  38937. * Creates a new DualShock gamepad object
  38938. * @param id defines the id of this gamepad
  38939. * @param index defines its index
  38940. * @param gamepad defines the internal HTML gamepad object
  38941. */
  38942. constructor(id: string, index: number, gamepad: any);
  38943. /**
  38944. * Defines the callback to call when left trigger is pressed
  38945. * @param callback defines the callback to use
  38946. */
  38947. onlefttriggerchanged(callback: (value: number) => void): void;
  38948. /**
  38949. * Defines the callback to call when right trigger is pressed
  38950. * @param callback defines the callback to use
  38951. */
  38952. onrighttriggerchanged(callback: (value: number) => void): void;
  38953. /**
  38954. * Gets the left trigger value
  38955. */
  38956. /**
  38957. * Sets the left trigger value
  38958. */
  38959. leftTrigger: number;
  38960. /**
  38961. * Gets the right trigger value
  38962. */
  38963. /**
  38964. * Sets the right trigger value
  38965. */
  38966. rightTrigger: number;
  38967. /**
  38968. * Defines the callback to call when a button is pressed
  38969. * @param callback defines the callback to use
  38970. */
  38971. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  38972. /**
  38973. * Defines the callback to call when a button is released
  38974. * @param callback defines the callback to use
  38975. */
  38976. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  38977. /**
  38978. * Defines the callback to call when a pad is pressed
  38979. * @param callback defines the callback to use
  38980. */
  38981. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  38982. /**
  38983. * Defines the callback to call when a pad is released
  38984. * @param callback defines the callback to use
  38985. */
  38986. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  38987. private _setButtonValue;
  38988. private _setDPadValue;
  38989. /**
  38990. * Gets the value of the `Cross` button
  38991. */
  38992. /**
  38993. * Sets the value of the `Cross` button
  38994. */
  38995. buttonCross: number;
  38996. /**
  38997. * Gets the value of the `Circle` button
  38998. */
  38999. /**
  39000. * Sets the value of the `Circle` button
  39001. */
  39002. buttonCircle: number;
  39003. /**
  39004. * Gets the value of the `Square` button
  39005. */
  39006. /**
  39007. * Sets the value of the `Square` button
  39008. */
  39009. buttonSquare: number;
  39010. /**
  39011. * Gets the value of the `Triangle` button
  39012. */
  39013. /**
  39014. * Sets the value of the `Triangle` button
  39015. */
  39016. buttonTriangle: number;
  39017. /**
  39018. * Gets the value of the `Options` button
  39019. */
  39020. /**
  39021. * Sets the value of the `Options` button
  39022. */
  39023. buttonOptions: number;
  39024. /**
  39025. * Gets the value of the `Share` button
  39026. */
  39027. /**
  39028. * Sets the value of the `Share` button
  39029. */
  39030. buttonShare: number;
  39031. /**
  39032. * Gets the value of the `L1` button
  39033. */
  39034. /**
  39035. * Sets the value of the `L1` button
  39036. */
  39037. buttonL1: number;
  39038. /**
  39039. * Gets the value of the `R1` button
  39040. */
  39041. /**
  39042. * Sets the value of the `R1` button
  39043. */
  39044. buttonR1: number;
  39045. /**
  39046. * Gets the value of the Left joystick
  39047. */
  39048. /**
  39049. * Sets the value of the Left joystick
  39050. */
  39051. buttonLeftStick: number;
  39052. /**
  39053. * Gets the value of the Right joystick
  39054. */
  39055. /**
  39056. * Sets the value of the Right joystick
  39057. */
  39058. buttonRightStick: number;
  39059. /**
  39060. * Gets the value of D-pad up
  39061. */
  39062. /**
  39063. * Sets the value of D-pad up
  39064. */
  39065. dPadUp: number;
  39066. /**
  39067. * Gets the value of D-pad down
  39068. */
  39069. /**
  39070. * Sets the value of D-pad down
  39071. */
  39072. dPadDown: number;
  39073. /**
  39074. * Gets the value of D-pad left
  39075. */
  39076. /**
  39077. * Sets the value of D-pad left
  39078. */
  39079. dPadLeft: number;
  39080. /**
  39081. * Gets the value of D-pad right
  39082. */
  39083. /**
  39084. * Sets the value of D-pad right
  39085. */
  39086. dPadRight: number;
  39087. /**
  39088. * Force the gamepad to synchronize with device values
  39089. */
  39090. update(): void;
  39091. /**
  39092. * Disposes the gamepad
  39093. */
  39094. dispose(): void;
  39095. }
  39096. }
  39097. declare module BABYLON {
  39098. /**
  39099. * Manager for handling gamepads
  39100. */
  39101. export class GamepadManager {
  39102. private _scene?;
  39103. private _babylonGamepads;
  39104. private _oneGamepadConnected;
  39105. /** @hidden */
  39106. _isMonitoring: boolean;
  39107. private _gamepadEventSupported;
  39108. private _gamepadSupport;
  39109. /**
  39110. * observable to be triggered when the gamepad controller has been connected
  39111. */
  39112. onGamepadConnectedObservable: Observable<Gamepad>;
  39113. /**
  39114. * observable to be triggered when the gamepad controller has been disconnected
  39115. */
  39116. onGamepadDisconnectedObservable: Observable<Gamepad>;
  39117. private _onGamepadConnectedEvent;
  39118. private _onGamepadDisconnectedEvent;
  39119. /**
  39120. * Initializes the gamepad manager
  39121. * @param _scene BabylonJS scene
  39122. */
  39123. constructor(_scene?: Scene | undefined);
  39124. /**
  39125. * The gamepads in the game pad manager
  39126. */
  39127. readonly gamepads: Gamepad[];
  39128. /**
  39129. * Get the gamepad controllers based on type
  39130. * @param type The type of gamepad controller
  39131. * @returns Nullable gamepad
  39132. */
  39133. getGamepadByType(type?: number): Nullable<Gamepad>;
  39134. /**
  39135. * Disposes the gamepad manager
  39136. */
  39137. dispose(): void;
  39138. private _addNewGamepad;
  39139. private _startMonitoringGamepads;
  39140. private _stopMonitoringGamepads;
  39141. /** @hidden */
  39142. _checkGamepadsStatus(): void;
  39143. private _updateGamepadObjects;
  39144. }
  39145. }
  39146. declare module BABYLON {
  39147. interface Scene {
  39148. /** @hidden */
  39149. _gamepadManager: Nullable<GamepadManager>;
  39150. /**
  39151. * Gets the gamepad manager associated with the scene
  39152. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  39153. */
  39154. gamepadManager: GamepadManager;
  39155. }
  39156. /**
  39157. * Interface representing a free camera inputs manager
  39158. */
  39159. interface FreeCameraInputsManager {
  39160. /**
  39161. * Adds gamepad input support to the FreeCameraInputsManager.
  39162. * @returns the FreeCameraInputsManager
  39163. */
  39164. addGamepad(): FreeCameraInputsManager;
  39165. }
  39166. /**
  39167. * Interface representing an arc rotate camera inputs manager
  39168. */
  39169. interface ArcRotateCameraInputsManager {
  39170. /**
  39171. * Adds gamepad input support to the ArcRotateCamera InputManager.
  39172. * @returns the camera inputs manager
  39173. */
  39174. addGamepad(): ArcRotateCameraInputsManager;
  39175. }
  39176. /**
  39177. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  39178. */
  39179. export class GamepadSystemSceneComponent implements ISceneComponent {
  39180. /**
  39181. * The component name helpfull to identify the component in the list of scene components.
  39182. */
  39183. readonly name: string;
  39184. /**
  39185. * The scene the component belongs to.
  39186. */
  39187. scene: Scene;
  39188. /**
  39189. * Creates a new instance of the component for the given scene
  39190. * @param scene Defines the scene to register the component in
  39191. */
  39192. constructor(scene: Scene);
  39193. /**
  39194. * Registers the component in a given scene
  39195. */
  39196. register(): void;
  39197. /**
  39198. * Rebuilds the elements related to this component in case of
  39199. * context lost for instance.
  39200. */
  39201. rebuild(): void;
  39202. /**
  39203. * Disposes the component and the associated ressources
  39204. */
  39205. dispose(): void;
  39206. private _beforeCameraUpdate;
  39207. }
  39208. }
  39209. declare module BABYLON {
  39210. /**
  39211. * 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,
  39212. * which still works and will still be found in many Playgrounds.
  39213. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39214. */
  39215. export class UniversalCamera extends TouchCamera {
  39216. /**
  39217. * Defines the gamepad rotation sensiblity.
  39218. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  39219. */
  39220. gamepadAngularSensibility: number;
  39221. /**
  39222. * Defines the gamepad move sensiblity.
  39223. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  39224. */
  39225. gamepadMoveSensibility: number;
  39226. /**
  39227. * 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,
  39228. * which still works and will still be found in many Playgrounds.
  39229. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39230. * @param name Define the name of the camera in the scene
  39231. * @param position Define the start position of the camera in the scene
  39232. * @param scene Define the scene the camera belongs to
  39233. */
  39234. constructor(name: string, position: Vector3, scene: Scene);
  39235. /**
  39236. * Gets the current object class name.
  39237. * @return the class name
  39238. */
  39239. getClassName(): string;
  39240. }
  39241. }
  39242. declare module BABYLON {
  39243. /**
  39244. * This represents a FPS type of camera. This is only here for back compat purpose.
  39245. * Please use the UniversalCamera instead as both are identical.
  39246. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39247. */
  39248. export class GamepadCamera extends UniversalCamera {
  39249. /**
  39250. * Instantiates a new Gamepad Camera
  39251. * This represents a FPS type of camera. This is only here for back compat purpose.
  39252. * Please use the UniversalCamera instead as both are identical.
  39253. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39254. * @param name Define the name of the camera in the scene
  39255. * @param position Define the start position of the camera in the scene
  39256. * @param scene Define the scene the camera belongs to
  39257. */
  39258. constructor(name: string, position: Vector3, scene: Scene);
  39259. /**
  39260. * Gets the current object class name.
  39261. * @return the class name
  39262. */
  39263. getClassName(): string;
  39264. }
  39265. }
  39266. declare module BABYLON {
  39267. /** @hidden */
  39268. export var passPixelShader: {
  39269. name: string;
  39270. shader: string;
  39271. };
  39272. }
  39273. declare module BABYLON {
  39274. /** @hidden */
  39275. export var passCubePixelShader: {
  39276. name: string;
  39277. shader: string;
  39278. };
  39279. }
  39280. declare module BABYLON {
  39281. /**
  39282. * PassPostProcess which produces an output the same as it's input
  39283. */
  39284. export class PassPostProcess extends PostProcess {
  39285. /**
  39286. * Creates the PassPostProcess
  39287. * @param name The name of the effect.
  39288. * @param options The required width/height ratio to downsize to before computing the render pass.
  39289. * @param camera The camera to apply the render pass to.
  39290. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  39291. * @param engine The engine which the post process will be applied. (default: current engine)
  39292. * @param reusable If the post process can be reused on the same frame. (default: false)
  39293. * @param textureType The type of texture to be used when performing the post processing.
  39294. * @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)
  39295. */
  39296. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  39297. }
  39298. /**
  39299. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  39300. */
  39301. export class PassCubePostProcess extends PostProcess {
  39302. private _face;
  39303. /**
  39304. * Gets or sets the cube face to display.
  39305. * * 0 is +X
  39306. * * 1 is -X
  39307. * * 2 is +Y
  39308. * * 3 is -Y
  39309. * * 4 is +Z
  39310. * * 5 is -Z
  39311. */
  39312. face: number;
  39313. /**
  39314. * Creates the PassCubePostProcess
  39315. * @param name The name of the effect.
  39316. * @param options The required width/height ratio to downsize to before computing the render pass.
  39317. * @param camera The camera to apply the render pass to.
  39318. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  39319. * @param engine The engine which the post process will be applied. (default: current engine)
  39320. * @param reusable If the post process can be reused on the same frame. (default: false)
  39321. * @param textureType The type of texture to be used when performing the post processing.
  39322. * @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)
  39323. */
  39324. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  39325. }
  39326. }
  39327. declare module BABYLON {
  39328. /** @hidden */
  39329. export var anaglyphPixelShader: {
  39330. name: string;
  39331. shader: string;
  39332. };
  39333. }
  39334. declare module BABYLON {
  39335. /**
  39336. * Postprocess used to generate anaglyphic rendering
  39337. */
  39338. export class AnaglyphPostProcess extends PostProcess {
  39339. private _passedProcess;
  39340. /**
  39341. * Creates a new AnaglyphPostProcess
  39342. * @param name defines postprocess name
  39343. * @param options defines creation options or target ratio scale
  39344. * @param rigCameras defines cameras using this postprocess
  39345. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  39346. * @param engine defines hosting engine
  39347. * @param reusable defines if the postprocess will be reused multiple times per frame
  39348. */
  39349. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  39350. }
  39351. }
  39352. declare module BABYLON {
  39353. /**
  39354. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  39355. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39356. */
  39357. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  39358. /**
  39359. * Creates a new AnaglyphArcRotateCamera
  39360. * @param name defines camera name
  39361. * @param alpha defines alpha angle (in radians)
  39362. * @param beta defines beta angle (in radians)
  39363. * @param radius defines radius
  39364. * @param target defines camera target
  39365. * @param interaxialDistance defines distance between each color axis
  39366. * @param scene defines the hosting scene
  39367. */
  39368. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  39369. /**
  39370. * Gets camera class name
  39371. * @returns AnaglyphArcRotateCamera
  39372. */
  39373. getClassName(): string;
  39374. }
  39375. }
  39376. declare module BABYLON {
  39377. /**
  39378. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  39379. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39380. */
  39381. export class AnaglyphFreeCamera extends FreeCamera {
  39382. /**
  39383. * Creates a new AnaglyphFreeCamera
  39384. * @param name defines camera name
  39385. * @param position defines initial position
  39386. * @param interaxialDistance defines distance between each color axis
  39387. * @param scene defines the hosting scene
  39388. */
  39389. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  39390. /**
  39391. * Gets camera class name
  39392. * @returns AnaglyphFreeCamera
  39393. */
  39394. getClassName(): string;
  39395. }
  39396. }
  39397. declare module BABYLON {
  39398. /**
  39399. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  39400. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39401. */
  39402. export class AnaglyphGamepadCamera extends GamepadCamera {
  39403. /**
  39404. * Creates a new AnaglyphGamepadCamera
  39405. * @param name defines camera name
  39406. * @param position defines initial position
  39407. * @param interaxialDistance defines distance between each color axis
  39408. * @param scene defines the hosting scene
  39409. */
  39410. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  39411. /**
  39412. * Gets camera class name
  39413. * @returns AnaglyphGamepadCamera
  39414. */
  39415. getClassName(): string;
  39416. }
  39417. }
  39418. declare module BABYLON {
  39419. /**
  39420. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  39421. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39422. */
  39423. export class AnaglyphUniversalCamera extends UniversalCamera {
  39424. /**
  39425. * Creates a new AnaglyphUniversalCamera
  39426. * @param name defines camera name
  39427. * @param position defines initial position
  39428. * @param interaxialDistance defines distance between each color axis
  39429. * @param scene defines the hosting scene
  39430. */
  39431. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  39432. /**
  39433. * Gets camera class name
  39434. * @returns AnaglyphUniversalCamera
  39435. */
  39436. getClassName(): string;
  39437. }
  39438. }
  39439. declare module BABYLON {
  39440. /** @hidden */
  39441. export var stereoscopicInterlacePixelShader: {
  39442. name: string;
  39443. shader: string;
  39444. };
  39445. }
  39446. declare module BABYLON {
  39447. /**
  39448. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  39449. */
  39450. export class StereoscopicInterlacePostProcess extends PostProcess {
  39451. private _stepSize;
  39452. private _passedProcess;
  39453. /**
  39454. * Initializes a StereoscopicInterlacePostProcess
  39455. * @param name The name of the effect.
  39456. * @param rigCameras The rig cameras to be appled to the post process
  39457. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  39458. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  39459. * @param engine The engine which the post process will be applied. (default: current engine)
  39460. * @param reusable If the post process can be reused on the same frame. (default: false)
  39461. */
  39462. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  39463. }
  39464. }
  39465. declare module BABYLON {
  39466. /**
  39467. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  39468. * @see http://doc.babylonjs.com/features/cameras
  39469. */
  39470. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  39471. /**
  39472. * Creates a new StereoscopicArcRotateCamera
  39473. * @param name defines camera name
  39474. * @param alpha defines alpha angle (in radians)
  39475. * @param beta defines beta angle (in radians)
  39476. * @param radius defines radius
  39477. * @param target defines camera target
  39478. * @param interaxialDistance defines distance between each color axis
  39479. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  39480. * @param scene defines the hosting scene
  39481. */
  39482. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  39483. /**
  39484. * Gets camera class name
  39485. * @returns StereoscopicArcRotateCamera
  39486. */
  39487. getClassName(): string;
  39488. }
  39489. }
  39490. declare module BABYLON {
  39491. /**
  39492. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  39493. * @see http://doc.babylonjs.com/features/cameras
  39494. */
  39495. export class StereoscopicFreeCamera extends FreeCamera {
  39496. /**
  39497. * Creates a new StereoscopicFreeCamera
  39498. * @param name defines camera name
  39499. * @param position defines initial position
  39500. * @param interaxialDistance defines distance between each color axis
  39501. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  39502. * @param scene defines the hosting scene
  39503. */
  39504. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  39505. /**
  39506. * Gets camera class name
  39507. * @returns StereoscopicFreeCamera
  39508. */
  39509. getClassName(): string;
  39510. }
  39511. }
  39512. declare module BABYLON {
  39513. /**
  39514. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  39515. * @see http://doc.babylonjs.com/features/cameras
  39516. */
  39517. export class StereoscopicGamepadCamera extends GamepadCamera {
  39518. /**
  39519. * Creates a new StereoscopicGamepadCamera
  39520. * @param name defines camera name
  39521. * @param position defines initial position
  39522. * @param interaxialDistance defines distance between each color axis
  39523. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  39524. * @param scene defines the hosting scene
  39525. */
  39526. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  39527. /**
  39528. * Gets camera class name
  39529. * @returns StereoscopicGamepadCamera
  39530. */
  39531. getClassName(): string;
  39532. }
  39533. }
  39534. declare module BABYLON {
  39535. /**
  39536. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  39537. * @see http://doc.babylonjs.com/features/cameras
  39538. */
  39539. export class StereoscopicUniversalCamera extends UniversalCamera {
  39540. /**
  39541. * Creates a new StereoscopicUniversalCamera
  39542. * @param name defines camera name
  39543. * @param position defines initial position
  39544. * @param interaxialDistance defines distance between each color axis
  39545. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  39546. * @param scene defines the hosting scene
  39547. */
  39548. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  39549. /**
  39550. * Gets camera class name
  39551. * @returns StereoscopicUniversalCamera
  39552. */
  39553. getClassName(): string;
  39554. }
  39555. }
  39556. declare module BABYLON {
  39557. /**
  39558. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  39559. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  39560. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  39561. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  39562. */
  39563. export class VirtualJoysticksCamera extends FreeCamera {
  39564. /**
  39565. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  39566. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  39567. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  39568. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  39569. * @param name Define the name of the camera in the scene
  39570. * @param position Define the start position of the camera in the scene
  39571. * @param scene Define the scene the camera belongs to
  39572. */
  39573. constructor(name: string, position: Vector3, scene: Scene);
  39574. /**
  39575. * Gets the current object class name.
  39576. * @return the class name
  39577. */
  39578. getClassName(): string;
  39579. }
  39580. }
  39581. declare module BABYLON {
  39582. /**
  39583. * This represents all the required metrics to create a VR camera.
  39584. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  39585. */
  39586. export class VRCameraMetrics {
  39587. /**
  39588. * Define the horizontal resolution off the screen.
  39589. */
  39590. hResolution: number;
  39591. /**
  39592. * Define the vertical resolution off the screen.
  39593. */
  39594. vResolution: number;
  39595. /**
  39596. * Define the horizontal screen size.
  39597. */
  39598. hScreenSize: number;
  39599. /**
  39600. * Define the vertical screen size.
  39601. */
  39602. vScreenSize: number;
  39603. /**
  39604. * Define the vertical screen center position.
  39605. */
  39606. vScreenCenter: number;
  39607. /**
  39608. * Define the distance of the eyes to the screen.
  39609. */
  39610. eyeToScreenDistance: number;
  39611. /**
  39612. * Define the distance between both lenses
  39613. */
  39614. lensSeparationDistance: number;
  39615. /**
  39616. * Define the distance between both viewer's eyes.
  39617. */
  39618. interpupillaryDistance: number;
  39619. /**
  39620. * Define the distortion factor of the VR postprocess.
  39621. * Please, touch with care.
  39622. */
  39623. distortionK: number[];
  39624. /**
  39625. * Define the chromatic aberration correction factors for the VR post process.
  39626. */
  39627. chromaAbCorrection: number[];
  39628. /**
  39629. * Define the scale factor of the post process.
  39630. * The smaller the better but the slower.
  39631. */
  39632. postProcessScaleFactor: number;
  39633. /**
  39634. * Define an offset for the lens center.
  39635. */
  39636. lensCenterOffset: number;
  39637. /**
  39638. * Define if the current vr camera should compensate the distortion of the lense or not.
  39639. */
  39640. compensateDistortion: boolean;
  39641. /**
  39642. * Defines if multiview should be enabled when rendering (Default: false)
  39643. */
  39644. multiviewEnabled: boolean;
  39645. /**
  39646. * Gets the rendering aspect ratio based on the provided resolutions.
  39647. */
  39648. readonly aspectRatio: number;
  39649. /**
  39650. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  39651. */
  39652. readonly aspectRatioFov: number;
  39653. /**
  39654. * @hidden
  39655. */
  39656. readonly leftHMatrix: Matrix;
  39657. /**
  39658. * @hidden
  39659. */
  39660. readonly rightHMatrix: Matrix;
  39661. /**
  39662. * @hidden
  39663. */
  39664. readonly leftPreViewMatrix: Matrix;
  39665. /**
  39666. * @hidden
  39667. */
  39668. readonly rightPreViewMatrix: Matrix;
  39669. /**
  39670. * Get the default VRMetrics based on the most generic setup.
  39671. * @returns the default vr metrics
  39672. */
  39673. static GetDefault(): VRCameraMetrics;
  39674. }
  39675. }
  39676. declare module BABYLON {
  39677. /** @hidden */
  39678. export var vrDistortionCorrectionPixelShader: {
  39679. name: string;
  39680. shader: string;
  39681. };
  39682. }
  39683. declare module BABYLON {
  39684. /**
  39685. * VRDistortionCorrectionPostProcess used for mobile VR
  39686. */
  39687. export class VRDistortionCorrectionPostProcess extends PostProcess {
  39688. private _isRightEye;
  39689. private _distortionFactors;
  39690. private _postProcessScaleFactor;
  39691. private _lensCenterOffset;
  39692. private _scaleIn;
  39693. private _scaleFactor;
  39694. private _lensCenter;
  39695. /**
  39696. * Initializes the VRDistortionCorrectionPostProcess
  39697. * @param name The name of the effect.
  39698. * @param camera The camera to apply the render pass to.
  39699. * @param isRightEye If this is for the right eye distortion
  39700. * @param vrMetrics All the required metrics for the VR camera
  39701. */
  39702. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  39703. }
  39704. }
  39705. declare module BABYLON {
  39706. /**
  39707. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  39708. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  39709. */
  39710. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  39711. /**
  39712. * Creates a new VRDeviceOrientationArcRotateCamera
  39713. * @param name defines camera name
  39714. * @param alpha defines the camera rotation along the logitudinal axis
  39715. * @param beta defines the camera rotation along the latitudinal axis
  39716. * @param radius defines the camera distance from its target
  39717. * @param target defines the camera target
  39718. * @param scene defines the scene the camera belongs to
  39719. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  39720. * @param vrCameraMetrics defines the vr metrics associated to the camera
  39721. */
  39722. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  39723. /**
  39724. * Gets camera class name
  39725. * @returns VRDeviceOrientationArcRotateCamera
  39726. */
  39727. getClassName(): string;
  39728. }
  39729. }
  39730. declare module BABYLON {
  39731. /**
  39732. * Camera used to simulate VR rendering (based on FreeCamera)
  39733. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  39734. */
  39735. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  39736. /**
  39737. * Creates a new VRDeviceOrientationFreeCamera
  39738. * @param name defines camera name
  39739. * @param position defines the start position of the camera
  39740. * @param scene defines the scene the camera belongs to
  39741. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  39742. * @param vrCameraMetrics defines the vr metrics associated to the camera
  39743. */
  39744. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  39745. /**
  39746. * Gets camera class name
  39747. * @returns VRDeviceOrientationFreeCamera
  39748. */
  39749. getClassName(): string;
  39750. }
  39751. }
  39752. declare module BABYLON {
  39753. /**
  39754. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  39755. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  39756. */
  39757. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  39758. /**
  39759. * Creates a new VRDeviceOrientationGamepadCamera
  39760. * @param name defines camera name
  39761. * @param position defines the start position of the camera
  39762. * @param scene defines the scene the camera belongs to
  39763. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  39764. * @param vrCameraMetrics defines the vr metrics associated to the camera
  39765. */
  39766. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  39767. /**
  39768. * Gets camera class name
  39769. * @returns VRDeviceOrientationGamepadCamera
  39770. */
  39771. getClassName(): string;
  39772. }
  39773. }
  39774. declare module BABYLON {
  39775. /**
  39776. * Base class of materials working in push mode in babylon JS
  39777. * @hidden
  39778. */
  39779. export class PushMaterial extends Material {
  39780. protected _activeEffect: Effect;
  39781. protected _normalMatrix: Matrix;
  39782. /**
  39783. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  39784. * This means that the material can keep using a previous shader while a new one is being compiled.
  39785. * This is mostly used when shader parallel compilation is supported (true by default)
  39786. */
  39787. allowShaderHotSwapping: boolean;
  39788. constructor(name: string, scene: Scene);
  39789. getEffect(): Effect;
  39790. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  39791. /**
  39792. * Binds the given world matrix to the active effect
  39793. *
  39794. * @param world the matrix to bind
  39795. */
  39796. bindOnlyWorldMatrix(world: Matrix): void;
  39797. /**
  39798. * Binds the given normal matrix to the active effect
  39799. *
  39800. * @param normalMatrix the matrix to bind
  39801. */
  39802. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  39803. bind(world: Matrix, mesh?: Mesh): void;
  39804. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  39805. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  39806. }
  39807. }
  39808. declare module BABYLON {
  39809. /**
  39810. * This groups all the flags used to control the materials channel.
  39811. */
  39812. export class MaterialFlags {
  39813. private static _DiffuseTextureEnabled;
  39814. /**
  39815. * Are diffuse textures enabled in the application.
  39816. */
  39817. static DiffuseTextureEnabled: boolean;
  39818. private static _AmbientTextureEnabled;
  39819. /**
  39820. * Are ambient textures enabled in the application.
  39821. */
  39822. static AmbientTextureEnabled: boolean;
  39823. private static _OpacityTextureEnabled;
  39824. /**
  39825. * Are opacity textures enabled in the application.
  39826. */
  39827. static OpacityTextureEnabled: boolean;
  39828. private static _ReflectionTextureEnabled;
  39829. /**
  39830. * Are reflection textures enabled in the application.
  39831. */
  39832. static ReflectionTextureEnabled: boolean;
  39833. private static _EmissiveTextureEnabled;
  39834. /**
  39835. * Are emissive textures enabled in the application.
  39836. */
  39837. static EmissiveTextureEnabled: boolean;
  39838. private static _SpecularTextureEnabled;
  39839. /**
  39840. * Are specular textures enabled in the application.
  39841. */
  39842. static SpecularTextureEnabled: boolean;
  39843. private static _BumpTextureEnabled;
  39844. /**
  39845. * Are bump textures enabled in the application.
  39846. */
  39847. static BumpTextureEnabled: boolean;
  39848. private static _LightmapTextureEnabled;
  39849. /**
  39850. * Are lightmap textures enabled in the application.
  39851. */
  39852. static LightmapTextureEnabled: boolean;
  39853. private static _RefractionTextureEnabled;
  39854. /**
  39855. * Are refraction textures enabled in the application.
  39856. */
  39857. static RefractionTextureEnabled: boolean;
  39858. private static _ColorGradingTextureEnabled;
  39859. /**
  39860. * Are color grading textures enabled in the application.
  39861. */
  39862. static ColorGradingTextureEnabled: boolean;
  39863. private static _FresnelEnabled;
  39864. /**
  39865. * Are fresnels enabled in the application.
  39866. */
  39867. static FresnelEnabled: boolean;
  39868. private static _ClearCoatTextureEnabled;
  39869. /**
  39870. * Are clear coat textures enabled in the application.
  39871. */
  39872. static ClearCoatTextureEnabled: boolean;
  39873. private static _ClearCoatBumpTextureEnabled;
  39874. /**
  39875. * Are clear coat bump textures enabled in the application.
  39876. */
  39877. static ClearCoatBumpTextureEnabled: boolean;
  39878. private static _ClearCoatTintTextureEnabled;
  39879. /**
  39880. * Are clear coat tint textures enabled in the application.
  39881. */
  39882. static ClearCoatTintTextureEnabled: boolean;
  39883. private static _SheenTextureEnabled;
  39884. /**
  39885. * Are sheen textures enabled in the application.
  39886. */
  39887. static SheenTextureEnabled: boolean;
  39888. private static _AnisotropicTextureEnabled;
  39889. /**
  39890. * Are anisotropic textures enabled in the application.
  39891. */
  39892. static AnisotropicTextureEnabled: boolean;
  39893. private static _ThicknessTextureEnabled;
  39894. /**
  39895. * Are thickness textures enabled in the application.
  39896. */
  39897. static ThicknessTextureEnabled: boolean;
  39898. }
  39899. }
  39900. declare module BABYLON {
  39901. /** @hidden */
  39902. export var defaultFragmentDeclaration: {
  39903. name: string;
  39904. shader: string;
  39905. };
  39906. }
  39907. declare module BABYLON {
  39908. /** @hidden */
  39909. export var defaultUboDeclaration: {
  39910. name: string;
  39911. shader: string;
  39912. };
  39913. }
  39914. declare module BABYLON {
  39915. /** @hidden */
  39916. export var lightFragmentDeclaration: {
  39917. name: string;
  39918. shader: string;
  39919. };
  39920. }
  39921. declare module BABYLON {
  39922. /** @hidden */
  39923. export var lightUboDeclaration: {
  39924. name: string;
  39925. shader: string;
  39926. };
  39927. }
  39928. declare module BABYLON {
  39929. /** @hidden */
  39930. export var lightsFragmentFunctions: {
  39931. name: string;
  39932. shader: string;
  39933. };
  39934. }
  39935. declare module BABYLON {
  39936. /** @hidden */
  39937. export var shadowsFragmentFunctions: {
  39938. name: string;
  39939. shader: string;
  39940. };
  39941. }
  39942. declare module BABYLON {
  39943. /** @hidden */
  39944. export var fresnelFunction: {
  39945. name: string;
  39946. shader: string;
  39947. };
  39948. }
  39949. declare module BABYLON {
  39950. /** @hidden */
  39951. export var reflectionFunction: {
  39952. name: string;
  39953. shader: string;
  39954. };
  39955. }
  39956. declare module BABYLON {
  39957. /** @hidden */
  39958. export var bumpFragmentFunctions: {
  39959. name: string;
  39960. shader: string;
  39961. };
  39962. }
  39963. declare module BABYLON {
  39964. /** @hidden */
  39965. export var logDepthDeclaration: {
  39966. name: string;
  39967. shader: string;
  39968. };
  39969. }
  39970. declare module BABYLON {
  39971. /** @hidden */
  39972. export var bumpFragment: {
  39973. name: string;
  39974. shader: string;
  39975. };
  39976. }
  39977. declare module BABYLON {
  39978. /** @hidden */
  39979. export var depthPrePass: {
  39980. name: string;
  39981. shader: string;
  39982. };
  39983. }
  39984. declare module BABYLON {
  39985. /** @hidden */
  39986. export var lightFragment: {
  39987. name: string;
  39988. shader: string;
  39989. };
  39990. }
  39991. declare module BABYLON {
  39992. /** @hidden */
  39993. export var logDepthFragment: {
  39994. name: string;
  39995. shader: string;
  39996. };
  39997. }
  39998. declare module BABYLON {
  39999. /** @hidden */
  40000. export var defaultPixelShader: {
  40001. name: string;
  40002. shader: string;
  40003. };
  40004. }
  40005. declare module BABYLON {
  40006. /** @hidden */
  40007. export var defaultVertexDeclaration: {
  40008. name: string;
  40009. shader: string;
  40010. };
  40011. }
  40012. declare module BABYLON {
  40013. /** @hidden */
  40014. export var bumpVertexDeclaration: {
  40015. name: string;
  40016. shader: string;
  40017. };
  40018. }
  40019. declare module BABYLON {
  40020. /** @hidden */
  40021. export var bumpVertex: {
  40022. name: string;
  40023. shader: string;
  40024. };
  40025. }
  40026. declare module BABYLON {
  40027. /** @hidden */
  40028. export var fogVertex: {
  40029. name: string;
  40030. shader: string;
  40031. };
  40032. }
  40033. declare module BABYLON {
  40034. /** @hidden */
  40035. export var shadowsVertex: {
  40036. name: string;
  40037. shader: string;
  40038. };
  40039. }
  40040. declare module BABYLON {
  40041. /** @hidden */
  40042. export var pointCloudVertex: {
  40043. name: string;
  40044. shader: string;
  40045. };
  40046. }
  40047. declare module BABYLON {
  40048. /** @hidden */
  40049. export var logDepthVertex: {
  40050. name: string;
  40051. shader: string;
  40052. };
  40053. }
  40054. declare module BABYLON {
  40055. /** @hidden */
  40056. export var defaultVertexShader: {
  40057. name: string;
  40058. shader: string;
  40059. };
  40060. }
  40061. declare module BABYLON {
  40062. /** @hidden */
  40063. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  40064. MAINUV1: boolean;
  40065. MAINUV2: boolean;
  40066. DIFFUSE: boolean;
  40067. DIFFUSEDIRECTUV: number;
  40068. AMBIENT: boolean;
  40069. AMBIENTDIRECTUV: number;
  40070. OPACITY: boolean;
  40071. OPACITYDIRECTUV: number;
  40072. OPACITYRGB: boolean;
  40073. REFLECTION: boolean;
  40074. EMISSIVE: boolean;
  40075. EMISSIVEDIRECTUV: number;
  40076. SPECULAR: boolean;
  40077. SPECULARDIRECTUV: number;
  40078. BUMP: boolean;
  40079. BUMPDIRECTUV: number;
  40080. PARALLAX: boolean;
  40081. PARALLAXOCCLUSION: boolean;
  40082. SPECULAROVERALPHA: boolean;
  40083. CLIPPLANE: boolean;
  40084. CLIPPLANE2: boolean;
  40085. CLIPPLANE3: boolean;
  40086. CLIPPLANE4: boolean;
  40087. ALPHATEST: boolean;
  40088. DEPTHPREPASS: boolean;
  40089. ALPHAFROMDIFFUSE: boolean;
  40090. POINTSIZE: boolean;
  40091. FOG: boolean;
  40092. SPECULARTERM: boolean;
  40093. DIFFUSEFRESNEL: boolean;
  40094. OPACITYFRESNEL: boolean;
  40095. REFLECTIONFRESNEL: boolean;
  40096. REFRACTIONFRESNEL: boolean;
  40097. EMISSIVEFRESNEL: boolean;
  40098. FRESNEL: boolean;
  40099. NORMAL: boolean;
  40100. UV1: boolean;
  40101. UV2: boolean;
  40102. VERTEXCOLOR: boolean;
  40103. VERTEXALPHA: boolean;
  40104. NUM_BONE_INFLUENCERS: number;
  40105. BonesPerMesh: number;
  40106. BONETEXTURE: boolean;
  40107. INSTANCES: boolean;
  40108. GLOSSINESS: boolean;
  40109. ROUGHNESS: boolean;
  40110. EMISSIVEASILLUMINATION: boolean;
  40111. LINKEMISSIVEWITHDIFFUSE: boolean;
  40112. REFLECTIONFRESNELFROMSPECULAR: boolean;
  40113. LIGHTMAP: boolean;
  40114. LIGHTMAPDIRECTUV: number;
  40115. OBJECTSPACE_NORMALMAP: boolean;
  40116. USELIGHTMAPASSHADOWMAP: boolean;
  40117. REFLECTIONMAP_3D: boolean;
  40118. REFLECTIONMAP_SPHERICAL: boolean;
  40119. REFLECTIONMAP_PLANAR: boolean;
  40120. REFLECTIONMAP_CUBIC: boolean;
  40121. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  40122. REFLECTIONMAP_PROJECTION: boolean;
  40123. REFLECTIONMAP_SKYBOX: boolean;
  40124. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  40125. REFLECTIONMAP_EXPLICIT: boolean;
  40126. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  40127. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  40128. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  40129. INVERTCUBICMAP: boolean;
  40130. LOGARITHMICDEPTH: boolean;
  40131. REFRACTION: boolean;
  40132. REFRACTIONMAP_3D: boolean;
  40133. REFLECTIONOVERALPHA: boolean;
  40134. TWOSIDEDLIGHTING: boolean;
  40135. SHADOWFLOAT: boolean;
  40136. MORPHTARGETS: boolean;
  40137. MORPHTARGETS_NORMAL: boolean;
  40138. MORPHTARGETS_TANGENT: boolean;
  40139. MORPHTARGETS_UV: boolean;
  40140. NUM_MORPH_INFLUENCERS: number;
  40141. NONUNIFORMSCALING: boolean;
  40142. PREMULTIPLYALPHA: boolean;
  40143. IMAGEPROCESSING: boolean;
  40144. VIGNETTE: boolean;
  40145. VIGNETTEBLENDMODEMULTIPLY: boolean;
  40146. VIGNETTEBLENDMODEOPAQUE: boolean;
  40147. TONEMAPPING: boolean;
  40148. TONEMAPPING_ACES: boolean;
  40149. CONTRAST: boolean;
  40150. COLORCURVES: boolean;
  40151. COLORGRADING: boolean;
  40152. COLORGRADING3D: boolean;
  40153. SAMPLER3DGREENDEPTH: boolean;
  40154. SAMPLER3DBGRMAP: boolean;
  40155. IMAGEPROCESSINGPOSTPROCESS: boolean;
  40156. MULTIVIEW: boolean;
  40157. /**
  40158. * If the reflection texture on this material is in linear color space
  40159. * @hidden
  40160. */
  40161. IS_REFLECTION_LINEAR: boolean;
  40162. /**
  40163. * If the refraction texture on this material is in linear color space
  40164. * @hidden
  40165. */
  40166. IS_REFRACTION_LINEAR: boolean;
  40167. EXPOSURE: boolean;
  40168. constructor();
  40169. setReflectionMode(modeToEnable: string): void;
  40170. }
  40171. /**
  40172. * This is the default material used in Babylon. It is the best trade off between quality
  40173. * and performances.
  40174. * @see http://doc.babylonjs.com/babylon101/materials
  40175. */
  40176. export class StandardMaterial extends PushMaterial {
  40177. private _diffuseTexture;
  40178. /**
  40179. * The basic texture of the material as viewed under a light.
  40180. */
  40181. diffuseTexture: Nullable<BaseTexture>;
  40182. private _ambientTexture;
  40183. /**
  40184. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  40185. */
  40186. ambientTexture: Nullable<BaseTexture>;
  40187. private _opacityTexture;
  40188. /**
  40189. * Define the transparency of the material from a texture.
  40190. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  40191. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  40192. */
  40193. opacityTexture: Nullable<BaseTexture>;
  40194. private _reflectionTexture;
  40195. /**
  40196. * Define the texture used to display the reflection.
  40197. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  40198. */
  40199. reflectionTexture: Nullable<BaseTexture>;
  40200. private _emissiveTexture;
  40201. /**
  40202. * Define texture of the material as if self lit.
  40203. * This will be mixed in the final result even in the absence of light.
  40204. */
  40205. emissiveTexture: Nullable<BaseTexture>;
  40206. private _specularTexture;
  40207. /**
  40208. * Define how the color and intensity of the highlight given by the light in the material.
  40209. */
  40210. specularTexture: Nullable<BaseTexture>;
  40211. private _bumpTexture;
  40212. /**
  40213. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  40214. * 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.
  40215. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  40216. */
  40217. bumpTexture: Nullable<BaseTexture>;
  40218. private _lightmapTexture;
  40219. /**
  40220. * Complex lighting can be computationally expensive to compute at runtime.
  40221. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  40222. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  40223. */
  40224. lightmapTexture: Nullable<BaseTexture>;
  40225. private _refractionTexture;
  40226. /**
  40227. * Define the texture used to display the refraction.
  40228. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  40229. */
  40230. refractionTexture: Nullable<BaseTexture>;
  40231. /**
  40232. * The color of the material lit by the environmental background lighting.
  40233. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  40234. */
  40235. ambientColor: Color3;
  40236. /**
  40237. * The basic color of the material as viewed under a light.
  40238. */
  40239. diffuseColor: Color3;
  40240. /**
  40241. * Define how the color and intensity of the highlight given by the light in the material.
  40242. */
  40243. specularColor: Color3;
  40244. /**
  40245. * Define the color of the material as if self lit.
  40246. * This will be mixed in the final result even in the absence of light.
  40247. */
  40248. emissiveColor: Color3;
  40249. /**
  40250. * Defines how sharp are the highlights in the material.
  40251. * The bigger the value the sharper giving a more glossy feeling to the result.
  40252. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  40253. */
  40254. specularPower: number;
  40255. private _useAlphaFromDiffuseTexture;
  40256. /**
  40257. * Does the transparency come from the diffuse texture alpha channel.
  40258. */
  40259. useAlphaFromDiffuseTexture: boolean;
  40260. private _useEmissiveAsIllumination;
  40261. /**
  40262. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  40263. */
  40264. useEmissiveAsIllumination: boolean;
  40265. private _linkEmissiveWithDiffuse;
  40266. /**
  40267. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  40268. * the emissive level when the final color is close to one.
  40269. */
  40270. linkEmissiveWithDiffuse: boolean;
  40271. private _useSpecularOverAlpha;
  40272. /**
  40273. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  40274. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  40275. */
  40276. useSpecularOverAlpha: boolean;
  40277. private _useReflectionOverAlpha;
  40278. /**
  40279. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  40280. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  40281. */
  40282. useReflectionOverAlpha: boolean;
  40283. private _disableLighting;
  40284. /**
  40285. * Does lights from the scene impacts this material.
  40286. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  40287. */
  40288. disableLighting: boolean;
  40289. private _useObjectSpaceNormalMap;
  40290. /**
  40291. * Allows using an object space normal map (instead of tangent space).
  40292. */
  40293. useObjectSpaceNormalMap: boolean;
  40294. private _useParallax;
  40295. /**
  40296. * Is parallax enabled or not.
  40297. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  40298. */
  40299. useParallax: boolean;
  40300. private _useParallaxOcclusion;
  40301. /**
  40302. * Is parallax occlusion enabled or not.
  40303. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  40304. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  40305. */
  40306. useParallaxOcclusion: boolean;
  40307. /**
  40308. * 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.
  40309. */
  40310. parallaxScaleBias: number;
  40311. private _roughness;
  40312. /**
  40313. * Helps to define how blurry the reflections should appears in the material.
  40314. */
  40315. roughness: number;
  40316. /**
  40317. * In case of refraction, define the value of the index of refraction.
  40318. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  40319. */
  40320. indexOfRefraction: number;
  40321. /**
  40322. * Invert the refraction texture alongside the y axis.
  40323. * It can be useful with procedural textures or probe for instance.
  40324. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  40325. */
  40326. invertRefractionY: boolean;
  40327. /**
  40328. * Defines the alpha limits in alpha test mode.
  40329. */
  40330. alphaCutOff: number;
  40331. private _useLightmapAsShadowmap;
  40332. /**
  40333. * In case of light mapping, define whether the map contains light or shadow informations.
  40334. */
  40335. useLightmapAsShadowmap: boolean;
  40336. private _diffuseFresnelParameters;
  40337. /**
  40338. * Define the diffuse fresnel parameters of the material.
  40339. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40340. */
  40341. diffuseFresnelParameters: FresnelParameters;
  40342. private _opacityFresnelParameters;
  40343. /**
  40344. * Define the opacity fresnel parameters of the material.
  40345. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40346. */
  40347. opacityFresnelParameters: FresnelParameters;
  40348. private _reflectionFresnelParameters;
  40349. /**
  40350. * Define the reflection fresnel parameters of the material.
  40351. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40352. */
  40353. reflectionFresnelParameters: FresnelParameters;
  40354. private _refractionFresnelParameters;
  40355. /**
  40356. * Define the refraction fresnel parameters of the material.
  40357. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40358. */
  40359. refractionFresnelParameters: FresnelParameters;
  40360. private _emissiveFresnelParameters;
  40361. /**
  40362. * Define the emissive fresnel parameters of the material.
  40363. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40364. */
  40365. emissiveFresnelParameters: FresnelParameters;
  40366. private _useReflectionFresnelFromSpecular;
  40367. /**
  40368. * If true automatically deducts the fresnels values from the material specularity.
  40369. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40370. */
  40371. useReflectionFresnelFromSpecular: boolean;
  40372. private _useGlossinessFromSpecularMapAlpha;
  40373. /**
  40374. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  40375. */
  40376. useGlossinessFromSpecularMapAlpha: boolean;
  40377. private _maxSimultaneousLights;
  40378. /**
  40379. * Defines the maximum number of lights that can be used in the material
  40380. */
  40381. maxSimultaneousLights: number;
  40382. private _invertNormalMapX;
  40383. /**
  40384. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  40385. */
  40386. invertNormalMapX: boolean;
  40387. private _invertNormalMapY;
  40388. /**
  40389. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  40390. */
  40391. invertNormalMapY: boolean;
  40392. private _twoSidedLighting;
  40393. /**
  40394. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  40395. */
  40396. twoSidedLighting: boolean;
  40397. /**
  40398. * Default configuration related to image processing available in the standard Material.
  40399. */
  40400. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  40401. /**
  40402. * Gets the image processing configuration used either in this material.
  40403. */
  40404. /**
  40405. * Sets the Default image processing configuration used either in the this material.
  40406. *
  40407. * If sets to null, the scene one is in use.
  40408. */
  40409. imageProcessingConfiguration: ImageProcessingConfiguration;
  40410. /**
  40411. * Keep track of the image processing observer to allow dispose and replace.
  40412. */
  40413. private _imageProcessingObserver;
  40414. /**
  40415. * Attaches a new image processing configuration to the Standard Material.
  40416. * @param configuration
  40417. */
  40418. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  40419. /**
  40420. * Gets wether the color curves effect is enabled.
  40421. */
  40422. /**
  40423. * Sets wether the color curves effect is enabled.
  40424. */
  40425. cameraColorCurvesEnabled: boolean;
  40426. /**
  40427. * Gets wether the color grading effect is enabled.
  40428. */
  40429. /**
  40430. * Gets wether the color grading effect is enabled.
  40431. */
  40432. cameraColorGradingEnabled: boolean;
  40433. /**
  40434. * Gets wether tonemapping is enabled or not.
  40435. */
  40436. /**
  40437. * Sets wether tonemapping is enabled or not
  40438. */
  40439. cameraToneMappingEnabled: boolean;
  40440. /**
  40441. * The camera exposure used on this material.
  40442. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  40443. * This corresponds to a photographic exposure.
  40444. */
  40445. /**
  40446. * The camera exposure used on this material.
  40447. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  40448. * This corresponds to a photographic exposure.
  40449. */
  40450. cameraExposure: number;
  40451. /**
  40452. * Gets The camera contrast used on this material.
  40453. */
  40454. /**
  40455. * Sets The camera contrast used on this material.
  40456. */
  40457. cameraContrast: number;
  40458. /**
  40459. * Gets the Color Grading 2D Lookup Texture.
  40460. */
  40461. /**
  40462. * Sets the Color Grading 2D Lookup Texture.
  40463. */
  40464. cameraColorGradingTexture: Nullable<BaseTexture>;
  40465. /**
  40466. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  40467. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  40468. * 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;
  40469. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  40470. */
  40471. /**
  40472. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  40473. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  40474. * 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;
  40475. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  40476. */
  40477. cameraColorCurves: Nullable<ColorCurves>;
  40478. /**
  40479. * Custom callback helping to override the default shader used in the material.
  40480. */
  40481. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  40482. protected _renderTargets: SmartArray<RenderTargetTexture>;
  40483. protected _worldViewProjectionMatrix: Matrix;
  40484. protected _globalAmbientColor: Color3;
  40485. protected _useLogarithmicDepth: boolean;
  40486. protected _rebuildInParallel: boolean;
  40487. /**
  40488. * Instantiates a new standard material.
  40489. * This is the default material used in Babylon. It is the best trade off between quality
  40490. * and performances.
  40491. * @see http://doc.babylonjs.com/babylon101/materials
  40492. * @param name Define the name of the material in the scene
  40493. * @param scene Define the scene the material belong to
  40494. */
  40495. constructor(name: string, scene: Scene);
  40496. /**
  40497. * Gets a boolean indicating that current material needs to register RTT
  40498. */
  40499. readonly hasRenderTargetTextures: boolean;
  40500. /**
  40501. * Gets the current class name of the material e.g. "StandardMaterial"
  40502. * Mainly use in serialization.
  40503. * @returns the class name
  40504. */
  40505. getClassName(): string;
  40506. /**
  40507. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  40508. * You can try switching to logarithmic depth.
  40509. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  40510. */
  40511. useLogarithmicDepth: boolean;
  40512. /**
  40513. * Specifies if the material will require alpha blending
  40514. * @returns a boolean specifying if alpha blending is needed
  40515. */
  40516. needAlphaBlending(): boolean;
  40517. /**
  40518. * Specifies if this material should be rendered in alpha test mode
  40519. * @returns a boolean specifying if an alpha test is needed.
  40520. */
  40521. needAlphaTesting(): boolean;
  40522. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  40523. /**
  40524. * Get the texture used for alpha test purpose.
  40525. * @returns the diffuse texture in case of the standard material.
  40526. */
  40527. getAlphaTestTexture(): Nullable<BaseTexture>;
  40528. /**
  40529. * Get if the submesh is ready to be used and all its information available.
  40530. * Child classes can use it to update shaders
  40531. * @param mesh defines the mesh to check
  40532. * @param subMesh defines which submesh to check
  40533. * @param useInstances specifies that instances should be used
  40534. * @returns a boolean indicating that the submesh is ready or not
  40535. */
  40536. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  40537. /**
  40538. * Builds the material UBO layouts.
  40539. * Used internally during the effect preparation.
  40540. */
  40541. buildUniformLayout(): void;
  40542. /**
  40543. * Unbinds the material from the mesh
  40544. */
  40545. unbind(): void;
  40546. /**
  40547. * Binds the submesh to this material by preparing the effect and shader to draw
  40548. * @param world defines the world transformation matrix
  40549. * @param mesh defines the mesh containing the submesh
  40550. * @param subMesh defines the submesh to bind the material to
  40551. */
  40552. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  40553. /**
  40554. * Get the list of animatables in the material.
  40555. * @returns the list of animatables object used in the material
  40556. */
  40557. getAnimatables(): IAnimatable[];
  40558. /**
  40559. * Gets the active textures from the material
  40560. * @returns an array of textures
  40561. */
  40562. getActiveTextures(): BaseTexture[];
  40563. /**
  40564. * Specifies if the material uses a texture
  40565. * @param texture defines the texture to check against the material
  40566. * @returns a boolean specifying if the material uses the texture
  40567. */
  40568. hasTexture(texture: BaseTexture): boolean;
  40569. /**
  40570. * Disposes the material
  40571. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  40572. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  40573. */
  40574. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  40575. /**
  40576. * Makes a duplicate of the material, and gives it a new name
  40577. * @param name defines the new name for the duplicated material
  40578. * @returns the cloned material
  40579. */
  40580. clone(name: string): StandardMaterial;
  40581. /**
  40582. * Serializes this material in a JSON representation
  40583. * @returns the serialized material object
  40584. */
  40585. serialize(): any;
  40586. /**
  40587. * Creates a standard material from parsed material data
  40588. * @param source defines the JSON representation of the material
  40589. * @param scene defines the hosting scene
  40590. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  40591. * @returns a new standard material
  40592. */
  40593. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  40594. /**
  40595. * Are diffuse textures enabled in the application.
  40596. */
  40597. static DiffuseTextureEnabled: boolean;
  40598. /**
  40599. * Are ambient textures enabled in the application.
  40600. */
  40601. static AmbientTextureEnabled: boolean;
  40602. /**
  40603. * Are opacity textures enabled in the application.
  40604. */
  40605. static OpacityTextureEnabled: boolean;
  40606. /**
  40607. * Are reflection textures enabled in the application.
  40608. */
  40609. static ReflectionTextureEnabled: boolean;
  40610. /**
  40611. * Are emissive textures enabled in the application.
  40612. */
  40613. static EmissiveTextureEnabled: boolean;
  40614. /**
  40615. * Are specular textures enabled in the application.
  40616. */
  40617. static SpecularTextureEnabled: boolean;
  40618. /**
  40619. * Are bump textures enabled in the application.
  40620. */
  40621. static BumpTextureEnabled: boolean;
  40622. /**
  40623. * Are lightmap textures enabled in the application.
  40624. */
  40625. static LightmapTextureEnabled: boolean;
  40626. /**
  40627. * Are refraction textures enabled in the application.
  40628. */
  40629. static RefractionTextureEnabled: boolean;
  40630. /**
  40631. * Are color grading textures enabled in the application.
  40632. */
  40633. static ColorGradingTextureEnabled: boolean;
  40634. /**
  40635. * Are fresnels enabled in the application.
  40636. */
  40637. static FresnelEnabled: boolean;
  40638. }
  40639. }
  40640. declare module BABYLON {
  40641. /** @hidden */
  40642. export var imageProcessingPixelShader: {
  40643. name: string;
  40644. shader: string;
  40645. };
  40646. }
  40647. declare module BABYLON {
  40648. /**
  40649. * ImageProcessingPostProcess
  40650. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  40651. */
  40652. export class ImageProcessingPostProcess extends PostProcess {
  40653. /**
  40654. * Default configuration related to image processing available in the PBR Material.
  40655. */
  40656. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  40657. /**
  40658. * Gets the image processing configuration used either in this material.
  40659. */
  40660. /**
  40661. * Sets the Default image processing configuration used either in the this material.
  40662. *
  40663. * If sets to null, the scene one is in use.
  40664. */
  40665. imageProcessingConfiguration: ImageProcessingConfiguration;
  40666. /**
  40667. * Keep track of the image processing observer to allow dispose and replace.
  40668. */
  40669. private _imageProcessingObserver;
  40670. /**
  40671. * Attaches a new image processing configuration to the PBR Material.
  40672. * @param configuration
  40673. */
  40674. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  40675. /**
  40676. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  40677. */
  40678. /**
  40679. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  40680. */
  40681. colorCurves: Nullable<ColorCurves>;
  40682. /**
  40683. * Gets wether the color curves effect is enabled.
  40684. */
  40685. /**
  40686. * Sets wether the color curves effect is enabled.
  40687. */
  40688. colorCurvesEnabled: boolean;
  40689. /**
  40690. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  40691. */
  40692. /**
  40693. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  40694. */
  40695. colorGradingTexture: Nullable<BaseTexture>;
  40696. /**
  40697. * Gets wether the color grading effect is enabled.
  40698. */
  40699. /**
  40700. * Gets wether the color grading effect is enabled.
  40701. */
  40702. colorGradingEnabled: boolean;
  40703. /**
  40704. * Gets exposure used in the effect.
  40705. */
  40706. /**
  40707. * Sets exposure used in the effect.
  40708. */
  40709. exposure: number;
  40710. /**
  40711. * Gets wether tonemapping is enabled or not.
  40712. */
  40713. /**
  40714. * Sets wether tonemapping is enabled or not
  40715. */
  40716. toneMappingEnabled: boolean;
  40717. /**
  40718. * Gets the type of tone mapping effect.
  40719. */
  40720. /**
  40721. * Sets the type of tone mapping effect.
  40722. */
  40723. toneMappingType: number;
  40724. /**
  40725. * Gets contrast used in the effect.
  40726. */
  40727. /**
  40728. * Sets contrast used in the effect.
  40729. */
  40730. contrast: number;
  40731. /**
  40732. * Gets Vignette stretch size.
  40733. */
  40734. /**
  40735. * Sets Vignette stretch size.
  40736. */
  40737. vignetteStretch: number;
  40738. /**
  40739. * Gets Vignette centre X Offset.
  40740. */
  40741. /**
  40742. * Sets Vignette centre X Offset.
  40743. */
  40744. vignetteCentreX: number;
  40745. /**
  40746. * Gets Vignette centre Y Offset.
  40747. */
  40748. /**
  40749. * Sets Vignette centre Y Offset.
  40750. */
  40751. vignetteCentreY: number;
  40752. /**
  40753. * Gets Vignette weight or intensity of the vignette effect.
  40754. */
  40755. /**
  40756. * Sets Vignette weight or intensity of the vignette effect.
  40757. */
  40758. vignetteWeight: number;
  40759. /**
  40760. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  40761. * if vignetteEnabled is set to true.
  40762. */
  40763. /**
  40764. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  40765. * if vignetteEnabled is set to true.
  40766. */
  40767. vignetteColor: Color4;
  40768. /**
  40769. * Gets Camera field of view used by the Vignette effect.
  40770. */
  40771. /**
  40772. * Sets Camera field of view used by the Vignette effect.
  40773. */
  40774. vignetteCameraFov: number;
  40775. /**
  40776. * Gets the vignette blend mode allowing different kind of effect.
  40777. */
  40778. /**
  40779. * Sets the vignette blend mode allowing different kind of effect.
  40780. */
  40781. vignetteBlendMode: number;
  40782. /**
  40783. * Gets wether the vignette effect is enabled.
  40784. */
  40785. /**
  40786. * Sets wether the vignette effect is enabled.
  40787. */
  40788. vignetteEnabled: boolean;
  40789. private _fromLinearSpace;
  40790. /**
  40791. * Gets wether the input of the processing is in Gamma or Linear Space.
  40792. */
  40793. /**
  40794. * Sets wether the input of the processing is in Gamma or Linear Space.
  40795. */
  40796. fromLinearSpace: boolean;
  40797. /**
  40798. * Defines cache preventing GC.
  40799. */
  40800. private _defines;
  40801. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  40802. /**
  40803. * "ImageProcessingPostProcess"
  40804. * @returns "ImageProcessingPostProcess"
  40805. */
  40806. getClassName(): string;
  40807. protected _updateParameters(): void;
  40808. dispose(camera?: Camera): void;
  40809. }
  40810. }
  40811. declare module BABYLON {
  40812. /**
  40813. * Class containing static functions to help procedurally build meshes
  40814. */
  40815. export class GroundBuilder {
  40816. /**
  40817. * Creates a ground mesh
  40818. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  40819. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  40820. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40821. * @param name defines the name of the mesh
  40822. * @param options defines the options used to create the mesh
  40823. * @param scene defines the hosting scene
  40824. * @returns the ground mesh
  40825. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  40826. */
  40827. static CreateGround(name: string, options: {
  40828. width?: number;
  40829. height?: number;
  40830. subdivisions?: number;
  40831. subdivisionsX?: number;
  40832. subdivisionsY?: number;
  40833. updatable?: boolean;
  40834. }, scene: any): Mesh;
  40835. /**
  40836. * Creates a tiled ground mesh
  40837. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  40838. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  40839. * * 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
  40840. * * 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
  40841. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40842. * @param name defines the name of the mesh
  40843. * @param options defines the options used to create the mesh
  40844. * @param scene defines the hosting scene
  40845. * @returns the tiled ground mesh
  40846. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  40847. */
  40848. static CreateTiledGround(name: string, options: {
  40849. xmin: number;
  40850. zmin: number;
  40851. xmax: number;
  40852. zmax: number;
  40853. subdivisions?: {
  40854. w: number;
  40855. h: number;
  40856. };
  40857. precision?: {
  40858. w: number;
  40859. h: number;
  40860. };
  40861. updatable?: boolean;
  40862. }, scene?: Nullable<Scene>): Mesh;
  40863. /**
  40864. * Creates a ground mesh from a height map
  40865. * * The parameter `url` sets the URL of the height map image resource.
  40866. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  40867. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  40868. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  40869. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  40870. * * 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.
  40871. * * 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).
  40872. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  40873. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40874. * @param name defines the name of the mesh
  40875. * @param url defines the url to the height map
  40876. * @param options defines the options used to create the mesh
  40877. * @param scene defines the hosting scene
  40878. * @returns the ground mesh
  40879. * @see https://doc.babylonjs.com/babylon101/height_map
  40880. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  40881. */
  40882. static CreateGroundFromHeightMap(name: string, url: string, options: {
  40883. width?: number;
  40884. height?: number;
  40885. subdivisions?: number;
  40886. minHeight?: number;
  40887. maxHeight?: number;
  40888. colorFilter?: Color3;
  40889. alphaFilter?: number;
  40890. updatable?: boolean;
  40891. onReady?: (mesh: GroundMesh) => void;
  40892. }, scene?: Nullable<Scene>): GroundMesh;
  40893. }
  40894. }
  40895. declare module BABYLON {
  40896. /**
  40897. * Class containing static functions to help procedurally build meshes
  40898. */
  40899. export class TorusBuilder {
  40900. /**
  40901. * Creates a torus mesh
  40902. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  40903. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  40904. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  40905. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40906. * * 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
  40907. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40908. * @param name defines the name of the mesh
  40909. * @param options defines the options used to create the mesh
  40910. * @param scene defines the hosting scene
  40911. * @returns the torus mesh
  40912. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  40913. */
  40914. static CreateTorus(name: string, options: {
  40915. diameter?: number;
  40916. thickness?: number;
  40917. tessellation?: number;
  40918. updatable?: boolean;
  40919. sideOrientation?: number;
  40920. frontUVs?: Vector4;
  40921. backUVs?: Vector4;
  40922. }, scene: any): Mesh;
  40923. }
  40924. }
  40925. declare module BABYLON {
  40926. /**
  40927. * Class containing static functions to help procedurally build meshes
  40928. */
  40929. export class CylinderBuilder {
  40930. /**
  40931. * Creates a cylinder or a cone mesh
  40932. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  40933. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  40934. * * 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.
  40935. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  40936. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  40937. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  40938. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  40939. * * 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).
  40940. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  40941. * * 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).
  40942. * * 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
  40943. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  40944. * * 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
  40945. * * 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.
  40946. * * If `enclose` is false, a ring surface is one element.
  40947. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  40948. * * 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
  40949. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40950. * * 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
  40951. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40952. * @param name defines the name of the mesh
  40953. * @param options defines the options used to create the mesh
  40954. * @param scene defines the hosting scene
  40955. * @returns the cylinder mesh
  40956. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  40957. */
  40958. static CreateCylinder(name: string, options: {
  40959. height?: number;
  40960. diameterTop?: number;
  40961. diameterBottom?: number;
  40962. diameter?: number;
  40963. tessellation?: number;
  40964. subdivisions?: number;
  40965. arc?: number;
  40966. faceColors?: Color4[];
  40967. faceUV?: Vector4[];
  40968. updatable?: boolean;
  40969. hasRings?: boolean;
  40970. enclose?: boolean;
  40971. cap?: number;
  40972. sideOrientation?: number;
  40973. frontUVs?: Vector4;
  40974. backUVs?: Vector4;
  40975. }, scene: any): Mesh;
  40976. }
  40977. }
  40978. declare module BABYLON {
  40979. /**
  40980. * Options to modify the vr teleportation behavior.
  40981. */
  40982. export interface VRTeleportationOptions {
  40983. /**
  40984. * The name of the mesh which should be used as the teleportation floor. (default: null)
  40985. */
  40986. floorMeshName?: string;
  40987. /**
  40988. * A list of meshes to be used as the teleportation floor. (default: empty)
  40989. */
  40990. floorMeshes?: Mesh[];
  40991. }
  40992. /**
  40993. * Options to modify the vr experience helper's behavior.
  40994. */
  40995. export interface VRExperienceHelperOptions extends WebVROptions {
  40996. /**
  40997. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  40998. */
  40999. createDeviceOrientationCamera?: boolean;
  41000. /**
  41001. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  41002. */
  41003. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  41004. /**
  41005. * Uses the main button on the controller to toggle the laser casted. (default: true)
  41006. */
  41007. laserToggle?: boolean;
  41008. /**
  41009. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  41010. */
  41011. floorMeshes?: Mesh[];
  41012. /**
  41013. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  41014. */
  41015. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  41016. }
  41017. /**
  41018. * Event containing information after VR has been entered
  41019. */
  41020. export class OnAfterEnteringVRObservableEvent {
  41021. /**
  41022. * If entering vr was successful
  41023. */
  41024. success: boolean;
  41025. }
  41026. /**
  41027. * Helps to quickly add VR support to an existing scene.
  41028. * See http://doc.babylonjs.com/how_to/webvr_helper
  41029. */
  41030. export class VRExperienceHelper {
  41031. /** Options to modify the vr experience helper's behavior. */
  41032. webVROptions: VRExperienceHelperOptions;
  41033. private _scene;
  41034. private _position;
  41035. private _btnVR;
  41036. private _btnVRDisplayed;
  41037. private _webVRsupported;
  41038. private _webVRready;
  41039. private _webVRrequesting;
  41040. private _webVRpresenting;
  41041. private _hasEnteredVR;
  41042. private _fullscreenVRpresenting;
  41043. private _canvas;
  41044. private _webVRCamera;
  41045. private _vrDeviceOrientationCamera;
  41046. private _deviceOrientationCamera;
  41047. private _existingCamera;
  41048. private _onKeyDown;
  41049. private _onVrDisplayPresentChange;
  41050. private _onVRDisplayChanged;
  41051. private _onVRRequestPresentStart;
  41052. private _onVRRequestPresentComplete;
  41053. /**
  41054. * Gets or sets a boolean indicating that gaze can be enabled even if pointer lock is not engage (useful on iOS where fullscreen mode and pointer lock are not supported)
  41055. */
  41056. enableGazeEvenWhenNoPointerLock: boolean;
  41057. /**
  41058. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  41059. */
  41060. exitVROnDoubleTap: boolean;
  41061. /**
  41062. * Observable raised right before entering VR.
  41063. */
  41064. onEnteringVRObservable: Observable<VRExperienceHelper>;
  41065. /**
  41066. * Observable raised when entering VR has completed.
  41067. */
  41068. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  41069. /**
  41070. * Observable raised when exiting VR.
  41071. */
  41072. onExitingVRObservable: Observable<VRExperienceHelper>;
  41073. /**
  41074. * Observable raised when controller mesh is loaded.
  41075. */
  41076. onControllerMeshLoadedObservable: Observable<WebVRController>;
  41077. /** Return this.onEnteringVRObservable
  41078. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  41079. */
  41080. readonly onEnteringVR: Observable<VRExperienceHelper>;
  41081. /** Return this.onExitingVRObservable
  41082. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  41083. */
  41084. readonly onExitingVR: Observable<VRExperienceHelper>;
  41085. /** Return this.onControllerMeshLoadedObservable
  41086. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  41087. */
  41088. readonly onControllerMeshLoaded: Observable<WebVRController>;
  41089. private _rayLength;
  41090. private _useCustomVRButton;
  41091. private _teleportationRequested;
  41092. private _teleportActive;
  41093. private _floorMeshName;
  41094. private _floorMeshesCollection;
  41095. private _rotationAllowed;
  41096. private _teleportBackwardsVector;
  41097. private _teleportationTarget;
  41098. private _isDefaultTeleportationTarget;
  41099. private _postProcessMove;
  41100. private _teleportationFillColor;
  41101. private _teleportationBorderColor;
  41102. private _rotationAngle;
  41103. private _haloCenter;
  41104. private _cameraGazer;
  41105. private _padSensibilityUp;
  41106. private _padSensibilityDown;
  41107. private _leftController;
  41108. private _rightController;
  41109. /**
  41110. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  41111. */
  41112. onNewMeshSelected: Observable<AbstractMesh>;
  41113. /**
  41114. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  41115. * This observable will provide the mesh and the controller used to select the mesh
  41116. */
  41117. onMeshSelectedWithController: Observable<{
  41118. mesh: AbstractMesh;
  41119. controller: WebVRController;
  41120. }>;
  41121. /**
  41122. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  41123. */
  41124. onNewMeshPicked: Observable<PickingInfo>;
  41125. private _circleEase;
  41126. /**
  41127. * Observable raised before camera teleportation
  41128. */
  41129. onBeforeCameraTeleport: Observable<Vector3>;
  41130. /**
  41131. * Observable raised after camera teleportation
  41132. */
  41133. onAfterCameraTeleport: Observable<Vector3>;
  41134. /**
  41135. * Observable raised when current selected mesh gets unselected
  41136. */
  41137. onSelectedMeshUnselected: Observable<AbstractMesh>;
  41138. private _raySelectionPredicate;
  41139. /**
  41140. * To be optionaly changed by user to define custom ray selection
  41141. */
  41142. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  41143. /**
  41144. * To be optionaly changed by user to define custom selection logic (after ray selection)
  41145. */
  41146. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  41147. /**
  41148. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  41149. */
  41150. teleportationEnabled: boolean;
  41151. private _defaultHeight;
  41152. private _teleportationInitialized;
  41153. private _interactionsEnabled;
  41154. private _interactionsRequested;
  41155. private _displayGaze;
  41156. private _displayLaserPointer;
  41157. /**
  41158. * The mesh used to display where the user is going to teleport.
  41159. */
  41160. /**
  41161. * Sets the mesh to be used to display where the user is going to teleport.
  41162. */
  41163. teleportationTarget: Mesh;
  41164. /**
  41165. * 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
  41166. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  41167. * See http://doc.babylonjs.com/resources/baking_transformations
  41168. */
  41169. gazeTrackerMesh: Mesh;
  41170. /**
  41171. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  41172. */
  41173. updateGazeTrackerScale: boolean;
  41174. /**
  41175. * If the gaze trackers color should be updated when selecting meshes
  41176. */
  41177. updateGazeTrackerColor: boolean;
  41178. /**
  41179. * If the controller laser color should be updated when selecting meshes
  41180. */
  41181. updateControllerLaserColor: boolean;
  41182. /**
  41183. * The gaze tracking mesh corresponding to the left controller
  41184. */
  41185. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  41186. /**
  41187. * The gaze tracking mesh corresponding to the right controller
  41188. */
  41189. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  41190. /**
  41191. * If the ray of the gaze should be displayed.
  41192. */
  41193. /**
  41194. * Sets if the ray of the gaze should be displayed.
  41195. */
  41196. displayGaze: boolean;
  41197. /**
  41198. * If the ray of the LaserPointer should be displayed.
  41199. */
  41200. /**
  41201. * Sets if the ray of the LaserPointer should be displayed.
  41202. */
  41203. displayLaserPointer: boolean;
  41204. /**
  41205. * The deviceOrientationCamera used as the camera when not in VR.
  41206. */
  41207. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  41208. /**
  41209. * Based on the current WebVR support, returns the current VR camera used.
  41210. */
  41211. readonly currentVRCamera: Nullable<Camera>;
  41212. /**
  41213. * The webVRCamera which is used when in VR.
  41214. */
  41215. readonly webVRCamera: WebVRFreeCamera;
  41216. /**
  41217. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  41218. */
  41219. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  41220. /**
  41221. * The html button that is used to trigger entering into VR.
  41222. */
  41223. readonly vrButton: Nullable<HTMLButtonElement>;
  41224. private readonly _teleportationRequestInitiated;
  41225. /**
  41226. * Defines wether or not Pointer lock should be requested when switching to
  41227. * full screen.
  41228. */
  41229. requestPointerLockOnFullScreen: boolean;
  41230. /**
  41231. * Instantiates a VRExperienceHelper.
  41232. * Helps to quickly add VR support to an existing scene.
  41233. * @param scene The scene the VRExperienceHelper belongs to.
  41234. * @param webVROptions Options to modify the vr experience helper's behavior.
  41235. */
  41236. constructor(scene: Scene,
  41237. /** Options to modify the vr experience helper's behavior. */
  41238. webVROptions?: VRExperienceHelperOptions);
  41239. private _onDefaultMeshLoaded;
  41240. private _onResize;
  41241. private _onFullscreenChange;
  41242. /**
  41243. * Gets a value indicating if we are currently in VR mode.
  41244. */
  41245. readonly isInVRMode: boolean;
  41246. private onVrDisplayPresentChange;
  41247. private onVRDisplayChanged;
  41248. private moveButtonToBottomRight;
  41249. private displayVRButton;
  41250. private updateButtonVisibility;
  41251. private _cachedAngularSensibility;
  41252. /**
  41253. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  41254. * Otherwise, will use the fullscreen API.
  41255. */
  41256. enterVR(): void;
  41257. /**
  41258. * Attempt to exit VR, or fullscreen.
  41259. */
  41260. exitVR(): void;
  41261. /**
  41262. * The position of the vr experience helper.
  41263. */
  41264. /**
  41265. * Sets the position of the vr experience helper.
  41266. */
  41267. position: Vector3;
  41268. /**
  41269. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  41270. */
  41271. enableInteractions(): void;
  41272. private readonly _noControllerIsActive;
  41273. private beforeRender;
  41274. private _isTeleportationFloor;
  41275. /**
  41276. * Adds a floor mesh to be used for teleportation.
  41277. * @param floorMesh the mesh to be used for teleportation.
  41278. */
  41279. addFloorMesh(floorMesh: Mesh): void;
  41280. /**
  41281. * Removes a floor mesh from being used for teleportation.
  41282. * @param floorMesh the mesh to be removed.
  41283. */
  41284. removeFloorMesh(floorMesh: Mesh): void;
  41285. /**
  41286. * Enables interactions and teleportation using the VR controllers and gaze.
  41287. * @param vrTeleportationOptions options to modify teleportation behavior.
  41288. */
  41289. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  41290. private _onNewGamepadConnected;
  41291. private _tryEnableInteractionOnController;
  41292. private _onNewGamepadDisconnected;
  41293. private _enableInteractionOnController;
  41294. private _checkTeleportWithRay;
  41295. private _checkRotate;
  41296. private _checkTeleportBackwards;
  41297. private _enableTeleportationOnController;
  41298. private _createTeleportationCircles;
  41299. private _displayTeleportationTarget;
  41300. private _hideTeleportationTarget;
  41301. private _rotateCamera;
  41302. private _moveTeleportationSelectorTo;
  41303. private _workingVector;
  41304. private _workingQuaternion;
  41305. private _workingMatrix;
  41306. /**
  41307. * Teleports the users feet to the desired location
  41308. * @param location The location where the user's feet should be placed
  41309. */
  41310. teleportCamera(location: Vector3): void;
  41311. private _convertNormalToDirectionOfRay;
  41312. private _castRayAndSelectObject;
  41313. private _notifySelectedMeshUnselected;
  41314. /**
  41315. * Sets the color of the laser ray from the vr controllers.
  41316. * @param color new color for the ray.
  41317. */
  41318. changeLaserColor(color: Color3): void;
  41319. /**
  41320. * Sets the color of the ray from the vr headsets gaze.
  41321. * @param color new color for the ray.
  41322. */
  41323. changeGazeColor(color: Color3): void;
  41324. /**
  41325. * Exits VR and disposes of the vr experience helper
  41326. */
  41327. dispose(): void;
  41328. /**
  41329. * Gets the name of the VRExperienceHelper class
  41330. * @returns "VRExperienceHelper"
  41331. */
  41332. getClassName(): string;
  41333. }
  41334. }
  41335. declare module BABYLON {
  41336. /**
  41337. * Manages an XRSession to work with Babylon's engine
  41338. * @see https://doc.babylonjs.com/how_to/webxr
  41339. */
  41340. export class WebXRSessionManager implements IDisposable {
  41341. private scene;
  41342. /**
  41343. * Fires every time a new xrFrame arrives which can be used to update the camera
  41344. */
  41345. onXRFrameObservable: Observable<any>;
  41346. /**
  41347. * Fires when the xr session is ended either by the device or manually done
  41348. */
  41349. onXRSessionEnded: Observable<any>;
  41350. /**
  41351. * Underlying xr session
  41352. */
  41353. session: XRSession;
  41354. /**
  41355. * Type of reference space used when creating the session
  41356. */
  41357. referenceSpace: XRReferenceSpace;
  41358. /** @hidden */
  41359. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  41360. /**
  41361. * Current XR frame
  41362. */
  41363. currentFrame: Nullable<XRFrame>;
  41364. private _xrNavigator;
  41365. private baseLayer;
  41366. /**
  41367. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  41368. * @param scene The scene which the session should be created for
  41369. */
  41370. constructor(scene: Scene);
  41371. /**
  41372. * Initializes the manager
  41373. * After initialization enterXR can be called to start an XR session
  41374. * @returns Promise which resolves after it is initialized
  41375. */
  41376. initializeAsync(): Promise<void>;
  41377. /**
  41378. * Initializes an xr session
  41379. * @param xrSessionMode mode to initialize
  41380. * @returns a promise which will resolve once the session has been initialized
  41381. */
  41382. initializeSessionAsync(xrSessionMode: XRSessionMode): any;
  41383. /**
  41384. * Sets the reference space on the xr session
  41385. * @param referenceSpace space to set
  41386. * @returns a promise that will resolve once the reference space has been set
  41387. */
  41388. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  41389. /**
  41390. * Updates the render state of the session
  41391. * @param state state to set
  41392. * @returns a promise that resolves once the render state has been updated
  41393. */
  41394. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  41395. /**
  41396. * Starts rendering to the xr layer
  41397. * @returns a promise that will resolve once rendering has started
  41398. */
  41399. startRenderingToXRAsync(): Promise<void>;
  41400. /**
  41401. * Stops the xrSession and restores the renderloop
  41402. * @returns Promise which resolves after it exits XR
  41403. */
  41404. exitXRAsync(): Promise<unknown>;
  41405. /**
  41406. * Checks if a session would be supported for the creation options specified
  41407. * @param sessionMode session mode to check if supported eg. immersive-vr
  41408. * @returns true if supported
  41409. */
  41410. supportsSessionAsync(sessionMode: XRSessionMode): any;
  41411. /**
  41412. * @hidden
  41413. * Converts the render layer of xrSession to a render target
  41414. * @param session session to create render target for
  41415. * @param scene scene the new render target should be created for
  41416. */
  41417. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  41418. /**
  41419. * Disposes of the session manager
  41420. */
  41421. dispose(): void;
  41422. }
  41423. }
  41424. declare module BABYLON {
  41425. /**
  41426. * WebXR Camera which holds the views for the xrSession
  41427. * @see https://doc.babylonjs.com/how_to/webxr
  41428. */
  41429. export class WebXRCamera extends FreeCamera {
  41430. private static _TmpMatrix;
  41431. /**
  41432. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  41433. * @param name the name of the camera
  41434. * @param scene the scene to add the camera to
  41435. */
  41436. constructor(name: string, scene: Scene);
  41437. private _updateNumberOfRigCameras;
  41438. /** @hidden */
  41439. _updateForDualEyeDebugging(pupilDistance?: number): void;
  41440. /**
  41441. * Updates the cameras position from the current pose information of the XR session
  41442. * @param xrSessionManager the session containing pose information
  41443. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  41444. */
  41445. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  41446. }
  41447. }
  41448. declare module BABYLON {
  41449. /**
  41450. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  41451. */
  41452. export class WebXRManagedOutputCanvas implements IDisposable {
  41453. private helper;
  41454. private _canvas;
  41455. /**
  41456. * xrpresent context of the canvas which can be used to display/mirror xr content
  41457. */
  41458. canvasContext: WebGLRenderingContext;
  41459. /**
  41460. * xr layer for the canvas
  41461. */
  41462. xrLayer: Nullable<XRWebGLLayer>;
  41463. /**
  41464. * Initializes the xr layer for the session
  41465. * @param xrSession xr session
  41466. * @returns a promise that will resolve once the XR Layer has been created
  41467. */
  41468. initializeXRLayerAsync(xrSession: any): any;
  41469. /**
  41470. * Initializes the canvas to be added/removed upon entering/exiting xr
  41471. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  41472. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  41473. */
  41474. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  41475. /**
  41476. * Disposes of the object
  41477. */
  41478. dispose(): void;
  41479. private _setManagedOutputCanvas;
  41480. private _addCanvas;
  41481. private _removeCanvas;
  41482. }
  41483. }
  41484. declare module BABYLON {
  41485. /**
  41486. * States of the webXR experience
  41487. */
  41488. export enum WebXRState {
  41489. /**
  41490. * Transitioning to being in XR mode
  41491. */
  41492. ENTERING_XR = 0,
  41493. /**
  41494. * Transitioning to non XR mode
  41495. */
  41496. EXITING_XR = 1,
  41497. /**
  41498. * In XR mode and presenting
  41499. */
  41500. IN_XR = 2,
  41501. /**
  41502. * Not entered XR mode
  41503. */
  41504. NOT_IN_XR = 3
  41505. }
  41506. /**
  41507. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  41508. * @see https://doc.babylonjs.com/how_to/webxr
  41509. */
  41510. export class WebXRExperienceHelper implements IDisposable {
  41511. private scene;
  41512. /**
  41513. * 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
  41514. */
  41515. container: AbstractMesh;
  41516. /**
  41517. * Camera used to render xr content
  41518. */
  41519. camera: WebXRCamera;
  41520. /**
  41521. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  41522. */
  41523. state: WebXRState;
  41524. private _setState;
  41525. private static _TmpVector;
  41526. /**
  41527. * Fires when the state of the experience helper has changed
  41528. */
  41529. onStateChangedObservable: Observable<WebXRState>;
  41530. /** Session manager used to keep track of xr session */
  41531. sessionManager: WebXRSessionManager;
  41532. private _nonVRCamera;
  41533. private _originalSceneAutoClear;
  41534. private _supported;
  41535. /**
  41536. * Creates the experience helper
  41537. * @param scene the scene to attach the experience helper to
  41538. * @returns a promise for the experience helper
  41539. */
  41540. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  41541. /**
  41542. * Creates a WebXRExperienceHelper
  41543. * @param scene The scene the helper should be created in
  41544. */
  41545. private constructor();
  41546. /**
  41547. * Exits XR mode and returns the scene to its original state
  41548. * @returns promise that resolves after xr mode has exited
  41549. */
  41550. exitXRAsync(): Promise<unknown>;
  41551. /**
  41552. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  41553. * @param sessionCreationOptions options for the XR session
  41554. * @param referenceSpaceType frame of reference of the XR session
  41555. * @param outputCanvas the output canvas that will be used to enter XR mode
  41556. * @returns promise that resolves after xr mode has entered
  41557. */
  41558. enterXRAsync(sessionCreationOptions: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, outputCanvas: WebXRManagedOutputCanvas): any;
  41559. /**
  41560. * Updates the global position of the camera by moving the camera's container
  41561. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  41562. * @param position The desired global position of the camera
  41563. */
  41564. setPositionOfCameraUsingContainer(position: Vector3): void;
  41565. /**
  41566. * Rotates the xr camera by rotating the camera's container around the camera's position
  41567. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  41568. * @param rotation the desired quaternion rotation to apply to the camera
  41569. */
  41570. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  41571. /**
  41572. * Disposes of the experience helper
  41573. */
  41574. dispose(): void;
  41575. }
  41576. }
  41577. declare module BABYLON {
  41578. /**
  41579. * Button which can be used to enter a different mode of XR
  41580. */
  41581. export class WebXREnterExitUIButton {
  41582. /** button element */
  41583. element: HTMLElement;
  41584. /** XR initialization options for the button */
  41585. sessionMode: XRSessionMode;
  41586. /** Reference space type */
  41587. referenceSpaceType: XRReferenceSpaceType;
  41588. /**
  41589. * Creates a WebXREnterExitUIButton
  41590. * @param element button element
  41591. * @param sessionMode XR initialization session mode
  41592. * @param referenceSpaceType the type of reference space to be used
  41593. */
  41594. constructor(
  41595. /** button element */
  41596. element: HTMLElement,
  41597. /** XR initialization options for the button */
  41598. sessionMode: XRSessionMode,
  41599. /** Reference space type */
  41600. referenceSpaceType: XRReferenceSpaceType);
  41601. /**
  41602. * Overwritable function which can be used to update the button's visuals when the state changes
  41603. * @param activeButton the current active button in the UI
  41604. */
  41605. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  41606. }
  41607. /**
  41608. * Options to create the webXR UI
  41609. */
  41610. export class WebXREnterExitUIOptions {
  41611. /**
  41612. * Context to enter xr with
  41613. */
  41614. webXRManagedOutputCanvas?: Nullable<WebXRManagedOutputCanvas>;
  41615. /**
  41616. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  41617. */
  41618. customButtons?: Array<WebXREnterExitUIButton>;
  41619. }
  41620. /**
  41621. * UI to allow the user to enter/exit XR mode
  41622. */
  41623. export class WebXREnterExitUI implements IDisposable {
  41624. private scene;
  41625. private _overlay;
  41626. private _buttons;
  41627. private _activeButton;
  41628. /**
  41629. * Fired every time the active button is changed.
  41630. *
  41631. * When xr is entered via a button that launches xr that button will be the callback parameter
  41632. *
  41633. * When exiting xr the callback parameter will be null)
  41634. */
  41635. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  41636. /**
  41637. * Creates UI to allow the user to enter/exit XR mode
  41638. * @param scene the scene to add the ui to
  41639. * @param helper the xr experience helper to enter/exit xr with
  41640. * @param options options to configure the UI
  41641. * @returns the created ui
  41642. */
  41643. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  41644. private constructor();
  41645. private _updateButtons;
  41646. /**
  41647. * Disposes of the object
  41648. */
  41649. dispose(): void;
  41650. }
  41651. }
  41652. declare module BABYLON {
  41653. /**
  41654. * Represents an XR input
  41655. */
  41656. export class WebXRController {
  41657. private scene;
  41658. /** The underlying input source for the controller */
  41659. inputSource: XRInputSource;
  41660. private parentContainer;
  41661. /**
  41662. * 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
  41663. */
  41664. grip?: AbstractMesh;
  41665. /**
  41666. * Pointer which can be used to select objects or attach a visible laser to
  41667. */
  41668. pointer: AbstractMesh;
  41669. /**
  41670. * Event that fires when the controller is removed/disposed
  41671. */
  41672. onDisposeObservable: Observable<{}>;
  41673. private _tmpMatrix;
  41674. private _tmpQuaternion;
  41675. private _tmpVector;
  41676. /**
  41677. * Creates the controller
  41678. * @see https://doc.babylonjs.com/how_to/webxr
  41679. * @param scene the scene which the controller should be associated to
  41680. * @param inputSource the underlying input source for the controller
  41681. * @param parentContainer parent that the controller meshes should be children of
  41682. */
  41683. constructor(scene: Scene,
  41684. /** The underlying input source for the controller */
  41685. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  41686. /**
  41687. * Updates the controller pose based on the given XRFrame
  41688. * @param xrFrame xr frame to update the pose with
  41689. * @param referenceSpace reference space to use
  41690. */
  41691. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  41692. /**
  41693. * Gets a world space ray coming from the controller
  41694. * @param result the resulting ray
  41695. */
  41696. getWorldPointerRayToRef(result: Ray): void;
  41697. /**
  41698. * Disposes of the object
  41699. */
  41700. dispose(): void;
  41701. }
  41702. }
  41703. declare module BABYLON {
  41704. /**
  41705. * XR input used to track XR inputs such as controllers/rays
  41706. */
  41707. export class WebXRInput implements IDisposable {
  41708. /**
  41709. * Base experience the input listens to
  41710. */
  41711. baseExperience: WebXRExperienceHelper;
  41712. /**
  41713. * XR controllers being tracked
  41714. */
  41715. controllers: Array<WebXRController>;
  41716. private _frameObserver;
  41717. private _stateObserver;
  41718. /**
  41719. * Event when a controller has been connected/added
  41720. */
  41721. onControllerAddedObservable: Observable<WebXRController>;
  41722. /**
  41723. * Event when a controller has been removed/disconnected
  41724. */
  41725. onControllerRemovedObservable: Observable<WebXRController>;
  41726. /**
  41727. * Initializes the WebXRInput
  41728. * @param baseExperience experience helper which the input should be created for
  41729. */
  41730. constructor(
  41731. /**
  41732. * Base experience the input listens to
  41733. */
  41734. baseExperience: WebXRExperienceHelper);
  41735. private _onInputSourcesChange;
  41736. private _addAndRemoveControllers;
  41737. /**
  41738. * Disposes of the object
  41739. */
  41740. dispose(): void;
  41741. }
  41742. }
  41743. declare module BABYLON {
  41744. /**
  41745. * Enables teleportation
  41746. */
  41747. export class WebXRControllerTeleportation {
  41748. private _teleportationFillColor;
  41749. private _teleportationBorderColor;
  41750. private _tmpRay;
  41751. private _tmpVector;
  41752. /**
  41753. * Creates a WebXRControllerTeleportation
  41754. * @param input input manager to add teleportation to
  41755. * @param floorMeshes floormeshes which can be teleported to
  41756. */
  41757. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  41758. }
  41759. }
  41760. declare module BABYLON {
  41761. /**
  41762. * Handles pointer input automatically for the pointer of XR controllers
  41763. */
  41764. export class WebXRControllerPointerSelection {
  41765. private static _idCounter;
  41766. private _tmpRay;
  41767. /**
  41768. * Creates a WebXRControllerPointerSelection
  41769. * @param input input manager to setup pointer selection
  41770. */
  41771. constructor(input: WebXRInput);
  41772. private _convertNormalToDirectionOfRay;
  41773. private _updatePointerDistance;
  41774. }
  41775. }
  41776. declare module BABYLON {
  41777. /**
  41778. * Class used to represent data loading progression
  41779. */
  41780. export class SceneLoaderProgressEvent {
  41781. /** defines if data length to load can be evaluated */
  41782. readonly lengthComputable: boolean;
  41783. /** defines the loaded data length */
  41784. readonly loaded: number;
  41785. /** defines the data length to load */
  41786. readonly total: number;
  41787. /**
  41788. * Create a new progress event
  41789. * @param lengthComputable defines if data length to load can be evaluated
  41790. * @param loaded defines the loaded data length
  41791. * @param total defines the data length to load
  41792. */
  41793. constructor(
  41794. /** defines if data length to load can be evaluated */
  41795. lengthComputable: boolean,
  41796. /** defines the loaded data length */
  41797. loaded: number,
  41798. /** defines the data length to load */
  41799. total: number);
  41800. /**
  41801. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  41802. * @param event defines the source event
  41803. * @returns a new SceneLoaderProgressEvent
  41804. */
  41805. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  41806. }
  41807. /**
  41808. * Interface used by SceneLoader plugins to define supported file extensions
  41809. */
  41810. export interface ISceneLoaderPluginExtensions {
  41811. /**
  41812. * Defines the list of supported extensions
  41813. */
  41814. [extension: string]: {
  41815. isBinary: boolean;
  41816. };
  41817. }
  41818. /**
  41819. * Interface used by SceneLoader plugin factory
  41820. */
  41821. export interface ISceneLoaderPluginFactory {
  41822. /**
  41823. * Defines the name of the factory
  41824. */
  41825. name: string;
  41826. /**
  41827. * Function called to create a new plugin
  41828. * @return the new plugin
  41829. */
  41830. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  41831. /**
  41832. * Boolean indicating if the plugin can direct load specific data
  41833. */
  41834. canDirectLoad?: (data: string) => boolean;
  41835. }
  41836. /**
  41837. * Interface used to define a SceneLoader plugin
  41838. */
  41839. export interface ISceneLoaderPlugin {
  41840. /**
  41841. * The friendly name of this plugin.
  41842. */
  41843. name: string;
  41844. /**
  41845. * The file extensions supported by this plugin.
  41846. */
  41847. extensions: string | ISceneLoaderPluginExtensions;
  41848. /**
  41849. * Import meshes into a scene.
  41850. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41851. * @param scene The scene to import into
  41852. * @param data The data to import
  41853. * @param rootUrl The root url for scene and resources
  41854. * @param meshes The meshes array to import into
  41855. * @param particleSystems The particle systems array to import into
  41856. * @param skeletons The skeletons array to import into
  41857. * @param onError The callback when import fails
  41858. * @returns True if successful or false otherwise
  41859. */
  41860. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  41861. /**
  41862. * Load into a scene.
  41863. * @param scene The scene to load into
  41864. * @param data The data to import
  41865. * @param rootUrl The root url for scene and resources
  41866. * @param onError The callback when import fails
  41867. * @returns true if successful or false otherwise
  41868. */
  41869. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  41870. /**
  41871. * The callback that returns true if the data can be directly loaded.
  41872. */
  41873. canDirectLoad?: (data: string) => boolean;
  41874. /**
  41875. * The callback that allows custom handling of the root url based on the response url.
  41876. */
  41877. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  41878. /**
  41879. * Load into an asset container.
  41880. * @param scene The scene to load into
  41881. * @param data The data to import
  41882. * @param rootUrl The root url for scene and resources
  41883. * @param onError The callback when import fails
  41884. * @returns The loaded asset container
  41885. */
  41886. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  41887. }
  41888. /**
  41889. * Interface used to define an async SceneLoader plugin
  41890. */
  41891. export interface ISceneLoaderPluginAsync {
  41892. /**
  41893. * The friendly name of this plugin.
  41894. */
  41895. name: string;
  41896. /**
  41897. * The file extensions supported by this plugin.
  41898. */
  41899. extensions: string | ISceneLoaderPluginExtensions;
  41900. /**
  41901. * Import meshes into a scene.
  41902. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41903. * @param scene The scene to import into
  41904. * @param data The data to import
  41905. * @param rootUrl The root url for scene and resources
  41906. * @param onProgress The callback when the load progresses
  41907. * @param fileName Defines the name of the file to load
  41908. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  41909. */
  41910. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  41911. meshes: AbstractMesh[];
  41912. particleSystems: IParticleSystem[];
  41913. skeletons: Skeleton[];
  41914. animationGroups: AnimationGroup[];
  41915. }>;
  41916. /**
  41917. * Load into a scene.
  41918. * @param scene The scene to load into
  41919. * @param data The data to import
  41920. * @param rootUrl The root url for scene and resources
  41921. * @param onProgress The callback when the load progresses
  41922. * @param fileName Defines the name of the file to load
  41923. * @returns Nothing
  41924. */
  41925. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  41926. /**
  41927. * The callback that returns true if the data can be directly loaded.
  41928. */
  41929. canDirectLoad?: (data: string) => boolean;
  41930. /**
  41931. * The callback that allows custom handling of the root url based on the response url.
  41932. */
  41933. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  41934. /**
  41935. * Load into an asset container.
  41936. * @param scene The scene to load into
  41937. * @param data The data to import
  41938. * @param rootUrl The root url for scene and resources
  41939. * @param onProgress The callback when the load progresses
  41940. * @param fileName Defines the name of the file to load
  41941. * @returns The loaded asset container
  41942. */
  41943. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  41944. }
  41945. /**
  41946. * Class used to load scene from various file formats using registered plugins
  41947. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  41948. */
  41949. export class SceneLoader {
  41950. /**
  41951. * No logging while loading
  41952. */
  41953. static readonly NO_LOGGING: number;
  41954. /**
  41955. * Minimal logging while loading
  41956. */
  41957. static readonly MINIMAL_LOGGING: number;
  41958. /**
  41959. * Summary logging while loading
  41960. */
  41961. static readonly SUMMARY_LOGGING: number;
  41962. /**
  41963. * Detailled logging while loading
  41964. */
  41965. static readonly DETAILED_LOGGING: number;
  41966. /**
  41967. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  41968. */
  41969. static ForceFullSceneLoadingForIncremental: boolean;
  41970. /**
  41971. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  41972. */
  41973. static ShowLoadingScreen: boolean;
  41974. /**
  41975. * Defines the current logging level (while loading the scene)
  41976. * @ignorenaming
  41977. */
  41978. static loggingLevel: number;
  41979. /**
  41980. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  41981. */
  41982. static CleanBoneMatrixWeights: boolean;
  41983. /**
  41984. * Event raised when a plugin is used to load a scene
  41985. */
  41986. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  41987. private static _registeredPlugins;
  41988. private static _getDefaultPlugin;
  41989. private static _getPluginForExtension;
  41990. private static _getPluginForDirectLoad;
  41991. private static _getPluginForFilename;
  41992. private static _getDirectLoad;
  41993. private static _loadData;
  41994. private static _getFileInfo;
  41995. /**
  41996. * Gets a plugin that can load the given extension
  41997. * @param extension defines the extension to load
  41998. * @returns a plugin or null if none works
  41999. */
  42000. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  42001. /**
  42002. * Gets a boolean indicating that the given extension can be loaded
  42003. * @param extension defines the extension to load
  42004. * @returns true if the extension is supported
  42005. */
  42006. static IsPluginForExtensionAvailable(extension: string): boolean;
  42007. /**
  42008. * Adds a new plugin to the list of registered plugins
  42009. * @param plugin defines the plugin to add
  42010. */
  42011. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  42012. /**
  42013. * Import meshes into a scene
  42014. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42015. * @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)
  42016. * @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)
  42017. * @param scene the instance of BABYLON.Scene to append to
  42018. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  42019. * @param onProgress a callback with a progress event for each file being loaded
  42020. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42021. * @param pluginExtension the extension used to determine the plugin
  42022. * @returns The loaded plugin
  42023. */
  42024. 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>;
  42025. /**
  42026. * Import meshes into a scene
  42027. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42028. * @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)
  42029. * @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)
  42030. * @param scene the instance of BABYLON.Scene to append to
  42031. * @param onProgress a callback with a progress event for each file being loaded
  42032. * @param pluginExtension the extension used to determine the plugin
  42033. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  42034. */
  42035. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  42036. meshes: AbstractMesh[];
  42037. particleSystems: IParticleSystem[];
  42038. skeletons: Skeleton[];
  42039. animationGroups: AnimationGroup[];
  42040. }>;
  42041. /**
  42042. * Load a scene
  42043. * @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)
  42044. * @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)
  42045. * @param engine is the instance of BABYLON.Engine to use to create the scene
  42046. * @param onSuccess a callback with the scene when import succeeds
  42047. * @param onProgress a callback with a progress event for each file being loaded
  42048. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42049. * @param pluginExtension the extension used to determine the plugin
  42050. * @returns The loaded plugin
  42051. */
  42052. 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>;
  42053. /**
  42054. * Load a scene
  42055. * @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)
  42056. * @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)
  42057. * @param engine is the instance of BABYLON.Engine to use to create the scene
  42058. * @param onProgress a callback with a progress event for each file being loaded
  42059. * @param pluginExtension the extension used to determine the plugin
  42060. * @returns The loaded scene
  42061. */
  42062. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  42063. /**
  42064. * Append a scene
  42065. * @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)
  42066. * @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)
  42067. * @param scene is the instance of BABYLON.Scene to append to
  42068. * @param onSuccess a callback with the scene when import succeeds
  42069. * @param onProgress a callback with a progress event for each file being loaded
  42070. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42071. * @param pluginExtension the extension used to determine the plugin
  42072. * @returns The loaded plugin
  42073. */
  42074. 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>;
  42075. /**
  42076. * Append a scene
  42077. * @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)
  42078. * @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)
  42079. * @param scene is the instance of BABYLON.Scene to append to
  42080. * @param onProgress a callback with a progress event for each file being loaded
  42081. * @param pluginExtension the extension used to determine the plugin
  42082. * @returns The given scene
  42083. */
  42084. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  42085. /**
  42086. * Load a scene into an asset container
  42087. * @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)
  42088. * @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)
  42089. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  42090. * @param onSuccess a callback with the scene when import succeeds
  42091. * @param onProgress a callback with a progress event for each file being loaded
  42092. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42093. * @param pluginExtension the extension used to determine the plugin
  42094. * @returns The loaded plugin
  42095. */
  42096. 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>;
  42097. /**
  42098. * Load a scene into an asset container
  42099. * @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)
  42100. * @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)
  42101. * @param scene is the instance of Scene to append to
  42102. * @param onProgress a callback with a progress event for each file being loaded
  42103. * @param pluginExtension the extension used to determine the plugin
  42104. * @returns The loaded asset container
  42105. */
  42106. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  42107. }
  42108. }
  42109. declare module BABYLON {
  42110. /**
  42111. * Generic Controller
  42112. */
  42113. export class GenericController extends WebVRController {
  42114. /**
  42115. * Base Url for the controller model.
  42116. */
  42117. static readonly MODEL_BASE_URL: string;
  42118. /**
  42119. * File name for the controller model.
  42120. */
  42121. static readonly MODEL_FILENAME: string;
  42122. /**
  42123. * Creates a new GenericController from a gamepad
  42124. * @param vrGamepad the gamepad that the controller should be created from
  42125. */
  42126. constructor(vrGamepad: any);
  42127. /**
  42128. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42129. * @param scene scene in which to add meshes
  42130. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42131. */
  42132. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42133. /**
  42134. * Called once for each button that changed state since the last frame
  42135. * @param buttonIdx Which button index changed
  42136. * @param state New state of the button
  42137. * @param changes Which properties on the state changed since last frame
  42138. */
  42139. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42140. }
  42141. }
  42142. declare module BABYLON {
  42143. /**
  42144. * Defines the WindowsMotionController object that the state of the windows motion controller
  42145. */
  42146. export class WindowsMotionController extends WebVRController {
  42147. /**
  42148. * The base url used to load the left and right controller models
  42149. */
  42150. static MODEL_BASE_URL: string;
  42151. /**
  42152. * The name of the left controller model file
  42153. */
  42154. static MODEL_LEFT_FILENAME: string;
  42155. /**
  42156. * The name of the right controller model file
  42157. */
  42158. static MODEL_RIGHT_FILENAME: string;
  42159. /**
  42160. * The controller name prefix for this controller type
  42161. */
  42162. static readonly GAMEPAD_ID_PREFIX: string;
  42163. /**
  42164. * The controller id pattern for this controller type
  42165. */
  42166. private static readonly GAMEPAD_ID_PATTERN;
  42167. private _loadedMeshInfo;
  42168. private readonly _mapping;
  42169. /**
  42170. * Fired when the trackpad on this controller is clicked
  42171. */
  42172. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  42173. /**
  42174. * Fired when the trackpad on this controller is modified
  42175. */
  42176. onTrackpadValuesChangedObservable: Observable<StickValues>;
  42177. /**
  42178. * The current x and y values of this controller's trackpad
  42179. */
  42180. trackpad: StickValues;
  42181. /**
  42182. * Creates a new WindowsMotionController from a gamepad
  42183. * @param vrGamepad the gamepad that the controller should be created from
  42184. */
  42185. constructor(vrGamepad: any);
  42186. /**
  42187. * Fired when the trigger on this controller is modified
  42188. */
  42189. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42190. /**
  42191. * Fired when the menu button on this controller is modified
  42192. */
  42193. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42194. /**
  42195. * Fired when the grip button on this controller is modified
  42196. */
  42197. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42198. /**
  42199. * Fired when the thumbstick button on this controller is modified
  42200. */
  42201. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42202. /**
  42203. * Fired when the touchpad button on this controller is modified
  42204. */
  42205. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42206. /**
  42207. * Fired when the touchpad values on this controller are modified
  42208. */
  42209. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  42210. private _updateTrackpad;
  42211. /**
  42212. * Called once per frame by the engine.
  42213. */
  42214. update(): void;
  42215. /**
  42216. * Called once for each button that changed state since the last frame
  42217. * @param buttonIdx Which button index changed
  42218. * @param state New state of the button
  42219. * @param changes Which properties on the state changed since last frame
  42220. */
  42221. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42222. /**
  42223. * Moves the buttons on the controller mesh based on their current state
  42224. * @param buttonName the name of the button to move
  42225. * @param buttonValue the value of the button which determines the buttons new position
  42226. */
  42227. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  42228. /**
  42229. * Moves the axis on the controller mesh based on its current state
  42230. * @param axis the index of the axis
  42231. * @param axisValue the value of the axis which determines the meshes new position
  42232. * @hidden
  42233. */
  42234. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  42235. /**
  42236. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42237. * @param scene scene in which to add meshes
  42238. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42239. */
  42240. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  42241. /**
  42242. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  42243. * can be transformed by button presses and axes values, based on this._mapping.
  42244. *
  42245. * @param scene scene in which the meshes exist
  42246. * @param meshes list of meshes that make up the controller model to process
  42247. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  42248. */
  42249. private processModel;
  42250. private createMeshInfo;
  42251. /**
  42252. * Gets the ray of the controller in the direction the controller is pointing
  42253. * @param length the length the resulting ray should be
  42254. * @returns a ray in the direction the controller is pointing
  42255. */
  42256. getForwardRay(length?: number): Ray;
  42257. /**
  42258. * Disposes of the controller
  42259. */
  42260. dispose(): void;
  42261. }
  42262. }
  42263. declare module BABYLON {
  42264. /**
  42265. * Oculus Touch Controller
  42266. */
  42267. export class OculusTouchController extends WebVRController {
  42268. /**
  42269. * Base Url for the controller model.
  42270. */
  42271. static MODEL_BASE_URL: string;
  42272. /**
  42273. * File name for the left controller model.
  42274. */
  42275. static MODEL_LEFT_FILENAME: string;
  42276. /**
  42277. * File name for the right controller model.
  42278. */
  42279. static MODEL_RIGHT_FILENAME: string;
  42280. /**
  42281. * Base Url for the Quest controller model.
  42282. */
  42283. static QUEST_MODEL_BASE_URL: string;
  42284. /**
  42285. * @hidden
  42286. * If the controllers are running on a device that needs the updated Quest controller models
  42287. */
  42288. static _IsQuest: boolean;
  42289. /**
  42290. * Fired when the secondary trigger on this controller is modified
  42291. */
  42292. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  42293. /**
  42294. * Fired when the thumb rest on this controller is modified
  42295. */
  42296. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  42297. /**
  42298. * Creates a new OculusTouchController from a gamepad
  42299. * @param vrGamepad the gamepad that the controller should be created from
  42300. */
  42301. constructor(vrGamepad: any);
  42302. /**
  42303. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42304. * @param scene scene in which to add meshes
  42305. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42306. */
  42307. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42308. /**
  42309. * Fired when the A button on this controller is modified
  42310. */
  42311. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42312. /**
  42313. * Fired when the B button on this controller is modified
  42314. */
  42315. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42316. /**
  42317. * Fired when the X button on this controller is modified
  42318. */
  42319. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42320. /**
  42321. * Fired when the Y button on this controller is modified
  42322. */
  42323. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42324. /**
  42325. * Called once for each button that changed state since the last frame
  42326. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  42327. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  42328. * 2) secondary trigger (same)
  42329. * 3) A (right) X (left), touch, pressed = value
  42330. * 4) B / Y
  42331. * 5) thumb rest
  42332. * @param buttonIdx Which button index changed
  42333. * @param state New state of the button
  42334. * @param changes Which properties on the state changed since last frame
  42335. */
  42336. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42337. }
  42338. }
  42339. declare module BABYLON {
  42340. /**
  42341. * Vive Controller
  42342. */
  42343. export class ViveController extends WebVRController {
  42344. /**
  42345. * Base Url for the controller model.
  42346. */
  42347. static MODEL_BASE_URL: string;
  42348. /**
  42349. * File name for the controller model.
  42350. */
  42351. static MODEL_FILENAME: string;
  42352. /**
  42353. * Creates a new ViveController from a gamepad
  42354. * @param vrGamepad the gamepad that the controller should be created from
  42355. */
  42356. constructor(vrGamepad: any);
  42357. /**
  42358. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42359. * @param scene scene in which to add meshes
  42360. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42361. */
  42362. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42363. /**
  42364. * Fired when the left button on this controller is modified
  42365. */
  42366. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42367. /**
  42368. * Fired when the right button on this controller is modified
  42369. */
  42370. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42371. /**
  42372. * Fired when the menu button on this controller is modified
  42373. */
  42374. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42375. /**
  42376. * Called once for each button that changed state since the last frame
  42377. * Vive mapping:
  42378. * 0: touchpad
  42379. * 1: trigger
  42380. * 2: left AND right buttons
  42381. * 3: menu button
  42382. * @param buttonIdx Which button index changed
  42383. * @param state New state of the button
  42384. * @param changes Which properties on the state changed since last frame
  42385. */
  42386. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42387. }
  42388. }
  42389. declare module BABYLON {
  42390. /**
  42391. * Loads a controller model and adds it as a child of the WebXRControllers grip when the controller is created
  42392. */
  42393. export class WebXRControllerModelLoader {
  42394. /**
  42395. * Creates the WebXRControllerModelLoader
  42396. * @param input xr input that creates the controllers
  42397. */
  42398. constructor(input: WebXRInput);
  42399. }
  42400. }
  42401. declare module BABYLON {
  42402. /**
  42403. * Contains an array of blocks representing the octree
  42404. */
  42405. export interface IOctreeContainer<T> {
  42406. /**
  42407. * Blocks within the octree
  42408. */
  42409. blocks: Array<OctreeBlock<T>>;
  42410. }
  42411. /**
  42412. * Class used to store a cell in an octree
  42413. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42414. */
  42415. export class OctreeBlock<T> {
  42416. /**
  42417. * Gets the content of the current block
  42418. */
  42419. entries: T[];
  42420. /**
  42421. * Gets the list of block children
  42422. */
  42423. blocks: Array<OctreeBlock<T>>;
  42424. private _depth;
  42425. private _maxDepth;
  42426. private _capacity;
  42427. private _minPoint;
  42428. private _maxPoint;
  42429. private _boundingVectors;
  42430. private _creationFunc;
  42431. /**
  42432. * Creates a new block
  42433. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  42434. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  42435. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  42436. * @param depth defines the current depth of this block in the octree
  42437. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  42438. * @param creationFunc defines a callback to call when an element is added to the block
  42439. */
  42440. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  42441. /**
  42442. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  42443. */
  42444. readonly capacity: number;
  42445. /**
  42446. * Gets the minimum vector (in world space) of the block's bounding box
  42447. */
  42448. readonly minPoint: Vector3;
  42449. /**
  42450. * Gets the maximum vector (in world space) of the block's bounding box
  42451. */
  42452. readonly maxPoint: Vector3;
  42453. /**
  42454. * Add a new element to this block
  42455. * @param entry defines the element to add
  42456. */
  42457. addEntry(entry: T): void;
  42458. /**
  42459. * Remove an element from this block
  42460. * @param entry defines the element to remove
  42461. */
  42462. removeEntry(entry: T): void;
  42463. /**
  42464. * Add an array of elements to this block
  42465. * @param entries defines the array of elements to add
  42466. */
  42467. addEntries(entries: T[]): void;
  42468. /**
  42469. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  42470. * @param frustumPlanes defines the frustum planes to test
  42471. * @param selection defines the array to store current content if selection is positive
  42472. * @param allowDuplicate defines if the selection array can contains duplicated entries
  42473. */
  42474. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  42475. /**
  42476. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  42477. * @param sphereCenter defines the bounding sphere center
  42478. * @param sphereRadius defines the bounding sphere radius
  42479. * @param selection defines the array to store current content if selection is positive
  42480. * @param allowDuplicate defines if the selection array can contains duplicated entries
  42481. */
  42482. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  42483. /**
  42484. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  42485. * @param ray defines the ray to test with
  42486. * @param selection defines the array to store current content if selection is positive
  42487. */
  42488. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  42489. /**
  42490. * Subdivide the content into child blocks (this block will then be empty)
  42491. */
  42492. createInnerBlocks(): void;
  42493. /**
  42494. * @hidden
  42495. */
  42496. 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;
  42497. }
  42498. }
  42499. declare module BABYLON {
  42500. /**
  42501. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  42502. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42503. */
  42504. export class Octree<T> {
  42505. /** 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.) */
  42506. maxDepth: number;
  42507. /**
  42508. * Blocks within the octree containing objects
  42509. */
  42510. blocks: Array<OctreeBlock<T>>;
  42511. /**
  42512. * Content stored in the octree
  42513. */
  42514. dynamicContent: T[];
  42515. private _maxBlockCapacity;
  42516. private _selectionContent;
  42517. private _creationFunc;
  42518. /**
  42519. * Creates a octree
  42520. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42521. * @param creationFunc function to be used to instatiate the octree
  42522. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  42523. * @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.)
  42524. */
  42525. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  42526. /** 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.) */
  42527. maxDepth?: number);
  42528. /**
  42529. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  42530. * @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);
  42531. * @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);
  42532. * @param entries meshes to be added to the octree blocks
  42533. */
  42534. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  42535. /**
  42536. * Adds a mesh to the octree
  42537. * @param entry Mesh to add to the octree
  42538. */
  42539. addMesh(entry: T): void;
  42540. /**
  42541. * Remove an element from the octree
  42542. * @param entry defines the element to remove
  42543. */
  42544. removeMesh(entry: T): void;
  42545. /**
  42546. * Selects an array of meshes within the frustum
  42547. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  42548. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  42549. * @returns array of meshes within the frustum
  42550. */
  42551. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  42552. /**
  42553. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  42554. * @param sphereCenter defines the bounding sphere center
  42555. * @param sphereRadius defines the bounding sphere radius
  42556. * @param allowDuplicate defines if the selection array can contains duplicated entries
  42557. * @returns an array of objects that intersect the sphere
  42558. */
  42559. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  42560. /**
  42561. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  42562. * @param ray defines the ray to test with
  42563. * @returns array of intersected objects
  42564. */
  42565. intersectsRay(ray: Ray): SmartArray<T>;
  42566. /**
  42567. * Adds a mesh into the octree block if it intersects the block
  42568. */
  42569. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  42570. /**
  42571. * Adds a submesh into the octree block if it intersects the block
  42572. */
  42573. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  42574. }
  42575. }
  42576. declare module BABYLON {
  42577. interface Scene {
  42578. /**
  42579. * @hidden
  42580. * Backing Filed
  42581. */
  42582. _selectionOctree: Octree<AbstractMesh>;
  42583. /**
  42584. * Gets the octree used to boost mesh selection (picking)
  42585. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42586. */
  42587. selectionOctree: Octree<AbstractMesh>;
  42588. /**
  42589. * Creates or updates the octree used to boost selection (picking)
  42590. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42591. * @param maxCapacity defines the maximum capacity per leaf
  42592. * @param maxDepth defines the maximum depth of the octree
  42593. * @returns an octree of AbstractMesh
  42594. */
  42595. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  42596. }
  42597. interface AbstractMesh {
  42598. /**
  42599. * @hidden
  42600. * Backing Field
  42601. */
  42602. _submeshesOctree: Octree<SubMesh>;
  42603. /**
  42604. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  42605. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  42606. * @param maxCapacity defines the maximum size of each block (64 by default)
  42607. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  42608. * @returns the new octree
  42609. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  42610. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42611. */
  42612. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  42613. }
  42614. /**
  42615. * Defines the octree scene component responsible to manage any octrees
  42616. * in a given scene.
  42617. */
  42618. export class OctreeSceneComponent {
  42619. /**
  42620. * The component name help to identify the component in the list of scene components.
  42621. */
  42622. readonly name: string;
  42623. /**
  42624. * The scene the component belongs to.
  42625. */
  42626. scene: Scene;
  42627. /**
  42628. * Indicates if the meshes have been checked to make sure they are isEnabled()
  42629. */
  42630. readonly checksIsEnabled: boolean;
  42631. /**
  42632. * Creates a new instance of the component for the given scene
  42633. * @param scene Defines the scene to register the component in
  42634. */
  42635. constructor(scene: Scene);
  42636. /**
  42637. * Registers the component in a given scene
  42638. */
  42639. register(): void;
  42640. /**
  42641. * Return the list of active meshes
  42642. * @returns the list of active meshes
  42643. */
  42644. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  42645. /**
  42646. * Return the list of active sub meshes
  42647. * @param mesh The mesh to get the candidates sub meshes from
  42648. * @returns the list of active sub meshes
  42649. */
  42650. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  42651. private _tempRay;
  42652. /**
  42653. * Return the list of sub meshes intersecting with a given local ray
  42654. * @param mesh defines the mesh to find the submesh for
  42655. * @param localRay defines the ray in local space
  42656. * @returns the list of intersecting sub meshes
  42657. */
  42658. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  42659. /**
  42660. * Return the list of sub meshes colliding with a collider
  42661. * @param mesh defines the mesh to find the submesh for
  42662. * @param collider defines the collider to evaluate the collision against
  42663. * @returns the list of colliding sub meshes
  42664. */
  42665. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  42666. /**
  42667. * Rebuilds the elements related to this component in case of
  42668. * context lost for instance.
  42669. */
  42670. rebuild(): void;
  42671. /**
  42672. * Disposes the component and the associated ressources.
  42673. */
  42674. dispose(): void;
  42675. }
  42676. }
  42677. declare module BABYLON {
  42678. /**
  42679. * Renders a layer on top of an existing scene
  42680. */
  42681. export class UtilityLayerRenderer implements IDisposable {
  42682. /** the original scene that will be rendered on top of */
  42683. originalScene: Scene;
  42684. private _pointerCaptures;
  42685. private _lastPointerEvents;
  42686. private static _DefaultUtilityLayer;
  42687. private static _DefaultKeepDepthUtilityLayer;
  42688. private _sharedGizmoLight;
  42689. private _renderCamera;
  42690. /**
  42691. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  42692. * @returns the camera that is used when rendering the utility layer
  42693. */
  42694. getRenderCamera(): Nullable<Camera>;
  42695. /**
  42696. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  42697. * @param cam the camera that should be used when rendering the utility layer
  42698. */
  42699. setRenderCamera(cam: Nullable<Camera>): void;
  42700. /**
  42701. * @hidden
  42702. * Light which used by gizmos to get light shading
  42703. */
  42704. _getSharedGizmoLight(): HemisphericLight;
  42705. /**
  42706. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  42707. */
  42708. pickUtilitySceneFirst: boolean;
  42709. /**
  42710. * 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)
  42711. */
  42712. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  42713. /**
  42714. * 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)
  42715. */
  42716. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  42717. /**
  42718. * The scene that is rendered on top of the original scene
  42719. */
  42720. utilityLayerScene: Scene;
  42721. /**
  42722. * If the utility layer should automatically be rendered on top of existing scene
  42723. */
  42724. shouldRender: boolean;
  42725. /**
  42726. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  42727. */
  42728. onlyCheckPointerDownEvents: boolean;
  42729. /**
  42730. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  42731. */
  42732. processAllEvents: boolean;
  42733. /**
  42734. * Observable raised when the pointer move from the utility layer scene to the main scene
  42735. */
  42736. onPointerOutObservable: Observable<number>;
  42737. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  42738. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  42739. private _afterRenderObserver;
  42740. private _sceneDisposeObserver;
  42741. private _originalPointerObserver;
  42742. /**
  42743. * Instantiates a UtilityLayerRenderer
  42744. * @param originalScene the original scene that will be rendered on top of
  42745. * @param handleEvents boolean indicating if the utility layer should handle events
  42746. */
  42747. constructor(
  42748. /** the original scene that will be rendered on top of */
  42749. originalScene: Scene, handleEvents?: boolean);
  42750. private _notifyObservers;
  42751. /**
  42752. * Renders the utility layers scene on top of the original scene
  42753. */
  42754. render(): void;
  42755. /**
  42756. * Disposes of the renderer
  42757. */
  42758. dispose(): void;
  42759. private _updateCamera;
  42760. }
  42761. }
  42762. declare module BABYLON {
  42763. /**
  42764. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  42765. */
  42766. export class Gizmo implements IDisposable {
  42767. /** The utility layer the gizmo will be added to */
  42768. gizmoLayer: UtilityLayerRenderer;
  42769. /**
  42770. * The root mesh of the gizmo
  42771. */
  42772. _rootMesh: Mesh;
  42773. private _attachedMesh;
  42774. /**
  42775. * Ratio for the scale of the gizmo (Default: 1)
  42776. */
  42777. scaleRatio: number;
  42778. /**
  42779. * If a custom mesh has been set (Default: false)
  42780. */
  42781. protected _customMeshSet: boolean;
  42782. /**
  42783. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  42784. * * When set, interactions will be enabled
  42785. */
  42786. attachedMesh: Nullable<AbstractMesh>;
  42787. /**
  42788. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  42789. * @param mesh The mesh to replace the default mesh of the gizmo
  42790. */
  42791. setCustomMesh(mesh: Mesh): void;
  42792. /**
  42793. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  42794. */
  42795. updateGizmoRotationToMatchAttachedMesh: boolean;
  42796. /**
  42797. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  42798. */
  42799. updateGizmoPositionToMatchAttachedMesh: boolean;
  42800. /**
  42801. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  42802. */
  42803. updateScale: boolean;
  42804. protected _interactionsEnabled: boolean;
  42805. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42806. private _beforeRenderObserver;
  42807. private _tempVector;
  42808. /**
  42809. * Creates a gizmo
  42810. * @param gizmoLayer The utility layer the gizmo will be added to
  42811. */
  42812. constructor(
  42813. /** The utility layer the gizmo will be added to */
  42814. gizmoLayer?: UtilityLayerRenderer);
  42815. /**
  42816. * Updates the gizmo to match the attached mesh's position/rotation
  42817. */
  42818. protected _update(): void;
  42819. /**
  42820. * Disposes of the gizmo
  42821. */
  42822. dispose(): void;
  42823. }
  42824. }
  42825. declare module BABYLON {
  42826. /**
  42827. * Single plane drag gizmo
  42828. */
  42829. export class PlaneDragGizmo extends Gizmo {
  42830. /**
  42831. * Drag behavior responsible for the gizmos dragging interactions
  42832. */
  42833. dragBehavior: PointerDragBehavior;
  42834. private _pointerObserver;
  42835. /**
  42836. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42837. */
  42838. snapDistance: number;
  42839. /**
  42840. * Event that fires each time the gizmo snaps to a new location.
  42841. * * snapDistance is the the change in distance
  42842. */
  42843. onSnapObservable: Observable<{
  42844. snapDistance: number;
  42845. }>;
  42846. private _plane;
  42847. private _coloredMaterial;
  42848. private _hoverMaterial;
  42849. private _isEnabled;
  42850. private _parent;
  42851. /** @hidden */
  42852. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  42853. /** @hidden */
  42854. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  42855. /**
  42856. * Creates a PlaneDragGizmo
  42857. * @param gizmoLayer The utility layer the gizmo will be added to
  42858. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  42859. * @param color The color of the gizmo
  42860. */
  42861. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  42862. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42863. /**
  42864. * If the gizmo is enabled
  42865. */
  42866. isEnabled: boolean;
  42867. /**
  42868. * Disposes of the gizmo
  42869. */
  42870. dispose(): void;
  42871. }
  42872. }
  42873. declare module BABYLON {
  42874. /**
  42875. * Gizmo that enables dragging a mesh along 3 axis
  42876. */
  42877. export class PositionGizmo extends Gizmo {
  42878. /**
  42879. * Internal gizmo used for interactions on the x axis
  42880. */
  42881. xGizmo: AxisDragGizmo;
  42882. /**
  42883. * Internal gizmo used for interactions on the y axis
  42884. */
  42885. yGizmo: AxisDragGizmo;
  42886. /**
  42887. * Internal gizmo used for interactions on the z axis
  42888. */
  42889. zGizmo: AxisDragGizmo;
  42890. /**
  42891. * Internal gizmo used for interactions on the yz plane
  42892. */
  42893. xPlaneGizmo: PlaneDragGizmo;
  42894. /**
  42895. * Internal gizmo used for interactions on the xz plane
  42896. */
  42897. yPlaneGizmo: PlaneDragGizmo;
  42898. /**
  42899. * Internal gizmo used for interactions on the xy plane
  42900. */
  42901. zPlaneGizmo: PlaneDragGizmo;
  42902. /**
  42903. * private variables
  42904. */
  42905. private _meshAttached;
  42906. private _updateGizmoRotationToMatchAttachedMesh;
  42907. private _snapDistance;
  42908. private _scaleRatio;
  42909. /** Fires an event when any of it's sub gizmos are dragged */
  42910. onDragStartObservable: Observable<unknown>;
  42911. /** Fires an event when any of it's sub gizmos are released from dragging */
  42912. onDragEndObservable: Observable<unknown>;
  42913. /**
  42914. * If set to true, planar drag is enabled
  42915. */
  42916. private _planarGizmoEnabled;
  42917. attachedMesh: Nullable<AbstractMesh>;
  42918. /**
  42919. * Creates a PositionGizmo
  42920. * @param gizmoLayer The utility layer the gizmo will be added to
  42921. */
  42922. constructor(gizmoLayer?: UtilityLayerRenderer);
  42923. /**
  42924. * If the planar drag gizmo is enabled
  42925. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  42926. */
  42927. planarGizmoEnabled: boolean;
  42928. updateGizmoRotationToMatchAttachedMesh: boolean;
  42929. /**
  42930. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42931. */
  42932. snapDistance: number;
  42933. /**
  42934. * Ratio for the scale of the gizmo (Default: 1)
  42935. */
  42936. scaleRatio: number;
  42937. /**
  42938. * Disposes of the gizmo
  42939. */
  42940. dispose(): void;
  42941. /**
  42942. * CustomMeshes are not supported by this gizmo
  42943. * @param mesh The mesh to replace the default mesh of the gizmo
  42944. */
  42945. setCustomMesh(mesh: Mesh): void;
  42946. }
  42947. }
  42948. declare module BABYLON {
  42949. /**
  42950. * Single axis drag gizmo
  42951. */
  42952. export class AxisDragGizmo extends Gizmo {
  42953. /**
  42954. * Drag behavior responsible for the gizmos dragging interactions
  42955. */
  42956. dragBehavior: PointerDragBehavior;
  42957. private _pointerObserver;
  42958. /**
  42959. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42960. */
  42961. snapDistance: number;
  42962. /**
  42963. * Event that fires each time the gizmo snaps to a new location.
  42964. * * snapDistance is the the change in distance
  42965. */
  42966. onSnapObservable: Observable<{
  42967. snapDistance: number;
  42968. }>;
  42969. private _isEnabled;
  42970. private _parent;
  42971. private _arrow;
  42972. private _coloredMaterial;
  42973. private _hoverMaterial;
  42974. /** @hidden */
  42975. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  42976. /** @hidden */
  42977. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  42978. /**
  42979. * Creates an AxisDragGizmo
  42980. * @param gizmoLayer The utility layer the gizmo will be added to
  42981. * @param dragAxis The axis which the gizmo will be able to drag on
  42982. * @param color The color of the gizmo
  42983. */
  42984. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  42985. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42986. /**
  42987. * If the gizmo is enabled
  42988. */
  42989. isEnabled: boolean;
  42990. /**
  42991. * Disposes of the gizmo
  42992. */
  42993. dispose(): void;
  42994. }
  42995. }
  42996. declare module BABYLON.Debug {
  42997. /**
  42998. * The Axes viewer will show 3 axes in a specific point in space
  42999. */
  43000. export class AxesViewer {
  43001. private _xAxis;
  43002. private _yAxis;
  43003. private _zAxis;
  43004. private _scaleLinesFactor;
  43005. private _instanced;
  43006. /**
  43007. * Gets the hosting scene
  43008. */
  43009. scene: Scene;
  43010. /**
  43011. * Gets or sets a number used to scale line length
  43012. */
  43013. scaleLines: number;
  43014. /** Gets the node hierarchy used to render x-axis */
  43015. readonly xAxis: TransformNode;
  43016. /** Gets the node hierarchy used to render y-axis */
  43017. readonly yAxis: TransformNode;
  43018. /** Gets the node hierarchy used to render z-axis */
  43019. readonly zAxis: TransformNode;
  43020. /**
  43021. * Creates a new AxesViewer
  43022. * @param scene defines the hosting scene
  43023. * @param scaleLines defines a number used to scale line length (1 by default)
  43024. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  43025. * @param xAxis defines the node hierarchy used to render the x-axis
  43026. * @param yAxis defines the node hierarchy used to render the y-axis
  43027. * @param zAxis defines the node hierarchy used to render the z-axis
  43028. */
  43029. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  43030. /**
  43031. * Force the viewer to update
  43032. * @param position defines the position of the viewer
  43033. * @param xaxis defines the x axis of the viewer
  43034. * @param yaxis defines the y axis of the viewer
  43035. * @param zaxis defines the z axis of the viewer
  43036. */
  43037. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  43038. /**
  43039. * Creates an instance of this axes viewer.
  43040. * @returns a new axes viewer with instanced meshes
  43041. */
  43042. createInstance(): AxesViewer;
  43043. /** Releases resources */
  43044. dispose(): void;
  43045. private static _SetRenderingGroupId;
  43046. }
  43047. }
  43048. declare module BABYLON.Debug {
  43049. /**
  43050. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  43051. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  43052. */
  43053. export class BoneAxesViewer extends AxesViewer {
  43054. /**
  43055. * Gets or sets the target mesh where to display the axes viewer
  43056. */
  43057. mesh: Nullable<Mesh>;
  43058. /**
  43059. * Gets or sets the target bone where to display the axes viewer
  43060. */
  43061. bone: Nullable<Bone>;
  43062. /** Gets current position */
  43063. pos: Vector3;
  43064. /** Gets direction of X axis */
  43065. xaxis: Vector3;
  43066. /** Gets direction of Y axis */
  43067. yaxis: Vector3;
  43068. /** Gets direction of Z axis */
  43069. zaxis: Vector3;
  43070. /**
  43071. * Creates a new BoneAxesViewer
  43072. * @param scene defines the hosting scene
  43073. * @param bone defines the target bone
  43074. * @param mesh defines the target mesh
  43075. * @param scaleLines defines a scaling factor for line length (1 by default)
  43076. */
  43077. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  43078. /**
  43079. * Force the viewer to update
  43080. */
  43081. update(): void;
  43082. /** Releases resources */
  43083. dispose(): void;
  43084. }
  43085. }
  43086. declare module BABYLON {
  43087. /**
  43088. * Interface used to define scene explorer extensibility option
  43089. */
  43090. export interface IExplorerExtensibilityOption {
  43091. /**
  43092. * Define the option label
  43093. */
  43094. label: string;
  43095. /**
  43096. * Defines the action to execute on click
  43097. */
  43098. action: (entity: any) => void;
  43099. }
  43100. /**
  43101. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  43102. */
  43103. export interface IExplorerExtensibilityGroup {
  43104. /**
  43105. * Defines a predicate to test if a given type mut be extended
  43106. */
  43107. predicate: (entity: any) => boolean;
  43108. /**
  43109. * Gets the list of options added to a type
  43110. */
  43111. entries: IExplorerExtensibilityOption[];
  43112. }
  43113. /**
  43114. * Interface used to define the options to use to create the Inspector
  43115. */
  43116. export interface IInspectorOptions {
  43117. /**
  43118. * Display in overlay mode (default: false)
  43119. */
  43120. overlay?: boolean;
  43121. /**
  43122. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  43123. */
  43124. globalRoot?: HTMLElement;
  43125. /**
  43126. * Display the Scene explorer
  43127. */
  43128. showExplorer?: boolean;
  43129. /**
  43130. * Display the property inspector
  43131. */
  43132. showInspector?: boolean;
  43133. /**
  43134. * Display in embed mode (both panes on the right)
  43135. */
  43136. embedMode?: boolean;
  43137. /**
  43138. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  43139. */
  43140. handleResize?: boolean;
  43141. /**
  43142. * Allow the panes to popup (default: true)
  43143. */
  43144. enablePopup?: boolean;
  43145. /**
  43146. * Allow the panes to be closed by users (default: true)
  43147. */
  43148. enableClose?: boolean;
  43149. /**
  43150. * Optional list of extensibility entries
  43151. */
  43152. explorerExtensibility?: IExplorerExtensibilityGroup[];
  43153. /**
  43154. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  43155. */
  43156. inspectorURL?: string;
  43157. }
  43158. interface Scene {
  43159. /**
  43160. * @hidden
  43161. * Backing field
  43162. */
  43163. _debugLayer: DebugLayer;
  43164. /**
  43165. * Gets the debug layer (aka Inspector) associated with the scene
  43166. * @see http://doc.babylonjs.com/features/playground_debuglayer
  43167. */
  43168. debugLayer: DebugLayer;
  43169. }
  43170. /**
  43171. * The debug layer (aka Inspector) is the go to tool in order to better understand
  43172. * what is happening in your scene
  43173. * @see http://doc.babylonjs.com/features/playground_debuglayer
  43174. */
  43175. export class DebugLayer {
  43176. /**
  43177. * Define the url to get the inspector script from.
  43178. * By default it uses the babylonjs CDN.
  43179. * @ignoreNaming
  43180. */
  43181. static InspectorURL: string;
  43182. private _scene;
  43183. private BJSINSPECTOR;
  43184. private _onPropertyChangedObservable?;
  43185. /**
  43186. * Observable triggered when a property is changed through the inspector.
  43187. */
  43188. readonly onPropertyChangedObservable: any;
  43189. /**
  43190. * Instantiates a new debug layer.
  43191. * The debug layer (aka Inspector) is the go to tool in order to better understand
  43192. * what is happening in your scene
  43193. * @see http://doc.babylonjs.com/features/playground_debuglayer
  43194. * @param scene Defines the scene to inspect
  43195. */
  43196. constructor(scene: Scene);
  43197. /** Creates the inspector window. */
  43198. private _createInspector;
  43199. /**
  43200. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  43201. * @param entity defines the entity to select
  43202. * @param lineContainerTitle defines the specific block to highlight
  43203. */
  43204. select(entity: any, lineContainerTitle?: string): void;
  43205. /** Get the inspector from bundle or global */
  43206. private _getGlobalInspector;
  43207. /**
  43208. * Get if the inspector is visible or not.
  43209. * @returns true if visible otherwise, false
  43210. */
  43211. isVisible(): boolean;
  43212. /**
  43213. * Hide the inspector and close its window.
  43214. */
  43215. hide(): void;
  43216. /**
  43217. * Launch the debugLayer.
  43218. * @param config Define the configuration of the inspector
  43219. * @return a promise fulfilled when the debug layer is visible
  43220. */
  43221. show(config?: IInspectorOptions): Promise<DebugLayer>;
  43222. }
  43223. }
  43224. declare module BABYLON {
  43225. /**
  43226. * Class containing static functions to help procedurally build meshes
  43227. */
  43228. export class BoxBuilder {
  43229. /**
  43230. * Creates a box mesh
  43231. * * The parameter `size` sets the size (float) of each box side (default 1)
  43232. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  43233. * * 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)
  43234. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  43235. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43236. * * 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
  43237. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43238. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  43239. * @param name defines the name of the mesh
  43240. * @param options defines the options used to create the mesh
  43241. * @param scene defines the hosting scene
  43242. * @returns the box mesh
  43243. */
  43244. static CreateBox(name: string, options: {
  43245. size?: number;
  43246. width?: number;
  43247. height?: number;
  43248. depth?: number;
  43249. faceUV?: Vector4[];
  43250. faceColors?: Color4[];
  43251. sideOrientation?: number;
  43252. frontUVs?: Vector4;
  43253. backUVs?: Vector4;
  43254. wrap?: boolean;
  43255. topBaseAt?: number;
  43256. bottomBaseAt?: number;
  43257. updatable?: boolean;
  43258. }, scene?: Nullable<Scene>): Mesh;
  43259. }
  43260. }
  43261. declare module BABYLON {
  43262. /**
  43263. * Class containing static functions to help procedurally build meshes
  43264. */
  43265. export class SphereBuilder {
  43266. /**
  43267. * Creates a sphere mesh
  43268. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  43269. * * 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`)
  43270. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  43271. * * 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
  43272. * * 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)
  43273. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43274. * * 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
  43275. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43276. * @param name defines the name of the mesh
  43277. * @param options defines the options used to create the mesh
  43278. * @param scene defines the hosting scene
  43279. * @returns the sphere mesh
  43280. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  43281. */
  43282. static CreateSphere(name: string, options: {
  43283. segments?: number;
  43284. diameter?: number;
  43285. diameterX?: number;
  43286. diameterY?: number;
  43287. diameterZ?: number;
  43288. arc?: number;
  43289. slice?: number;
  43290. sideOrientation?: number;
  43291. frontUVs?: Vector4;
  43292. backUVs?: Vector4;
  43293. updatable?: boolean;
  43294. }, scene?: Nullable<Scene>): Mesh;
  43295. }
  43296. }
  43297. declare module BABYLON.Debug {
  43298. /**
  43299. * Used to show the physics impostor around the specific mesh
  43300. */
  43301. export class PhysicsViewer {
  43302. /** @hidden */
  43303. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  43304. /** @hidden */
  43305. protected _meshes: Array<Nullable<AbstractMesh>>;
  43306. /** @hidden */
  43307. protected _scene: Nullable<Scene>;
  43308. /** @hidden */
  43309. protected _numMeshes: number;
  43310. /** @hidden */
  43311. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  43312. private _renderFunction;
  43313. private _utilityLayer;
  43314. private _debugBoxMesh;
  43315. private _debugSphereMesh;
  43316. private _debugCylinderMesh;
  43317. private _debugMaterial;
  43318. private _debugMeshMeshes;
  43319. /**
  43320. * Creates a new PhysicsViewer
  43321. * @param scene defines the hosting scene
  43322. */
  43323. constructor(scene: Scene);
  43324. /** @hidden */
  43325. protected _updateDebugMeshes(): void;
  43326. /**
  43327. * Renders a specified physic impostor
  43328. * @param impostor defines the impostor to render
  43329. * @param targetMesh defines the mesh represented by the impostor
  43330. * @returns the new debug mesh used to render the impostor
  43331. */
  43332. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  43333. /**
  43334. * Hides a specified physic impostor
  43335. * @param impostor defines the impostor to hide
  43336. */
  43337. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  43338. private _getDebugMaterial;
  43339. private _getDebugBoxMesh;
  43340. private _getDebugSphereMesh;
  43341. private _getDebugCylinderMesh;
  43342. private _getDebugMeshMesh;
  43343. private _getDebugMesh;
  43344. /** Releases all resources */
  43345. dispose(): void;
  43346. }
  43347. }
  43348. declare module BABYLON {
  43349. /**
  43350. * Class containing static functions to help procedurally build meshes
  43351. */
  43352. export class LinesBuilder {
  43353. /**
  43354. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  43355. * * 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
  43356. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  43357. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  43358. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  43359. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  43360. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  43361. * * 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
  43362. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  43363. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43364. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  43365. * @param name defines the name of the new line system
  43366. * @param options defines the options used to create the line system
  43367. * @param scene defines the hosting scene
  43368. * @returns a new line system mesh
  43369. */
  43370. static CreateLineSystem(name: string, options: {
  43371. lines: Vector3[][];
  43372. updatable?: boolean;
  43373. instance?: Nullable<LinesMesh>;
  43374. colors?: Nullable<Color4[][]>;
  43375. useVertexAlpha?: boolean;
  43376. }, scene: Nullable<Scene>): LinesMesh;
  43377. /**
  43378. * Creates a line mesh
  43379. * 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
  43380. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  43381. * * The parameter `points` is an array successive Vector3
  43382. * * 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
  43383. * * The optional parameter `colors` is an array of successive Color4, one per line point
  43384. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  43385. * * When updating an instance, remember that only point positions can change, not the number of points
  43386. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43387. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  43388. * @param name defines the name of the new line system
  43389. * @param options defines the options used to create the line system
  43390. * @param scene defines the hosting scene
  43391. * @returns a new line mesh
  43392. */
  43393. static CreateLines(name: string, options: {
  43394. points: Vector3[];
  43395. updatable?: boolean;
  43396. instance?: Nullable<LinesMesh>;
  43397. colors?: Color4[];
  43398. useVertexAlpha?: boolean;
  43399. }, scene?: Nullable<Scene>): LinesMesh;
  43400. /**
  43401. * Creates a dashed line mesh
  43402. * * 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
  43403. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  43404. * * The parameter `points` is an array successive Vector3
  43405. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  43406. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  43407. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  43408. * * 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
  43409. * * When updating an instance, remember that only point positions can change, not the number of points
  43410. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43411. * @param name defines the name of the mesh
  43412. * @param options defines the options used to create the mesh
  43413. * @param scene defines the hosting scene
  43414. * @returns the dashed line mesh
  43415. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  43416. */
  43417. static CreateDashedLines(name: string, options: {
  43418. points: Vector3[];
  43419. dashSize?: number;
  43420. gapSize?: number;
  43421. dashNb?: number;
  43422. updatable?: boolean;
  43423. instance?: LinesMesh;
  43424. }, scene?: Nullable<Scene>): LinesMesh;
  43425. }
  43426. }
  43427. declare module BABYLON {
  43428. /**
  43429. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  43430. * in order to better appreciate the issue one might have.
  43431. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  43432. */
  43433. export class RayHelper {
  43434. /**
  43435. * Defines the ray we are currently tryin to visualize.
  43436. */
  43437. ray: Nullable<Ray>;
  43438. private _renderPoints;
  43439. private _renderLine;
  43440. private _renderFunction;
  43441. private _scene;
  43442. private _updateToMeshFunction;
  43443. private _attachedToMesh;
  43444. private _meshSpaceDirection;
  43445. private _meshSpaceOrigin;
  43446. /**
  43447. * Helper function to create a colored helper in a scene in one line.
  43448. * @param ray Defines the ray we are currently tryin to visualize
  43449. * @param scene Defines the scene the ray is used in
  43450. * @param color Defines the color we want to see the ray in
  43451. * @returns The newly created ray helper.
  43452. */
  43453. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  43454. /**
  43455. * Instantiate a new ray helper.
  43456. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  43457. * in order to better appreciate the issue one might have.
  43458. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  43459. * @param ray Defines the ray we are currently tryin to visualize
  43460. */
  43461. constructor(ray: Ray);
  43462. /**
  43463. * Shows the ray we are willing to debug.
  43464. * @param scene Defines the scene the ray needs to be rendered in
  43465. * @param color Defines the color the ray needs to be rendered in
  43466. */
  43467. show(scene: Scene, color?: Color3): void;
  43468. /**
  43469. * Hides the ray we are debugging.
  43470. */
  43471. hide(): void;
  43472. private _render;
  43473. /**
  43474. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  43475. * @param mesh Defines the mesh we want the helper attached to
  43476. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  43477. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  43478. * @param length Defines the length of the ray
  43479. */
  43480. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  43481. /**
  43482. * Detach the ray helper from the mesh it has previously been attached to.
  43483. */
  43484. detachFromMesh(): void;
  43485. private _updateToMesh;
  43486. /**
  43487. * Dispose the helper and release its associated resources.
  43488. */
  43489. dispose(): void;
  43490. }
  43491. }
  43492. declare module BABYLON.Debug {
  43493. /**
  43494. * Class used to render a debug view of a given skeleton
  43495. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  43496. */
  43497. export class SkeletonViewer {
  43498. /** defines the skeleton to render */
  43499. skeleton: Skeleton;
  43500. /** defines the mesh attached to the skeleton */
  43501. mesh: AbstractMesh;
  43502. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  43503. autoUpdateBonesMatrices: boolean;
  43504. /** defines the rendering group id to use with the viewer */
  43505. renderingGroupId: number;
  43506. /** Gets or sets the color used to render the skeleton */
  43507. color: Color3;
  43508. private _scene;
  43509. private _debugLines;
  43510. private _debugMesh;
  43511. private _isEnabled;
  43512. private _renderFunction;
  43513. private _utilityLayer;
  43514. /**
  43515. * Returns the mesh used to render the bones
  43516. */
  43517. readonly debugMesh: Nullable<LinesMesh>;
  43518. /**
  43519. * Creates a new SkeletonViewer
  43520. * @param skeleton defines the skeleton to render
  43521. * @param mesh defines the mesh attached to the skeleton
  43522. * @param scene defines the hosting scene
  43523. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  43524. * @param renderingGroupId defines the rendering group id to use with the viewer
  43525. */
  43526. constructor(
  43527. /** defines the skeleton to render */
  43528. skeleton: Skeleton,
  43529. /** defines the mesh attached to the skeleton */
  43530. mesh: AbstractMesh, scene: Scene,
  43531. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  43532. autoUpdateBonesMatrices?: boolean,
  43533. /** defines the rendering group id to use with the viewer */
  43534. renderingGroupId?: number);
  43535. /** Gets or sets a boolean indicating if the viewer is enabled */
  43536. isEnabled: boolean;
  43537. private _getBonePosition;
  43538. private _getLinesForBonesWithLength;
  43539. private _getLinesForBonesNoLength;
  43540. /** Update the viewer to sync with current skeleton state */
  43541. update(): void;
  43542. /** Release associated resources */
  43543. dispose(): void;
  43544. }
  43545. }
  43546. declare module BABYLON {
  43547. /**
  43548. * Options to create the null engine
  43549. */
  43550. export class NullEngineOptions {
  43551. /**
  43552. * Render width (Default: 512)
  43553. */
  43554. renderWidth: number;
  43555. /**
  43556. * Render height (Default: 256)
  43557. */
  43558. renderHeight: number;
  43559. /**
  43560. * Texture size (Default: 512)
  43561. */
  43562. textureSize: number;
  43563. /**
  43564. * If delta time between frames should be constant
  43565. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43566. */
  43567. deterministicLockstep: boolean;
  43568. /**
  43569. * Maximum about of steps between frames (Default: 4)
  43570. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43571. */
  43572. lockstepMaxSteps: number;
  43573. }
  43574. /**
  43575. * The null engine class provides support for headless version of babylon.js.
  43576. * This can be used in server side scenario or for testing purposes
  43577. */
  43578. export class NullEngine extends Engine {
  43579. private _options;
  43580. /**
  43581. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  43582. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43583. * @returns true if engine is in deterministic lock step mode
  43584. */
  43585. isDeterministicLockStep(): boolean;
  43586. /**
  43587. * Gets the max steps when engine is running in deterministic lock step
  43588. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43589. * @returns the max steps
  43590. */
  43591. getLockstepMaxSteps(): number;
  43592. /**
  43593. * Gets the current hardware scaling level.
  43594. * By default the hardware scaling level is computed from the window device ratio.
  43595. * 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.
  43596. * @returns a number indicating the current hardware scaling level
  43597. */
  43598. getHardwareScalingLevel(): number;
  43599. constructor(options?: NullEngineOptions);
  43600. /**
  43601. * Creates a vertex buffer
  43602. * @param vertices the data for the vertex buffer
  43603. * @returns the new WebGL static buffer
  43604. */
  43605. createVertexBuffer(vertices: FloatArray): DataBuffer;
  43606. /**
  43607. * Creates a new index buffer
  43608. * @param indices defines the content of the index buffer
  43609. * @param updatable defines if the index buffer must be updatable
  43610. * @returns a new webGL buffer
  43611. */
  43612. createIndexBuffer(indices: IndicesArray): DataBuffer;
  43613. /**
  43614. * Clear the current render buffer or the current render target (if any is set up)
  43615. * @param color defines the color to use
  43616. * @param backBuffer defines if the back buffer must be cleared
  43617. * @param depth defines if the depth buffer must be cleared
  43618. * @param stencil defines if the stencil buffer must be cleared
  43619. */
  43620. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  43621. /**
  43622. * Gets the current render width
  43623. * @param useScreen defines if screen size must be used (or the current render target if any)
  43624. * @returns a number defining the current render width
  43625. */
  43626. getRenderWidth(useScreen?: boolean): number;
  43627. /**
  43628. * Gets the current render height
  43629. * @param useScreen defines if screen size must be used (or the current render target if any)
  43630. * @returns a number defining the current render height
  43631. */
  43632. getRenderHeight(useScreen?: boolean): number;
  43633. /**
  43634. * Set the WebGL's viewport
  43635. * @param viewport defines the viewport element to be used
  43636. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  43637. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  43638. */
  43639. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  43640. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  43641. /**
  43642. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  43643. * @param pipelineContext defines the pipeline context to use
  43644. * @param uniformsNames defines the list of uniform names
  43645. * @returns an array of webGL uniform locations
  43646. */
  43647. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  43648. /**
  43649. * Gets the lsit of active attributes for a given webGL program
  43650. * @param pipelineContext defines the pipeline context to use
  43651. * @param attributesNames defines the list of attribute names to get
  43652. * @returns an array of indices indicating the offset of each attribute
  43653. */
  43654. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  43655. /**
  43656. * Binds an effect to the webGL context
  43657. * @param effect defines the effect to bind
  43658. */
  43659. bindSamplers(effect: Effect): void;
  43660. /**
  43661. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  43662. * @param effect defines the effect to activate
  43663. */
  43664. enableEffect(effect: Effect): void;
  43665. /**
  43666. * Set various states to the webGL context
  43667. * @param culling defines backface culling state
  43668. * @param zOffset defines the value to apply to zOffset (0 by default)
  43669. * @param force defines if states must be applied even if cache is up to date
  43670. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  43671. */
  43672. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  43673. /**
  43674. * Set the value of an uniform to an array of int32
  43675. * @param uniform defines the webGL uniform location where to store the value
  43676. * @param array defines the array of int32 to store
  43677. */
  43678. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  43679. /**
  43680. * Set the value of an uniform to an array of int32 (stored as vec2)
  43681. * @param uniform defines the webGL uniform location where to store the value
  43682. * @param array defines the array of int32 to store
  43683. */
  43684. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  43685. /**
  43686. * Set the value of an uniform to an array of int32 (stored as vec3)
  43687. * @param uniform defines the webGL uniform location where to store the value
  43688. * @param array defines the array of int32 to store
  43689. */
  43690. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  43691. /**
  43692. * Set the value of an uniform to an array of int32 (stored as vec4)
  43693. * @param uniform defines the webGL uniform location where to store the value
  43694. * @param array defines the array of int32 to store
  43695. */
  43696. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  43697. /**
  43698. * Set the value of an uniform to an array of float32
  43699. * @param uniform defines the webGL uniform location where to store the value
  43700. * @param array defines the array of float32 to store
  43701. */
  43702. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  43703. /**
  43704. * Set the value of an uniform to an array of float32 (stored as vec2)
  43705. * @param uniform defines the webGL uniform location where to store the value
  43706. * @param array defines the array of float32 to store
  43707. */
  43708. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  43709. /**
  43710. * Set the value of an uniform to an array of float32 (stored as vec3)
  43711. * @param uniform defines the webGL uniform location where to store the value
  43712. * @param array defines the array of float32 to store
  43713. */
  43714. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  43715. /**
  43716. * Set the value of an uniform to an array of float32 (stored as vec4)
  43717. * @param uniform defines the webGL uniform location where to store the value
  43718. * @param array defines the array of float32 to store
  43719. */
  43720. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  43721. /**
  43722. * Set the value of an uniform to an array of number
  43723. * @param uniform defines the webGL uniform location where to store the value
  43724. * @param array defines the array of number to store
  43725. */
  43726. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  43727. /**
  43728. * Set the value of an uniform to an array of number (stored as vec2)
  43729. * @param uniform defines the webGL uniform location where to store the value
  43730. * @param array defines the array of number to store
  43731. */
  43732. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  43733. /**
  43734. * Set the value of an uniform to an array of number (stored as vec3)
  43735. * @param uniform defines the webGL uniform location where to store the value
  43736. * @param array defines the array of number to store
  43737. */
  43738. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  43739. /**
  43740. * Set the value of an uniform to an array of number (stored as vec4)
  43741. * @param uniform defines the webGL uniform location where to store the value
  43742. * @param array defines the array of number to store
  43743. */
  43744. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  43745. /**
  43746. * Set the value of an uniform to an array of float32 (stored as matrices)
  43747. * @param uniform defines the webGL uniform location where to store the value
  43748. * @param matrices defines the array of float32 to store
  43749. */
  43750. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  43751. /**
  43752. * Set the value of an uniform to a matrix (3x3)
  43753. * @param uniform defines the webGL uniform location where to store the value
  43754. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  43755. */
  43756. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  43757. /**
  43758. * Set the value of an uniform to a matrix (2x2)
  43759. * @param uniform defines the webGL uniform location where to store the value
  43760. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  43761. */
  43762. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  43763. /**
  43764. * Set the value of an uniform to a number (float)
  43765. * @param uniform defines the webGL uniform location where to store the value
  43766. * @param value defines the float number to store
  43767. */
  43768. setFloat(uniform: WebGLUniformLocation, value: number): void;
  43769. /**
  43770. * Set the value of an uniform to a vec2
  43771. * @param uniform defines the webGL uniform location where to store the value
  43772. * @param x defines the 1st component of the value
  43773. * @param y defines the 2nd component of the value
  43774. */
  43775. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  43776. /**
  43777. * Set the value of an uniform to a vec3
  43778. * @param uniform defines the webGL uniform location where to store the value
  43779. * @param x defines the 1st component of the value
  43780. * @param y defines the 2nd component of the value
  43781. * @param z defines the 3rd component of the value
  43782. */
  43783. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  43784. /**
  43785. * Set the value of an uniform to a boolean
  43786. * @param uniform defines the webGL uniform location where to store the value
  43787. * @param bool defines the boolean to store
  43788. */
  43789. setBool(uniform: WebGLUniformLocation, bool: number): void;
  43790. /**
  43791. * Set the value of an uniform to a vec4
  43792. * @param uniform defines the webGL uniform location where to store the value
  43793. * @param x defines the 1st component of the value
  43794. * @param y defines the 2nd component of the value
  43795. * @param z defines the 3rd component of the value
  43796. * @param w defines the 4th component of the value
  43797. */
  43798. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  43799. /**
  43800. * Sets the current alpha mode
  43801. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  43802. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  43803. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  43804. */
  43805. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  43806. /**
  43807. * Bind webGl buffers directly to the webGL context
  43808. * @param vertexBuffers defines the vertex buffer to bind
  43809. * @param indexBuffer defines the index buffer to bind
  43810. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  43811. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  43812. * @param effect defines the effect associated with the vertex buffer
  43813. */
  43814. bindBuffers(vertexBuffers: {
  43815. [key: string]: VertexBuffer;
  43816. }, indexBuffer: DataBuffer, effect: Effect): void;
  43817. /**
  43818. * Force the entire cache to be cleared
  43819. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  43820. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  43821. */
  43822. wipeCaches(bruteForce?: boolean): void;
  43823. /**
  43824. * Send a draw order
  43825. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  43826. * @param indexStart defines the starting index
  43827. * @param indexCount defines the number of index to draw
  43828. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  43829. */
  43830. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  43831. /**
  43832. * Draw a list of indexed primitives
  43833. * @param fillMode defines the primitive to use
  43834. * @param indexStart defines the starting index
  43835. * @param indexCount defines the number of index to draw
  43836. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  43837. */
  43838. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  43839. /**
  43840. * Draw a list of unindexed primitives
  43841. * @param fillMode defines the primitive to use
  43842. * @param verticesStart defines the index of first vertex to draw
  43843. * @param verticesCount defines the count of vertices to draw
  43844. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  43845. */
  43846. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  43847. /** @hidden */
  43848. _createTexture(): WebGLTexture;
  43849. /** @hidden */
  43850. _releaseTexture(texture: InternalTexture): void;
  43851. /**
  43852. * Usually called from Texture.ts.
  43853. * Passed information to create a WebGLTexture
  43854. * @param urlArg defines a value which contains one of the following:
  43855. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  43856. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  43857. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  43858. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  43859. * @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)
  43860. * @param scene needed for loading to the correct scene
  43861. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  43862. * @param onLoad optional callback to be called upon successful completion
  43863. * @param onError optional callback to be called upon failure
  43864. * @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
  43865. * @param fallBack an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  43866. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  43867. * @param forcedExtension defines the extension to use to pick the right loader
  43868. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  43869. * @returns a InternalTexture for assignment back into BABYLON.Texture
  43870. */
  43871. 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;
  43872. /**
  43873. * Creates a new render target texture
  43874. * @param size defines the size of the texture
  43875. * @param options defines the options used to create the texture
  43876. * @returns a new render target texture stored in an InternalTexture
  43877. */
  43878. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  43879. /**
  43880. * Update the sampling mode of a given texture
  43881. * @param samplingMode defines the required sampling mode
  43882. * @param texture defines the texture to update
  43883. */
  43884. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  43885. /**
  43886. * Binds the frame buffer to the specified texture.
  43887. * @param texture The texture to render to or null for the default canvas
  43888. * @param faceIndex The face of the texture to render to in case of cube texture
  43889. * @param requiredWidth The width of the target to render to
  43890. * @param requiredHeight The height of the target to render to
  43891. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  43892. * @param depthStencilTexture The depth stencil texture to use to render
  43893. * @param lodLevel defines le lod level to bind to the frame buffer
  43894. */
  43895. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  43896. /**
  43897. * Unbind the current render target texture from the webGL context
  43898. * @param texture defines the render target texture to unbind
  43899. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  43900. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  43901. */
  43902. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  43903. /**
  43904. * Creates a dynamic vertex buffer
  43905. * @param vertices the data for the dynamic vertex buffer
  43906. * @returns the new WebGL dynamic buffer
  43907. */
  43908. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  43909. /**
  43910. * Update the content of a dynamic texture
  43911. * @param texture defines the texture to update
  43912. * @param canvas defines the canvas containing the source
  43913. * @param invertY defines if data must be stored with Y axis inverted
  43914. * @param premulAlpha defines if alpha is stored as premultiplied
  43915. * @param format defines the format of the data
  43916. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  43917. */
  43918. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  43919. /**
  43920. * Gets a boolean indicating if all created effects are ready
  43921. * @returns true if all effects are ready
  43922. */
  43923. areAllEffectsReady(): boolean;
  43924. /**
  43925. * @hidden
  43926. * Get the current error code of the webGL context
  43927. * @returns the error code
  43928. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  43929. */
  43930. getError(): number;
  43931. /** @hidden */
  43932. _getUnpackAlignement(): number;
  43933. /** @hidden */
  43934. _unpackFlipY(value: boolean): void;
  43935. /**
  43936. * Update a dynamic index buffer
  43937. * @param indexBuffer defines the target index buffer
  43938. * @param indices defines the data to update
  43939. * @param offset defines the offset in the target index buffer where update should start
  43940. */
  43941. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  43942. /**
  43943. * Updates a dynamic vertex buffer.
  43944. * @param vertexBuffer the vertex buffer to update
  43945. * @param vertices the data used to update the vertex buffer
  43946. * @param byteOffset the byte offset of the data (optional)
  43947. * @param byteLength the byte length of the data (optional)
  43948. */
  43949. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  43950. /** @hidden */
  43951. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  43952. /** @hidden */
  43953. _bindTexture(channel: number, texture: InternalTexture): void;
  43954. protected _deleteBuffer(buffer: WebGLBuffer): void;
  43955. /**
  43956. * 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
  43957. */
  43958. releaseEffects(): void;
  43959. displayLoadingUI(): void;
  43960. hideLoadingUI(): void;
  43961. /** @hidden */
  43962. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  43963. /** @hidden */
  43964. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  43965. /** @hidden */
  43966. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  43967. /** @hidden */
  43968. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  43969. }
  43970. }
  43971. declare module BABYLON {
  43972. /** @hidden */
  43973. export class _OcclusionDataStorage {
  43974. /** @hidden */
  43975. occlusionInternalRetryCounter: number;
  43976. /** @hidden */
  43977. isOcclusionQueryInProgress: boolean;
  43978. /** @hidden */
  43979. isOccluded: boolean;
  43980. /** @hidden */
  43981. occlusionRetryCount: number;
  43982. /** @hidden */
  43983. occlusionType: number;
  43984. /** @hidden */
  43985. occlusionQueryAlgorithmType: number;
  43986. }
  43987. interface Engine {
  43988. /**
  43989. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  43990. * @return the new query
  43991. */
  43992. createQuery(): WebGLQuery;
  43993. /**
  43994. * Delete and release a webGL query
  43995. * @param query defines the query to delete
  43996. * @return the current engine
  43997. */
  43998. deleteQuery(query: WebGLQuery): Engine;
  43999. /**
  44000. * Check if a given query has resolved and got its value
  44001. * @param query defines the query to check
  44002. * @returns true if the query got its value
  44003. */
  44004. isQueryResultAvailable(query: WebGLQuery): boolean;
  44005. /**
  44006. * Gets the value of a given query
  44007. * @param query defines the query to check
  44008. * @returns the value of the query
  44009. */
  44010. getQueryResult(query: WebGLQuery): number;
  44011. /**
  44012. * Initiates an occlusion query
  44013. * @param algorithmType defines the algorithm to use
  44014. * @param query defines the query to use
  44015. * @returns the current engine
  44016. * @see http://doc.babylonjs.com/features/occlusionquery
  44017. */
  44018. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  44019. /**
  44020. * Ends an occlusion query
  44021. * @see http://doc.babylonjs.com/features/occlusionquery
  44022. * @param algorithmType defines the algorithm to use
  44023. * @returns the current engine
  44024. */
  44025. endOcclusionQuery(algorithmType: number): Engine;
  44026. /**
  44027. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  44028. * Please note that only one query can be issued at a time
  44029. * @returns a time token used to track the time span
  44030. */
  44031. startTimeQuery(): Nullable<_TimeToken>;
  44032. /**
  44033. * Ends a time query
  44034. * @param token defines the token used to measure the time span
  44035. * @returns the time spent (in ns)
  44036. */
  44037. endTimeQuery(token: _TimeToken): int;
  44038. /** @hidden */
  44039. _currentNonTimestampToken: Nullable<_TimeToken>;
  44040. /** @hidden */
  44041. _createTimeQuery(): WebGLQuery;
  44042. /** @hidden */
  44043. _deleteTimeQuery(query: WebGLQuery): void;
  44044. /** @hidden */
  44045. _getGlAlgorithmType(algorithmType: number): number;
  44046. /** @hidden */
  44047. _getTimeQueryResult(query: WebGLQuery): any;
  44048. /** @hidden */
  44049. _getTimeQueryAvailability(query: WebGLQuery): any;
  44050. }
  44051. interface AbstractMesh {
  44052. /**
  44053. * Backing filed
  44054. * @hidden
  44055. */
  44056. __occlusionDataStorage: _OcclusionDataStorage;
  44057. /**
  44058. * Access property
  44059. * @hidden
  44060. */
  44061. _occlusionDataStorage: _OcclusionDataStorage;
  44062. /**
  44063. * 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.
  44064. * The default value is -1 which means don't break the query and wait till the result
  44065. * @see http://doc.babylonjs.com/features/occlusionquery
  44066. */
  44067. occlusionRetryCount: number;
  44068. /**
  44069. * 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:
  44070. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  44071. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  44072. * * 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.
  44073. * @see http://doc.babylonjs.com/features/occlusionquery
  44074. */
  44075. occlusionType: number;
  44076. /**
  44077. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  44078. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  44079. * * 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.
  44080. * @see http://doc.babylonjs.com/features/occlusionquery
  44081. */
  44082. occlusionQueryAlgorithmType: number;
  44083. /**
  44084. * 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
  44085. * @see http://doc.babylonjs.com/features/occlusionquery
  44086. */
  44087. isOccluded: boolean;
  44088. /**
  44089. * Flag to check the progress status of the query
  44090. * @see http://doc.babylonjs.com/features/occlusionquery
  44091. */
  44092. isOcclusionQueryInProgress: boolean;
  44093. }
  44094. }
  44095. declare module BABYLON {
  44096. /** @hidden */
  44097. export var _forceTransformFeedbackToBundle: boolean;
  44098. interface Engine {
  44099. /**
  44100. * Creates a webGL transform feedback object
  44101. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  44102. * @returns the webGL transform feedback object
  44103. */
  44104. createTransformFeedback(): WebGLTransformFeedback;
  44105. /**
  44106. * Delete a webGL transform feedback object
  44107. * @param value defines the webGL transform feedback object to delete
  44108. */
  44109. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  44110. /**
  44111. * Bind a webGL transform feedback object to the webgl context
  44112. * @param value defines the webGL transform feedback object to bind
  44113. */
  44114. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  44115. /**
  44116. * Begins a transform feedback operation
  44117. * @param usePoints defines if points or triangles must be used
  44118. */
  44119. beginTransformFeedback(usePoints: boolean): void;
  44120. /**
  44121. * Ends a transform feedback operation
  44122. */
  44123. endTransformFeedback(): void;
  44124. /**
  44125. * Specify the varyings to use with transform feedback
  44126. * @param program defines the associated webGL program
  44127. * @param value defines the list of strings representing the varying names
  44128. */
  44129. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  44130. /**
  44131. * Bind a webGL buffer for a transform feedback operation
  44132. * @param value defines the webGL buffer to bind
  44133. */
  44134. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  44135. }
  44136. }
  44137. declare module BABYLON {
  44138. /**
  44139. * Creation options of the multi render target texture.
  44140. */
  44141. export interface IMultiRenderTargetOptions {
  44142. /**
  44143. * Define if the texture needs to create mip maps after render.
  44144. */
  44145. generateMipMaps?: boolean;
  44146. /**
  44147. * Define the types of all the draw buffers we want to create
  44148. */
  44149. types?: number[];
  44150. /**
  44151. * Define the sampling modes of all the draw buffers we want to create
  44152. */
  44153. samplingModes?: number[];
  44154. /**
  44155. * Define if a depth buffer is required
  44156. */
  44157. generateDepthBuffer?: boolean;
  44158. /**
  44159. * Define if a stencil buffer is required
  44160. */
  44161. generateStencilBuffer?: boolean;
  44162. /**
  44163. * Define if a depth texture is required instead of a depth buffer
  44164. */
  44165. generateDepthTexture?: boolean;
  44166. /**
  44167. * Define the number of desired draw buffers
  44168. */
  44169. textureCount?: number;
  44170. /**
  44171. * Define if aspect ratio should be adapted to the texture or stay the scene one
  44172. */
  44173. doNotChangeAspectRatio?: boolean;
  44174. /**
  44175. * Define the default type of the buffers we are creating
  44176. */
  44177. defaultType?: number;
  44178. }
  44179. /**
  44180. * A multi render target, like a render target provides the ability to render to a texture.
  44181. * Unlike the render target, it can render to several draw buffers in one draw.
  44182. * This is specially interesting in deferred rendering or for any effects requiring more than
  44183. * just one color from a single pass.
  44184. */
  44185. export class MultiRenderTarget extends RenderTargetTexture {
  44186. private _internalTextures;
  44187. private _textures;
  44188. private _multiRenderTargetOptions;
  44189. /**
  44190. * Get if draw buffers are currently supported by the used hardware and browser.
  44191. */
  44192. readonly isSupported: boolean;
  44193. /**
  44194. * Get the list of textures generated by the multi render target.
  44195. */
  44196. readonly textures: Texture[];
  44197. /**
  44198. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  44199. */
  44200. readonly depthTexture: Texture;
  44201. /**
  44202. * Set the wrapping mode on U of all the textures we are rendering to.
  44203. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  44204. */
  44205. wrapU: number;
  44206. /**
  44207. * Set the wrapping mode on V of all the textures we are rendering to.
  44208. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  44209. */
  44210. wrapV: number;
  44211. /**
  44212. * Instantiate a new multi render target texture.
  44213. * A multi render target, like a render target provides the ability to render to a texture.
  44214. * Unlike the render target, it can render to several draw buffers in one draw.
  44215. * This is specially interesting in deferred rendering or for any effects requiring more than
  44216. * just one color from a single pass.
  44217. * @param name Define the name of the texture
  44218. * @param size Define the size of the buffers to render to
  44219. * @param count Define the number of target we are rendering into
  44220. * @param scene Define the scene the texture belongs to
  44221. * @param options Define the options used to create the multi render target
  44222. */
  44223. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  44224. /** @hidden */
  44225. _rebuild(): void;
  44226. private _createInternalTextures;
  44227. private _createTextures;
  44228. /**
  44229. * Define the number of samples used if MSAA is enabled.
  44230. */
  44231. samples: number;
  44232. /**
  44233. * Resize all the textures in the multi render target.
  44234. * Be carrefull as it will recreate all the data in the new texture.
  44235. * @param size Define the new size
  44236. */
  44237. resize(size: any): void;
  44238. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  44239. /**
  44240. * Dispose the render targets and their associated resources
  44241. */
  44242. dispose(): void;
  44243. /**
  44244. * Release all the underlying texture used as draw buffers.
  44245. */
  44246. releaseInternalTextures(): void;
  44247. }
  44248. }
  44249. declare module BABYLON {
  44250. interface ThinEngine {
  44251. /**
  44252. * Unbind a list of render target textures from the webGL context
  44253. * This is used only when drawBuffer extension or webGL2 are active
  44254. * @param textures defines the render target textures to unbind
  44255. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  44256. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  44257. */
  44258. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  44259. /**
  44260. * Create a multi render target texture
  44261. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  44262. * @param size defines the size of the texture
  44263. * @param options defines the creation options
  44264. * @returns the cube texture as an InternalTexture
  44265. */
  44266. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  44267. /**
  44268. * Update the sample count for a given multiple render target texture
  44269. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  44270. * @param textures defines the textures to update
  44271. * @param samples defines the sample count to set
  44272. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  44273. */
  44274. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  44275. }
  44276. }
  44277. declare module BABYLON {
  44278. /**
  44279. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  44280. */
  44281. export interface CubeMapInfo {
  44282. /**
  44283. * The pixel array for the front face.
  44284. * This is stored in format, left to right, up to down format.
  44285. */
  44286. front: Nullable<ArrayBufferView>;
  44287. /**
  44288. * The pixel array for the back face.
  44289. * This is stored in format, left to right, up to down format.
  44290. */
  44291. back: Nullable<ArrayBufferView>;
  44292. /**
  44293. * The pixel array for the left face.
  44294. * This is stored in format, left to right, up to down format.
  44295. */
  44296. left: Nullable<ArrayBufferView>;
  44297. /**
  44298. * The pixel array for the right face.
  44299. * This is stored in format, left to right, up to down format.
  44300. */
  44301. right: Nullable<ArrayBufferView>;
  44302. /**
  44303. * The pixel array for the up face.
  44304. * This is stored in format, left to right, up to down format.
  44305. */
  44306. up: Nullable<ArrayBufferView>;
  44307. /**
  44308. * The pixel array for the down face.
  44309. * This is stored in format, left to right, up to down format.
  44310. */
  44311. down: Nullable<ArrayBufferView>;
  44312. /**
  44313. * The size of the cubemap stored.
  44314. *
  44315. * Each faces will be size * size pixels.
  44316. */
  44317. size: number;
  44318. /**
  44319. * The format of the texture.
  44320. *
  44321. * RGBA, RGB.
  44322. */
  44323. format: number;
  44324. /**
  44325. * The type of the texture data.
  44326. *
  44327. * UNSIGNED_INT, FLOAT.
  44328. */
  44329. type: number;
  44330. /**
  44331. * Specifies whether the texture is in gamma space.
  44332. */
  44333. gammaSpace: boolean;
  44334. }
  44335. /**
  44336. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  44337. */
  44338. export class PanoramaToCubeMapTools {
  44339. private static FACE_FRONT;
  44340. private static FACE_BACK;
  44341. private static FACE_RIGHT;
  44342. private static FACE_LEFT;
  44343. private static FACE_DOWN;
  44344. private static FACE_UP;
  44345. /**
  44346. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  44347. *
  44348. * @param float32Array The source data.
  44349. * @param inputWidth The width of the input panorama.
  44350. * @param inputHeight The height of the input panorama.
  44351. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  44352. * @return The cubemap data
  44353. */
  44354. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  44355. private static CreateCubemapTexture;
  44356. private static CalcProjectionSpherical;
  44357. }
  44358. }
  44359. declare module BABYLON {
  44360. /**
  44361. * Helper class dealing with the extraction of spherical polynomial dataArray
  44362. * from a cube map.
  44363. */
  44364. export class CubeMapToSphericalPolynomialTools {
  44365. private static FileFaces;
  44366. /**
  44367. * Converts a texture to the according Spherical Polynomial data.
  44368. * This extracts the first 3 orders only as they are the only one used in the lighting.
  44369. *
  44370. * @param texture The texture to extract the information from.
  44371. * @return The Spherical Polynomial data.
  44372. */
  44373. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  44374. /**
  44375. * Converts a cubemap to the according Spherical Polynomial data.
  44376. * This extracts the first 3 orders only as they are the only one used in the lighting.
  44377. *
  44378. * @param cubeInfo The Cube map to extract the information from.
  44379. * @return The Spherical Polynomial data.
  44380. */
  44381. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  44382. }
  44383. }
  44384. declare module BABYLON {
  44385. interface BaseTexture {
  44386. /**
  44387. * Get the polynomial representation of the texture data.
  44388. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  44389. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  44390. */
  44391. sphericalPolynomial: Nullable<SphericalPolynomial>;
  44392. }
  44393. }
  44394. declare module BABYLON {
  44395. /** @hidden */
  44396. export var rgbdEncodePixelShader: {
  44397. name: string;
  44398. shader: string;
  44399. };
  44400. }
  44401. declare module BABYLON {
  44402. /** @hidden */
  44403. export var rgbdDecodePixelShader: {
  44404. name: string;
  44405. shader: string;
  44406. };
  44407. }
  44408. declare module BABYLON {
  44409. /**
  44410. * Raw texture data and descriptor sufficient for WebGL texture upload
  44411. */
  44412. export interface EnvironmentTextureInfo {
  44413. /**
  44414. * Version of the environment map
  44415. */
  44416. version: number;
  44417. /**
  44418. * Width of image
  44419. */
  44420. width: number;
  44421. /**
  44422. * Irradiance information stored in the file.
  44423. */
  44424. irradiance: any;
  44425. /**
  44426. * Specular information stored in the file.
  44427. */
  44428. specular: any;
  44429. }
  44430. /**
  44431. * Defines One Image in the file. It requires only the position in the file
  44432. * as well as the length.
  44433. */
  44434. interface BufferImageData {
  44435. /**
  44436. * Length of the image data.
  44437. */
  44438. length: number;
  44439. /**
  44440. * Position of the data from the null terminator delimiting the end of the JSON.
  44441. */
  44442. position: number;
  44443. }
  44444. /**
  44445. * Defines the specular data enclosed in the file.
  44446. * This corresponds to the version 1 of the data.
  44447. */
  44448. export interface EnvironmentTextureSpecularInfoV1 {
  44449. /**
  44450. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  44451. */
  44452. specularDataPosition?: number;
  44453. /**
  44454. * This contains all the images data needed to reconstruct the cubemap.
  44455. */
  44456. mipmaps: Array<BufferImageData>;
  44457. /**
  44458. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  44459. */
  44460. lodGenerationScale: number;
  44461. }
  44462. /**
  44463. * Sets of helpers addressing the serialization and deserialization of environment texture
  44464. * stored in a BabylonJS env file.
  44465. * Those files are usually stored as .env files.
  44466. */
  44467. export class EnvironmentTextureTools {
  44468. /**
  44469. * Magic number identifying the env file.
  44470. */
  44471. private static _MagicBytes;
  44472. /**
  44473. * Gets the environment info from an env file.
  44474. * @param data The array buffer containing the .env bytes.
  44475. * @returns the environment file info (the json header) if successfully parsed.
  44476. */
  44477. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  44478. /**
  44479. * Creates an environment texture from a loaded cube texture.
  44480. * @param texture defines the cube texture to convert in env file
  44481. * @return a promise containing the environment data if succesfull.
  44482. */
  44483. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  44484. /**
  44485. * Creates a JSON representation of the spherical data.
  44486. * @param texture defines the texture containing the polynomials
  44487. * @return the JSON representation of the spherical info
  44488. */
  44489. private static _CreateEnvTextureIrradiance;
  44490. /**
  44491. * Creates the ArrayBufferViews used for initializing environment texture image data.
  44492. * @param arrayBuffer the underlying ArrayBuffer to which the views refer
  44493. * @param info parameters that determine what views will be created for accessing the underlying buffer
  44494. * @return the views described by info providing access to the underlying buffer
  44495. */
  44496. static CreateImageDataArrayBufferViews(arrayBuffer: any, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  44497. /**
  44498. * Uploads the texture info contained in the env file to the GPU.
  44499. * @param texture defines the internal texture to upload to
  44500. * @param arrayBuffer defines the buffer cotaining the data to load
  44501. * @param info defines the texture info retrieved through the GetEnvInfo method
  44502. * @returns a promise
  44503. */
  44504. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  44505. /**
  44506. * Uploads the levels of image data to the GPU.
  44507. * @param texture defines the internal texture to upload to
  44508. * @param imageData defines the array buffer views of image data [mipmap][face]
  44509. * @returns a promise
  44510. */
  44511. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  44512. /**
  44513. * Uploads spherical polynomials information to the texture.
  44514. * @param texture defines the texture we are trying to upload the information to
  44515. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  44516. */
  44517. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  44518. /** @hidden */
  44519. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  44520. }
  44521. }
  44522. declare module BABYLON {
  44523. /**
  44524. * Contains position and normal vectors for a vertex
  44525. */
  44526. export class PositionNormalVertex {
  44527. /** the position of the vertex (defaut: 0,0,0) */
  44528. position: Vector3;
  44529. /** the normal of the vertex (defaut: 0,1,0) */
  44530. normal: Vector3;
  44531. /**
  44532. * Creates a PositionNormalVertex
  44533. * @param position the position of the vertex (defaut: 0,0,0)
  44534. * @param normal the normal of the vertex (defaut: 0,1,0)
  44535. */
  44536. constructor(
  44537. /** the position of the vertex (defaut: 0,0,0) */
  44538. position?: Vector3,
  44539. /** the normal of the vertex (defaut: 0,1,0) */
  44540. normal?: Vector3);
  44541. /**
  44542. * Clones the PositionNormalVertex
  44543. * @returns the cloned PositionNormalVertex
  44544. */
  44545. clone(): PositionNormalVertex;
  44546. }
  44547. /**
  44548. * Contains position, normal and uv vectors for a vertex
  44549. */
  44550. export class PositionNormalTextureVertex {
  44551. /** the position of the vertex (defaut: 0,0,0) */
  44552. position: Vector3;
  44553. /** the normal of the vertex (defaut: 0,1,0) */
  44554. normal: Vector3;
  44555. /** the uv of the vertex (default: 0,0) */
  44556. uv: Vector2;
  44557. /**
  44558. * Creates a PositionNormalTextureVertex
  44559. * @param position the position of the vertex (defaut: 0,0,0)
  44560. * @param normal the normal of the vertex (defaut: 0,1,0)
  44561. * @param uv the uv of the vertex (default: 0,0)
  44562. */
  44563. constructor(
  44564. /** the position of the vertex (defaut: 0,0,0) */
  44565. position?: Vector3,
  44566. /** the normal of the vertex (defaut: 0,1,0) */
  44567. normal?: Vector3,
  44568. /** the uv of the vertex (default: 0,0) */
  44569. uv?: Vector2);
  44570. /**
  44571. * Clones the PositionNormalTextureVertex
  44572. * @returns the cloned PositionNormalTextureVertex
  44573. */
  44574. clone(): PositionNormalTextureVertex;
  44575. }
  44576. }
  44577. declare module BABYLON {
  44578. /** @hidden */
  44579. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  44580. private _genericAttributeLocation;
  44581. private _varyingLocationCount;
  44582. private _varyingLocationMap;
  44583. private _replacements;
  44584. private _textureCount;
  44585. private _uniforms;
  44586. lineProcessor(line: string): string;
  44587. attributeProcessor(attribute: string): string;
  44588. varyingProcessor(varying: string, isFragment: boolean): string;
  44589. uniformProcessor(uniform: string): string;
  44590. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  44591. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  44592. }
  44593. }
  44594. declare module BABYLON {
  44595. /**
  44596. * Container for accessors for natively-stored mesh data buffers.
  44597. */
  44598. class NativeDataBuffer extends DataBuffer {
  44599. /**
  44600. * Accessor value used to identify/retrieve a natively-stored index buffer.
  44601. */
  44602. nativeIndexBuffer?: any;
  44603. /**
  44604. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  44605. */
  44606. nativeVertexBuffer?: any;
  44607. }
  44608. /** @hidden */
  44609. export class NativeEngine extends Engine {
  44610. private readonly _native;
  44611. getHardwareScalingLevel(): number;
  44612. constructor();
  44613. /**
  44614. * Can be used to override the current requestAnimationFrame requester.
  44615. * @hidden
  44616. */
  44617. protected _queueNewFrame(bindedRenderFunction: any, requester: any): number;
  44618. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  44619. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  44620. createVertexBuffer(data: DataArray): NativeDataBuffer;
  44621. recordVertexArrayObject(vertexBuffers: {
  44622. [key: string]: VertexBuffer;
  44623. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  44624. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  44625. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  44626. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  44627. /**
  44628. * Draw a list of indexed primitives
  44629. * @param fillMode defines the primitive to use
  44630. * @param indexStart defines the starting index
  44631. * @param indexCount defines the number of index to draw
  44632. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  44633. */
  44634. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  44635. /**
  44636. * Draw a list of unindexed primitives
  44637. * @param fillMode defines the primitive to use
  44638. * @param verticesStart defines the index of first vertex to draw
  44639. * @param verticesCount defines the count of vertices to draw
  44640. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  44641. */
  44642. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  44643. createPipelineContext(): IPipelineContext;
  44644. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  44645. /** @hidden */
  44646. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  44647. /** @hidden */
  44648. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  44649. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  44650. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  44651. protected _setProgram(program: WebGLProgram): void;
  44652. _releaseEffect(effect: Effect): void;
  44653. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  44654. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  44655. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  44656. bindSamplers(effect: Effect): void;
  44657. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  44658. getRenderWidth(useScreen?: boolean): number;
  44659. getRenderHeight(useScreen?: boolean): number;
  44660. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  44661. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  44662. /**
  44663. * Set the z offset to apply to current rendering
  44664. * @param value defines the offset to apply
  44665. */
  44666. setZOffset(value: number): void;
  44667. /**
  44668. * Gets the current value of the zOffset
  44669. * @returns the current zOffset state
  44670. */
  44671. getZOffset(): number;
  44672. /**
  44673. * Enable or disable depth buffering
  44674. * @param enable defines the state to set
  44675. */
  44676. setDepthBuffer(enable: boolean): void;
  44677. /**
  44678. * Gets a boolean indicating if depth writing is enabled
  44679. * @returns the current depth writing state
  44680. */
  44681. getDepthWrite(): boolean;
  44682. /**
  44683. * Enable or disable depth writing
  44684. * @param enable defines the state to set
  44685. */
  44686. setDepthWrite(enable: boolean): void;
  44687. /**
  44688. * Enable or disable color writing
  44689. * @param enable defines the state to set
  44690. */
  44691. setColorWrite(enable: boolean): void;
  44692. /**
  44693. * Gets a boolean indicating if color writing is enabled
  44694. * @returns the current color writing state
  44695. */
  44696. getColorWrite(): boolean;
  44697. /**
  44698. * Sets alpha constants used by some alpha blending modes
  44699. * @param r defines the red component
  44700. * @param g defines the green component
  44701. * @param b defines the blue component
  44702. * @param a defines the alpha component
  44703. */
  44704. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  44705. /**
  44706. * Sets the current alpha mode
  44707. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  44708. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  44709. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  44710. */
  44711. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  44712. /**
  44713. * Gets the current alpha mode
  44714. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  44715. * @returns the current alpha mode
  44716. */
  44717. getAlphaMode(): number;
  44718. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  44719. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  44720. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  44721. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  44722. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  44723. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  44724. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  44725. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  44726. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  44727. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  44728. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  44729. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  44730. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  44731. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  44732. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  44733. setFloat(uniform: WebGLUniformLocation, value: number): void;
  44734. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  44735. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  44736. setBool(uniform: WebGLUniformLocation, bool: number): void;
  44737. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  44738. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  44739. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  44740. wipeCaches(bruteForce?: boolean): void;
  44741. _createTexture(): WebGLTexture;
  44742. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  44743. /**
  44744. * Usually called from BABYLON.Texture.ts.
  44745. * Passed information to create a WebGLTexture
  44746. * @param urlArg defines a value which contains one of the following:
  44747. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  44748. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  44749. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  44750. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  44751. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  44752. * @param scene needed for loading to the correct scene
  44753. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  44754. * @param onLoad optional callback to be called upon successful completion
  44755. * @param onError optional callback to be called upon failure
  44756. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), or a Blob
  44757. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  44758. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  44759. * @param forcedExtension defines the extension to use to pick the right loader
  44760. * @returns a InternalTexture for assignment back into BABYLON.Texture
  44761. */
  44762. createTexture(urlArg: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<Scene>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | Blob>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>): InternalTexture;
  44763. /**
  44764. * Creates a cube texture
  44765. * @param rootUrl defines the url where the files to load is located
  44766. * @param scene defines the current scene
  44767. * @param files defines the list of files to load (1 per face)
  44768. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  44769. * @param onLoad defines an optional callback raised when the texture is loaded
  44770. * @param onError defines an optional callback raised if there is an issue to load the texture
  44771. * @param format defines the format of the data
  44772. * @param forcedExtension defines the extension to use to pick the right loader
  44773. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  44774. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  44775. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  44776. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  44777. * @returns the cube texture as an InternalTexture
  44778. */
  44779. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap?: boolean, onLoad?: Nullable<(data?: any) => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, forcedExtension?: any, createPolynomials?: boolean, lodScale?: number, lodOffset?: number, fallback?: Nullable<InternalTexture>): InternalTexture;
  44780. private _getSamplingFilter;
  44781. private static _GetNativeTextureFormat;
  44782. createRenderTargetTexture(size: number | {
  44783. width: number;
  44784. height: number;
  44785. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  44786. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  44787. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  44788. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  44789. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  44790. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  44791. /**
  44792. * Updates a dynamic vertex buffer.
  44793. * @param vertexBuffer the vertex buffer to update
  44794. * @param data the data used to update the vertex buffer
  44795. * @param byteOffset the byte offset of the data (optional)
  44796. * @param byteLength the byte length of the data (optional)
  44797. */
  44798. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  44799. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  44800. private _updateAnisotropicLevel;
  44801. private _getAddressMode;
  44802. /** @hidden */
  44803. _bindTexture(channel: number, texture: InternalTexture): void;
  44804. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  44805. releaseEffects(): void;
  44806. /** @hidden */
  44807. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  44808. /** @hidden */
  44809. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  44810. /** @hidden */
  44811. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  44812. /** @hidden */
  44813. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  44814. }
  44815. }
  44816. declare module BABYLON {
  44817. /**
  44818. * Gather the list of clipboard event types as constants.
  44819. */
  44820. export class ClipboardEventTypes {
  44821. /**
  44822. * The clipboard event is fired when a copy command is active (pressed).
  44823. */
  44824. static readonly COPY: number;
  44825. /**
  44826. * The clipboard event is fired when a cut command is active (pressed).
  44827. */
  44828. static readonly CUT: number;
  44829. /**
  44830. * The clipboard event is fired when a paste command is active (pressed).
  44831. */
  44832. static readonly PASTE: number;
  44833. }
  44834. /**
  44835. * This class is used to store clipboard related info for the onClipboardObservable event.
  44836. */
  44837. export class ClipboardInfo {
  44838. /**
  44839. * Defines the type of event (BABYLON.ClipboardEventTypes)
  44840. */
  44841. type: number;
  44842. /**
  44843. * Defines the related dom event
  44844. */
  44845. event: ClipboardEvent;
  44846. /**
  44847. *Creates an instance of ClipboardInfo.
  44848. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  44849. * @param event Defines the related dom event
  44850. */
  44851. constructor(
  44852. /**
  44853. * Defines the type of event (BABYLON.ClipboardEventTypes)
  44854. */
  44855. type: number,
  44856. /**
  44857. * Defines the related dom event
  44858. */
  44859. event: ClipboardEvent);
  44860. /**
  44861. * Get the clipboard event's type from the keycode.
  44862. * @param keyCode Defines the keyCode for the current keyboard event.
  44863. * @return {number}
  44864. */
  44865. static GetTypeFromCharacter(keyCode: number): number;
  44866. }
  44867. }
  44868. declare module BABYLON {
  44869. /**
  44870. * Google Daydream controller
  44871. */
  44872. export class DaydreamController extends WebVRController {
  44873. /**
  44874. * Base Url for the controller model.
  44875. */
  44876. static MODEL_BASE_URL: string;
  44877. /**
  44878. * File name for the controller model.
  44879. */
  44880. static MODEL_FILENAME: string;
  44881. /**
  44882. * Gamepad Id prefix used to identify Daydream Controller.
  44883. */
  44884. static readonly GAMEPAD_ID_PREFIX: string;
  44885. /**
  44886. * Creates a new DaydreamController from a gamepad
  44887. * @param vrGamepad the gamepad that the controller should be created from
  44888. */
  44889. constructor(vrGamepad: any);
  44890. /**
  44891. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44892. * @param scene scene in which to add meshes
  44893. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44894. */
  44895. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44896. /**
  44897. * Called once for each button that changed state since the last frame
  44898. * @param buttonIdx Which button index changed
  44899. * @param state New state of the button
  44900. * @param changes Which properties on the state changed since last frame
  44901. */
  44902. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44903. }
  44904. }
  44905. declare module BABYLON {
  44906. /**
  44907. * Gear VR Controller
  44908. */
  44909. export class GearVRController extends WebVRController {
  44910. /**
  44911. * Base Url for the controller model.
  44912. */
  44913. static MODEL_BASE_URL: string;
  44914. /**
  44915. * File name for the controller model.
  44916. */
  44917. static MODEL_FILENAME: string;
  44918. /**
  44919. * Gamepad Id prefix used to identify this controller.
  44920. */
  44921. static readonly GAMEPAD_ID_PREFIX: string;
  44922. private readonly _buttonIndexToObservableNameMap;
  44923. /**
  44924. * Creates a new GearVRController from a gamepad
  44925. * @param vrGamepad the gamepad that the controller should be created from
  44926. */
  44927. constructor(vrGamepad: any);
  44928. /**
  44929. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44930. * @param scene scene in which to add meshes
  44931. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44932. */
  44933. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44934. /**
  44935. * Called once for each button that changed state since the last frame
  44936. * @param buttonIdx Which button index changed
  44937. * @param state New state of the button
  44938. * @param changes Which properties on the state changed since last frame
  44939. */
  44940. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44941. }
  44942. }
  44943. declare module BABYLON {
  44944. /**
  44945. * Class containing static functions to help procedurally build meshes
  44946. */
  44947. export class PolyhedronBuilder {
  44948. /**
  44949. * Creates a polyhedron mesh
  44950. * * 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
  44951. * * The parameter `size` (positive float, default 1) sets the polygon size
  44952. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  44953. * * 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`
  44954. * * 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
  44955. * * 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)`)
  44956. * * 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
  44957. * * 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
  44958. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44959. * * 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
  44960. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44961. * @param name defines the name of the mesh
  44962. * @param options defines the options used to create the mesh
  44963. * @param scene defines the hosting scene
  44964. * @returns the polyhedron mesh
  44965. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  44966. */
  44967. static CreatePolyhedron(name: string, options: {
  44968. type?: number;
  44969. size?: number;
  44970. sizeX?: number;
  44971. sizeY?: number;
  44972. sizeZ?: number;
  44973. custom?: any;
  44974. faceUV?: Vector4[];
  44975. faceColors?: Color4[];
  44976. flat?: boolean;
  44977. updatable?: boolean;
  44978. sideOrientation?: number;
  44979. frontUVs?: Vector4;
  44980. backUVs?: Vector4;
  44981. }, scene?: Nullable<Scene>): Mesh;
  44982. }
  44983. }
  44984. declare module BABYLON {
  44985. /**
  44986. * Gizmo that enables scaling a mesh along 3 axis
  44987. */
  44988. export class ScaleGizmo extends Gizmo {
  44989. /**
  44990. * Internal gizmo used for interactions on the x axis
  44991. */
  44992. xGizmo: AxisScaleGizmo;
  44993. /**
  44994. * Internal gizmo used for interactions on the y axis
  44995. */
  44996. yGizmo: AxisScaleGizmo;
  44997. /**
  44998. * Internal gizmo used for interactions on the z axis
  44999. */
  45000. zGizmo: AxisScaleGizmo;
  45001. /**
  45002. * Internal gizmo used to scale all axis equally
  45003. */
  45004. uniformScaleGizmo: AxisScaleGizmo;
  45005. private _meshAttached;
  45006. private _updateGizmoRotationToMatchAttachedMesh;
  45007. private _snapDistance;
  45008. private _scaleRatio;
  45009. private _uniformScalingMesh;
  45010. private _octahedron;
  45011. /** Fires an event when any of it's sub gizmos are dragged */
  45012. onDragStartObservable: Observable<unknown>;
  45013. /** Fires an event when any of it's sub gizmos are released from dragging */
  45014. onDragEndObservable: Observable<unknown>;
  45015. attachedMesh: Nullable<AbstractMesh>;
  45016. /**
  45017. * Creates a ScaleGizmo
  45018. * @param gizmoLayer The utility layer the gizmo will be added to
  45019. */
  45020. constructor(gizmoLayer?: UtilityLayerRenderer);
  45021. updateGizmoRotationToMatchAttachedMesh: boolean;
  45022. /**
  45023. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  45024. */
  45025. snapDistance: number;
  45026. /**
  45027. * Ratio for the scale of the gizmo (Default: 1)
  45028. */
  45029. scaleRatio: number;
  45030. /**
  45031. * Disposes of the gizmo
  45032. */
  45033. dispose(): void;
  45034. }
  45035. }
  45036. declare module BABYLON {
  45037. /**
  45038. * Single axis scale gizmo
  45039. */
  45040. export class AxisScaleGizmo extends Gizmo {
  45041. /**
  45042. * Drag behavior responsible for the gizmos dragging interactions
  45043. */
  45044. dragBehavior: PointerDragBehavior;
  45045. private _pointerObserver;
  45046. /**
  45047. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  45048. */
  45049. snapDistance: number;
  45050. /**
  45051. * Event that fires each time the gizmo snaps to a new location.
  45052. * * snapDistance is the the change in distance
  45053. */
  45054. onSnapObservable: Observable<{
  45055. snapDistance: number;
  45056. }>;
  45057. /**
  45058. * If the scaling operation should be done on all axis (default: false)
  45059. */
  45060. uniformScaling: boolean;
  45061. private _isEnabled;
  45062. private _parent;
  45063. private _arrow;
  45064. private _coloredMaterial;
  45065. private _hoverMaterial;
  45066. /**
  45067. * Creates an AxisScaleGizmo
  45068. * @param gizmoLayer The utility layer the gizmo will be added to
  45069. * @param dragAxis The axis which the gizmo will be able to scale on
  45070. * @param color The color of the gizmo
  45071. */
  45072. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  45073. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45074. /**
  45075. * If the gizmo is enabled
  45076. */
  45077. isEnabled: boolean;
  45078. /**
  45079. * Disposes of the gizmo
  45080. */
  45081. dispose(): void;
  45082. /**
  45083. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  45084. * @param mesh The mesh to replace the default mesh of the gizmo
  45085. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  45086. */
  45087. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  45088. }
  45089. }
  45090. declare module BABYLON {
  45091. /**
  45092. * Bounding box gizmo
  45093. */
  45094. export class BoundingBoxGizmo extends Gizmo {
  45095. private _lineBoundingBox;
  45096. private _rotateSpheresParent;
  45097. private _scaleBoxesParent;
  45098. private _boundingDimensions;
  45099. private _renderObserver;
  45100. private _pointerObserver;
  45101. private _scaleDragSpeed;
  45102. private _tmpQuaternion;
  45103. private _tmpVector;
  45104. private _tmpRotationMatrix;
  45105. /**
  45106. * 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)
  45107. */
  45108. ignoreChildren: boolean;
  45109. /**
  45110. * 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)
  45111. */
  45112. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  45113. /**
  45114. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  45115. */
  45116. rotationSphereSize: number;
  45117. /**
  45118. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  45119. */
  45120. scaleBoxSize: number;
  45121. /**
  45122. * 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)
  45123. */
  45124. fixedDragMeshScreenSize: boolean;
  45125. /**
  45126. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  45127. */
  45128. fixedDragMeshScreenSizeDistanceFactor: number;
  45129. /**
  45130. * Fired when a rotation sphere or scale box is dragged
  45131. */
  45132. onDragStartObservable: Observable<{}>;
  45133. /**
  45134. * Fired when a scale box is dragged
  45135. */
  45136. onScaleBoxDragObservable: Observable<{}>;
  45137. /**
  45138. * Fired when a scale box drag is ended
  45139. */
  45140. onScaleBoxDragEndObservable: Observable<{}>;
  45141. /**
  45142. * Fired when a rotation sphere is dragged
  45143. */
  45144. onRotationSphereDragObservable: Observable<{}>;
  45145. /**
  45146. * Fired when a rotation sphere drag is ended
  45147. */
  45148. onRotationSphereDragEndObservable: Observable<{}>;
  45149. /**
  45150. * 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)
  45151. */
  45152. scalePivot: Nullable<Vector3>;
  45153. /**
  45154. * Mesh used as a pivot to rotate the attached mesh
  45155. */
  45156. private _anchorMesh;
  45157. private _existingMeshScale;
  45158. private _dragMesh;
  45159. private pointerDragBehavior;
  45160. private coloredMaterial;
  45161. private hoverColoredMaterial;
  45162. /**
  45163. * Sets the color of the bounding box gizmo
  45164. * @param color the color to set
  45165. */
  45166. setColor(color: Color3): void;
  45167. /**
  45168. * Creates an BoundingBoxGizmo
  45169. * @param gizmoLayer The utility layer the gizmo will be added to
  45170. * @param color The color of the gizmo
  45171. */
  45172. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  45173. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45174. private _selectNode;
  45175. /**
  45176. * Updates the bounding box information for the Gizmo
  45177. */
  45178. updateBoundingBox(): void;
  45179. private _updateRotationSpheres;
  45180. private _updateScaleBoxes;
  45181. /**
  45182. * Enables rotation on the specified axis and disables rotation on the others
  45183. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  45184. */
  45185. setEnabledRotationAxis(axis: string): void;
  45186. /**
  45187. * Enables/disables scaling
  45188. * @param enable if scaling should be enabled
  45189. */
  45190. setEnabledScaling(enable: boolean): void;
  45191. private _updateDummy;
  45192. /**
  45193. * Enables a pointer drag behavior on the bounding box of the gizmo
  45194. */
  45195. enableDragBehavior(): void;
  45196. /**
  45197. * Disposes of the gizmo
  45198. */
  45199. dispose(): void;
  45200. /**
  45201. * 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)
  45202. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  45203. * @returns the bounding box mesh with the passed in mesh as a child
  45204. */
  45205. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  45206. /**
  45207. * CustomMeshes are not supported by this gizmo
  45208. * @param mesh The mesh to replace the default mesh of the gizmo
  45209. */
  45210. setCustomMesh(mesh: Mesh): void;
  45211. }
  45212. }
  45213. declare module BABYLON {
  45214. /**
  45215. * Single plane rotation gizmo
  45216. */
  45217. export class PlaneRotationGizmo extends Gizmo {
  45218. /**
  45219. * Drag behavior responsible for the gizmos dragging interactions
  45220. */
  45221. dragBehavior: PointerDragBehavior;
  45222. private _pointerObserver;
  45223. /**
  45224. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  45225. */
  45226. snapDistance: number;
  45227. /**
  45228. * Event that fires each time the gizmo snaps to a new location.
  45229. * * snapDistance is the the change in distance
  45230. */
  45231. onSnapObservable: Observable<{
  45232. snapDistance: number;
  45233. }>;
  45234. private _isEnabled;
  45235. private _parent;
  45236. /**
  45237. * Creates a PlaneRotationGizmo
  45238. * @param gizmoLayer The utility layer the gizmo will be added to
  45239. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  45240. * @param color The color of the gizmo
  45241. * @param tessellation Amount of tessellation to be used when creating rotation circles
  45242. * @param useEulerRotation Use and update Euler angle instead of quaternion
  45243. */
  45244. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  45245. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45246. /**
  45247. * If the gizmo is enabled
  45248. */
  45249. isEnabled: boolean;
  45250. /**
  45251. * Disposes of the gizmo
  45252. */
  45253. dispose(): void;
  45254. }
  45255. }
  45256. declare module BABYLON {
  45257. /**
  45258. * Gizmo that enables rotating a mesh along 3 axis
  45259. */
  45260. export class RotationGizmo extends Gizmo {
  45261. /**
  45262. * Internal gizmo used for interactions on the x axis
  45263. */
  45264. xGizmo: PlaneRotationGizmo;
  45265. /**
  45266. * Internal gizmo used for interactions on the y axis
  45267. */
  45268. yGizmo: PlaneRotationGizmo;
  45269. /**
  45270. * Internal gizmo used for interactions on the z axis
  45271. */
  45272. zGizmo: PlaneRotationGizmo;
  45273. /** Fires an event when any of it's sub gizmos are dragged */
  45274. onDragStartObservable: Observable<unknown>;
  45275. /** Fires an event when any of it's sub gizmos are released from dragging */
  45276. onDragEndObservable: Observable<unknown>;
  45277. private _meshAttached;
  45278. attachedMesh: Nullable<AbstractMesh>;
  45279. /**
  45280. * Creates a RotationGizmo
  45281. * @param gizmoLayer The utility layer the gizmo will be added to
  45282. * @param tessellation Amount of tessellation to be used when creating rotation circles
  45283. * @param useEulerRotation Use and update Euler angle instead of quaternion
  45284. */
  45285. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  45286. updateGizmoRotationToMatchAttachedMesh: boolean;
  45287. /**
  45288. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  45289. */
  45290. snapDistance: number;
  45291. /**
  45292. * Ratio for the scale of the gizmo (Default: 1)
  45293. */
  45294. scaleRatio: number;
  45295. /**
  45296. * Disposes of the gizmo
  45297. */
  45298. dispose(): void;
  45299. /**
  45300. * CustomMeshes are not supported by this gizmo
  45301. * @param mesh The mesh to replace the default mesh of the gizmo
  45302. */
  45303. setCustomMesh(mesh: Mesh): void;
  45304. }
  45305. }
  45306. declare module BABYLON {
  45307. /**
  45308. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  45309. */
  45310. export class GizmoManager implements IDisposable {
  45311. private scene;
  45312. /**
  45313. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  45314. */
  45315. gizmos: {
  45316. positionGizmo: Nullable<PositionGizmo>;
  45317. rotationGizmo: Nullable<RotationGizmo>;
  45318. scaleGizmo: Nullable<ScaleGizmo>;
  45319. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  45320. };
  45321. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  45322. clearGizmoOnEmptyPointerEvent: boolean;
  45323. /** Fires an event when the manager is attached to a mesh */
  45324. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  45325. private _gizmosEnabled;
  45326. private _pointerObserver;
  45327. private _attachedMesh;
  45328. private _boundingBoxColor;
  45329. private _defaultUtilityLayer;
  45330. private _defaultKeepDepthUtilityLayer;
  45331. /**
  45332. * When bounding box gizmo is enabled, this can be used to track drag/end events
  45333. */
  45334. boundingBoxDragBehavior: SixDofDragBehavior;
  45335. /**
  45336. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  45337. */
  45338. attachableMeshes: Nullable<Array<AbstractMesh>>;
  45339. /**
  45340. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  45341. */
  45342. usePointerToAttachGizmos: boolean;
  45343. /**
  45344. * Utility layer that the bounding box gizmo belongs to
  45345. */
  45346. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  45347. /**
  45348. * Utility layer that all gizmos besides bounding box belong to
  45349. */
  45350. readonly utilityLayer: UtilityLayerRenderer;
  45351. /**
  45352. * Instatiates a gizmo manager
  45353. * @param scene the scene to overlay the gizmos on top of
  45354. */
  45355. constructor(scene: Scene);
  45356. /**
  45357. * Attaches a set of gizmos to the specified mesh
  45358. * @param mesh The mesh the gizmo's should be attached to
  45359. */
  45360. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  45361. /**
  45362. * If the position gizmo is enabled
  45363. */
  45364. positionGizmoEnabled: boolean;
  45365. /**
  45366. * If the rotation gizmo is enabled
  45367. */
  45368. rotationGizmoEnabled: boolean;
  45369. /**
  45370. * If the scale gizmo is enabled
  45371. */
  45372. scaleGizmoEnabled: boolean;
  45373. /**
  45374. * If the boundingBox gizmo is enabled
  45375. */
  45376. boundingBoxGizmoEnabled: boolean;
  45377. /**
  45378. * Disposes of the gizmo manager
  45379. */
  45380. dispose(): void;
  45381. }
  45382. }
  45383. declare module BABYLON {
  45384. /**
  45385. * A directional light is defined by a direction (what a surprise!).
  45386. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  45387. * 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.
  45388. * Documentation: https://doc.babylonjs.com/babylon101/lights
  45389. */
  45390. export class DirectionalLight extends ShadowLight {
  45391. private _shadowFrustumSize;
  45392. /**
  45393. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  45394. */
  45395. /**
  45396. * Specifies a fix frustum size for the shadow generation.
  45397. */
  45398. shadowFrustumSize: number;
  45399. private _shadowOrthoScale;
  45400. /**
  45401. * Gets the shadow projection scale against the optimal computed one.
  45402. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  45403. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  45404. */
  45405. /**
  45406. * Sets the shadow projection scale against the optimal computed one.
  45407. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  45408. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  45409. */
  45410. shadowOrthoScale: number;
  45411. /**
  45412. * Automatically compute the projection matrix to best fit (including all the casters)
  45413. * on each frame.
  45414. */
  45415. autoUpdateExtends: boolean;
  45416. private _orthoLeft;
  45417. private _orthoRight;
  45418. private _orthoTop;
  45419. private _orthoBottom;
  45420. /**
  45421. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  45422. * The directional light is emitted from everywhere in the given direction.
  45423. * It can cast shadows.
  45424. * Documentation : https://doc.babylonjs.com/babylon101/lights
  45425. * @param name The friendly name of the light
  45426. * @param direction The direction of the light
  45427. * @param scene The scene the light belongs to
  45428. */
  45429. constructor(name: string, direction: Vector3, scene: Scene);
  45430. /**
  45431. * Returns the string "DirectionalLight".
  45432. * @return The class name
  45433. */
  45434. getClassName(): string;
  45435. /**
  45436. * Returns the integer 1.
  45437. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  45438. */
  45439. getTypeID(): number;
  45440. /**
  45441. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  45442. * Returns the DirectionalLight Shadow projection matrix.
  45443. */
  45444. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  45445. /**
  45446. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  45447. * Returns the DirectionalLight Shadow projection matrix.
  45448. */
  45449. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  45450. /**
  45451. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  45452. * Returns the DirectionalLight Shadow projection matrix.
  45453. */
  45454. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  45455. protected _buildUniformLayout(): void;
  45456. /**
  45457. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  45458. * @param effect The effect to update
  45459. * @param lightIndex The index of the light in the effect to update
  45460. * @returns The directional light
  45461. */
  45462. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  45463. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  45464. /**
  45465. * Gets the minZ used for shadow according to both the scene and the light.
  45466. *
  45467. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  45468. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  45469. * @param activeCamera The camera we are returning the min for
  45470. * @returns the depth min z
  45471. */
  45472. getDepthMinZ(activeCamera: Camera): number;
  45473. /**
  45474. * Gets the maxZ used for shadow according to both the scene and the light.
  45475. *
  45476. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  45477. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  45478. * @param activeCamera The camera we are returning the max for
  45479. * @returns the depth max z
  45480. */
  45481. getDepthMaxZ(activeCamera: Camera): number;
  45482. /**
  45483. * Prepares the list of defines specific to the light type.
  45484. * @param defines the list of defines
  45485. * @param lightIndex defines the index of the light for the effect
  45486. */
  45487. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  45488. }
  45489. }
  45490. declare module BABYLON {
  45491. /**
  45492. * Class containing static functions to help procedurally build meshes
  45493. */
  45494. export class HemisphereBuilder {
  45495. /**
  45496. * Creates a hemisphere mesh
  45497. * @param name defines the name of the mesh
  45498. * @param options defines the options used to create the mesh
  45499. * @param scene defines the hosting scene
  45500. * @returns the hemisphere mesh
  45501. */
  45502. static CreateHemisphere(name: string, options: {
  45503. segments?: number;
  45504. diameter?: number;
  45505. sideOrientation?: number;
  45506. }, scene: any): Mesh;
  45507. }
  45508. }
  45509. declare module BABYLON {
  45510. /**
  45511. * A spot light is defined by a position, a direction, an angle, and an exponent.
  45512. * These values define a cone of light starting from the position, emitting toward the direction.
  45513. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  45514. * and the exponent defines the speed of the decay of the light with distance (reach).
  45515. * Documentation: https://doc.babylonjs.com/babylon101/lights
  45516. */
  45517. export class SpotLight extends ShadowLight {
  45518. private _angle;
  45519. private _innerAngle;
  45520. private _cosHalfAngle;
  45521. private _lightAngleScale;
  45522. private _lightAngleOffset;
  45523. /**
  45524. * Gets the cone angle of the spot light in Radians.
  45525. */
  45526. /**
  45527. * Sets the cone angle of the spot light in Radians.
  45528. */
  45529. angle: number;
  45530. /**
  45531. * Only used in gltf falloff mode, this defines the angle where
  45532. * the directional falloff will start before cutting at angle which could be seen
  45533. * as outer angle.
  45534. */
  45535. /**
  45536. * Only used in gltf falloff mode, this defines the angle where
  45537. * the directional falloff will start before cutting at angle which could be seen
  45538. * as outer angle.
  45539. */
  45540. innerAngle: number;
  45541. private _shadowAngleScale;
  45542. /**
  45543. * Allows scaling the angle of the light for shadow generation only.
  45544. */
  45545. /**
  45546. * Allows scaling the angle of the light for shadow generation only.
  45547. */
  45548. shadowAngleScale: number;
  45549. /**
  45550. * The light decay speed with the distance from the emission spot.
  45551. */
  45552. exponent: number;
  45553. private _projectionTextureMatrix;
  45554. /**
  45555. * Allows reading the projecton texture
  45556. */
  45557. readonly projectionTextureMatrix: Matrix;
  45558. protected _projectionTextureLightNear: number;
  45559. /**
  45560. * Gets the near clip of the Spotlight for texture projection.
  45561. */
  45562. /**
  45563. * Sets the near clip of the Spotlight for texture projection.
  45564. */
  45565. projectionTextureLightNear: number;
  45566. protected _projectionTextureLightFar: number;
  45567. /**
  45568. * Gets the far clip of the Spotlight for texture projection.
  45569. */
  45570. /**
  45571. * Sets the far clip of the Spotlight for texture projection.
  45572. */
  45573. projectionTextureLightFar: number;
  45574. protected _projectionTextureUpDirection: Vector3;
  45575. /**
  45576. * Gets the Up vector of the Spotlight for texture projection.
  45577. */
  45578. /**
  45579. * Sets the Up vector of the Spotlight for texture projection.
  45580. */
  45581. projectionTextureUpDirection: Vector3;
  45582. private _projectionTexture;
  45583. /**
  45584. * Gets the projection texture of the light.
  45585. */
  45586. /**
  45587. * Sets the projection texture of the light.
  45588. */
  45589. projectionTexture: Nullable<BaseTexture>;
  45590. private _projectionTextureViewLightDirty;
  45591. private _projectionTextureProjectionLightDirty;
  45592. private _projectionTextureDirty;
  45593. private _projectionTextureViewTargetVector;
  45594. private _projectionTextureViewLightMatrix;
  45595. private _projectionTextureProjectionLightMatrix;
  45596. private _projectionTextureScalingMatrix;
  45597. /**
  45598. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  45599. * It can cast shadows.
  45600. * Documentation : https://doc.babylonjs.com/babylon101/lights
  45601. * @param name The light friendly name
  45602. * @param position The position of the spot light in the scene
  45603. * @param direction The direction of the light in the scene
  45604. * @param angle The cone angle of the light in Radians
  45605. * @param exponent The light decay speed with the distance from the emission spot
  45606. * @param scene The scene the lights belongs to
  45607. */
  45608. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  45609. /**
  45610. * Returns the string "SpotLight".
  45611. * @returns the class name
  45612. */
  45613. getClassName(): string;
  45614. /**
  45615. * Returns the integer 2.
  45616. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  45617. */
  45618. getTypeID(): number;
  45619. /**
  45620. * Overrides the direction setter to recompute the projection texture view light Matrix.
  45621. */
  45622. protected _setDirection(value: Vector3): void;
  45623. /**
  45624. * Overrides the position setter to recompute the projection texture view light Matrix.
  45625. */
  45626. protected _setPosition(value: Vector3): void;
  45627. /**
  45628. * 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.
  45629. * Returns the SpotLight.
  45630. */
  45631. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  45632. protected _computeProjectionTextureViewLightMatrix(): void;
  45633. protected _computeProjectionTextureProjectionLightMatrix(): void;
  45634. /**
  45635. * Main function for light texture projection matrix computing.
  45636. */
  45637. protected _computeProjectionTextureMatrix(): void;
  45638. protected _buildUniformLayout(): void;
  45639. private _computeAngleValues;
  45640. /**
  45641. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  45642. * @param effect The effect to update
  45643. * @param lightIndex The index of the light in the effect to update
  45644. * @returns The spot light
  45645. */
  45646. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  45647. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  45648. /**
  45649. * Disposes the light and the associated resources.
  45650. */
  45651. dispose(): void;
  45652. /**
  45653. * Prepares the list of defines specific to the light type.
  45654. * @param defines the list of defines
  45655. * @param lightIndex defines the index of the light for the effect
  45656. */
  45657. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  45658. }
  45659. }
  45660. declare module BABYLON {
  45661. /**
  45662. * Gizmo that enables viewing a light
  45663. */
  45664. export class LightGizmo extends Gizmo {
  45665. private _lightMesh;
  45666. private _material;
  45667. private cachedPosition;
  45668. private cachedForward;
  45669. /**
  45670. * Creates a LightGizmo
  45671. * @param gizmoLayer The utility layer the gizmo will be added to
  45672. */
  45673. constructor(gizmoLayer?: UtilityLayerRenderer);
  45674. private _light;
  45675. /**
  45676. * The light that the gizmo is attached to
  45677. */
  45678. light: Nullable<Light>;
  45679. /**
  45680. * Gets the material used to render the light gizmo
  45681. */
  45682. readonly material: StandardMaterial;
  45683. /**
  45684. * @hidden
  45685. * Updates the gizmo to match the attached mesh's position/rotation
  45686. */
  45687. protected _update(): void;
  45688. private static _Scale;
  45689. /**
  45690. * Creates the lines for a light mesh
  45691. */
  45692. private static _createLightLines;
  45693. /**
  45694. * Disposes of the light gizmo
  45695. */
  45696. dispose(): void;
  45697. private static _CreateHemisphericLightMesh;
  45698. private static _CreatePointLightMesh;
  45699. private static _CreateSpotLightMesh;
  45700. private static _CreateDirectionalLightMesh;
  45701. }
  45702. }
  45703. declare module BABYLON {
  45704. /** @hidden */
  45705. export var backgroundFragmentDeclaration: {
  45706. name: string;
  45707. shader: string;
  45708. };
  45709. }
  45710. declare module BABYLON {
  45711. /** @hidden */
  45712. export var backgroundUboDeclaration: {
  45713. name: string;
  45714. shader: string;
  45715. };
  45716. }
  45717. declare module BABYLON {
  45718. /** @hidden */
  45719. export var backgroundPixelShader: {
  45720. name: string;
  45721. shader: string;
  45722. };
  45723. }
  45724. declare module BABYLON {
  45725. /** @hidden */
  45726. export var backgroundVertexDeclaration: {
  45727. name: string;
  45728. shader: string;
  45729. };
  45730. }
  45731. declare module BABYLON {
  45732. /** @hidden */
  45733. export var backgroundVertexShader: {
  45734. name: string;
  45735. shader: string;
  45736. };
  45737. }
  45738. declare module BABYLON {
  45739. /**
  45740. * Background material used to create an efficient environement around your scene.
  45741. */
  45742. export class BackgroundMaterial extends PushMaterial {
  45743. /**
  45744. * Standard reflectance value at parallel view angle.
  45745. */
  45746. static StandardReflectance0: number;
  45747. /**
  45748. * Standard reflectance value at grazing angle.
  45749. */
  45750. static StandardReflectance90: number;
  45751. protected _primaryColor: Color3;
  45752. /**
  45753. * Key light Color (multiply against the environement texture)
  45754. */
  45755. primaryColor: Color3;
  45756. protected __perceptualColor: Nullable<Color3>;
  45757. /**
  45758. * Experimental Internal Use Only.
  45759. *
  45760. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  45761. * This acts as a helper to set the primary color to a more "human friendly" value.
  45762. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  45763. * output color as close as possible from the chosen value.
  45764. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  45765. * part of lighting setup.)
  45766. */
  45767. _perceptualColor: Nullable<Color3>;
  45768. protected _primaryColorShadowLevel: float;
  45769. /**
  45770. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  45771. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  45772. */
  45773. primaryColorShadowLevel: float;
  45774. protected _primaryColorHighlightLevel: float;
  45775. /**
  45776. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  45777. * The primary color is used at the level chosen to define what the white area would look.
  45778. */
  45779. primaryColorHighlightLevel: float;
  45780. protected _reflectionTexture: Nullable<BaseTexture>;
  45781. /**
  45782. * Reflection Texture used in the material.
  45783. * Should be author in a specific way for the best result (refer to the documentation).
  45784. */
  45785. reflectionTexture: Nullable<BaseTexture>;
  45786. protected _reflectionBlur: float;
  45787. /**
  45788. * Reflection Texture level of blur.
  45789. *
  45790. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  45791. * texture twice.
  45792. */
  45793. reflectionBlur: float;
  45794. protected _diffuseTexture: Nullable<BaseTexture>;
  45795. /**
  45796. * Diffuse Texture used in the material.
  45797. * Should be author in a specific way for the best result (refer to the documentation).
  45798. */
  45799. diffuseTexture: Nullable<BaseTexture>;
  45800. protected _shadowLights: Nullable<IShadowLight[]>;
  45801. /**
  45802. * Specify the list of lights casting shadow on the material.
  45803. * All scene shadow lights will be included if null.
  45804. */
  45805. shadowLights: Nullable<IShadowLight[]>;
  45806. protected _shadowLevel: float;
  45807. /**
  45808. * Helps adjusting the shadow to a softer level if required.
  45809. * 0 means black shadows and 1 means no shadows.
  45810. */
  45811. shadowLevel: float;
  45812. protected _sceneCenter: Vector3;
  45813. /**
  45814. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  45815. * It is usually zero but might be interesting to modify according to your setup.
  45816. */
  45817. sceneCenter: Vector3;
  45818. protected _opacityFresnel: boolean;
  45819. /**
  45820. * This helps specifying that the material is falling off to the sky box at grazing angle.
  45821. * This helps ensuring a nice transition when the camera goes under the ground.
  45822. */
  45823. opacityFresnel: boolean;
  45824. protected _reflectionFresnel: boolean;
  45825. /**
  45826. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  45827. * This helps adding a mirror texture on the ground.
  45828. */
  45829. reflectionFresnel: boolean;
  45830. protected _reflectionFalloffDistance: number;
  45831. /**
  45832. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  45833. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  45834. */
  45835. reflectionFalloffDistance: number;
  45836. protected _reflectionAmount: number;
  45837. /**
  45838. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  45839. */
  45840. reflectionAmount: number;
  45841. protected _reflectionReflectance0: number;
  45842. /**
  45843. * This specifies the weight of the reflection at grazing angle.
  45844. */
  45845. reflectionReflectance0: number;
  45846. protected _reflectionReflectance90: number;
  45847. /**
  45848. * This specifies the weight of the reflection at a perpendicular point of view.
  45849. */
  45850. reflectionReflectance90: number;
  45851. /**
  45852. * Sets the reflection reflectance fresnel values according to the default standard
  45853. * empirically know to work well :-)
  45854. */
  45855. reflectionStandardFresnelWeight: number;
  45856. protected _useRGBColor: boolean;
  45857. /**
  45858. * Helps to directly use the maps channels instead of their level.
  45859. */
  45860. useRGBColor: boolean;
  45861. protected _enableNoise: boolean;
  45862. /**
  45863. * This helps reducing the banding effect that could occur on the background.
  45864. */
  45865. enableNoise: boolean;
  45866. /**
  45867. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  45868. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  45869. * Recommended to be keep at 1.0 except for special cases.
  45870. */
  45871. fovMultiplier: number;
  45872. private _fovMultiplier;
  45873. /**
  45874. * Enable the FOV adjustment feature controlled by fovMultiplier.
  45875. */
  45876. useEquirectangularFOV: boolean;
  45877. private _maxSimultaneousLights;
  45878. /**
  45879. * Number of Simultaneous lights allowed on the material.
  45880. */
  45881. maxSimultaneousLights: int;
  45882. /**
  45883. * Default configuration related to image processing available in the Background Material.
  45884. */
  45885. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  45886. /**
  45887. * Keep track of the image processing observer to allow dispose and replace.
  45888. */
  45889. private _imageProcessingObserver;
  45890. /**
  45891. * Attaches a new image processing configuration to the PBR Material.
  45892. * @param configuration (if null the scene configuration will be use)
  45893. */
  45894. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  45895. /**
  45896. * Gets the image processing configuration used either in this material.
  45897. */
  45898. /**
  45899. * Sets the Default image processing configuration used either in the this material.
  45900. *
  45901. * If sets to null, the scene one is in use.
  45902. */
  45903. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  45904. /**
  45905. * Gets wether the color curves effect is enabled.
  45906. */
  45907. /**
  45908. * Sets wether the color curves effect is enabled.
  45909. */
  45910. cameraColorCurvesEnabled: boolean;
  45911. /**
  45912. * Gets wether the color grading effect is enabled.
  45913. */
  45914. /**
  45915. * Gets wether the color grading effect is enabled.
  45916. */
  45917. cameraColorGradingEnabled: boolean;
  45918. /**
  45919. * Gets wether tonemapping is enabled or not.
  45920. */
  45921. /**
  45922. * Sets wether tonemapping is enabled or not
  45923. */
  45924. cameraToneMappingEnabled: boolean;
  45925. /**
  45926. * The camera exposure used on this material.
  45927. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45928. * This corresponds to a photographic exposure.
  45929. */
  45930. /**
  45931. * The camera exposure used on this material.
  45932. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45933. * This corresponds to a photographic exposure.
  45934. */
  45935. cameraExposure: float;
  45936. /**
  45937. * Gets The camera contrast used on this material.
  45938. */
  45939. /**
  45940. * Sets The camera contrast used on this material.
  45941. */
  45942. cameraContrast: float;
  45943. /**
  45944. * Gets the Color Grading 2D Lookup Texture.
  45945. */
  45946. /**
  45947. * Sets the Color Grading 2D Lookup Texture.
  45948. */
  45949. cameraColorGradingTexture: Nullable<BaseTexture>;
  45950. /**
  45951. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45952. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45953. * 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;
  45954. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45955. */
  45956. /**
  45957. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45958. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45959. * 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;
  45960. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45961. */
  45962. cameraColorCurves: Nullable<ColorCurves>;
  45963. /**
  45964. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  45965. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  45966. */
  45967. switchToBGR: boolean;
  45968. private _renderTargets;
  45969. private _reflectionControls;
  45970. private _white;
  45971. private _primaryShadowColor;
  45972. private _primaryHighlightColor;
  45973. /**
  45974. * Instantiates a Background Material in the given scene
  45975. * @param name The friendly name of the material
  45976. * @param scene The scene to add the material to
  45977. */
  45978. constructor(name: string, scene: Scene);
  45979. /**
  45980. * Gets a boolean indicating that current material needs to register RTT
  45981. */
  45982. readonly hasRenderTargetTextures: boolean;
  45983. /**
  45984. * The entire material has been created in order to prevent overdraw.
  45985. * @returns false
  45986. */
  45987. needAlphaTesting(): boolean;
  45988. /**
  45989. * The entire material has been created in order to prevent overdraw.
  45990. * @returns true if blending is enable
  45991. */
  45992. needAlphaBlending(): boolean;
  45993. /**
  45994. * Checks wether the material is ready to be rendered for a given mesh.
  45995. * @param mesh The mesh to render
  45996. * @param subMesh The submesh to check against
  45997. * @param useInstances Specify wether or not the material is used with instances
  45998. * @returns true if all the dependencies are ready (Textures, Effects...)
  45999. */
  46000. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  46001. /**
  46002. * Compute the primary color according to the chosen perceptual color.
  46003. */
  46004. private _computePrimaryColorFromPerceptualColor;
  46005. /**
  46006. * Compute the highlights and shadow colors according to their chosen levels.
  46007. */
  46008. private _computePrimaryColors;
  46009. /**
  46010. * Build the uniform buffer used in the material.
  46011. */
  46012. buildUniformLayout(): void;
  46013. /**
  46014. * Unbind the material.
  46015. */
  46016. unbind(): void;
  46017. /**
  46018. * Bind only the world matrix to the material.
  46019. * @param world The world matrix to bind.
  46020. */
  46021. bindOnlyWorldMatrix(world: Matrix): void;
  46022. /**
  46023. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  46024. * @param world The world matrix to bind.
  46025. * @param subMesh The submesh to bind for.
  46026. */
  46027. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  46028. /**
  46029. * Checks to see if a texture is used in the material.
  46030. * @param texture - Base texture to use.
  46031. * @returns - Boolean specifying if a texture is used in the material.
  46032. */
  46033. hasTexture(texture: BaseTexture): boolean;
  46034. /**
  46035. * Dispose the material.
  46036. * @param forceDisposeEffect Force disposal of the associated effect.
  46037. * @param forceDisposeTextures Force disposal of the associated textures.
  46038. */
  46039. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  46040. /**
  46041. * Clones the material.
  46042. * @param name The cloned name.
  46043. * @returns The cloned material.
  46044. */
  46045. clone(name: string): BackgroundMaterial;
  46046. /**
  46047. * Serializes the current material to its JSON representation.
  46048. * @returns The JSON representation.
  46049. */
  46050. serialize(): any;
  46051. /**
  46052. * Gets the class name of the material
  46053. * @returns "BackgroundMaterial"
  46054. */
  46055. getClassName(): string;
  46056. /**
  46057. * Parse a JSON input to create back a background material.
  46058. * @param source The JSON data to parse
  46059. * @param scene The scene to create the parsed material in
  46060. * @param rootUrl The root url of the assets the material depends upon
  46061. * @returns the instantiated BackgroundMaterial.
  46062. */
  46063. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  46064. }
  46065. }
  46066. declare module BABYLON {
  46067. /**
  46068. * Represents the different options available during the creation of
  46069. * a Environment helper.
  46070. *
  46071. * This can control the default ground, skybox and image processing setup of your scene.
  46072. */
  46073. export interface IEnvironmentHelperOptions {
  46074. /**
  46075. * Specifies wether or not to create a ground.
  46076. * True by default.
  46077. */
  46078. createGround: boolean;
  46079. /**
  46080. * Specifies the ground size.
  46081. * 15 by default.
  46082. */
  46083. groundSize: number;
  46084. /**
  46085. * The texture used on the ground for the main color.
  46086. * Comes from the BabylonJS CDN by default.
  46087. *
  46088. * Remarks: Can be either a texture or a url.
  46089. */
  46090. groundTexture: string | BaseTexture;
  46091. /**
  46092. * The color mixed in the ground texture by default.
  46093. * BabylonJS clearColor by default.
  46094. */
  46095. groundColor: Color3;
  46096. /**
  46097. * Specifies the ground opacity.
  46098. * 1 by default.
  46099. */
  46100. groundOpacity: number;
  46101. /**
  46102. * Enables the ground to receive shadows.
  46103. * True by default.
  46104. */
  46105. enableGroundShadow: boolean;
  46106. /**
  46107. * Helps preventing the shadow to be fully black on the ground.
  46108. * 0.5 by default.
  46109. */
  46110. groundShadowLevel: number;
  46111. /**
  46112. * Creates a mirror texture attach to the ground.
  46113. * false by default.
  46114. */
  46115. enableGroundMirror: boolean;
  46116. /**
  46117. * Specifies the ground mirror size ratio.
  46118. * 0.3 by default as the default kernel is 64.
  46119. */
  46120. groundMirrorSizeRatio: number;
  46121. /**
  46122. * Specifies the ground mirror blur kernel size.
  46123. * 64 by default.
  46124. */
  46125. groundMirrorBlurKernel: number;
  46126. /**
  46127. * Specifies the ground mirror visibility amount.
  46128. * 1 by default
  46129. */
  46130. groundMirrorAmount: number;
  46131. /**
  46132. * Specifies the ground mirror reflectance weight.
  46133. * This uses the standard weight of the background material to setup the fresnel effect
  46134. * of the mirror.
  46135. * 1 by default.
  46136. */
  46137. groundMirrorFresnelWeight: number;
  46138. /**
  46139. * Specifies the ground mirror Falloff distance.
  46140. * This can helps reducing the size of the reflection.
  46141. * 0 by Default.
  46142. */
  46143. groundMirrorFallOffDistance: number;
  46144. /**
  46145. * Specifies the ground mirror texture type.
  46146. * Unsigned Int by Default.
  46147. */
  46148. groundMirrorTextureType: number;
  46149. /**
  46150. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  46151. * the shown objects.
  46152. */
  46153. groundYBias: number;
  46154. /**
  46155. * Specifies wether or not to create a skybox.
  46156. * True by default.
  46157. */
  46158. createSkybox: boolean;
  46159. /**
  46160. * Specifies the skybox size.
  46161. * 20 by default.
  46162. */
  46163. skyboxSize: number;
  46164. /**
  46165. * The texture used on the skybox for the main color.
  46166. * Comes from the BabylonJS CDN by default.
  46167. *
  46168. * Remarks: Can be either a texture or a url.
  46169. */
  46170. skyboxTexture: string | BaseTexture;
  46171. /**
  46172. * The color mixed in the skybox texture by default.
  46173. * BabylonJS clearColor by default.
  46174. */
  46175. skyboxColor: Color3;
  46176. /**
  46177. * The background rotation around the Y axis of the scene.
  46178. * This helps aligning the key lights of your scene with the background.
  46179. * 0 by default.
  46180. */
  46181. backgroundYRotation: number;
  46182. /**
  46183. * Compute automatically the size of the elements to best fit with the scene.
  46184. */
  46185. sizeAuto: boolean;
  46186. /**
  46187. * Default position of the rootMesh if autoSize is not true.
  46188. */
  46189. rootPosition: Vector3;
  46190. /**
  46191. * Sets up the image processing in the scene.
  46192. * true by default.
  46193. */
  46194. setupImageProcessing: boolean;
  46195. /**
  46196. * The texture used as your environment texture in the scene.
  46197. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  46198. *
  46199. * Remarks: Can be either a texture or a url.
  46200. */
  46201. environmentTexture: string | BaseTexture;
  46202. /**
  46203. * The value of the exposure to apply to the scene.
  46204. * 0.6 by default if setupImageProcessing is true.
  46205. */
  46206. cameraExposure: number;
  46207. /**
  46208. * The value of the contrast to apply to the scene.
  46209. * 1.6 by default if setupImageProcessing is true.
  46210. */
  46211. cameraContrast: number;
  46212. /**
  46213. * Specifies wether or not tonemapping should be enabled in the scene.
  46214. * true by default if setupImageProcessing is true.
  46215. */
  46216. toneMappingEnabled: boolean;
  46217. }
  46218. /**
  46219. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  46220. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  46221. * It also helps with the default setup of your imageProcessing configuration.
  46222. */
  46223. export class EnvironmentHelper {
  46224. /**
  46225. * Default ground texture URL.
  46226. */
  46227. private static _groundTextureCDNUrl;
  46228. /**
  46229. * Default skybox texture URL.
  46230. */
  46231. private static _skyboxTextureCDNUrl;
  46232. /**
  46233. * Default environment texture URL.
  46234. */
  46235. private static _environmentTextureCDNUrl;
  46236. /**
  46237. * Creates the default options for the helper.
  46238. */
  46239. private static _getDefaultOptions;
  46240. private _rootMesh;
  46241. /**
  46242. * Gets the root mesh created by the helper.
  46243. */
  46244. readonly rootMesh: Mesh;
  46245. private _skybox;
  46246. /**
  46247. * Gets the skybox created by the helper.
  46248. */
  46249. readonly skybox: Nullable<Mesh>;
  46250. private _skyboxTexture;
  46251. /**
  46252. * Gets the skybox texture created by the helper.
  46253. */
  46254. readonly skyboxTexture: Nullable<BaseTexture>;
  46255. private _skyboxMaterial;
  46256. /**
  46257. * Gets the skybox material created by the helper.
  46258. */
  46259. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  46260. private _ground;
  46261. /**
  46262. * Gets the ground mesh created by the helper.
  46263. */
  46264. readonly ground: Nullable<Mesh>;
  46265. private _groundTexture;
  46266. /**
  46267. * Gets the ground texture created by the helper.
  46268. */
  46269. readonly groundTexture: Nullable<BaseTexture>;
  46270. private _groundMirror;
  46271. /**
  46272. * Gets the ground mirror created by the helper.
  46273. */
  46274. readonly groundMirror: Nullable<MirrorTexture>;
  46275. /**
  46276. * Gets the ground mirror render list to helps pushing the meshes
  46277. * you wish in the ground reflection.
  46278. */
  46279. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  46280. private _groundMaterial;
  46281. /**
  46282. * Gets the ground material created by the helper.
  46283. */
  46284. readonly groundMaterial: Nullable<BackgroundMaterial>;
  46285. /**
  46286. * Stores the creation options.
  46287. */
  46288. private readonly _scene;
  46289. private _options;
  46290. /**
  46291. * This observable will be notified with any error during the creation of the environment,
  46292. * mainly texture creation errors.
  46293. */
  46294. onErrorObservable: Observable<{
  46295. message?: string;
  46296. exception?: any;
  46297. }>;
  46298. /**
  46299. * constructor
  46300. * @param options Defines the options we want to customize the helper
  46301. * @param scene The scene to add the material to
  46302. */
  46303. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  46304. /**
  46305. * Updates the background according to the new options
  46306. * @param options
  46307. */
  46308. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  46309. /**
  46310. * Sets the primary color of all the available elements.
  46311. * @param color the main color to affect to the ground and the background
  46312. */
  46313. setMainColor(color: Color3): void;
  46314. /**
  46315. * Setup the image processing according to the specified options.
  46316. */
  46317. private _setupImageProcessing;
  46318. /**
  46319. * Setup the environment texture according to the specified options.
  46320. */
  46321. private _setupEnvironmentTexture;
  46322. /**
  46323. * Setup the background according to the specified options.
  46324. */
  46325. private _setupBackground;
  46326. /**
  46327. * Get the scene sizes according to the setup.
  46328. */
  46329. private _getSceneSize;
  46330. /**
  46331. * Setup the ground according to the specified options.
  46332. */
  46333. private _setupGround;
  46334. /**
  46335. * Setup the ground material according to the specified options.
  46336. */
  46337. private _setupGroundMaterial;
  46338. /**
  46339. * Setup the ground diffuse texture according to the specified options.
  46340. */
  46341. private _setupGroundDiffuseTexture;
  46342. /**
  46343. * Setup the ground mirror texture according to the specified options.
  46344. */
  46345. private _setupGroundMirrorTexture;
  46346. /**
  46347. * Setup the ground to receive the mirror texture.
  46348. */
  46349. private _setupMirrorInGroundMaterial;
  46350. /**
  46351. * Setup the skybox according to the specified options.
  46352. */
  46353. private _setupSkybox;
  46354. /**
  46355. * Setup the skybox material according to the specified options.
  46356. */
  46357. private _setupSkyboxMaterial;
  46358. /**
  46359. * Setup the skybox reflection texture according to the specified options.
  46360. */
  46361. private _setupSkyboxReflectionTexture;
  46362. private _errorHandler;
  46363. /**
  46364. * Dispose all the elements created by the Helper.
  46365. */
  46366. dispose(): void;
  46367. }
  46368. }
  46369. declare module BABYLON {
  46370. /**
  46371. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  46372. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  46373. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  46374. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  46375. */
  46376. export class PhotoDome extends TransformNode {
  46377. /**
  46378. * Define the image as a Monoscopic panoramic 360 image.
  46379. */
  46380. static readonly MODE_MONOSCOPIC: number;
  46381. /**
  46382. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  46383. */
  46384. static readonly MODE_TOPBOTTOM: number;
  46385. /**
  46386. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  46387. */
  46388. static readonly MODE_SIDEBYSIDE: number;
  46389. private _useDirectMapping;
  46390. /**
  46391. * The texture being displayed on the sphere
  46392. */
  46393. protected _photoTexture: Texture;
  46394. /**
  46395. * Gets or sets the texture being displayed on the sphere
  46396. */
  46397. photoTexture: Texture;
  46398. /**
  46399. * Observable raised when an error occured while loading the 360 image
  46400. */
  46401. onLoadErrorObservable: Observable<string>;
  46402. /**
  46403. * The skybox material
  46404. */
  46405. protected _material: BackgroundMaterial;
  46406. /**
  46407. * The surface used for the skybox
  46408. */
  46409. protected _mesh: Mesh;
  46410. /**
  46411. * Gets the mesh used for the skybox.
  46412. */
  46413. readonly mesh: Mesh;
  46414. /**
  46415. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  46416. * Also see the options.resolution property.
  46417. */
  46418. fovMultiplier: number;
  46419. private _imageMode;
  46420. /**
  46421. * Gets or set the current video mode for the video. It can be:
  46422. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  46423. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  46424. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  46425. */
  46426. imageMode: number;
  46427. /**
  46428. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  46429. * @param name Element's name, child elements will append suffixes for their own names.
  46430. * @param urlsOfPhoto defines the url of the photo to display
  46431. * @param options defines an object containing optional or exposed sub element properties
  46432. * @param onError defines a callback called when an error occured while loading the texture
  46433. */
  46434. constructor(name: string, urlOfPhoto: string, options: {
  46435. resolution?: number;
  46436. size?: number;
  46437. useDirectMapping?: boolean;
  46438. faceForward?: boolean;
  46439. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  46440. private _onBeforeCameraRenderObserver;
  46441. private _changeImageMode;
  46442. /**
  46443. * Releases resources associated with this node.
  46444. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  46445. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  46446. */
  46447. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  46448. }
  46449. }
  46450. declare module BABYLON {
  46451. /**
  46452. * Class used to host RGBD texture specific utilities
  46453. */
  46454. export class RGBDTextureTools {
  46455. /**
  46456. * Expand the RGBD Texture from RGBD to Half Float if possible.
  46457. * @param texture the texture to expand.
  46458. */
  46459. static ExpandRGBDTexture(texture: Texture): void;
  46460. }
  46461. }
  46462. declare module BABYLON {
  46463. /**
  46464. * Class used to host texture specific utilities
  46465. */
  46466. export class BRDFTextureTools {
  46467. /**
  46468. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  46469. * @param scene defines the hosting scene
  46470. * @returns the environment BRDF texture
  46471. */
  46472. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  46473. private static _environmentBRDFBase64Texture;
  46474. }
  46475. }
  46476. declare module BABYLON {
  46477. /**
  46478. * @hidden
  46479. */
  46480. export interface IMaterialClearCoatDefines {
  46481. CLEARCOAT: boolean;
  46482. CLEARCOAT_DEFAULTIOR: boolean;
  46483. CLEARCOAT_TEXTURE: boolean;
  46484. CLEARCOAT_TEXTUREDIRECTUV: number;
  46485. CLEARCOAT_BUMP: boolean;
  46486. CLEARCOAT_BUMPDIRECTUV: number;
  46487. CLEARCOAT_TINT: boolean;
  46488. CLEARCOAT_TINT_TEXTURE: boolean;
  46489. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  46490. /** @hidden */
  46491. _areTexturesDirty: boolean;
  46492. }
  46493. /**
  46494. * Define the code related to the clear coat parameters of the pbr material.
  46495. */
  46496. export class PBRClearCoatConfiguration {
  46497. /**
  46498. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  46499. * The default fits with a polyurethane material.
  46500. */
  46501. private static readonly _DefaultIndexOfRefraction;
  46502. private _isEnabled;
  46503. /**
  46504. * Defines if the clear coat is enabled in the material.
  46505. */
  46506. isEnabled: boolean;
  46507. /**
  46508. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  46509. */
  46510. intensity: number;
  46511. /**
  46512. * Defines the clear coat layer roughness.
  46513. */
  46514. roughness: number;
  46515. private _indexOfRefraction;
  46516. /**
  46517. * Defines the index of refraction of the clear coat.
  46518. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  46519. * The default fits with a polyurethane material.
  46520. * Changing the default value is more performance intensive.
  46521. */
  46522. indexOfRefraction: number;
  46523. private _texture;
  46524. /**
  46525. * Stores the clear coat values in a texture.
  46526. */
  46527. texture: Nullable<BaseTexture>;
  46528. private _bumpTexture;
  46529. /**
  46530. * Define the clear coat specific bump texture.
  46531. */
  46532. bumpTexture: Nullable<BaseTexture>;
  46533. private _isTintEnabled;
  46534. /**
  46535. * Defines if the clear coat tint is enabled in the material.
  46536. */
  46537. isTintEnabled: boolean;
  46538. /**
  46539. * Defines the clear coat tint of the material.
  46540. * This is only use if tint is enabled
  46541. */
  46542. tintColor: Color3;
  46543. /**
  46544. * Defines the distance at which the tint color should be found in the
  46545. * clear coat media.
  46546. * This is only use if tint is enabled
  46547. */
  46548. tintColorAtDistance: number;
  46549. /**
  46550. * Defines the clear coat layer thickness.
  46551. * This is only use if tint is enabled
  46552. */
  46553. tintThickness: number;
  46554. private _tintTexture;
  46555. /**
  46556. * Stores the clear tint values in a texture.
  46557. * rgb is tint
  46558. * a is a thickness factor
  46559. */
  46560. tintTexture: Nullable<BaseTexture>;
  46561. /** @hidden */
  46562. private _internalMarkAllSubMeshesAsTexturesDirty;
  46563. /** @hidden */
  46564. _markAllSubMeshesAsTexturesDirty(): void;
  46565. /**
  46566. * Instantiate a new istance of clear coat configuration.
  46567. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  46568. */
  46569. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  46570. /**
  46571. * Gets wehter the submesh is ready to be used or not.
  46572. * @param defines the list of "defines" to update.
  46573. * @param scene defines the scene the material belongs to.
  46574. * @param engine defines the engine the material belongs to.
  46575. * @param disableBumpMap defines wether the material disables bump or not.
  46576. * @returns - boolean indicating that the submesh is ready or not.
  46577. */
  46578. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  46579. /**
  46580. * Checks to see if a texture is used in the material.
  46581. * @param defines the list of "defines" to update.
  46582. * @param scene defines the scene to the material belongs to.
  46583. */
  46584. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  46585. /**
  46586. * Binds the material data.
  46587. * @param uniformBuffer defines the Uniform buffer to fill in.
  46588. * @param scene defines the scene the material belongs to.
  46589. * @param engine defines the engine the material belongs to.
  46590. * @param disableBumpMap defines wether the material disables bump or not.
  46591. * @param isFrozen defines wether the material is frozen or not.
  46592. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  46593. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  46594. */
  46595. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  46596. /**
  46597. * Checks to see if a texture is used in the material.
  46598. * @param texture - Base texture to use.
  46599. * @returns - Boolean specifying if a texture is used in the material.
  46600. */
  46601. hasTexture(texture: BaseTexture): boolean;
  46602. /**
  46603. * Returns an array of the actively used textures.
  46604. * @param activeTextures Array of BaseTextures
  46605. */
  46606. getActiveTextures(activeTextures: BaseTexture[]): void;
  46607. /**
  46608. * Returns the animatable textures.
  46609. * @param animatables Array of animatable textures.
  46610. */
  46611. getAnimatables(animatables: IAnimatable[]): void;
  46612. /**
  46613. * Disposes the resources of the material.
  46614. * @param forceDisposeTextures - Forces the disposal of all textures.
  46615. */
  46616. dispose(forceDisposeTextures?: boolean): void;
  46617. /**
  46618. * Get the current class name of the texture useful for serialization or dynamic coding.
  46619. * @returns "PBRClearCoatConfiguration"
  46620. */
  46621. getClassName(): string;
  46622. /**
  46623. * Add fallbacks to the effect fallbacks list.
  46624. * @param defines defines the Base texture to use.
  46625. * @param fallbacks defines the current fallback list.
  46626. * @param currentRank defines the current fallback rank.
  46627. * @returns the new fallback rank.
  46628. */
  46629. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  46630. /**
  46631. * Add the required uniforms to the current list.
  46632. * @param uniforms defines the current uniform list.
  46633. */
  46634. static AddUniforms(uniforms: string[]): void;
  46635. /**
  46636. * Add the required samplers to the current list.
  46637. * @param samplers defines the current sampler list.
  46638. */
  46639. static AddSamplers(samplers: string[]): void;
  46640. /**
  46641. * Add the required uniforms to the current buffer.
  46642. * @param uniformBuffer defines the current uniform buffer.
  46643. */
  46644. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  46645. /**
  46646. * Makes a duplicate of the current configuration into another one.
  46647. * @param clearCoatConfiguration define the config where to copy the info
  46648. */
  46649. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  46650. /**
  46651. * Serializes this clear coat configuration.
  46652. * @returns - An object with the serialized config.
  46653. */
  46654. serialize(): any;
  46655. /**
  46656. * Parses a anisotropy Configuration from a serialized object.
  46657. * @param source - Serialized object.
  46658. * @param scene Defines the scene we are parsing for
  46659. * @param rootUrl Defines the rootUrl to load from
  46660. */
  46661. parse(source: any, scene: Scene, rootUrl: string): void;
  46662. }
  46663. }
  46664. declare module BABYLON {
  46665. /**
  46666. * @hidden
  46667. */
  46668. export interface IMaterialAnisotropicDefines {
  46669. ANISOTROPIC: boolean;
  46670. ANISOTROPIC_TEXTURE: boolean;
  46671. ANISOTROPIC_TEXTUREDIRECTUV: number;
  46672. MAINUV1: boolean;
  46673. _areTexturesDirty: boolean;
  46674. _needUVs: boolean;
  46675. }
  46676. /**
  46677. * Define the code related to the anisotropic parameters of the pbr material.
  46678. */
  46679. export class PBRAnisotropicConfiguration {
  46680. private _isEnabled;
  46681. /**
  46682. * Defines if the anisotropy is enabled in the material.
  46683. */
  46684. isEnabled: boolean;
  46685. /**
  46686. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  46687. */
  46688. intensity: number;
  46689. /**
  46690. * Defines if the effect is along the tangents, bitangents or in between.
  46691. * By default, the effect is "strectching" the highlights along the tangents.
  46692. */
  46693. direction: Vector2;
  46694. private _texture;
  46695. /**
  46696. * Stores the anisotropy values in a texture.
  46697. * rg is direction (like normal from -1 to 1)
  46698. * b is a intensity
  46699. */
  46700. texture: Nullable<BaseTexture>;
  46701. /** @hidden */
  46702. private _internalMarkAllSubMeshesAsTexturesDirty;
  46703. /** @hidden */
  46704. _markAllSubMeshesAsTexturesDirty(): void;
  46705. /**
  46706. * Instantiate a new istance of anisotropy configuration.
  46707. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  46708. */
  46709. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  46710. /**
  46711. * Specifies that the submesh is ready to be used.
  46712. * @param defines the list of "defines" to update.
  46713. * @param scene defines the scene the material belongs to.
  46714. * @returns - boolean indicating that the submesh is ready or not.
  46715. */
  46716. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  46717. /**
  46718. * Checks to see if a texture is used in the material.
  46719. * @param defines the list of "defines" to update.
  46720. * @param mesh the mesh we are preparing the defines for.
  46721. * @param scene defines the scene the material belongs to.
  46722. */
  46723. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  46724. /**
  46725. * Binds the material data.
  46726. * @param uniformBuffer defines the Uniform buffer to fill in.
  46727. * @param scene defines the scene the material belongs to.
  46728. * @param isFrozen defines wether the material is frozen or not.
  46729. */
  46730. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  46731. /**
  46732. * Checks to see if a texture is used in the material.
  46733. * @param texture - Base texture to use.
  46734. * @returns - Boolean specifying if a texture is used in the material.
  46735. */
  46736. hasTexture(texture: BaseTexture): boolean;
  46737. /**
  46738. * Returns an array of the actively used textures.
  46739. * @param activeTextures Array of BaseTextures
  46740. */
  46741. getActiveTextures(activeTextures: BaseTexture[]): void;
  46742. /**
  46743. * Returns the animatable textures.
  46744. * @param animatables Array of animatable textures.
  46745. */
  46746. getAnimatables(animatables: IAnimatable[]): void;
  46747. /**
  46748. * Disposes the resources of the material.
  46749. * @param forceDisposeTextures - Forces the disposal of all textures.
  46750. */
  46751. dispose(forceDisposeTextures?: boolean): void;
  46752. /**
  46753. * Get the current class name of the texture useful for serialization or dynamic coding.
  46754. * @returns "PBRAnisotropicConfiguration"
  46755. */
  46756. getClassName(): string;
  46757. /**
  46758. * Add fallbacks to the effect fallbacks list.
  46759. * @param defines defines the Base texture to use.
  46760. * @param fallbacks defines the current fallback list.
  46761. * @param currentRank defines the current fallback rank.
  46762. * @returns the new fallback rank.
  46763. */
  46764. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  46765. /**
  46766. * Add the required uniforms to the current list.
  46767. * @param uniforms defines the current uniform list.
  46768. */
  46769. static AddUniforms(uniforms: string[]): void;
  46770. /**
  46771. * Add the required uniforms to the current buffer.
  46772. * @param uniformBuffer defines the current uniform buffer.
  46773. */
  46774. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  46775. /**
  46776. * Add the required samplers to the current list.
  46777. * @param samplers defines the current sampler list.
  46778. */
  46779. static AddSamplers(samplers: string[]): void;
  46780. /**
  46781. * Makes a duplicate of the current configuration into another one.
  46782. * @param anisotropicConfiguration define the config where to copy the info
  46783. */
  46784. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  46785. /**
  46786. * Serializes this anisotropy configuration.
  46787. * @returns - An object with the serialized config.
  46788. */
  46789. serialize(): any;
  46790. /**
  46791. * Parses a anisotropy Configuration from a serialized object.
  46792. * @param source - Serialized object.
  46793. * @param scene Defines the scene we are parsing for
  46794. * @param rootUrl Defines the rootUrl to load from
  46795. */
  46796. parse(source: any, scene: Scene, rootUrl: string): void;
  46797. }
  46798. }
  46799. declare module BABYLON {
  46800. /**
  46801. * @hidden
  46802. */
  46803. export interface IMaterialBRDFDefines {
  46804. BRDF_V_HEIGHT_CORRELATED: boolean;
  46805. MS_BRDF_ENERGY_CONSERVATION: boolean;
  46806. SPHERICAL_HARMONICS: boolean;
  46807. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  46808. /** @hidden */
  46809. _areMiscDirty: boolean;
  46810. }
  46811. /**
  46812. * Define the code related to the BRDF parameters of the pbr material.
  46813. */
  46814. export class PBRBRDFConfiguration {
  46815. /**
  46816. * Default value used for the energy conservation.
  46817. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  46818. */
  46819. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  46820. /**
  46821. * Default value used for the Smith Visibility Height Correlated mode.
  46822. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  46823. */
  46824. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  46825. /**
  46826. * Default value used for the IBL diffuse part.
  46827. * This can help switching back to the polynomials mode globally which is a tiny bit
  46828. * less GPU intensive at the drawback of a lower quality.
  46829. */
  46830. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  46831. /**
  46832. * Default value used for activating energy conservation for the specular workflow.
  46833. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  46834. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  46835. */
  46836. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  46837. private _useEnergyConservation;
  46838. /**
  46839. * Defines if the material uses energy conservation.
  46840. */
  46841. useEnergyConservation: boolean;
  46842. private _useSmithVisibilityHeightCorrelated;
  46843. /**
  46844. * LEGACY Mode set to false
  46845. * Defines if the material uses height smith correlated visibility term.
  46846. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  46847. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  46848. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  46849. * Not relying on height correlated will also disable energy conservation.
  46850. */
  46851. useSmithVisibilityHeightCorrelated: boolean;
  46852. private _useSphericalHarmonics;
  46853. /**
  46854. * LEGACY Mode set to false
  46855. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  46856. * diffuse part of the IBL.
  46857. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  46858. * to the ground truth.
  46859. */
  46860. useSphericalHarmonics: boolean;
  46861. private _useSpecularGlossinessInputEnergyConservation;
  46862. /**
  46863. * Defines if the material uses energy conservation, when the specular workflow is active.
  46864. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  46865. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  46866. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  46867. */
  46868. useSpecularGlossinessInputEnergyConservation: boolean;
  46869. /** @hidden */
  46870. private _internalMarkAllSubMeshesAsMiscDirty;
  46871. /** @hidden */
  46872. _markAllSubMeshesAsMiscDirty(): void;
  46873. /**
  46874. * Instantiate a new istance of clear coat configuration.
  46875. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  46876. */
  46877. constructor(markAllSubMeshesAsMiscDirty: () => void);
  46878. /**
  46879. * Checks to see if a texture is used in the material.
  46880. * @param defines the list of "defines" to update.
  46881. */
  46882. prepareDefines(defines: IMaterialBRDFDefines): void;
  46883. /**
  46884. * Get the current class name of the texture useful for serialization or dynamic coding.
  46885. * @returns "PBRClearCoatConfiguration"
  46886. */
  46887. getClassName(): string;
  46888. /**
  46889. * Makes a duplicate of the current configuration into another one.
  46890. * @param brdfConfiguration define the config where to copy the info
  46891. */
  46892. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  46893. /**
  46894. * Serializes this BRDF configuration.
  46895. * @returns - An object with the serialized config.
  46896. */
  46897. serialize(): any;
  46898. /**
  46899. * Parses a anisotropy Configuration from a serialized object.
  46900. * @param source - Serialized object.
  46901. * @param scene Defines the scene we are parsing for
  46902. * @param rootUrl Defines the rootUrl to load from
  46903. */
  46904. parse(source: any, scene: Scene, rootUrl: string): void;
  46905. }
  46906. }
  46907. declare module BABYLON {
  46908. /**
  46909. * @hidden
  46910. */
  46911. export interface IMaterialSheenDefines {
  46912. SHEEN: boolean;
  46913. SHEEN_TEXTURE: boolean;
  46914. SHEEN_TEXTUREDIRECTUV: number;
  46915. SHEEN_LINKWITHALBEDO: boolean;
  46916. /** @hidden */
  46917. _areTexturesDirty: boolean;
  46918. }
  46919. /**
  46920. * Define the code related to the Sheen parameters of the pbr material.
  46921. */
  46922. export class PBRSheenConfiguration {
  46923. private _isEnabled;
  46924. /**
  46925. * Defines if the material uses sheen.
  46926. */
  46927. isEnabled: boolean;
  46928. private _linkSheenWithAlbedo;
  46929. /**
  46930. * Defines if the sheen is linked to the sheen color.
  46931. */
  46932. linkSheenWithAlbedo: boolean;
  46933. /**
  46934. * Defines the sheen intensity.
  46935. */
  46936. intensity: number;
  46937. /**
  46938. * Defines the sheen color.
  46939. */
  46940. color: Color3;
  46941. private _texture;
  46942. /**
  46943. * Stores the sheen tint values in a texture.
  46944. * rgb is tint
  46945. * a is a intensity
  46946. */
  46947. texture: Nullable<BaseTexture>;
  46948. /** @hidden */
  46949. private _internalMarkAllSubMeshesAsTexturesDirty;
  46950. /** @hidden */
  46951. _markAllSubMeshesAsTexturesDirty(): void;
  46952. /**
  46953. * Instantiate a new istance of clear coat configuration.
  46954. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  46955. */
  46956. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  46957. /**
  46958. * Specifies that the submesh is ready to be used.
  46959. * @param defines the list of "defines" to update.
  46960. * @param scene defines the scene the material belongs to.
  46961. * @returns - boolean indicating that the submesh is ready or not.
  46962. */
  46963. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  46964. /**
  46965. * Checks to see if a texture is used in the material.
  46966. * @param defines the list of "defines" to update.
  46967. * @param scene defines the scene the material belongs to.
  46968. */
  46969. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  46970. /**
  46971. * Binds the material data.
  46972. * @param uniformBuffer defines the Uniform buffer to fill in.
  46973. * @param scene defines the scene the material belongs to.
  46974. * @param isFrozen defines wether the material is frozen or not.
  46975. */
  46976. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  46977. /**
  46978. * Checks to see if a texture is used in the material.
  46979. * @param texture - Base texture to use.
  46980. * @returns - Boolean specifying if a texture is used in the material.
  46981. */
  46982. hasTexture(texture: BaseTexture): boolean;
  46983. /**
  46984. * Returns an array of the actively used textures.
  46985. * @param activeTextures Array of BaseTextures
  46986. */
  46987. getActiveTextures(activeTextures: BaseTexture[]): void;
  46988. /**
  46989. * Returns the animatable textures.
  46990. * @param animatables Array of animatable textures.
  46991. */
  46992. getAnimatables(animatables: IAnimatable[]): void;
  46993. /**
  46994. * Disposes the resources of the material.
  46995. * @param forceDisposeTextures - Forces the disposal of all textures.
  46996. */
  46997. dispose(forceDisposeTextures?: boolean): void;
  46998. /**
  46999. * Get the current class name of the texture useful for serialization or dynamic coding.
  47000. * @returns "PBRSheenConfiguration"
  47001. */
  47002. getClassName(): string;
  47003. /**
  47004. * Add fallbacks to the effect fallbacks list.
  47005. * @param defines defines the Base texture to use.
  47006. * @param fallbacks defines the current fallback list.
  47007. * @param currentRank defines the current fallback rank.
  47008. * @returns the new fallback rank.
  47009. */
  47010. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  47011. /**
  47012. * Add the required uniforms to the current list.
  47013. * @param uniforms defines the current uniform list.
  47014. */
  47015. static AddUniforms(uniforms: string[]): void;
  47016. /**
  47017. * Add the required uniforms to the current buffer.
  47018. * @param uniformBuffer defines the current uniform buffer.
  47019. */
  47020. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  47021. /**
  47022. * Add the required samplers to the current list.
  47023. * @param samplers defines the current sampler list.
  47024. */
  47025. static AddSamplers(samplers: string[]): void;
  47026. /**
  47027. * Makes a duplicate of the current configuration into another one.
  47028. * @param sheenConfiguration define the config where to copy the info
  47029. */
  47030. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  47031. /**
  47032. * Serializes this BRDF configuration.
  47033. * @returns - An object with the serialized config.
  47034. */
  47035. serialize(): any;
  47036. /**
  47037. * Parses a anisotropy Configuration from a serialized object.
  47038. * @param source - Serialized object.
  47039. * @param scene Defines the scene we are parsing for
  47040. * @param rootUrl Defines the rootUrl to load from
  47041. */
  47042. parse(source: any, scene: Scene, rootUrl: string): void;
  47043. }
  47044. }
  47045. declare module BABYLON {
  47046. /**
  47047. * @hidden
  47048. */
  47049. export interface IMaterialSubSurfaceDefines {
  47050. SUBSURFACE: boolean;
  47051. SS_REFRACTION: boolean;
  47052. SS_TRANSLUCENCY: boolean;
  47053. SS_SCATERRING: boolean;
  47054. SS_THICKNESSANDMASK_TEXTURE: boolean;
  47055. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  47056. SS_REFRACTIONMAP_3D: boolean;
  47057. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  47058. SS_LODINREFRACTIONALPHA: boolean;
  47059. SS_GAMMAREFRACTION: boolean;
  47060. SS_RGBDREFRACTION: boolean;
  47061. SS_LINEARSPECULARREFRACTION: boolean;
  47062. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  47063. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  47064. /** @hidden */
  47065. _areTexturesDirty: boolean;
  47066. }
  47067. /**
  47068. * Define the code related to the sub surface parameters of the pbr material.
  47069. */
  47070. export class PBRSubSurfaceConfiguration {
  47071. private _isRefractionEnabled;
  47072. /**
  47073. * Defines if the refraction is enabled in the material.
  47074. */
  47075. isRefractionEnabled: boolean;
  47076. private _isTranslucencyEnabled;
  47077. /**
  47078. * Defines if the translucency is enabled in the material.
  47079. */
  47080. isTranslucencyEnabled: boolean;
  47081. private _isScatteringEnabled;
  47082. /**
  47083. * Defines the refraction intensity of the material.
  47084. * The refraction when enabled replaces the Diffuse part of the material.
  47085. * The intensity helps transitionning between diffuse and refraction.
  47086. */
  47087. refractionIntensity: number;
  47088. /**
  47089. * Defines the translucency intensity of the material.
  47090. * When translucency has been enabled, this defines how much of the "translucency"
  47091. * is addded to the diffuse part of the material.
  47092. */
  47093. translucencyIntensity: number;
  47094. /**
  47095. * Defines the scattering intensity of the material.
  47096. * When scattering has been enabled, this defines how much of the "scattered light"
  47097. * is addded to the diffuse part of the material.
  47098. */
  47099. scatteringIntensity: number;
  47100. private _thicknessTexture;
  47101. /**
  47102. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  47103. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  47104. * 0 would mean minimumThickness
  47105. * 1 would mean maximumThickness
  47106. * The other channels might be use as a mask to vary the different effects intensity.
  47107. */
  47108. thicknessTexture: Nullable<BaseTexture>;
  47109. private _refractionTexture;
  47110. /**
  47111. * Defines the texture to use for refraction.
  47112. */
  47113. refractionTexture: Nullable<BaseTexture>;
  47114. private _indexOfRefraction;
  47115. /**
  47116. * Defines the index of refraction used in the material.
  47117. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  47118. */
  47119. indexOfRefraction: number;
  47120. private _invertRefractionY;
  47121. /**
  47122. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  47123. */
  47124. invertRefractionY: boolean;
  47125. private _linkRefractionWithTransparency;
  47126. /**
  47127. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  47128. * Materials half opaque for instance using refraction could benefit from this control.
  47129. */
  47130. linkRefractionWithTransparency: boolean;
  47131. /**
  47132. * Defines the minimum thickness stored in the thickness map.
  47133. * If no thickness map is defined, this value will be used to simulate thickness.
  47134. */
  47135. minimumThickness: number;
  47136. /**
  47137. * Defines the maximum thickness stored in the thickness map.
  47138. */
  47139. maximumThickness: number;
  47140. /**
  47141. * Defines the volume tint of the material.
  47142. * This is used for both translucency and scattering.
  47143. */
  47144. tintColor: Color3;
  47145. /**
  47146. * Defines the distance at which the tint color should be found in the media.
  47147. * This is used for refraction only.
  47148. */
  47149. tintColorAtDistance: number;
  47150. /**
  47151. * Defines how far each channel transmit through the media.
  47152. * It is defined as a color to simplify it selection.
  47153. */
  47154. diffusionDistance: Color3;
  47155. private _useMaskFromThicknessTexture;
  47156. /**
  47157. * Stores the intensity of the different subsurface effects in the thickness texture.
  47158. * * the green channel is the translucency intensity.
  47159. * * the blue channel is the scattering intensity.
  47160. * * the alpha channel is the refraction intensity.
  47161. */
  47162. useMaskFromThicknessTexture: boolean;
  47163. /** @hidden */
  47164. private _internalMarkAllSubMeshesAsTexturesDirty;
  47165. /** @hidden */
  47166. _markAllSubMeshesAsTexturesDirty(): void;
  47167. /**
  47168. * Instantiate a new istance of sub surface configuration.
  47169. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  47170. */
  47171. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  47172. /**
  47173. * Gets wehter the submesh is ready to be used or not.
  47174. * @param defines the list of "defines" to update.
  47175. * @param scene defines the scene the material belongs to.
  47176. * @returns - boolean indicating that the submesh is ready or not.
  47177. */
  47178. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  47179. /**
  47180. * Checks to see if a texture is used in the material.
  47181. * @param defines the list of "defines" to update.
  47182. * @param scene defines the scene to the material belongs to.
  47183. */
  47184. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  47185. /**
  47186. * Binds the material data.
  47187. * @param uniformBuffer defines the Uniform buffer to fill in.
  47188. * @param scene defines the scene the material belongs to.
  47189. * @param engine defines the engine the material belongs to.
  47190. * @param isFrozen defines wether the material is frozen or not.
  47191. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  47192. */
  47193. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  47194. /**
  47195. * Unbinds the material from the mesh.
  47196. * @param activeEffect defines the effect that should be unbound from.
  47197. * @returns true if unbound, otherwise false
  47198. */
  47199. unbind(activeEffect: Effect): boolean;
  47200. /**
  47201. * Returns the texture used for refraction or null if none is used.
  47202. * @param scene defines the scene the material belongs to.
  47203. * @returns - Refraction texture if present. If no refraction texture and refraction
  47204. * is linked with transparency, returns environment texture. Otherwise, returns null.
  47205. */
  47206. private _getRefractionTexture;
  47207. /**
  47208. * Returns true if alpha blending should be disabled.
  47209. */
  47210. readonly disableAlphaBlending: boolean;
  47211. /**
  47212. * Fills the list of render target textures.
  47213. * @param renderTargets the list of render targets to update
  47214. */
  47215. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  47216. /**
  47217. * Checks to see if a texture is used in the material.
  47218. * @param texture - Base texture to use.
  47219. * @returns - Boolean specifying if a texture is used in the material.
  47220. */
  47221. hasTexture(texture: BaseTexture): boolean;
  47222. /**
  47223. * Gets a boolean indicating that current material needs to register RTT
  47224. * @returns true if this uses a render target otherwise false.
  47225. */
  47226. hasRenderTargetTextures(): boolean;
  47227. /**
  47228. * Returns an array of the actively used textures.
  47229. * @param activeTextures Array of BaseTextures
  47230. */
  47231. getActiveTextures(activeTextures: BaseTexture[]): void;
  47232. /**
  47233. * Returns the animatable textures.
  47234. * @param animatables Array of animatable textures.
  47235. */
  47236. getAnimatables(animatables: IAnimatable[]): void;
  47237. /**
  47238. * Disposes the resources of the material.
  47239. * @param forceDisposeTextures - Forces the disposal of all textures.
  47240. */
  47241. dispose(forceDisposeTextures?: boolean): void;
  47242. /**
  47243. * Get the current class name of the texture useful for serialization or dynamic coding.
  47244. * @returns "PBRSubSurfaceConfiguration"
  47245. */
  47246. getClassName(): string;
  47247. /**
  47248. * Add fallbacks to the effect fallbacks list.
  47249. * @param defines defines the Base texture to use.
  47250. * @param fallbacks defines the current fallback list.
  47251. * @param currentRank defines the current fallback rank.
  47252. * @returns the new fallback rank.
  47253. */
  47254. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  47255. /**
  47256. * Add the required uniforms to the current list.
  47257. * @param uniforms defines the current uniform list.
  47258. */
  47259. static AddUniforms(uniforms: string[]): void;
  47260. /**
  47261. * Add the required samplers to the current list.
  47262. * @param samplers defines the current sampler list.
  47263. */
  47264. static AddSamplers(samplers: string[]): void;
  47265. /**
  47266. * Add the required uniforms to the current buffer.
  47267. * @param uniformBuffer defines the current uniform buffer.
  47268. */
  47269. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  47270. /**
  47271. * Makes a duplicate of the current configuration into another one.
  47272. * @param configuration define the config where to copy the info
  47273. */
  47274. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  47275. /**
  47276. * Serializes this Sub Surface configuration.
  47277. * @returns - An object with the serialized config.
  47278. */
  47279. serialize(): any;
  47280. /**
  47281. * Parses a anisotropy Configuration from a serialized object.
  47282. * @param source - Serialized object.
  47283. * @param scene Defines the scene we are parsing for
  47284. * @param rootUrl Defines the rootUrl to load from
  47285. */
  47286. parse(source: any, scene: Scene, rootUrl: string): void;
  47287. }
  47288. }
  47289. declare module BABYLON {
  47290. /** @hidden */
  47291. export var pbrFragmentDeclaration: {
  47292. name: string;
  47293. shader: string;
  47294. };
  47295. }
  47296. declare module BABYLON {
  47297. /** @hidden */
  47298. export var pbrUboDeclaration: {
  47299. name: string;
  47300. shader: string;
  47301. };
  47302. }
  47303. declare module BABYLON {
  47304. /** @hidden */
  47305. export var pbrFragmentExtraDeclaration: {
  47306. name: string;
  47307. shader: string;
  47308. };
  47309. }
  47310. declare module BABYLON {
  47311. /** @hidden */
  47312. export var pbrFragmentSamplersDeclaration: {
  47313. name: string;
  47314. shader: string;
  47315. };
  47316. }
  47317. declare module BABYLON {
  47318. /** @hidden */
  47319. export var pbrHelperFunctions: {
  47320. name: string;
  47321. shader: string;
  47322. };
  47323. }
  47324. declare module BABYLON {
  47325. /** @hidden */
  47326. export var harmonicsFunctions: {
  47327. name: string;
  47328. shader: string;
  47329. };
  47330. }
  47331. declare module BABYLON {
  47332. /** @hidden */
  47333. export var pbrDirectLightingSetupFunctions: {
  47334. name: string;
  47335. shader: string;
  47336. };
  47337. }
  47338. declare module BABYLON {
  47339. /** @hidden */
  47340. export var pbrDirectLightingFalloffFunctions: {
  47341. name: string;
  47342. shader: string;
  47343. };
  47344. }
  47345. declare module BABYLON {
  47346. /** @hidden */
  47347. export var pbrBRDFFunctions: {
  47348. name: string;
  47349. shader: string;
  47350. };
  47351. }
  47352. declare module BABYLON {
  47353. /** @hidden */
  47354. export var pbrDirectLightingFunctions: {
  47355. name: string;
  47356. shader: string;
  47357. };
  47358. }
  47359. declare module BABYLON {
  47360. /** @hidden */
  47361. export var pbrIBLFunctions: {
  47362. name: string;
  47363. shader: string;
  47364. };
  47365. }
  47366. declare module BABYLON {
  47367. /** @hidden */
  47368. export var pbrDebug: {
  47369. name: string;
  47370. shader: string;
  47371. };
  47372. }
  47373. declare module BABYLON {
  47374. /** @hidden */
  47375. export var pbrPixelShader: {
  47376. name: string;
  47377. shader: string;
  47378. };
  47379. }
  47380. declare module BABYLON {
  47381. /** @hidden */
  47382. export var pbrVertexDeclaration: {
  47383. name: string;
  47384. shader: string;
  47385. };
  47386. }
  47387. declare module BABYLON {
  47388. /** @hidden */
  47389. export var pbrVertexShader: {
  47390. name: string;
  47391. shader: string;
  47392. };
  47393. }
  47394. declare module BABYLON {
  47395. /**
  47396. * Manages the defines for the PBR Material.
  47397. * @hidden
  47398. */
  47399. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  47400. PBR: boolean;
  47401. MAINUV1: boolean;
  47402. MAINUV2: boolean;
  47403. UV1: boolean;
  47404. UV2: boolean;
  47405. ALBEDO: boolean;
  47406. ALBEDODIRECTUV: number;
  47407. VERTEXCOLOR: boolean;
  47408. AMBIENT: boolean;
  47409. AMBIENTDIRECTUV: number;
  47410. AMBIENTINGRAYSCALE: boolean;
  47411. OPACITY: boolean;
  47412. VERTEXALPHA: boolean;
  47413. OPACITYDIRECTUV: number;
  47414. OPACITYRGB: boolean;
  47415. ALPHATEST: boolean;
  47416. DEPTHPREPASS: boolean;
  47417. ALPHABLEND: boolean;
  47418. ALPHAFROMALBEDO: boolean;
  47419. ALPHATESTVALUE: string;
  47420. SPECULAROVERALPHA: boolean;
  47421. RADIANCEOVERALPHA: boolean;
  47422. ALPHAFRESNEL: boolean;
  47423. LINEARALPHAFRESNEL: boolean;
  47424. PREMULTIPLYALPHA: boolean;
  47425. EMISSIVE: boolean;
  47426. EMISSIVEDIRECTUV: number;
  47427. REFLECTIVITY: boolean;
  47428. REFLECTIVITYDIRECTUV: number;
  47429. SPECULARTERM: boolean;
  47430. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  47431. MICROSURFACEAUTOMATIC: boolean;
  47432. LODBASEDMICROSFURACE: boolean;
  47433. MICROSURFACEMAP: boolean;
  47434. MICROSURFACEMAPDIRECTUV: number;
  47435. METALLICWORKFLOW: boolean;
  47436. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  47437. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  47438. METALLNESSSTOREINMETALMAPBLUE: boolean;
  47439. AOSTOREINMETALMAPRED: boolean;
  47440. ENVIRONMENTBRDF: boolean;
  47441. ENVIRONMENTBRDF_RGBD: boolean;
  47442. NORMAL: boolean;
  47443. TANGENT: boolean;
  47444. BUMP: boolean;
  47445. BUMPDIRECTUV: number;
  47446. OBJECTSPACE_NORMALMAP: boolean;
  47447. PARALLAX: boolean;
  47448. PARALLAXOCCLUSION: boolean;
  47449. NORMALXYSCALE: boolean;
  47450. LIGHTMAP: boolean;
  47451. LIGHTMAPDIRECTUV: number;
  47452. USELIGHTMAPASSHADOWMAP: boolean;
  47453. GAMMALIGHTMAP: boolean;
  47454. RGBDLIGHTMAP: boolean;
  47455. REFLECTION: boolean;
  47456. REFLECTIONMAP_3D: boolean;
  47457. REFLECTIONMAP_SPHERICAL: boolean;
  47458. REFLECTIONMAP_PLANAR: boolean;
  47459. REFLECTIONMAP_CUBIC: boolean;
  47460. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  47461. REFLECTIONMAP_PROJECTION: boolean;
  47462. REFLECTIONMAP_SKYBOX: boolean;
  47463. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  47464. REFLECTIONMAP_EXPLICIT: boolean;
  47465. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  47466. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  47467. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  47468. INVERTCUBICMAP: boolean;
  47469. USESPHERICALFROMREFLECTIONMAP: boolean;
  47470. USEIRRADIANCEMAP: boolean;
  47471. SPHERICAL_HARMONICS: boolean;
  47472. USESPHERICALINVERTEX: boolean;
  47473. REFLECTIONMAP_OPPOSITEZ: boolean;
  47474. LODINREFLECTIONALPHA: boolean;
  47475. GAMMAREFLECTION: boolean;
  47476. RGBDREFLECTION: boolean;
  47477. LINEARSPECULARREFLECTION: boolean;
  47478. RADIANCEOCCLUSION: boolean;
  47479. HORIZONOCCLUSION: boolean;
  47480. INSTANCES: boolean;
  47481. NUM_BONE_INFLUENCERS: number;
  47482. BonesPerMesh: number;
  47483. BONETEXTURE: boolean;
  47484. NONUNIFORMSCALING: boolean;
  47485. MORPHTARGETS: boolean;
  47486. MORPHTARGETS_NORMAL: boolean;
  47487. MORPHTARGETS_TANGENT: boolean;
  47488. MORPHTARGETS_UV: boolean;
  47489. NUM_MORPH_INFLUENCERS: number;
  47490. IMAGEPROCESSING: boolean;
  47491. VIGNETTE: boolean;
  47492. VIGNETTEBLENDMODEMULTIPLY: boolean;
  47493. VIGNETTEBLENDMODEOPAQUE: boolean;
  47494. TONEMAPPING: boolean;
  47495. TONEMAPPING_ACES: boolean;
  47496. CONTRAST: boolean;
  47497. COLORCURVES: boolean;
  47498. COLORGRADING: boolean;
  47499. COLORGRADING3D: boolean;
  47500. SAMPLER3DGREENDEPTH: boolean;
  47501. SAMPLER3DBGRMAP: boolean;
  47502. IMAGEPROCESSINGPOSTPROCESS: boolean;
  47503. EXPOSURE: boolean;
  47504. MULTIVIEW: boolean;
  47505. USEPHYSICALLIGHTFALLOFF: boolean;
  47506. USEGLTFLIGHTFALLOFF: boolean;
  47507. TWOSIDEDLIGHTING: boolean;
  47508. SHADOWFLOAT: boolean;
  47509. CLIPPLANE: boolean;
  47510. CLIPPLANE2: boolean;
  47511. CLIPPLANE3: boolean;
  47512. CLIPPLANE4: boolean;
  47513. POINTSIZE: boolean;
  47514. FOG: boolean;
  47515. LOGARITHMICDEPTH: boolean;
  47516. FORCENORMALFORWARD: boolean;
  47517. SPECULARAA: boolean;
  47518. CLEARCOAT: boolean;
  47519. CLEARCOAT_DEFAULTIOR: boolean;
  47520. CLEARCOAT_TEXTURE: boolean;
  47521. CLEARCOAT_TEXTUREDIRECTUV: number;
  47522. CLEARCOAT_BUMP: boolean;
  47523. CLEARCOAT_BUMPDIRECTUV: number;
  47524. CLEARCOAT_TINT: boolean;
  47525. CLEARCOAT_TINT_TEXTURE: boolean;
  47526. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  47527. ANISOTROPIC: boolean;
  47528. ANISOTROPIC_TEXTURE: boolean;
  47529. ANISOTROPIC_TEXTUREDIRECTUV: number;
  47530. BRDF_V_HEIGHT_CORRELATED: boolean;
  47531. MS_BRDF_ENERGY_CONSERVATION: boolean;
  47532. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  47533. SHEEN: boolean;
  47534. SHEEN_TEXTURE: boolean;
  47535. SHEEN_TEXTUREDIRECTUV: number;
  47536. SHEEN_LINKWITHALBEDO: boolean;
  47537. SUBSURFACE: boolean;
  47538. SS_REFRACTION: boolean;
  47539. SS_TRANSLUCENCY: boolean;
  47540. SS_SCATERRING: boolean;
  47541. SS_THICKNESSANDMASK_TEXTURE: boolean;
  47542. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  47543. SS_REFRACTIONMAP_3D: boolean;
  47544. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  47545. SS_LODINREFRACTIONALPHA: boolean;
  47546. SS_GAMMAREFRACTION: boolean;
  47547. SS_RGBDREFRACTION: boolean;
  47548. SS_LINEARSPECULARREFRACTION: boolean;
  47549. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  47550. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  47551. UNLIT: boolean;
  47552. DEBUGMODE: number;
  47553. /**
  47554. * Initializes the PBR Material defines.
  47555. */
  47556. constructor();
  47557. /**
  47558. * Resets the PBR Material defines.
  47559. */
  47560. reset(): void;
  47561. }
  47562. /**
  47563. * The Physically based material base class of BJS.
  47564. *
  47565. * This offers the main features of a standard PBR material.
  47566. * For more information, please refer to the documentation :
  47567. * https://doc.babylonjs.com/how_to/physically_based_rendering
  47568. */
  47569. export abstract class PBRBaseMaterial extends PushMaterial {
  47570. /**
  47571. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  47572. */
  47573. static readonly PBRMATERIAL_OPAQUE: number;
  47574. /**
  47575. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  47576. */
  47577. static readonly PBRMATERIAL_ALPHATEST: number;
  47578. /**
  47579. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  47580. */
  47581. static readonly PBRMATERIAL_ALPHABLEND: number;
  47582. /**
  47583. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  47584. * They are also discarded below the alpha cutoff threshold to improve performances.
  47585. */
  47586. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  47587. /**
  47588. * Defines the default value of how much AO map is occluding the analytical lights
  47589. * (point spot...).
  47590. */
  47591. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  47592. /**
  47593. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  47594. */
  47595. static readonly LIGHTFALLOFF_PHYSICAL: number;
  47596. /**
  47597. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  47598. * to enhance interoperability with other engines.
  47599. */
  47600. static readonly LIGHTFALLOFF_GLTF: number;
  47601. /**
  47602. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  47603. * to enhance interoperability with other materials.
  47604. */
  47605. static readonly LIGHTFALLOFF_STANDARD: number;
  47606. /**
  47607. * Intensity of the direct lights e.g. the four lights available in your scene.
  47608. * This impacts both the direct diffuse and specular highlights.
  47609. */
  47610. protected _directIntensity: number;
  47611. /**
  47612. * Intensity of the emissive part of the material.
  47613. * This helps controlling the emissive effect without modifying the emissive color.
  47614. */
  47615. protected _emissiveIntensity: number;
  47616. /**
  47617. * Intensity of the environment e.g. how much the environment will light the object
  47618. * either through harmonics for rough material or through the refelction for shiny ones.
  47619. */
  47620. protected _environmentIntensity: number;
  47621. /**
  47622. * This is a special control allowing the reduction of the specular highlights coming from the
  47623. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  47624. */
  47625. protected _specularIntensity: number;
  47626. /**
  47627. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  47628. */
  47629. private _lightingInfos;
  47630. /**
  47631. * Debug Control allowing disabling the bump map on this material.
  47632. */
  47633. protected _disableBumpMap: boolean;
  47634. /**
  47635. * AKA Diffuse Texture in standard nomenclature.
  47636. */
  47637. protected _albedoTexture: Nullable<BaseTexture>;
  47638. /**
  47639. * AKA Occlusion Texture in other nomenclature.
  47640. */
  47641. protected _ambientTexture: Nullable<BaseTexture>;
  47642. /**
  47643. * AKA Occlusion Texture Intensity in other nomenclature.
  47644. */
  47645. protected _ambientTextureStrength: number;
  47646. /**
  47647. * Defines how much the AO map is occluding the analytical lights (point spot...).
  47648. * 1 means it completely occludes it
  47649. * 0 mean it has no impact
  47650. */
  47651. protected _ambientTextureImpactOnAnalyticalLights: number;
  47652. /**
  47653. * Stores the alpha values in a texture.
  47654. */
  47655. protected _opacityTexture: Nullable<BaseTexture>;
  47656. /**
  47657. * Stores the reflection values in a texture.
  47658. */
  47659. protected _reflectionTexture: Nullable<BaseTexture>;
  47660. /**
  47661. * Stores the emissive values in a texture.
  47662. */
  47663. protected _emissiveTexture: Nullable<BaseTexture>;
  47664. /**
  47665. * AKA Specular texture in other nomenclature.
  47666. */
  47667. protected _reflectivityTexture: Nullable<BaseTexture>;
  47668. /**
  47669. * Used to switch from specular/glossiness to metallic/roughness workflow.
  47670. */
  47671. protected _metallicTexture: Nullable<BaseTexture>;
  47672. /**
  47673. * Specifies the metallic scalar of the metallic/roughness workflow.
  47674. * Can also be used to scale the metalness values of the metallic texture.
  47675. */
  47676. protected _metallic: Nullable<number>;
  47677. /**
  47678. * Specifies the roughness scalar of the metallic/roughness workflow.
  47679. * Can also be used to scale the roughness values of the metallic texture.
  47680. */
  47681. protected _roughness: Nullable<number>;
  47682. /**
  47683. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  47684. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  47685. */
  47686. protected _microSurfaceTexture: Nullable<BaseTexture>;
  47687. /**
  47688. * Stores surface normal data used to displace a mesh in a texture.
  47689. */
  47690. protected _bumpTexture: Nullable<BaseTexture>;
  47691. /**
  47692. * Stores the pre-calculated light information of a mesh in a texture.
  47693. */
  47694. protected _lightmapTexture: Nullable<BaseTexture>;
  47695. /**
  47696. * The color of a material in ambient lighting.
  47697. */
  47698. protected _ambientColor: Color3;
  47699. /**
  47700. * AKA Diffuse Color in other nomenclature.
  47701. */
  47702. protected _albedoColor: Color3;
  47703. /**
  47704. * AKA Specular Color in other nomenclature.
  47705. */
  47706. protected _reflectivityColor: Color3;
  47707. /**
  47708. * The color applied when light is reflected from a material.
  47709. */
  47710. protected _reflectionColor: Color3;
  47711. /**
  47712. * The color applied when light is emitted from a material.
  47713. */
  47714. protected _emissiveColor: Color3;
  47715. /**
  47716. * AKA Glossiness in other nomenclature.
  47717. */
  47718. protected _microSurface: number;
  47719. /**
  47720. * Specifies that the material will use the light map as a show map.
  47721. */
  47722. protected _useLightmapAsShadowmap: boolean;
  47723. /**
  47724. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  47725. * makes the reflect vector face the model (under horizon).
  47726. */
  47727. protected _useHorizonOcclusion: boolean;
  47728. /**
  47729. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  47730. * too much the area relying on ambient texture to define their ambient occlusion.
  47731. */
  47732. protected _useRadianceOcclusion: boolean;
  47733. /**
  47734. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  47735. */
  47736. protected _useAlphaFromAlbedoTexture: boolean;
  47737. /**
  47738. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  47739. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  47740. */
  47741. protected _useSpecularOverAlpha: boolean;
  47742. /**
  47743. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  47744. */
  47745. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  47746. /**
  47747. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  47748. */
  47749. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  47750. /**
  47751. * Specifies if the metallic texture contains the roughness information in its green channel.
  47752. */
  47753. protected _useRoughnessFromMetallicTextureGreen: boolean;
  47754. /**
  47755. * Specifies if the metallic texture contains the metallness information in its blue channel.
  47756. */
  47757. protected _useMetallnessFromMetallicTextureBlue: boolean;
  47758. /**
  47759. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  47760. */
  47761. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  47762. /**
  47763. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  47764. */
  47765. protected _useAmbientInGrayScale: boolean;
  47766. /**
  47767. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  47768. * The material will try to infer what glossiness each pixel should be.
  47769. */
  47770. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  47771. /**
  47772. * Defines the falloff type used in this material.
  47773. * It by default is Physical.
  47774. */
  47775. protected _lightFalloff: number;
  47776. /**
  47777. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  47778. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  47779. */
  47780. protected _useRadianceOverAlpha: boolean;
  47781. /**
  47782. * Allows using an object space normal map (instead of tangent space).
  47783. */
  47784. protected _useObjectSpaceNormalMap: boolean;
  47785. /**
  47786. * Allows using the bump map in parallax mode.
  47787. */
  47788. protected _useParallax: boolean;
  47789. /**
  47790. * Allows using the bump map in parallax occlusion mode.
  47791. */
  47792. protected _useParallaxOcclusion: boolean;
  47793. /**
  47794. * Controls the scale bias of the parallax mode.
  47795. */
  47796. protected _parallaxScaleBias: number;
  47797. /**
  47798. * If sets to true, disables all the lights affecting the material.
  47799. */
  47800. protected _disableLighting: boolean;
  47801. /**
  47802. * Number of Simultaneous lights allowed on the material.
  47803. */
  47804. protected _maxSimultaneousLights: number;
  47805. /**
  47806. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  47807. */
  47808. protected _invertNormalMapX: boolean;
  47809. /**
  47810. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  47811. */
  47812. protected _invertNormalMapY: boolean;
  47813. /**
  47814. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  47815. */
  47816. protected _twoSidedLighting: boolean;
  47817. /**
  47818. * Defines the alpha limits in alpha test mode.
  47819. */
  47820. protected _alphaCutOff: number;
  47821. /**
  47822. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  47823. */
  47824. protected _forceAlphaTest: boolean;
  47825. /**
  47826. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  47827. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  47828. */
  47829. protected _useAlphaFresnel: boolean;
  47830. /**
  47831. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  47832. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  47833. */
  47834. protected _useLinearAlphaFresnel: boolean;
  47835. /**
  47836. * The transparency mode of the material.
  47837. */
  47838. protected _transparencyMode: Nullable<number>;
  47839. /**
  47840. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  47841. * from cos thetav and roughness:
  47842. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  47843. */
  47844. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  47845. /**
  47846. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  47847. */
  47848. protected _forceIrradianceInFragment: boolean;
  47849. /**
  47850. * Force normal to face away from face.
  47851. */
  47852. protected _forceNormalForward: boolean;
  47853. /**
  47854. * Enables specular anti aliasing in the PBR shader.
  47855. * It will both interacts on the Geometry for analytical and IBL lighting.
  47856. * It also prefilter the roughness map based on the bump values.
  47857. */
  47858. protected _enableSpecularAntiAliasing: boolean;
  47859. /**
  47860. * Default configuration related to image processing available in the PBR Material.
  47861. */
  47862. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  47863. /**
  47864. * Keep track of the image processing observer to allow dispose and replace.
  47865. */
  47866. private _imageProcessingObserver;
  47867. /**
  47868. * Attaches a new image processing configuration to the PBR Material.
  47869. * @param configuration
  47870. */
  47871. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  47872. /**
  47873. * Stores the available render targets.
  47874. */
  47875. private _renderTargets;
  47876. /**
  47877. * Sets the global ambient color for the material used in lighting calculations.
  47878. */
  47879. private _globalAmbientColor;
  47880. /**
  47881. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  47882. */
  47883. private _useLogarithmicDepth;
  47884. /**
  47885. * If set to true, no lighting calculations will be applied.
  47886. */
  47887. private _unlit;
  47888. private _debugMode;
  47889. /**
  47890. * @hidden
  47891. * This is reserved for the inspector.
  47892. * Defines the material debug mode.
  47893. * It helps seeing only some components of the material while troubleshooting.
  47894. */
  47895. debugMode: number;
  47896. /**
  47897. * @hidden
  47898. * This is reserved for the inspector.
  47899. * Specify from where on screen the debug mode should start.
  47900. * The value goes from -1 (full screen) to 1 (not visible)
  47901. * It helps with side by side comparison against the final render
  47902. * This defaults to -1
  47903. */
  47904. private debugLimit;
  47905. /**
  47906. * @hidden
  47907. * This is reserved for the inspector.
  47908. * As the default viewing range might not be enough (if the ambient is really small for instance)
  47909. * You can use the factor to better multiply the final value.
  47910. */
  47911. private debugFactor;
  47912. /**
  47913. * Defines the clear coat layer parameters for the material.
  47914. */
  47915. readonly clearCoat: PBRClearCoatConfiguration;
  47916. /**
  47917. * Defines the anisotropic parameters for the material.
  47918. */
  47919. readonly anisotropy: PBRAnisotropicConfiguration;
  47920. /**
  47921. * Defines the BRDF parameters for the material.
  47922. */
  47923. readonly brdf: PBRBRDFConfiguration;
  47924. /**
  47925. * Defines the Sheen parameters for the material.
  47926. */
  47927. readonly sheen: PBRSheenConfiguration;
  47928. /**
  47929. * Defines the SubSurface parameters for the material.
  47930. */
  47931. readonly subSurface: PBRSubSurfaceConfiguration;
  47932. /**
  47933. * Custom callback helping to override the default shader used in the material.
  47934. */
  47935. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  47936. protected _rebuildInParallel: boolean;
  47937. /**
  47938. * Instantiates a new PBRMaterial instance.
  47939. *
  47940. * @param name The material name
  47941. * @param scene The scene the material will be use in.
  47942. */
  47943. constructor(name: string, scene: Scene);
  47944. /**
  47945. * Gets a boolean indicating that current material needs to register RTT
  47946. */
  47947. readonly hasRenderTargetTextures: boolean;
  47948. /**
  47949. * Gets the name of the material class.
  47950. */
  47951. getClassName(): string;
  47952. /**
  47953. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  47954. */
  47955. /**
  47956. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  47957. */
  47958. useLogarithmicDepth: boolean;
  47959. /**
  47960. * Gets the current transparency mode.
  47961. */
  47962. /**
  47963. * Sets the transparency mode of the material.
  47964. *
  47965. * | Value | Type | Description |
  47966. * | ----- | ----------------------------------- | ----------- |
  47967. * | 0 | OPAQUE | |
  47968. * | 1 | ALPHATEST | |
  47969. * | 2 | ALPHABLEND | |
  47970. * | 3 | ALPHATESTANDBLEND | |
  47971. *
  47972. */
  47973. transparencyMode: Nullable<number>;
  47974. /**
  47975. * Returns true if alpha blending should be disabled.
  47976. */
  47977. private readonly _disableAlphaBlending;
  47978. /**
  47979. * Specifies whether or not this material should be rendered in alpha blend mode.
  47980. */
  47981. needAlphaBlending(): boolean;
  47982. /**
  47983. * Specifies if the mesh will require alpha blending.
  47984. * @param mesh - BJS mesh.
  47985. */
  47986. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  47987. /**
  47988. * Specifies whether or not this material should be rendered in alpha test mode.
  47989. */
  47990. needAlphaTesting(): boolean;
  47991. /**
  47992. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  47993. */
  47994. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  47995. /**
  47996. * Gets the texture used for the alpha test.
  47997. */
  47998. getAlphaTestTexture(): Nullable<BaseTexture>;
  47999. /**
  48000. * Specifies that the submesh is ready to be used.
  48001. * @param mesh - BJS mesh.
  48002. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  48003. * @param useInstances - Specifies that instances should be used.
  48004. * @returns - boolean indicating that the submesh is ready or not.
  48005. */
  48006. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  48007. /**
  48008. * Specifies if the material uses metallic roughness workflow.
  48009. * @returns boolean specifiying if the material uses metallic roughness workflow.
  48010. */
  48011. isMetallicWorkflow(): boolean;
  48012. private _prepareEffect;
  48013. private _prepareDefines;
  48014. /**
  48015. * Force shader compilation
  48016. */
  48017. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  48018. clipPlane: boolean;
  48019. }>): void;
  48020. /**
  48021. * Initializes the uniform buffer layout for the shader.
  48022. */
  48023. buildUniformLayout(): void;
  48024. /**
  48025. * Unbinds the material from the mesh
  48026. */
  48027. unbind(): void;
  48028. /**
  48029. * Binds the submesh data.
  48030. * @param world - The world matrix.
  48031. * @param mesh - The BJS mesh.
  48032. * @param subMesh - A submesh of the BJS mesh.
  48033. */
  48034. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  48035. /**
  48036. * Returns the animatable textures.
  48037. * @returns - Array of animatable textures.
  48038. */
  48039. getAnimatables(): IAnimatable[];
  48040. /**
  48041. * Returns the texture used for reflections.
  48042. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  48043. */
  48044. private _getReflectionTexture;
  48045. /**
  48046. * Returns an array of the actively used textures.
  48047. * @returns - Array of BaseTextures
  48048. */
  48049. getActiveTextures(): BaseTexture[];
  48050. /**
  48051. * Checks to see if a texture is used in the material.
  48052. * @param texture - Base texture to use.
  48053. * @returns - Boolean specifying if a texture is used in the material.
  48054. */
  48055. hasTexture(texture: BaseTexture): boolean;
  48056. /**
  48057. * Disposes the resources of the material.
  48058. * @param forceDisposeEffect - Forces the disposal of effects.
  48059. * @param forceDisposeTextures - Forces the disposal of all textures.
  48060. */
  48061. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  48062. }
  48063. }
  48064. declare module BABYLON {
  48065. /**
  48066. * The Physically based material of BJS.
  48067. *
  48068. * This offers the main features of a standard PBR material.
  48069. * For more information, please refer to the documentation :
  48070. * https://doc.babylonjs.com/how_to/physically_based_rendering
  48071. */
  48072. export class PBRMaterial extends PBRBaseMaterial {
  48073. /**
  48074. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  48075. */
  48076. static readonly PBRMATERIAL_OPAQUE: number;
  48077. /**
  48078. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  48079. */
  48080. static readonly PBRMATERIAL_ALPHATEST: number;
  48081. /**
  48082. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  48083. */
  48084. static readonly PBRMATERIAL_ALPHABLEND: number;
  48085. /**
  48086. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  48087. * They are also discarded below the alpha cutoff threshold to improve performances.
  48088. */
  48089. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  48090. /**
  48091. * Defines the default value of how much AO map is occluding the analytical lights
  48092. * (point spot...).
  48093. */
  48094. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  48095. /**
  48096. * Intensity of the direct lights e.g. the four lights available in your scene.
  48097. * This impacts both the direct diffuse and specular highlights.
  48098. */
  48099. directIntensity: number;
  48100. /**
  48101. * Intensity of the emissive part of the material.
  48102. * This helps controlling the emissive effect without modifying the emissive color.
  48103. */
  48104. emissiveIntensity: number;
  48105. /**
  48106. * Intensity of the environment e.g. how much the environment will light the object
  48107. * either through harmonics for rough material or through the refelction for shiny ones.
  48108. */
  48109. environmentIntensity: number;
  48110. /**
  48111. * This is a special control allowing the reduction of the specular highlights coming from the
  48112. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  48113. */
  48114. specularIntensity: number;
  48115. /**
  48116. * Debug Control allowing disabling the bump map on this material.
  48117. */
  48118. disableBumpMap: boolean;
  48119. /**
  48120. * AKA Diffuse Texture in standard nomenclature.
  48121. */
  48122. albedoTexture: BaseTexture;
  48123. /**
  48124. * AKA Occlusion Texture in other nomenclature.
  48125. */
  48126. ambientTexture: BaseTexture;
  48127. /**
  48128. * AKA Occlusion Texture Intensity in other nomenclature.
  48129. */
  48130. ambientTextureStrength: number;
  48131. /**
  48132. * Defines how much the AO map is occluding the analytical lights (point spot...).
  48133. * 1 means it completely occludes it
  48134. * 0 mean it has no impact
  48135. */
  48136. ambientTextureImpactOnAnalyticalLights: number;
  48137. /**
  48138. * Stores the alpha values in a texture.
  48139. */
  48140. opacityTexture: BaseTexture;
  48141. /**
  48142. * Stores the reflection values in a texture.
  48143. */
  48144. reflectionTexture: Nullable<BaseTexture>;
  48145. /**
  48146. * Stores the emissive values in a texture.
  48147. */
  48148. emissiveTexture: BaseTexture;
  48149. /**
  48150. * AKA Specular texture in other nomenclature.
  48151. */
  48152. reflectivityTexture: BaseTexture;
  48153. /**
  48154. * Used to switch from specular/glossiness to metallic/roughness workflow.
  48155. */
  48156. metallicTexture: BaseTexture;
  48157. /**
  48158. * Specifies the metallic scalar of the metallic/roughness workflow.
  48159. * Can also be used to scale the metalness values of the metallic texture.
  48160. */
  48161. metallic: Nullable<number>;
  48162. /**
  48163. * Specifies the roughness scalar of the metallic/roughness workflow.
  48164. * Can also be used to scale the roughness values of the metallic texture.
  48165. */
  48166. roughness: Nullable<number>;
  48167. /**
  48168. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  48169. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  48170. */
  48171. microSurfaceTexture: BaseTexture;
  48172. /**
  48173. * Stores surface normal data used to displace a mesh in a texture.
  48174. */
  48175. bumpTexture: BaseTexture;
  48176. /**
  48177. * Stores the pre-calculated light information of a mesh in a texture.
  48178. */
  48179. lightmapTexture: BaseTexture;
  48180. /**
  48181. * Stores the refracted light information in a texture.
  48182. */
  48183. refractionTexture: Nullable<BaseTexture>;
  48184. /**
  48185. * The color of a material in ambient lighting.
  48186. */
  48187. ambientColor: Color3;
  48188. /**
  48189. * AKA Diffuse Color in other nomenclature.
  48190. */
  48191. albedoColor: Color3;
  48192. /**
  48193. * AKA Specular Color in other nomenclature.
  48194. */
  48195. reflectivityColor: Color3;
  48196. /**
  48197. * The color reflected from the material.
  48198. */
  48199. reflectionColor: Color3;
  48200. /**
  48201. * The color emitted from the material.
  48202. */
  48203. emissiveColor: Color3;
  48204. /**
  48205. * AKA Glossiness in other nomenclature.
  48206. */
  48207. microSurface: number;
  48208. /**
  48209. * source material index of refraction (IOR)' / 'destination material IOR.
  48210. */
  48211. indexOfRefraction: number;
  48212. /**
  48213. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  48214. */
  48215. invertRefractionY: boolean;
  48216. /**
  48217. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  48218. * Materials half opaque for instance using refraction could benefit from this control.
  48219. */
  48220. linkRefractionWithTransparency: boolean;
  48221. /**
  48222. * If true, the light map contains occlusion information instead of lighting info.
  48223. */
  48224. useLightmapAsShadowmap: boolean;
  48225. /**
  48226. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  48227. */
  48228. useAlphaFromAlbedoTexture: boolean;
  48229. /**
  48230. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  48231. */
  48232. forceAlphaTest: boolean;
  48233. /**
  48234. * Defines the alpha limits in alpha test mode.
  48235. */
  48236. alphaCutOff: number;
  48237. /**
  48238. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  48239. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  48240. */
  48241. useSpecularOverAlpha: boolean;
  48242. /**
  48243. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  48244. */
  48245. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  48246. /**
  48247. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  48248. */
  48249. useRoughnessFromMetallicTextureAlpha: boolean;
  48250. /**
  48251. * Specifies if the metallic texture contains the roughness information in its green channel.
  48252. */
  48253. useRoughnessFromMetallicTextureGreen: boolean;
  48254. /**
  48255. * Specifies if the metallic texture contains the metallness information in its blue channel.
  48256. */
  48257. useMetallnessFromMetallicTextureBlue: boolean;
  48258. /**
  48259. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  48260. */
  48261. useAmbientOcclusionFromMetallicTextureRed: boolean;
  48262. /**
  48263. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  48264. */
  48265. useAmbientInGrayScale: boolean;
  48266. /**
  48267. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  48268. * The material will try to infer what glossiness each pixel should be.
  48269. */
  48270. useAutoMicroSurfaceFromReflectivityMap: boolean;
  48271. /**
  48272. * BJS is using an harcoded light falloff based on a manually sets up range.
  48273. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  48274. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  48275. */
  48276. /**
  48277. * BJS is using an harcoded light falloff based on a manually sets up range.
  48278. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  48279. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  48280. */
  48281. usePhysicalLightFalloff: boolean;
  48282. /**
  48283. * In order to support the falloff compatibility with gltf, a special mode has been added
  48284. * to reproduce the gltf light falloff.
  48285. */
  48286. /**
  48287. * In order to support the falloff compatibility with gltf, a special mode has been added
  48288. * to reproduce the gltf light falloff.
  48289. */
  48290. useGLTFLightFalloff: boolean;
  48291. /**
  48292. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  48293. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  48294. */
  48295. useRadianceOverAlpha: boolean;
  48296. /**
  48297. * Allows using an object space normal map (instead of tangent space).
  48298. */
  48299. useObjectSpaceNormalMap: boolean;
  48300. /**
  48301. * Allows using the bump map in parallax mode.
  48302. */
  48303. useParallax: boolean;
  48304. /**
  48305. * Allows using the bump map in parallax occlusion mode.
  48306. */
  48307. useParallaxOcclusion: boolean;
  48308. /**
  48309. * Controls the scale bias of the parallax mode.
  48310. */
  48311. parallaxScaleBias: number;
  48312. /**
  48313. * If sets to true, disables all the lights affecting the material.
  48314. */
  48315. disableLighting: boolean;
  48316. /**
  48317. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  48318. */
  48319. forceIrradianceInFragment: boolean;
  48320. /**
  48321. * Number of Simultaneous lights allowed on the material.
  48322. */
  48323. maxSimultaneousLights: number;
  48324. /**
  48325. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  48326. */
  48327. invertNormalMapX: boolean;
  48328. /**
  48329. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  48330. */
  48331. invertNormalMapY: boolean;
  48332. /**
  48333. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  48334. */
  48335. twoSidedLighting: boolean;
  48336. /**
  48337. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  48338. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  48339. */
  48340. useAlphaFresnel: boolean;
  48341. /**
  48342. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  48343. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  48344. */
  48345. useLinearAlphaFresnel: boolean;
  48346. /**
  48347. * Let user defines the brdf lookup texture used for IBL.
  48348. * A default 8bit version is embedded but you could point at :
  48349. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  48350. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  48351. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  48352. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  48353. */
  48354. environmentBRDFTexture: Nullable<BaseTexture>;
  48355. /**
  48356. * Force normal to face away from face.
  48357. */
  48358. forceNormalForward: boolean;
  48359. /**
  48360. * Enables specular anti aliasing in the PBR shader.
  48361. * It will both interacts on the Geometry for analytical and IBL lighting.
  48362. * It also prefilter the roughness map based on the bump values.
  48363. */
  48364. enableSpecularAntiAliasing: boolean;
  48365. /**
  48366. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  48367. * makes the reflect vector face the model (under horizon).
  48368. */
  48369. useHorizonOcclusion: boolean;
  48370. /**
  48371. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  48372. * too much the area relying on ambient texture to define their ambient occlusion.
  48373. */
  48374. useRadianceOcclusion: boolean;
  48375. /**
  48376. * If set to true, no lighting calculations will be applied.
  48377. */
  48378. unlit: boolean;
  48379. /**
  48380. * Gets the image processing configuration used either in this material.
  48381. */
  48382. /**
  48383. * Sets the Default image processing configuration used either in the this material.
  48384. *
  48385. * If sets to null, the scene one is in use.
  48386. */
  48387. imageProcessingConfiguration: ImageProcessingConfiguration;
  48388. /**
  48389. * Gets wether the color curves effect is enabled.
  48390. */
  48391. /**
  48392. * Sets wether the color curves effect is enabled.
  48393. */
  48394. cameraColorCurvesEnabled: boolean;
  48395. /**
  48396. * Gets wether the color grading effect is enabled.
  48397. */
  48398. /**
  48399. * Gets wether the color grading effect is enabled.
  48400. */
  48401. cameraColorGradingEnabled: boolean;
  48402. /**
  48403. * Gets wether tonemapping is enabled or not.
  48404. */
  48405. /**
  48406. * Sets wether tonemapping is enabled or not
  48407. */
  48408. cameraToneMappingEnabled: boolean;
  48409. /**
  48410. * The camera exposure used on this material.
  48411. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  48412. * This corresponds to a photographic exposure.
  48413. */
  48414. /**
  48415. * The camera exposure used on this material.
  48416. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  48417. * This corresponds to a photographic exposure.
  48418. */
  48419. cameraExposure: number;
  48420. /**
  48421. * Gets The camera contrast used on this material.
  48422. */
  48423. /**
  48424. * Sets The camera contrast used on this material.
  48425. */
  48426. cameraContrast: number;
  48427. /**
  48428. * Gets the Color Grading 2D Lookup Texture.
  48429. */
  48430. /**
  48431. * Sets the Color Grading 2D Lookup Texture.
  48432. */
  48433. cameraColorGradingTexture: Nullable<BaseTexture>;
  48434. /**
  48435. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  48436. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  48437. * 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;
  48438. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  48439. */
  48440. /**
  48441. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  48442. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  48443. * 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;
  48444. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  48445. */
  48446. cameraColorCurves: Nullable<ColorCurves>;
  48447. /**
  48448. * Instantiates a new PBRMaterial instance.
  48449. *
  48450. * @param name The material name
  48451. * @param scene The scene the material will be use in.
  48452. */
  48453. constructor(name: string, scene: Scene);
  48454. /**
  48455. * Returns the name of this material class.
  48456. */
  48457. getClassName(): string;
  48458. /**
  48459. * Makes a duplicate of the current material.
  48460. * @param name - name to use for the new material.
  48461. */
  48462. clone(name: string): PBRMaterial;
  48463. /**
  48464. * Serializes this PBR Material.
  48465. * @returns - An object with the serialized material.
  48466. */
  48467. serialize(): any;
  48468. /**
  48469. * Parses a PBR Material from a serialized object.
  48470. * @param source - Serialized object.
  48471. * @param scene - BJS scene instance.
  48472. * @param rootUrl - url for the scene object
  48473. * @returns - PBRMaterial
  48474. */
  48475. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  48476. }
  48477. }
  48478. declare module BABYLON {
  48479. /**
  48480. * Direct draw surface info
  48481. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  48482. */
  48483. export interface DDSInfo {
  48484. /**
  48485. * Width of the texture
  48486. */
  48487. width: number;
  48488. /**
  48489. * Width of the texture
  48490. */
  48491. height: number;
  48492. /**
  48493. * Number of Mipmaps for the texture
  48494. * @see https://en.wikipedia.org/wiki/Mipmap
  48495. */
  48496. mipmapCount: number;
  48497. /**
  48498. * If the textures format is a known fourCC format
  48499. * @see https://www.fourcc.org/
  48500. */
  48501. isFourCC: boolean;
  48502. /**
  48503. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  48504. */
  48505. isRGB: boolean;
  48506. /**
  48507. * If the texture is a lumincance format
  48508. */
  48509. isLuminance: boolean;
  48510. /**
  48511. * If this is a cube texture
  48512. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  48513. */
  48514. isCube: boolean;
  48515. /**
  48516. * If the texture is a compressed format eg. FOURCC_DXT1
  48517. */
  48518. isCompressed: boolean;
  48519. /**
  48520. * The dxgiFormat of the texture
  48521. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  48522. */
  48523. dxgiFormat: number;
  48524. /**
  48525. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  48526. */
  48527. textureType: number;
  48528. /**
  48529. * Sphericle polynomial created for the dds texture
  48530. */
  48531. sphericalPolynomial?: SphericalPolynomial;
  48532. }
  48533. /**
  48534. * Class used to provide DDS decompression tools
  48535. */
  48536. export class DDSTools {
  48537. /**
  48538. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  48539. */
  48540. static StoreLODInAlphaChannel: boolean;
  48541. /**
  48542. * Gets DDS information from an array buffer
  48543. * @param arrayBuffer defines the array buffer to read data from
  48544. * @returns the DDS information
  48545. */
  48546. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  48547. private static _FloatView;
  48548. private static _Int32View;
  48549. private static _ToHalfFloat;
  48550. private static _FromHalfFloat;
  48551. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  48552. private static _GetHalfFloatRGBAArrayBuffer;
  48553. private static _GetFloatRGBAArrayBuffer;
  48554. private static _GetFloatAsUIntRGBAArrayBuffer;
  48555. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  48556. private static _GetRGBAArrayBuffer;
  48557. private static _ExtractLongWordOrder;
  48558. private static _GetRGBArrayBuffer;
  48559. private static _GetLuminanceArrayBuffer;
  48560. /**
  48561. * Uploads DDS Levels to a Babylon Texture
  48562. * @hidden
  48563. */
  48564. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  48565. }
  48566. interface ThinEngine {
  48567. /**
  48568. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  48569. * @param rootUrl defines the url where the file to load is located
  48570. * @param scene defines the current scene
  48571. * @param lodScale defines scale to apply to the mip map selection
  48572. * @param lodOffset defines offset to apply to the mip map selection
  48573. * @param onLoad defines an optional callback raised when the texture is loaded
  48574. * @param onError defines an optional callback raised if there is an issue to load the texture
  48575. * @param format defines the format of the data
  48576. * @param forcedExtension defines the extension to use to pick the right loader
  48577. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  48578. * @returns the cube texture as an InternalTexture
  48579. */
  48580. 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;
  48581. }
  48582. }
  48583. declare module BABYLON {
  48584. /**
  48585. * Implementation of the DDS Texture Loader.
  48586. * @hidden
  48587. */
  48588. export class _DDSTextureLoader implements IInternalTextureLoader {
  48589. /**
  48590. * Defines wether the loader supports cascade loading the different faces.
  48591. */
  48592. readonly supportCascades: boolean;
  48593. /**
  48594. * This returns if the loader support the current file information.
  48595. * @param extension defines the file extension of the file being loaded
  48596. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48597. * @param fallback defines the fallback internal texture if any
  48598. * @param isBase64 defines whether the texture is encoded as a base64
  48599. * @param isBuffer defines whether the texture data are stored as a buffer
  48600. * @returns true if the loader can load the specified file
  48601. */
  48602. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  48603. /**
  48604. * Transform the url before loading if required.
  48605. * @param rootUrl the url of the texture
  48606. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48607. * @returns the transformed texture
  48608. */
  48609. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  48610. /**
  48611. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  48612. * @param rootUrl the url of the texture
  48613. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48614. * @returns the fallback texture
  48615. */
  48616. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48617. /**
  48618. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48619. * @param data contains the texture data
  48620. * @param texture defines the BabylonJS internal texture
  48621. * @param createPolynomials will be true if polynomials have been requested
  48622. * @param onLoad defines the callback to trigger once the texture is ready
  48623. * @param onError defines the callback to trigger in case of error
  48624. */
  48625. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  48626. /**
  48627. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  48628. * @param data contains the texture data
  48629. * @param texture defines the BabylonJS internal texture
  48630. * @param callback defines the method to call once ready to upload
  48631. */
  48632. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  48633. }
  48634. }
  48635. declare module BABYLON {
  48636. /**
  48637. * Implementation of the ENV Texture Loader.
  48638. * @hidden
  48639. */
  48640. export class _ENVTextureLoader implements IInternalTextureLoader {
  48641. /**
  48642. * Defines wether the loader supports cascade loading the different faces.
  48643. */
  48644. readonly supportCascades: boolean;
  48645. /**
  48646. * This returns if the loader support the current file information.
  48647. * @param extension defines the file extension of the file being loaded
  48648. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48649. * @param fallback defines the fallback internal texture if any
  48650. * @param isBase64 defines whether the texture is encoded as a base64
  48651. * @param isBuffer defines whether the texture data are stored as a buffer
  48652. * @returns true if the loader can load the specified file
  48653. */
  48654. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  48655. /**
  48656. * Transform the url before loading if required.
  48657. * @param rootUrl the url of the texture
  48658. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48659. * @returns the transformed texture
  48660. */
  48661. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  48662. /**
  48663. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  48664. * @param rootUrl the url of the texture
  48665. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48666. * @returns the fallback texture
  48667. */
  48668. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48669. /**
  48670. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48671. * @param data contains the texture data
  48672. * @param texture defines the BabylonJS internal texture
  48673. * @param createPolynomials will be true if polynomials have been requested
  48674. * @param onLoad defines the callback to trigger once the texture is ready
  48675. * @param onError defines the callback to trigger in case of error
  48676. */
  48677. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  48678. /**
  48679. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  48680. * @param data contains the texture data
  48681. * @param texture defines the BabylonJS internal texture
  48682. * @param callback defines the method to call once ready to upload
  48683. */
  48684. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  48685. }
  48686. }
  48687. declare module BABYLON {
  48688. /**
  48689. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  48690. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  48691. */
  48692. export class KhronosTextureContainer {
  48693. /** contents of the KTX container file */
  48694. arrayBuffer: any;
  48695. private static HEADER_LEN;
  48696. private static COMPRESSED_2D;
  48697. private static COMPRESSED_3D;
  48698. private static TEX_2D;
  48699. private static TEX_3D;
  48700. /**
  48701. * Gets the openGL type
  48702. */
  48703. glType: number;
  48704. /**
  48705. * Gets the openGL type size
  48706. */
  48707. glTypeSize: number;
  48708. /**
  48709. * Gets the openGL format
  48710. */
  48711. glFormat: number;
  48712. /**
  48713. * Gets the openGL internal format
  48714. */
  48715. glInternalFormat: number;
  48716. /**
  48717. * Gets the base internal format
  48718. */
  48719. glBaseInternalFormat: number;
  48720. /**
  48721. * Gets image width in pixel
  48722. */
  48723. pixelWidth: number;
  48724. /**
  48725. * Gets image height in pixel
  48726. */
  48727. pixelHeight: number;
  48728. /**
  48729. * Gets image depth in pixels
  48730. */
  48731. pixelDepth: number;
  48732. /**
  48733. * Gets the number of array elements
  48734. */
  48735. numberOfArrayElements: number;
  48736. /**
  48737. * Gets the number of faces
  48738. */
  48739. numberOfFaces: number;
  48740. /**
  48741. * Gets the number of mipmap levels
  48742. */
  48743. numberOfMipmapLevels: number;
  48744. /**
  48745. * Gets the bytes of key value data
  48746. */
  48747. bytesOfKeyValueData: number;
  48748. /**
  48749. * Gets the load type
  48750. */
  48751. loadType: number;
  48752. /**
  48753. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  48754. */
  48755. isInvalid: boolean;
  48756. /**
  48757. * Creates a new KhronosTextureContainer
  48758. * @param arrayBuffer contents of the KTX container file
  48759. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  48760. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  48761. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  48762. */
  48763. constructor(
  48764. /** contents of the KTX container file */
  48765. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  48766. /**
  48767. * Uploads KTX content to a Babylon Texture.
  48768. * It is assumed that the texture has already been created & is currently bound
  48769. * @hidden
  48770. */
  48771. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  48772. private _upload2DCompressedLevels;
  48773. }
  48774. }
  48775. declare module BABYLON {
  48776. /**
  48777. * Implementation of the KTX Texture Loader.
  48778. * @hidden
  48779. */
  48780. export class _KTXTextureLoader implements IInternalTextureLoader {
  48781. /**
  48782. * Defines wether the loader supports cascade loading the different faces.
  48783. */
  48784. readonly supportCascades: boolean;
  48785. /**
  48786. * This returns if the loader support the current file information.
  48787. * @param extension defines the file extension of the file being loaded
  48788. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48789. * @param fallback defines the fallback internal texture if any
  48790. * @param isBase64 defines whether the texture is encoded as a base64
  48791. * @param isBuffer defines whether the texture data are stored as a buffer
  48792. * @returns true if the loader can load the specified file
  48793. */
  48794. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  48795. /**
  48796. * Transform the url before loading if required.
  48797. * @param rootUrl the url of the texture
  48798. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48799. * @returns the transformed texture
  48800. */
  48801. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  48802. /**
  48803. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  48804. * @param rootUrl the url of the texture
  48805. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48806. * @returns the fallback texture
  48807. */
  48808. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48809. /**
  48810. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48811. * @param data contains the texture data
  48812. * @param texture defines the BabylonJS internal texture
  48813. * @param createPolynomials will be true if polynomials have been requested
  48814. * @param onLoad defines the callback to trigger once the texture is ready
  48815. * @param onError defines the callback to trigger in case of error
  48816. */
  48817. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  48818. /**
  48819. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  48820. * @param data contains the texture data
  48821. * @param texture defines the BabylonJS internal texture
  48822. * @param callback defines the method to call once ready to upload
  48823. */
  48824. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  48825. }
  48826. }
  48827. declare module BABYLON {
  48828. /**
  48829. * Options for the default xr helper
  48830. */
  48831. export class WebXRDefaultExperienceOptions {
  48832. /**
  48833. * Floor meshes that should be used for teleporting
  48834. */
  48835. floorMeshes: Array<AbstractMesh>;
  48836. }
  48837. /**
  48838. * Default experience which provides a similar setup to the previous webVRExperience
  48839. */
  48840. export class WebXRDefaultExperience {
  48841. /**
  48842. * Base experience
  48843. */
  48844. baseExperience: WebXRExperienceHelper;
  48845. /**
  48846. * Input experience extension
  48847. */
  48848. input: WebXRInput;
  48849. /**
  48850. * Loads the controller models
  48851. */
  48852. controllerModelLoader: WebXRControllerModelLoader;
  48853. /**
  48854. * Enables laser pointer and selection
  48855. */
  48856. pointerSelection: WebXRControllerPointerSelection;
  48857. /**
  48858. * Enables teleportation
  48859. */
  48860. teleportation: WebXRControllerTeleportation;
  48861. /**
  48862. * Enables ui for enetering/exiting xr
  48863. */
  48864. enterExitUI: WebXREnterExitUI;
  48865. /**
  48866. * Default output canvas xr should render to
  48867. */
  48868. outputCanvas: WebXRManagedOutputCanvas;
  48869. /**
  48870. * Creates the default xr experience
  48871. * @param scene scene
  48872. * @param options options for basic configuration
  48873. * @returns resulting WebXRDefaultExperience
  48874. */
  48875. static CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  48876. private constructor();
  48877. /**
  48878. * DIsposes of the experience helper
  48879. */
  48880. dispose(): void;
  48881. }
  48882. }
  48883. declare module BABYLON {
  48884. /** @hidden */
  48885. export var _forceSceneHelpersToBundle: boolean;
  48886. interface Scene {
  48887. /**
  48888. * Creates a default light for the scene.
  48889. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  48890. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  48891. */
  48892. createDefaultLight(replace?: boolean): void;
  48893. /**
  48894. * Creates a default camera for the scene.
  48895. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  48896. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  48897. * @param replace has default false, when true replaces the active camera in the scene
  48898. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  48899. */
  48900. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  48901. /**
  48902. * Creates a default camera and a default light.
  48903. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  48904. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  48905. * @param replace has the default false, when true replaces the active camera/light in the scene
  48906. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  48907. */
  48908. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  48909. /**
  48910. * Creates a new sky box
  48911. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  48912. * @param environmentTexture defines the texture to use as environment texture
  48913. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  48914. * @param scale defines the overall scale of the skybox
  48915. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  48916. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  48917. * @returns a new mesh holding the sky box
  48918. */
  48919. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  48920. /**
  48921. * Creates a new environment
  48922. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  48923. * @param options defines the options you can use to configure the environment
  48924. * @returns the new EnvironmentHelper
  48925. */
  48926. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  48927. /**
  48928. * Creates a new VREXperienceHelper
  48929. * @see http://doc.babylonjs.com/how_to/webvr_helper
  48930. * @param webVROptions defines the options used to create the new VREXperienceHelper
  48931. * @returns a new VREXperienceHelper
  48932. */
  48933. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  48934. /**
  48935. * Creates a new WebXRDefaultExperience
  48936. * @see http://doc.babylonjs.com/how_to/webxr
  48937. * @param options experience options
  48938. * @returns a promise for a new WebXRDefaultExperience
  48939. */
  48940. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  48941. }
  48942. }
  48943. declare module BABYLON {
  48944. /**
  48945. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  48946. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  48947. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  48948. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  48949. */
  48950. export class VideoDome extends TransformNode {
  48951. /**
  48952. * Define the video source as a Monoscopic panoramic 360 video.
  48953. */
  48954. static readonly MODE_MONOSCOPIC: number;
  48955. /**
  48956. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  48957. */
  48958. static readonly MODE_TOPBOTTOM: number;
  48959. /**
  48960. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  48961. */
  48962. static readonly MODE_SIDEBYSIDE: number;
  48963. private _halfDome;
  48964. private _useDirectMapping;
  48965. /**
  48966. * The video texture being displayed on the sphere
  48967. */
  48968. protected _videoTexture: VideoTexture;
  48969. /**
  48970. * Gets the video texture being displayed on the sphere
  48971. */
  48972. readonly videoTexture: VideoTexture;
  48973. /**
  48974. * The skybox material
  48975. */
  48976. protected _material: BackgroundMaterial;
  48977. /**
  48978. * The surface used for the skybox
  48979. */
  48980. protected _mesh: Mesh;
  48981. /**
  48982. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  48983. */
  48984. private _halfDomeMask;
  48985. /**
  48986. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  48987. * Also see the options.resolution property.
  48988. */
  48989. fovMultiplier: number;
  48990. private _videoMode;
  48991. /**
  48992. * Gets or set the current video mode for the video. It can be:
  48993. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  48994. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  48995. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  48996. */
  48997. videoMode: number;
  48998. /**
  48999. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  49000. *
  49001. */
  49002. /**
  49003. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  49004. */
  49005. halfDome: boolean;
  49006. /**
  49007. * Oberserver used in Stereoscopic VR Mode.
  49008. */
  49009. private _onBeforeCameraRenderObserver;
  49010. /**
  49011. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  49012. * @param name Element's name, child elements will append suffixes for their own names.
  49013. * @param urlsOrVideo defines the url(s) or the video element to use
  49014. * @param options An object containing optional or exposed sub element properties
  49015. */
  49016. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  49017. resolution?: number;
  49018. clickToPlay?: boolean;
  49019. autoPlay?: boolean;
  49020. loop?: boolean;
  49021. size?: number;
  49022. poster?: string;
  49023. faceForward?: boolean;
  49024. useDirectMapping?: boolean;
  49025. halfDomeMode?: boolean;
  49026. }, scene: Scene);
  49027. private _changeVideoMode;
  49028. /**
  49029. * Releases resources associated with this node.
  49030. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  49031. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  49032. */
  49033. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  49034. }
  49035. }
  49036. declare module BABYLON {
  49037. /**
  49038. * This class can be used to get instrumentation data from a Babylon engine
  49039. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  49040. */
  49041. export class EngineInstrumentation implements IDisposable {
  49042. /**
  49043. * Define the instrumented engine.
  49044. */
  49045. engine: Engine;
  49046. private _captureGPUFrameTime;
  49047. private _gpuFrameTimeToken;
  49048. private _gpuFrameTime;
  49049. private _captureShaderCompilationTime;
  49050. private _shaderCompilationTime;
  49051. private _onBeginFrameObserver;
  49052. private _onEndFrameObserver;
  49053. private _onBeforeShaderCompilationObserver;
  49054. private _onAfterShaderCompilationObserver;
  49055. /**
  49056. * Gets the perf counter used for GPU frame time
  49057. */
  49058. readonly gpuFrameTimeCounter: PerfCounter;
  49059. /**
  49060. * Gets the GPU frame time capture status
  49061. */
  49062. /**
  49063. * Enable or disable the GPU frame time capture
  49064. */
  49065. captureGPUFrameTime: boolean;
  49066. /**
  49067. * Gets the perf counter used for shader compilation time
  49068. */
  49069. readonly shaderCompilationTimeCounter: PerfCounter;
  49070. /**
  49071. * Gets the shader compilation time capture status
  49072. */
  49073. /**
  49074. * Enable or disable the shader compilation time capture
  49075. */
  49076. captureShaderCompilationTime: boolean;
  49077. /**
  49078. * Instantiates a new engine instrumentation.
  49079. * This class can be used to get instrumentation data from a Babylon engine
  49080. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  49081. * @param engine Defines the engine to instrument
  49082. */
  49083. constructor(
  49084. /**
  49085. * Define the instrumented engine.
  49086. */
  49087. engine: Engine);
  49088. /**
  49089. * Dispose and release associated resources.
  49090. */
  49091. dispose(): void;
  49092. }
  49093. }
  49094. declare module BABYLON {
  49095. /**
  49096. * This class can be used to get instrumentation data from a Babylon engine
  49097. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  49098. */
  49099. export class SceneInstrumentation implements IDisposable {
  49100. /**
  49101. * Defines the scene to instrument
  49102. */
  49103. scene: Scene;
  49104. private _captureActiveMeshesEvaluationTime;
  49105. private _activeMeshesEvaluationTime;
  49106. private _captureRenderTargetsRenderTime;
  49107. private _renderTargetsRenderTime;
  49108. private _captureFrameTime;
  49109. private _frameTime;
  49110. private _captureRenderTime;
  49111. private _renderTime;
  49112. private _captureInterFrameTime;
  49113. private _interFrameTime;
  49114. private _captureParticlesRenderTime;
  49115. private _particlesRenderTime;
  49116. private _captureSpritesRenderTime;
  49117. private _spritesRenderTime;
  49118. private _capturePhysicsTime;
  49119. private _physicsTime;
  49120. private _captureAnimationsTime;
  49121. private _animationsTime;
  49122. private _captureCameraRenderTime;
  49123. private _cameraRenderTime;
  49124. private _onBeforeActiveMeshesEvaluationObserver;
  49125. private _onAfterActiveMeshesEvaluationObserver;
  49126. private _onBeforeRenderTargetsRenderObserver;
  49127. private _onAfterRenderTargetsRenderObserver;
  49128. private _onAfterRenderObserver;
  49129. private _onBeforeDrawPhaseObserver;
  49130. private _onAfterDrawPhaseObserver;
  49131. private _onBeforeAnimationsObserver;
  49132. private _onBeforeParticlesRenderingObserver;
  49133. private _onAfterParticlesRenderingObserver;
  49134. private _onBeforeSpritesRenderingObserver;
  49135. private _onAfterSpritesRenderingObserver;
  49136. private _onBeforePhysicsObserver;
  49137. private _onAfterPhysicsObserver;
  49138. private _onAfterAnimationsObserver;
  49139. private _onBeforeCameraRenderObserver;
  49140. private _onAfterCameraRenderObserver;
  49141. /**
  49142. * Gets the perf counter used for active meshes evaluation time
  49143. */
  49144. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  49145. /**
  49146. * Gets the active meshes evaluation time capture status
  49147. */
  49148. /**
  49149. * Enable or disable the active meshes evaluation time capture
  49150. */
  49151. captureActiveMeshesEvaluationTime: boolean;
  49152. /**
  49153. * Gets the perf counter used for render targets render time
  49154. */
  49155. readonly renderTargetsRenderTimeCounter: PerfCounter;
  49156. /**
  49157. * Gets the render targets render time capture status
  49158. */
  49159. /**
  49160. * Enable or disable the render targets render time capture
  49161. */
  49162. captureRenderTargetsRenderTime: boolean;
  49163. /**
  49164. * Gets the perf counter used for particles render time
  49165. */
  49166. readonly particlesRenderTimeCounter: PerfCounter;
  49167. /**
  49168. * Gets the particles render time capture status
  49169. */
  49170. /**
  49171. * Enable or disable the particles render time capture
  49172. */
  49173. captureParticlesRenderTime: boolean;
  49174. /**
  49175. * Gets the perf counter used for sprites render time
  49176. */
  49177. readonly spritesRenderTimeCounter: PerfCounter;
  49178. /**
  49179. * Gets the sprites render time capture status
  49180. */
  49181. /**
  49182. * Enable or disable the sprites render time capture
  49183. */
  49184. captureSpritesRenderTime: boolean;
  49185. /**
  49186. * Gets the perf counter used for physics time
  49187. */
  49188. readonly physicsTimeCounter: PerfCounter;
  49189. /**
  49190. * Gets the physics time capture status
  49191. */
  49192. /**
  49193. * Enable or disable the physics time capture
  49194. */
  49195. capturePhysicsTime: boolean;
  49196. /**
  49197. * Gets the perf counter used for animations time
  49198. */
  49199. readonly animationsTimeCounter: PerfCounter;
  49200. /**
  49201. * Gets the animations time capture status
  49202. */
  49203. /**
  49204. * Enable or disable the animations time capture
  49205. */
  49206. captureAnimationsTime: boolean;
  49207. /**
  49208. * Gets the perf counter used for frame time capture
  49209. */
  49210. readonly frameTimeCounter: PerfCounter;
  49211. /**
  49212. * Gets the frame time capture status
  49213. */
  49214. /**
  49215. * Enable or disable the frame time capture
  49216. */
  49217. captureFrameTime: boolean;
  49218. /**
  49219. * Gets the perf counter used for inter-frames time capture
  49220. */
  49221. readonly interFrameTimeCounter: PerfCounter;
  49222. /**
  49223. * Gets the inter-frames time capture status
  49224. */
  49225. /**
  49226. * Enable or disable the inter-frames time capture
  49227. */
  49228. captureInterFrameTime: boolean;
  49229. /**
  49230. * Gets the perf counter used for render time capture
  49231. */
  49232. readonly renderTimeCounter: PerfCounter;
  49233. /**
  49234. * Gets the render time capture status
  49235. */
  49236. /**
  49237. * Enable or disable the render time capture
  49238. */
  49239. captureRenderTime: boolean;
  49240. /**
  49241. * Gets the perf counter used for camera render time capture
  49242. */
  49243. readonly cameraRenderTimeCounter: PerfCounter;
  49244. /**
  49245. * Gets the camera render time capture status
  49246. */
  49247. /**
  49248. * Enable or disable the camera render time capture
  49249. */
  49250. captureCameraRenderTime: boolean;
  49251. /**
  49252. * Gets the perf counter used for draw calls
  49253. */
  49254. readonly drawCallsCounter: PerfCounter;
  49255. /**
  49256. * Instantiates a new scene instrumentation.
  49257. * This class can be used to get instrumentation data from a Babylon engine
  49258. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  49259. * @param scene Defines the scene to instrument
  49260. */
  49261. constructor(
  49262. /**
  49263. * Defines the scene to instrument
  49264. */
  49265. scene: Scene);
  49266. /**
  49267. * Dispose and release associated resources.
  49268. */
  49269. dispose(): void;
  49270. }
  49271. }
  49272. declare module BABYLON {
  49273. /** @hidden */
  49274. export var glowMapGenerationPixelShader: {
  49275. name: string;
  49276. shader: string;
  49277. };
  49278. }
  49279. declare module BABYLON {
  49280. /** @hidden */
  49281. export var glowMapGenerationVertexShader: {
  49282. name: string;
  49283. shader: string;
  49284. };
  49285. }
  49286. declare module BABYLON {
  49287. /**
  49288. * Effect layer options. This helps customizing the behaviour
  49289. * of the effect layer.
  49290. */
  49291. export interface IEffectLayerOptions {
  49292. /**
  49293. * Multiplication factor apply to the canvas size to compute the render target size
  49294. * used to generated the objects (the smaller the faster).
  49295. */
  49296. mainTextureRatio: number;
  49297. /**
  49298. * Enforces a fixed size texture to ensure effect stability across devices.
  49299. */
  49300. mainTextureFixedSize?: number;
  49301. /**
  49302. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  49303. */
  49304. alphaBlendingMode: number;
  49305. /**
  49306. * The camera attached to the layer.
  49307. */
  49308. camera: Nullable<Camera>;
  49309. /**
  49310. * The rendering group to draw the layer in.
  49311. */
  49312. renderingGroupId: number;
  49313. }
  49314. /**
  49315. * The effect layer Helps adding post process effect blended with the main pass.
  49316. *
  49317. * This can be for instance use to generate glow or higlight effects on the scene.
  49318. *
  49319. * The effect layer class can not be used directly and is intented to inherited from to be
  49320. * customized per effects.
  49321. */
  49322. export abstract class EffectLayer {
  49323. private _vertexBuffers;
  49324. private _indexBuffer;
  49325. private _cachedDefines;
  49326. private _effectLayerMapGenerationEffect;
  49327. private _effectLayerOptions;
  49328. private _mergeEffect;
  49329. protected _scene: Scene;
  49330. protected _engine: Engine;
  49331. protected _maxSize: number;
  49332. protected _mainTextureDesiredSize: ISize;
  49333. protected _mainTexture: RenderTargetTexture;
  49334. protected _shouldRender: boolean;
  49335. protected _postProcesses: PostProcess[];
  49336. protected _textures: BaseTexture[];
  49337. protected _emissiveTextureAndColor: {
  49338. texture: Nullable<BaseTexture>;
  49339. color: Color4;
  49340. };
  49341. /**
  49342. * The name of the layer
  49343. */
  49344. name: string;
  49345. /**
  49346. * The clear color of the texture used to generate the glow map.
  49347. */
  49348. neutralColor: Color4;
  49349. /**
  49350. * Specifies wether the highlight layer is enabled or not.
  49351. */
  49352. isEnabled: boolean;
  49353. /**
  49354. * Gets the camera attached to the layer.
  49355. */
  49356. readonly camera: Nullable<Camera>;
  49357. /**
  49358. * Gets the rendering group id the layer should render in.
  49359. */
  49360. renderingGroupId: number;
  49361. /**
  49362. * An event triggered when the effect layer has been disposed.
  49363. */
  49364. onDisposeObservable: Observable<EffectLayer>;
  49365. /**
  49366. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  49367. */
  49368. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  49369. /**
  49370. * An event triggered when the generated texture is being merged in the scene.
  49371. */
  49372. onBeforeComposeObservable: Observable<EffectLayer>;
  49373. /**
  49374. * An event triggered when the generated texture has been merged in the scene.
  49375. */
  49376. onAfterComposeObservable: Observable<EffectLayer>;
  49377. /**
  49378. * An event triggered when the efffect layer changes its size.
  49379. */
  49380. onSizeChangedObservable: Observable<EffectLayer>;
  49381. /** @hidden */
  49382. static _SceneComponentInitialization: (scene: Scene) => void;
  49383. /**
  49384. * Instantiates a new effect Layer and references it in the scene.
  49385. * @param name The name of the layer
  49386. * @param scene The scene to use the layer in
  49387. */
  49388. constructor(
  49389. /** The Friendly of the effect in the scene */
  49390. name: string, scene: Scene);
  49391. /**
  49392. * Get the effect name of the layer.
  49393. * @return The effect name
  49394. */
  49395. abstract getEffectName(): string;
  49396. /**
  49397. * Checks for the readiness of the element composing the layer.
  49398. * @param subMesh the mesh to check for
  49399. * @param useInstances specify wether or not to use instances to render the mesh
  49400. * @return true if ready otherwise, false
  49401. */
  49402. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  49403. /**
  49404. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  49405. * @returns true if the effect requires stencil during the main canvas render pass.
  49406. */
  49407. abstract needStencil(): boolean;
  49408. /**
  49409. * Create the merge effect. This is the shader use to blit the information back
  49410. * to the main canvas at the end of the scene rendering.
  49411. * @returns The effect containing the shader used to merge the effect on the main canvas
  49412. */
  49413. protected abstract _createMergeEffect(): Effect;
  49414. /**
  49415. * Creates the render target textures and post processes used in the effect layer.
  49416. */
  49417. protected abstract _createTextureAndPostProcesses(): void;
  49418. /**
  49419. * Implementation specific of rendering the generating effect on the main canvas.
  49420. * @param effect The effect used to render through
  49421. */
  49422. protected abstract _internalRender(effect: Effect): void;
  49423. /**
  49424. * Sets the required values for both the emissive texture and and the main color.
  49425. */
  49426. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  49427. /**
  49428. * Free any resources and references associated to a mesh.
  49429. * Internal use
  49430. * @param mesh The mesh to free.
  49431. */
  49432. abstract _disposeMesh(mesh: Mesh): void;
  49433. /**
  49434. * Serializes this layer (Glow or Highlight for example)
  49435. * @returns a serialized layer object
  49436. */
  49437. abstract serialize?(): any;
  49438. /**
  49439. * Initializes the effect layer with the required options.
  49440. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  49441. */
  49442. protected _init(options: Partial<IEffectLayerOptions>): void;
  49443. /**
  49444. * Generates the index buffer of the full screen quad blending to the main canvas.
  49445. */
  49446. private _generateIndexBuffer;
  49447. /**
  49448. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  49449. */
  49450. private _generateVertexBuffer;
  49451. /**
  49452. * Sets the main texture desired size which is the closest power of two
  49453. * of the engine canvas size.
  49454. */
  49455. private _setMainTextureSize;
  49456. /**
  49457. * Creates the main texture for the effect layer.
  49458. */
  49459. protected _createMainTexture(): void;
  49460. /**
  49461. * Adds specific effects defines.
  49462. * @param defines The defines to add specifics to.
  49463. */
  49464. protected _addCustomEffectDefines(defines: string[]): void;
  49465. /**
  49466. * Checks for the readiness of the element composing the layer.
  49467. * @param subMesh the mesh to check for
  49468. * @param useInstances specify wether or not to use instances to render the mesh
  49469. * @param emissiveTexture the associated emissive texture used to generate the glow
  49470. * @return true if ready otherwise, false
  49471. */
  49472. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  49473. /**
  49474. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  49475. */
  49476. render(): void;
  49477. /**
  49478. * Determine if a given mesh will be used in the current effect.
  49479. * @param mesh mesh to test
  49480. * @returns true if the mesh will be used
  49481. */
  49482. hasMesh(mesh: AbstractMesh): boolean;
  49483. /**
  49484. * Returns true if the layer contains information to display, otherwise false.
  49485. * @returns true if the glow layer should be rendered
  49486. */
  49487. shouldRender(): boolean;
  49488. /**
  49489. * Returns true if the mesh should render, otherwise false.
  49490. * @param mesh The mesh to render
  49491. * @returns true if it should render otherwise false
  49492. */
  49493. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  49494. /**
  49495. * Returns true if the mesh can be rendered, otherwise false.
  49496. * @param mesh The mesh to render
  49497. * @param material The material used on the mesh
  49498. * @returns true if it can be rendered otherwise false
  49499. */
  49500. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  49501. /**
  49502. * Returns true if the mesh should render, otherwise false.
  49503. * @param mesh The mesh to render
  49504. * @returns true if it should render otherwise false
  49505. */
  49506. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  49507. /**
  49508. * Renders the submesh passed in parameter to the generation map.
  49509. */
  49510. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  49511. /**
  49512. * Rebuild the required buffers.
  49513. * @hidden Internal use only.
  49514. */
  49515. _rebuild(): void;
  49516. /**
  49517. * Dispose only the render target textures and post process.
  49518. */
  49519. private _disposeTextureAndPostProcesses;
  49520. /**
  49521. * Dispose the highlight layer and free resources.
  49522. */
  49523. dispose(): void;
  49524. /**
  49525. * Gets the class name of the effect layer
  49526. * @returns the string with the class name of the effect layer
  49527. */
  49528. getClassName(): string;
  49529. /**
  49530. * Creates an effect layer from parsed effect layer data
  49531. * @param parsedEffectLayer defines effect layer data
  49532. * @param scene defines the current scene
  49533. * @param rootUrl defines the root URL containing the effect layer information
  49534. * @returns a parsed effect Layer
  49535. */
  49536. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  49537. }
  49538. }
  49539. declare module BABYLON {
  49540. interface AbstractScene {
  49541. /**
  49542. * The list of effect layers (highlights/glow) added to the scene
  49543. * @see http://doc.babylonjs.com/how_to/highlight_layer
  49544. * @see http://doc.babylonjs.com/how_to/glow_layer
  49545. */
  49546. effectLayers: Array<EffectLayer>;
  49547. /**
  49548. * Removes the given effect layer from this scene.
  49549. * @param toRemove defines the effect layer to remove
  49550. * @returns the index of the removed effect layer
  49551. */
  49552. removeEffectLayer(toRemove: EffectLayer): number;
  49553. /**
  49554. * Adds the given effect layer to this scene
  49555. * @param newEffectLayer defines the effect layer to add
  49556. */
  49557. addEffectLayer(newEffectLayer: EffectLayer): void;
  49558. }
  49559. /**
  49560. * Defines the layer scene component responsible to manage any effect layers
  49561. * in a given scene.
  49562. */
  49563. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  49564. /**
  49565. * The component name helpfull to identify the component in the list of scene components.
  49566. */
  49567. readonly name: string;
  49568. /**
  49569. * The scene the component belongs to.
  49570. */
  49571. scene: Scene;
  49572. private _engine;
  49573. private _renderEffects;
  49574. private _needStencil;
  49575. private _previousStencilState;
  49576. /**
  49577. * Creates a new instance of the component for the given scene
  49578. * @param scene Defines the scene to register the component in
  49579. */
  49580. constructor(scene: Scene);
  49581. /**
  49582. * Registers the component in a given scene
  49583. */
  49584. register(): void;
  49585. /**
  49586. * Rebuilds the elements related to this component in case of
  49587. * context lost for instance.
  49588. */
  49589. rebuild(): void;
  49590. /**
  49591. * Serializes the component data to the specified json object
  49592. * @param serializationObject The object to serialize to
  49593. */
  49594. serialize(serializationObject: any): void;
  49595. /**
  49596. * Adds all the elements from the container to the scene
  49597. * @param container the container holding the elements
  49598. */
  49599. addFromContainer(container: AbstractScene): void;
  49600. /**
  49601. * Removes all the elements in the container from the scene
  49602. * @param container contains the elements to remove
  49603. * @param dispose if the removed element should be disposed (default: false)
  49604. */
  49605. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  49606. /**
  49607. * Disposes the component and the associated ressources.
  49608. */
  49609. dispose(): void;
  49610. private _isReadyForMesh;
  49611. private _renderMainTexture;
  49612. private _setStencil;
  49613. private _setStencilBack;
  49614. private _draw;
  49615. private _drawCamera;
  49616. private _drawRenderingGroup;
  49617. }
  49618. }
  49619. declare module BABYLON {
  49620. /** @hidden */
  49621. export var glowMapMergePixelShader: {
  49622. name: string;
  49623. shader: string;
  49624. };
  49625. }
  49626. declare module BABYLON {
  49627. /** @hidden */
  49628. export var glowMapMergeVertexShader: {
  49629. name: string;
  49630. shader: string;
  49631. };
  49632. }
  49633. declare module BABYLON {
  49634. interface AbstractScene {
  49635. /**
  49636. * Return a the first highlight layer of the scene with a given name.
  49637. * @param name The name of the highlight layer to look for.
  49638. * @return The highlight layer if found otherwise null.
  49639. */
  49640. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  49641. }
  49642. /**
  49643. * Glow layer options. This helps customizing the behaviour
  49644. * of the glow layer.
  49645. */
  49646. export interface IGlowLayerOptions {
  49647. /**
  49648. * Multiplication factor apply to the canvas size to compute the render target size
  49649. * used to generated the glowing objects (the smaller the faster).
  49650. */
  49651. mainTextureRatio: number;
  49652. /**
  49653. * Enforces a fixed size texture to ensure resize independant blur.
  49654. */
  49655. mainTextureFixedSize?: number;
  49656. /**
  49657. * How big is the kernel of the blur texture.
  49658. */
  49659. blurKernelSize: number;
  49660. /**
  49661. * The camera attached to the layer.
  49662. */
  49663. camera: Nullable<Camera>;
  49664. /**
  49665. * Enable MSAA by chosing the number of samples.
  49666. */
  49667. mainTextureSamples?: number;
  49668. /**
  49669. * The rendering group to draw the layer in.
  49670. */
  49671. renderingGroupId: number;
  49672. }
  49673. /**
  49674. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  49675. *
  49676. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  49677. * glowy meshes to your scene.
  49678. *
  49679. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  49680. */
  49681. export class GlowLayer extends EffectLayer {
  49682. /**
  49683. * Effect Name of the layer.
  49684. */
  49685. static readonly EffectName: string;
  49686. /**
  49687. * The default blur kernel size used for the glow.
  49688. */
  49689. static DefaultBlurKernelSize: number;
  49690. /**
  49691. * The default texture size ratio used for the glow.
  49692. */
  49693. static DefaultTextureRatio: number;
  49694. /**
  49695. * Sets the kernel size of the blur.
  49696. */
  49697. /**
  49698. * Gets the kernel size of the blur.
  49699. */
  49700. blurKernelSize: number;
  49701. /**
  49702. * Sets the glow intensity.
  49703. */
  49704. /**
  49705. * Gets the glow intensity.
  49706. */
  49707. intensity: number;
  49708. private _options;
  49709. private _intensity;
  49710. private _horizontalBlurPostprocess1;
  49711. private _verticalBlurPostprocess1;
  49712. private _horizontalBlurPostprocess2;
  49713. private _verticalBlurPostprocess2;
  49714. private _blurTexture1;
  49715. private _blurTexture2;
  49716. private _postProcesses1;
  49717. private _postProcesses2;
  49718. private _includedOnlyMeshes;
  49719. private _excludedMeshes;
  49720. /**
  49721. * Callback used to let the user override the color selection on a per mesh basis
  49722. */
  49723. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  49724. /**
  49725. * Callback used to let the user override the texture selection on a per mesh basis
  49726. */
  49727. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  49728. /**
  49729. * Instantiates a new glow Layer and references it to the scene.
  49730. * @param name The name of the layer
  49731. * @param scene The scene to use the layer in
  49732. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  49733. */
  49734. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  49735. /**
  49736. * Get the effect name of the layer.
  49737. * @return The effect name
  49738. */
  49739. getEffectName(): string;
  49740. /**
  49741. * Create the merge effect. This is the shader use to blit the information back
  49742. * to the main canvas at the end of the scene rendering.
  49743. */
  49744. protected _createMergeEffect(): Effect;
  49745. /**
  49746. * Creates the render target textures and post processes used in the glow layer.
  49747. */
  49748. protected _createTextureAndPostProcesses(): void;
  49749. /**
  49750. * Checks for the readiness of the element composing the layer.
  49751. * @param subMesh the mesh to check for
  49752. * @param useInstances specify wether or not to use instances to render the mesh
  49753. * @param emissiveTexture the associated emissive texture used to generate the glow
  49754. * @return true if ready otherwise, false
  49755. */
  49756. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  49757. /**
  49758. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  49759. */
  49760. needStencil(): boolean;
  49761. /**
  49762. * Returns true if the mesh can be rendered, otherwise false.
  49763. * @param mesh The mesh to render
  49764. * @param material The material used on the mesh
  49765. * @returns true if it can be rendered otherwise false
  49766. */
  49767. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  49768. /**
  49769. * Implementation specific of rendering the generating effect on the main canvas.
  49770. * @param effect The effect used to render through
  49771. */
  49772. protected _internalRender(effect: Effect): void;
  49773. /**
  49774. * Sets the required values for both the emissive texture and and the main color.
  49775. */
  49776. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  49777. /**
  49778. * Returns true if the mesh should render, otherwise false.
  49779. * @param mesh The mesh to render
  49780. * @returns true if it should render otherwise false
  49781. */
  49782. protected _shouldRenderMesh(mesh: Mesh): boolean;
  49783. /**
  49784. * Adds specific effects defines.
  49785. * @param defines The defines to add specifics to.
  49786. */
  49787. protected _addCustomEffectDefines(defines: string[]): void;
  49788. /**
  49789. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  49790. * @param mesh The mesh to exclude from the glow layer
  49791. */
  49792. addExcludedMesh(mesh: Mesh): void;
  49793. /**
  49794. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  49795. * @param mesh The mesh to remove
  49796. */
  49797. removeExcludedMesh(mesh: Mesh): void;
  49798. /**
  49799. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  49800. * @param mesh The mesh to include in the glow layer
  49801. */
  49802. addIncludedOnlyMesh(mesh: Mesh): void;
  49803. /**
  49804. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  49805. * @param mesh The mesh to remove
  49806. */
  49807. removeIncludedOnlyMesh(mesh: Mesh): void;
  49808. /**
  49809. * Determine if a given mesh will be used in the glow layer
  49810. * @param mesh The mesh to test
  49811. * @returns true if the mesh will be highlighted by the current glow layer
  49812. */
  49813. hasMesh(mesh: AbstractMesh): boolean;
  49814. /**
  49815. * Free any resources and references associated to a mesh.
  49816. * Internal use
  49817. * @param mesh The mesh to free.
  49818. * @hidden
  49819. */
  49820. _disposeMesh(mesh: Mesh): void;
  49821. /**
  49822. * Gets the class name of the effect layer
  49823. * @returns the string with the class name of the effect layer
  49824. */
  49825. getClassName(): string;
  49826. /**
  49827. * Serializes this glow layer
  49828. * @returns a serialized glow layer object
  49829. */
  49830. serialize(): any;
  49831. /**
  49832. * Creates a Glow Layer from parsed glow layer data
  49833. * @param parsedGlowLayer defines glow layer data
  49834. * @param scene defines the current scene
  49835. * @param rootUrl defines the root URL containing the glow layer information
  49836. * @returns a parsed Glow Layer
  49837. */
  49838. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  49839. }
  49840. }
  49841. declare module BABYLON {
  49842. /** @hidden */
  49843. export var glowBlurPostProcessPixelShader: {
  49844. name: string;
  49845. shader: string;
  49846. };
  49847. }
  49848. declare module BABYLON {
  49849. interface AbstractScene {
  49850. /**
  49851. * Return a the first highlight layer of the scene with a given name.
  49852. * @param name The name of the highlight layer to look for.
  49853. * @return The highlight layer if found otherwise null.
  49854. */
  49855. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  49856. }
  49857. /**
  49858. * Highlight layer options. This helps customizing the behaviour
  49859. * of the highlight layer.
  49860. */
  49861. export interface IHighlightLayerOptions {
  49862. /**
  49863. * Multiplication factor apply to the canvas size to compute the render target size
  49864. * used to generated the glowing objects (the smaller the faster).
  49865. */
  49866. mainTextureRatio: number;
  49867. /**
  49868. * Enforces a fixed size texture to ensure resize independant blur.
  49869. */
  49870. mainTextureFixedSize?: number;
  49871. /**
  49872. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  49873. * of the picture to blur (the smaller the faster).
  49874. */
  49875. blurTextureSizeRatio: number;
  49876. /**
  49877. * How big in texel of the blur texture is the vertical blur.
  49878. */
  49879. blurVerticalSize: number;
  49880. /**
  49881. * How big in texel of the blur texture is the horizontal blur.
  49882. */
  49883. blurHorizontalSize: number;
  49884. /**
  49885. * Alpha blending mode used to apply the blur. Default is combine.
  49886. */
  49887. alphaBlendingMode: number;
  49888. /**
  49889. * The camera attached to the layer.
  49890. */
  49891. camera: Nullable<Camera>;
  49892. /**
  49893. * Should we display highlight as a solid stroke?
  49894. */
  49895. isStroke?: boolean;
  49896. /**
  49897. * The rendering group to draw the layer in.
  49898. */
  49899. renderingGroupId: number;
  49900. }
  49901. /**
  49902. * The highlight layer Helps adding a glow effect around a mesh.
  49903. *
  49904. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  49905. * glowy meshes to your scene.
  49906. *
  49907. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  49908. */
  49909. export class HighlightLayer extends EffectLayer {
  49910. name: string;
  49911. /**
  49912. * Effect Name of the highlight layer.
  49913. */
  49914. static readonly EffectName: string;
  49915. /**
  49916. * The neutral color used during the preparation of the glow effect.
  49917. * This is black by default as the blend operation is a blend operation.
  49918. */
  49919. static NeutralColor: Color4;
  49920. /**
  49921. * Stencil value used for glowing meshes.
  49922. */
  49923. static GlowingMeshStencilReference: number;
  49924. /**
  49925. * Stencil value used for the other meshes in the scene.
  49926. */
  49927. static NormalMeshStencilReference: number;
  49928. /**
  49929. * Specifies whether or not the inner glow is ACTIVE in the layer.
  49930. */
  49931. innerGlow: boolean;
  49932. /**
  49933. * Specifies whether or not the outer glow is ACTIVE in the layer.
  49934. */
  49935. outerGlow: boolean;
  49936. /**
  49937. * Specifies the horizontal size of the blur.
  49938. */
  49939. /**
  49940. * Gets the horizontal size of the blur.
  49941. */
  49942. blurHorizontalSize: number;
  49943. /**
  49944. * Specifies the vertical size of the blur.
  49945. */
  49946. /**
  49947. * Gets the vertical size of the blur.
  49948. */
  49949. blurVerticalSize: number;
  49950. /**
  49951. * An event triggered when the highlight layer is being blurred.
  49952. */
  49953. onBeforeBlurObservable: Observable<HighlightLayer>;
  49954. /**
  49955. * An event triggered when the highlight layer has been blurred.
  49956. */
  49957. onAfterBlurObservable: Observable<HighlightLayer>;
  49958. private _instanceGlowingMeshStencilReference;
  49959. private _options;
  49960. private _downSamplePostprocess;
  49961. private _horizontalBlurPostprocess;
  49962. private _verticalBlurPostprocess;
  49963. private _blurTexture;
  49964. private _meshes;
  49965. private _excludedMeshes;
  49966. /**
  49967. * Instantiates a new highlight Layer and references it to the scene..
  49968. * @param name The name of the layer
  49969. * @param scene The scene to use the layer in
  49970. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  49971. */
  49972. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  49973. /**
  49974. * Get the effect name of the layer.
  49975. * @return The effect name
  49976. */
  49977. getEffectName(): string;
  49978. /**
  49979. * Create the merge effect. This is the shader use to blit the information back
  49980. * to the main canvas at the end of the scene rendering.
  49981. */
  49982. protected _createMergeEffect(): Effect;
  49983. /**
  49984. * Creates the render target textures and post processes used in the highlight layer.
  49985. */
  49986. protected _createTextureAndPostProcesses(): void;
  49987. /**
  49988. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  49989. */
  49990. needStencil(): boolean;
  49991. /**
  49992. * Checks for the readiness of the element composing the layer.
  49993. * @param subMesh the mesh to check for
  49994. * @param useInstances specify wether or not to use instances to render the mesh
  49995. * @param emissiveTexture the associated emissive texture used to generate the glow
  49996. * @return true if ready otherwise, false
  49997. */
  49998. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  49999. /**
  50000. * Implementation specific of rendering the generating effect on the main canvas.
  50001. * @param effect The effect used to render through
  50002. */
  50003. protected _internalRender(effect: Effect): void;
  50004. /**
  50005. * Returns true if the layer contains information to display, otherwise false.
  50006. */
  50007. shouldRender(): boolean;
  50008. /**
  50009. * Returns true if the mesh should render, otherwise false.
  50010. * @param mesh The mesh to render
  50011. * @returns true if it should render otherwise false
  50012. */
  50013. protected _shouldRenderMesh(mesh: Mesh): boolean;
  50014. /**
  50015. * Sets the required values for both the emissive texture and and the main color.
  50016. */
  50017. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  50018. /**
  50019. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  50020. * @param mesh The mesh to exclude from the highlight layer
  50021. */
  50022. addExcludedMesh(mesh: Mesh): void;
  50023. /**
  50024. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  50025. * @param mesh The mesh to highlight
  50026. */
  50027. removeExcludedMesh(mesh: Mesh): void;
  50028. /**
  50029. * Determine if a given mesh will be highlighted by the current HighlightLayer
  50030. * @param mesh mesh to test
  50031. * @returns true if the mesh will be highlighted by the current HighlightLayer
  50032. */
  50033. hasMesh(mesh: AbstractMesh): boolean;
  50034. /**
  50035. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  50036. * @param mesh The mesh to highlight
  50037. * @param color The color of the highlight
  50038. * @param glowEmissiveOnly Extract the glow from the emissive texture
  50039. */
  50040. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  50041. /**
  50042. * Remove a mesh from the highlight layer in order to make it stop glowing.
  50043. * @param mesh The mesh to highlight
  50044. */
  50045. removeMesh(mesh: Mesh): void;
  50046. /**
  50047. * Force the stencil to the normal expected value for none glowing parts
  50048. */
  50049. private _defaultStencilReference;
  50050. /**
  50051. * Free any resources and references associated to a mesh.
  50052. * Internal use
  50053. * @param mesh The mesh to free.
  50054. * @hidden
  50055. */
  50056. _disposeMesh(mesh: Mesh): void;
  50057. /**
  50058. * Dispose the highlight layer and free resources.
  50059. */
  50060. dispose(): void;
  50061. /**
  50062. * Gets the class name of the effect layer
  50063. * @returns the string with the class name of the effect layer
  50064. */
  50065. getClassName(): string;
  50066. /**
  50067. * Serializes this Highlight layer
  50068. * @returns a serialized Highlight layer object
  50069. */
  50070. serialize(): any;
  50071. /**
  50072. * Creates a Highlight layer from parsed Highlight layer data
  50073. * @param parsedHightlightLayer defines the Highlight layer data
  50074. * @param scene defines the current scene
  50075. * @param rootUrl defines the root URL containing the Highlight layer information
  50076. * @returns a parsed Highlight layer
  50077. */
  50078. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  50079. }
  50080. }
  50081. declare module BABYLON {
  50082. interface AbstractScene {
  50083. /**
  50084. * The list of layers (background and foreground) of the scene
  50085. */
  50086. layers: Array<Layer>;
  50087. }
  50088. /**
  50089. * Defines the layer scene component responsible to manage any layers
  50090. * in a given scene.
  50091. */
  50092. export class LayerSceneComponent implements ISceneComponent {
  50093. /**
  50094. * The component name helpfull to identify the component in the list of scene components.
  50095. */
  50096. readonly name: string;
  50097. /**
  50098. * The scene the component belongs to.
  50099. */
  50100. scene: Scene;
  50101. private _engine;
  50102. /**
  50103. * Creates a new instance of the component for the given scene
  50104. * @param scene Defines the scene to register the component in
  50105. */
  50106. constructor(scene: Scene);
  50107. /**
  50108. * Registers the component in a given scene
  50109. */
  50110. register(): void;
  50111. /**
  50112. * Rebuilds the elements related to this component in case of
  50113. * context lost for instance.
  50114. */
  50115. rebuild(): void;
  50116. /**
  50117. * Disposes the component and the associated ressources.
  50118. */
  50119. dispose(): void;
  50120. private _draw;
  50121. private _drawCameraPredicate;
  50122. private _drawCameraBackground;
  50123. private _drawCameraForeground;
  50124. private _drawRenderTargetPredicate;
  50125. private _drawRenderTargetBackground;
  50126. private _drawRenderTargetForeground;
  50127. /**
  50128. * Adds all the elements from the container to the scene
  50129. * @param container the container holding the elements
  50130. */
  50131. addFromContainer(container: AbstractScene): void;
  50132. /**
  50133. * Removes all the elements in the container from the scene
  50134. * @param container contains the elements to remove
  50135. * @param dispose if the removed element should be disposed (default: false)
  50136. */
  50137. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  50138. }
  50139. }
  50140. declare module BABYLON {
  50141. /** @hidden */
  50142. export var layerPixelShader: {
  50143. name: string;
  50144. shader: string;
  50145. };
  50146. }
  50147. declare module BABYLON {
  50148. /** @hidden */
  50149. export var layerVertexShader: {
  50150. name: string;
  50151. shader: string;
  50152. };
  50153. }
  50154. declare module BABYLON {
  50155. /**
  50156. * This represents a full screen 2d layer.
  50157. * This can be useful to display a picture in the background of your scene for instance.
  50158. * @see https://www.babylonjs-playground.com/#08A2BS#1
  50159. */
  50160. export class Layer {
  50161. /**
  50162. * Define the name of the layer.
  50163. */
  50164. name: string;
  50165. /**
  50166. * Define the texture the layer should display.
  50167. */
  50168. texture: Nullable<Texture>;
  50169. /**
  50170. * Is the layer in background or foreground.
  50171. */
  50172. isBackground: boolean;
  50173. /**
  50174. * Define the color of the layer (instead of texture).
  50175. */
  50176. color: Color4;
  50177. /**
  50178. * Define the scale of the layer in order to zoom in out of the texture.
  50179. */
  50180. scale: Vector2;
  50181. /**
  50182. * Define an offset for the layer in order to shift the texture.
  50183. */
  50184. offset: Vector2;
  50185. /**
  50186. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  50187. */
  50188. alphaBlendingMode: number;
  50189. /**
  50190. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  50191. * Alpha test will not mix with the background color in case of transparency.
  50192. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  50193. */
  50194. alphaTest: boolean;
  50195. /**
  50196. * Define a mask to restrict the layer to only some of the scene cameras.
  50197. */
  50198. layerMask: number;
  50199. /**
  50200. * Define the list of render target the layer is visible into.
  50201. */
  50202. renderTargetTextures: RenderTargetTexture[];
  50203. /**
  50204. * Define if the layer is only used in renderTarget or if it also
  50205. * renders in the main frame buffer of the canvas.
  50206. */
  50207. renderOnlyInRenderTargetTextures: boolean;
  50208. private _scene;
  50209. private _vertexBuffers;
  50210. private _indexBuffer;
  50211. private _effect;
  50212. private _alphaTestEffect;
  50213. /**
  50214. * An event triggered when the layer is disposed.
  50215. */
  50216. onDisposeObservable: Observable<Layer>;
  50217. private _onDisposeObserver;
  50218. /**
  50219. * Back compatibility with callback before the onDisposeObservable existed.
  50220. * The set callback will be triggered when the layer has been disposed.
  50221. */
  50222. onDispose: () => void;
  50223. /**
  50224. * An event triggered before rendering the scene
  50225. */
  50226. onBeforeRenderObservable: Observable<Layer>;
  50227. private _onBeforeRenderObserver;
  50228. /**
  50229. * Back compatibility with callback before the onBeforeRenderObservable existed.
  50230. * The set callback will be triggered just before rendering the layer.
  50231. */
  50232. onBeforeRender: () => void;
  50233. /**
  50234. * An event triggered after rendering the scene
  50235. */
  50236. onAfterRenderObservable: Observable<Layer>;
  50237. private _onAfterRenderObserver;
  50238. /**
  50239. * Back compatibility with callback before the onAfterRenderObservable existed.
  50240. * The set callback will be triggered just after rendering the layer.
  50241. */
  50242. onAfterRender: () => void;
  50243. /**
  50244. * Instantiates a new layer.
  50245. * This represents a full screen 2d layer.
  50246. * This can be useful to display a picture in the background of your scene for instance.
  50247. * @see https://www.babylonjs-playground.com/#08A2BS#1
  50248. * @param name Define the name of the layer in the scene
  50249. * @param imgUrl Define the url of the texture to display in the layer
  50250. * @param scene Define the scene the layer belongs to
  50251. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  50252. * @param color Defines a color for the layer
  50253. */
  50254. constructor(
  50255. /**
  50256. * Define the name of the layer.
  50257. */
  50258. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  50259. private _createIndexBuffer;
  50260. /** @hidden */
  50261. _rebuild(): void;
  50262. /**
  50263. * Renders the layer in the scene.
  50264. */
  50265. render(): void;
  50266. /**
  50267. * Disposes and releases the associated ressources.
  50268. */
  50269. dispose(): void;
  50270. }
  50271. }
  50272. declare module BABYLON {
  50273. /** @hidden */
  50274. export var lensFlarePixelShader: {
  50275. name: string;
  50276. shader: string;
  50277. };
  50278. }
  50279. declare module BABYLON {
  50280. /** @hidden */
  50281. export var lensFlareVertexShader: {
  50282. name: string;
  50283. shader: string;
  50284. };
  50285. }
  50286. declare module BABYLON {
  50287. /**
  50288. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  50289. * It is usually composed of several `lensFlare`.
  50290. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  50291. */
  50292. export class LensFlareSystem {
  50293. /**
  50294. * Define the name of the lens flare system
  50295. */
  50296. name: string;
  50297. /**
  50298. * List of lens flares used in this system.
  50299. */
  50300. lensFlares: LensFlare[];
  50301. /**
  50302. * Define a limit from the border the lens flare can be visible.
  50303. */
  50304. borderLimit: number;
  50305. /**
  50306. * Define a viewport border we do not want to see the lens flare in.
  50307. */
  50308. viewportBorder: number;
  50309. /**
  50310. * Define a predicate which could limit the list of meshes able to occlude the effect.
  50311. */
  50312. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  50313. /**
  50314. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  50315. */
  50316. layerMask: number;
  50317. /**
  50318. * Define the id of the lens flare system in the scene.
  50319. * (equal to name by default)
  50320. */
  50321. id: string;
  50322. private _scene;
  50323. private _emitter;
  50324. private _vertexBuffers;
  50325. private _indexBuffer;
  50326. private _effect;
  50327. private _positionX;
  50328. private _positionY;
  50329. private _isEnabled;
  50330. /** @hidden */
  50331. static _SceneComponentInitialization: (scene: Scene) => void;
  50332. /**
  50333. * Instantiates a lens flare system.
  50334. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  50335. * It is usually composed of several `lensFlare`.
  50336. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  50337. * @param name Define the name of the lens flare system in the scene
  50338. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  50339. * @param scene Define the scene the lens flare system belongs to
  50340. */
  50341. constructor(
  50342. /**
  50343. * Define the name of the lens flare system
  50344. */
  50345. name: string, emitter: any, scene: Scene);
  50346. /**
  50347. * Define if the lens flare system is enabled.
  50348. */
  50349. isEnabled: boolean;
  50350. /**
  50351. * Get the scene the effects belongs to.
  50352. * @returns the scene holding the lens flare system
  50353. */
  50354. getScene(): Scene;
  50355. /**
  50356. * Get the emitter of the lens flare system.
  50357. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  50358. * @returns the emitter of the lens flare system
  50359. */
  50360. getEmitter(): any;
  50361. /**
  50362. * Set the emitter of the lens flare system.
  50363. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  50364. * @param newEmitter Define the new emitter of the system
  50365. */
  50366. setEmitter(newEmitter: any): void;
  50367. /**
  50368. * Get the lens flare system emitter position.
  50369. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  50370. * @returns the position
  50371. */
  50372. getEmitterPosition(): Vector3;
  50373. /**
  50374. * @hidden
  50375. */
  50376. computeEffectivePosition(globalViewport: Viewport): boolean;
  50377. /** @hidden */
  50378. _isVisible(): boolean;
  50379. /**
  50380. * @hidden
  50381. */
  50382. render(): boolean;
  50383. /**
  50384. * Dispose and release the lens flare with its associated resources.
  50385. */
  50386. dispose(): void;
  50387. /**
  50388. * Parse a lens flare system from a JSON repressentation
  50389. * @param parsedLensFlareSystem Define the JSON to parse
  50390. * @param scene Define the scene the parsed system should be instantiated in
  50391. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  50392. * @returns the parsed system
  50393. */
  50394. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  50395. /**
  50396. * Serialize the current Lens Flare System into a JSON representation.
  50397. * @returns the serialized JSON
  50398. */
  50399. serialize(): any;
  50400. }
  50401. }
  50402. declare module BABYLON {
  50403. /**
  50404. * This represents one of the lens effect in a `lensFlareSystem`.
  50405. * It controls one of the indiviual texture used in the effect.
  50406. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  50407. */
  50408. export class LensFlare {
  50409. /**
  50410. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  50411. */
  50412. size: number;
  50413. /**
  50414. * 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.
  50415. */
  50416. position: number;
  50417. /**
  50418. * Define the lens color.
  50419. */
  50420. color: Color3;
  50421. /**
  50422. * Define the lens texture.
  50423. */
  50424. texture: Nullable<Texture>;
  50425. /**
  50426. * Define the alpha mode to render this particular lens.
  50427. */
  50428. alphaMode: number;
  50429. private _system;
  50430. /**
  50431. * Creates a new Lens Flare.
  50432. * This represents one of the lens effect in a `lensFlareSystem`.
  50433. * It controls one of the indiviual texture used in the effect.
  50434. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  50435. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  50436. * @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.
  50437. * @param color Define the lens color
  50438. * @param imgUrl Define the lens texture url
  50439. * @param system Define the `lensFlareSystem` this flare is part of
  50440. * @returns The newly created Lens Flare
  50441. */
  50442. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  50443. /**
  50444. * Instantiates a new Lens Flare.
  50445. * This represents one of the lens effect in a `lensFlareSystem`.
  50446. * It controls one of the indiviual texture used in the effect.
  50447. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  50448. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  50449. * @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.
  50450. * @param color Define the lens color
  50451. * @param imgUrl Define the lens texture url
  50452. * @param system Define the `lensFlareSystem` this flare is part of
  50453. */
  50454. constructor(
  50455. /**
  50456. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  50457. */
  50458. size: number,
  50459. /**
  50460. * 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.
  50461. */
  50462. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  50463. /**
  50464. * Dispose and release the lens flare with its associated resources.
  50465. */
  50466. dispose(): void;
  50467. }
  50468. }
  50469. declare module BABYLON {
  50470. interface AbstractScene {
  50471. /**
  50472. * The list of lens flare system added to the scene
  50473. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  50474. */
  50475. lensFlareSystems: Array<LensFlareSystem>;
  50476. /**
  50477. * Removes the given lens flare system from this scene.
  50478. * @param toRemove The lens flare system to remove
  50479. * @returns The index of the removed lens flare system
  50480. */
  50481. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  50482. /**
  50483. * Adds the given lens flare system to this scene
  50484. * @param newLensFlareSystem The lens flare system to add
  50485. */
  50486. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  50487. /**
  50488. * Gets a lens flare system using its name
  50489. * @param name defines the name to look for
  50490. * @returns the lens flare system or null if not found
  50491. */
  50492. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  50493. /**
  50494. * Gets a lens flare system using its id
  50495. * @param id defines the id to look for
  50496. * @returns the lens flare system or null if not found
  50497. */
  50498. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  50499. }
  50500. /**
  50501. * Defines the lens flare scene component responsible to manage any lens flares
  50502. * in a given scene.
  50503. */
  50504. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  50505. /**
  50506. * The component name helpfull to identify the component in the list of scene components.
  50507. */
  50508. readonly name: string;
  50509. /**
  50510. * The scene the component belongs to.
  50511. */
  50512. scene: Scene;
  50513. /**
  50514. * Creates a new instance of the component for the given scene
  50515. * @param scene Defines the scene to register the component in
  50516. */
  50517. constructor(scene: Scene);
  50518. /**
  50519. * Registers the component in a given scene
  50520. */
  50521. register(): void;
  50522. /**
  50523. * Rebuilds the elements related to this component in case of
  50524. * context lost for instance.
  50525. */
  50526. rebuild(): void;
  50527. /**
  50528. * Adds all the elements from the container to the scene
  50529. * @param container the container holding the elements
  50530. */
  50531. addFromContainer(container: AbstractScene): void;
  50532. /**
  50533. * Removes all the elements in the container from the scene
  50534. * @param container contains the elements to remove
  50535. * @param dispose if the removed element should be disposed (default: false)
  50536. */
  50537. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  50538. /**
  50539. * Serializes the component data to the specified json object
  50540. * @param serializationObject The object to serialize to
  50541. */
  50542. serialize(serializationObject: any): void;
  50543. /**
  50544. * Disposes the component and the associated ressources.
  50545. */
  50546. dispose(): void;
  50547. private _draw;
  50548. }
  50549. }
  50550. declare module BABYLON {
  50551. /**
  50552. * Defines the shadow generator component responsible to manage any shadow generators
  50553. * in a given scene.
  50554. */
  50555. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  50556. /**
  50557. * The component name helpfull to identify the component in the list of scene components.
  50558. */
  50559. readonly name: string;
  50560. /**
  50561. * The scene the component belongs to.
  50562. */
  50563. scene: Scene;
  50564. /**
  50565. * Creates a new instance of the component for the given scene
  50566. * @param scene Defines the scene to register the component in
  50567. */
  50568. constructor(scene: Scene);
  50569. /**
  50570. * Registers the component in a given scene
  50571. */
  50572. register(): void;
  50573. /**
  50574. * Rebuilds the elements related to this component in case of
  50575. * context lost for instance.
  50576. */
  50577. rebuild(): void;
  50578. /**
  50579. * Serializes the component data to the specified json object
  50580. * @param serializationObject The object to serialize to
  50581. */
  50582. serialize(serializationObject: any): void;
  50583. /**
  50584. * Adds all the elements from the container to the scene
  50585. * @param container the container holding the elements
  50586. */
  50587. addFromContainer(container: AbstractScene): void;
  50588. /**
  50589. * Removes all the elements in the container from the scene
  50590. * @param container contains the elements to remove
  50591. * @param dispose if the removed element should be disposed (default: false)
  50592. */
  50593. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  50594. /**
  50595. * Rebuilds the elements related to this component in case of
  50596. * context lost for instance.
  50597. */
  50598. dispose(): void;
  50599. private _gatherRenderTargets;
  50600. }
  50601. }
  50602. declare module BABYLON {
  50603. /**
  50604. * A point light is a light defined by an unique point in world space.
  50605. * The light is emitted in every direction from this point.
  50606. * A good example of a point light is a standard light bulb.
  50607. * Documentation: https://doc.babylonjs.com/babylon101/lights
  50608. */
  50609. export class PointLight extends ShadowLight {
  50610. private _shadowAngle;
  50611. /**
  50612. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  50613. * This specifies what angle the shadow will use to be created.
  50614. *
  50615. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  50616. */
  50617. /**
  50618. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  50619. * This specifies what angle the shadow will use to be created.
  50620. *
  50621. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  50622. */
  50623. shadowAngle: number;
  50624. /**
  50625. * Gets the direction if it has been set.
  50626. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  50627. */
  50628. /**
  50629. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  50630. */
  50631. direction: Vector3;
  50632. /**
  50633. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  50634. * A PointLight emits the light in every direction.
  50635. * It can cast shadows.
  50636. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  50637. * ```javascript
  50638. * var pointLight = new PointLight("pl", camera.position, scene);
  50639. * ```
  50640. * Documentation : https://doc.babylonjs.com/babylon101/lights
  50641. * @param name The light friendly name
  50642. * @param position The position of the point light in the scene
  50643. * @param scene The scene the lights belongs to
  50644. */
  50645. constructor(name: string, position: Vector3, scene: Scene);
  50646. /**
  50647. * Returns the string "PointLight"
  50648. * @returns the class name
  50649. */
  50650. getClassName(): string;
  50651. /**
  50652. * Returns the integer 0.
  50653. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  50654. */
  50655. getTypeID(): number;
  50656. /**
  50657. * Specifies wether or not the shadowmap should be a cube texture.
  50658. * @returns true if the shadowmap needs to be a cube texture.
  50659. */
  50660. needCube(): boolean;
  50661. /**
  50662. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  50663. * @param faceIndex The index of the face we are computed the direction to generate shadow
  50664. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  50665. */
  50666. getShadowDirection(faceIndex?: number): Vector3;
  50667. /**
  50668. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  50669. * - fov = PI / 2
  50670. * - aspect ratio : 1.0
  50671. * - z-near and far equal to the active camera minZ and maxZ.
  50672. * Returns the PointLight.
  50673. */
  50674. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  50675. protected _buildUniformLayout(): void;
  50676. /**
  50677. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  50678. * @param effect The effect to update
  50679. * @param lightIndex The index of the light in the effect to update
  50680. * @returns The point light
  50681. */
  50682. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  50683. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  50684. /**
  50685. * Prepares the list of defines specific to the light type.
  50686. * @param defines the list of defines
  50687. * @param lightIndex defines the index of the light for the effect
  50688. */
  50689. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  50690. }
  50691. }
  50692. declare module BABYLON {
  50693. /**
  50694. * Header information of HDR texture files.
  50695. */
  50696. export interface HDRInfo {
  50697. /**
  50698. * The height of the texture in pixels.
  50699. */
  50700. height: number;
  50701. /**
  50702. * The width of the texture in pixels.
  50703. */
  50704. width: number;
  50705. /**
  50706. * The index of the beginning of the data in the binary file.
  50707. */
  50708. dataPosition: number;
  50709. }
  50710. /**
  50711. * This groups tools to convert HDR texture to native colors array.
  50712. */
  50713. export class HDRTools {
  50714. private static Ldexp;
  50715. private static Rgbe2float;
  50716. private static readStringLine;
  50717. /**
  50718. * Reads header information from an RGBE texture stored in a native array.
  50719. * More information on this format are available here:
  50720. * https://en.wikipedia.org/wiki/RGBE_image_format
  50721. *
  50722. * @param uint8array The binary file stored in native array.
  50723. * @return The header information.
  50724. */
  50725. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  50726. /**
  50727. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  50728. * This RGBE texture needs to store the information as a panorama.
  50729. *
  50730. * More information on this format are available here:
  50731. * https://en.wikipedia.org/wiki/RGBE_image_format
  50732. *
  50733. * @param buffer The binary file stored in an array buffer.
  50734. * @param size The expected size of the extracted cubemap.
  50735. * @return The Cube Map information.
  50736. */
  50737. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  50738. /**
  50739. * Returns the pixels data extracted from an RGBE texture.
  50740. * This pixels will be stored left to right up to down in the R G B order in one array.
  50741. *
  50742. * More information on this format are available here:
  50743. * https://en.wikipedia.org/wiki/RGBE_image_format
  50744. *
  50745. * @param uint8array The binary file stored in an array buffer.
  50746. * @param hdrInfo The header information of the file.
  50747. * @return The pixels data in RGB right to left up to down order.
  50748. */
  50749. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  50750. private static RGBE_ReadPixels_RLE;
  50751. }
  50752. }
  50753. declare module BABYLON {
  50754. /**
  50755. * This represents a texture coming from an HDR input.
  50756. *
  50757. * The only supported format is currently panorama picture stored in RGBE format.
  50758. * Example of such files can be found on HDRLib: http://hdrlib.com/
  50759. */
  50760. export class HDRCubeTexture extends BaseTexture {
  50761. private static _facesMapping;
  50762. private _generateHarmonics;
  50763. private _noMipmap;
  50764. private _textureMatrix;
  50765. private _size;
  50766. private _onLoad;
  50767. private _onError;
  50768. /**
  50769. * The texture URL.
  50770. */
  50771. url: string;
  50772. /**
  50773. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  50774. */
  50775. coordinatesMode: number;
  50776. protected _isBlocking: boolean;
  50777. /**
  50778. * Sets wether or not the texture is blocking during loading.
  50779. */
  50780. /**
  50781. * Gets wether or not the texture is blocking during loading.
  50782. */
  50783. isBlocking: boolean;
  50784. protected _rotationY: number;
  50785. /**
  50786. * Sets texture matrix rotation angle around Y axis in radians.
  50787. */
  50788. /**
  50789. * Gets texture matrix rotation angle around Y axis radians.
  50790. */
  50791. rotationY: number;
  50792. /**
  50793. * Gets or sets the center of the bounding box associated with the cube texture
  50794. * It must define where the camera used to render the texture was set
  50795. */
  50796. boundingBoxPosition: Vector3;
  50797. private _boundingBoxSize;
  50798. /**
  50799. * Gets or sets the size of the bounding box associated with the cube texture
  50800. * When defined, the cubemap will switch to local mode
  50801. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  50802. * @example https://www.babylonjs-playground.com/#RNASML
  50803. */
  50804. boundingBoxSize: Vector3;
  50805. /**
  50806. * Instantiates an HDRTexture from the following parameters.
  50807. *
  50808. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  50809. * @param scene The scene the texture will be used in
  50810. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  50811. * @param noMipmap Forces to not generate the mipmap if true
  50812. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  50813. * @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)
  50814. * @param reserved Reserved flag for internal use.
  50815. */
  50816. 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>);
  50817. /**
  50818. * Get the current class name of the texture useful for serialization or dynamic coding.
  50819. * @returns "HDRCubeTexture"
  50820. */
  50821. getClassName(): string;
  50822. /**
  50823. * Occurs when the file is raw .hdr file.
  50824. */
  50825. private loadTexture;
  50826. clone(): HDRCubeTexture;
  50827. delayLoad(): void;
  50828. /**
  50829. * Get the texture reflection matrix used to rotate/transform the reflection.
  50830. * @returns the reflection matrix
  50831. */
  50832. getReflectionTextureMatrix(): Matrix;
  50833. /**
  50834. * Set the texture reflection matrix used to rotate/transform the reflection.
  50835. * @param value Define the reflection matrix to set
  50836. */
  50837. setReflectionTextureMatrix(value: Matrix): void;
  50838. /**
  50839. * Parses a JSON representation of an HDR Texture in order to create the texture
  50840. * @param parsedTexture Define the JSON representation
  50841. * @param scene Define the scene the texture should be created in
  50842. * @param rootUrl Define the root url in case we need to load relative dependencies
  50843. * @returns the newly created texture after parsing
  50844. */
  50845. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  50846. serialize(): any;
  50847. }
  50848. }
  50849. declare module BABYLON {
  50850. /**
  50851. * Class used to control physics engine
  50852. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  50853. */
  50854. export class PhysicsEngine implements IPhysicsEngine {
  50855. private _physicsPlugin;
  50856. /**
  50857. * Global value used to control the smallest number supported by the simulation
  50858. */
  50859. static Epsilon: number;
  50860. private _impostors;
  50861. private _joints;
  50862. /**
  50863. * Gets the gravity vector used by the simulation
  50864. */
  50865. gravity: Vector3;
  50866. /**
  50867. * Factory used to create the default physics plugin.
  50868. * @returns The default physics plugin
  50869. */
  50870. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  50871. /**
  50872. * Creates a new Physics Engine
  50873. * @param gravity defines the gravity vector used by the simulation
  50874. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  50875. */
  50876. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  50877. /**
  50878. * Sets the gravity vector used by the simulation
  50879. * @param gravity defines the gravity vector to use
  50880. */
  50881. setGravity(gravity: Vector3): void;
  50882. /**
  50883. * Set the time step of the physics engine.
  50884. * Default is 1/60.
  50885. * To slow it down, enter 1/600 for example.
  50886. * To speed it up, 1/30
  50887. * @param newTimeStep defines the new timestep to apply to this world.
  50888. */
  50889. setTimeStep(newTimeStep?: number): void;
  50890. /**
  50891. * Get the time step of the physics engine.
  50892. * @returns the current time step
  50893. */
  50894. getTimeStep(): number;
  50895. /**
  50896. * Release all resources
  50897. */
  50898. dispose(): void;
  50899. /**
  50900. * Gets the name of the current physics plugin
  50901. * @returns the name of the plugin
  50902. */
  50903. getPhysicsPluginName(): string;
  50904. /**
  50905. * Adding a new impostor for the impostor tracking.
  50906. * This will be done by the impostor itself.
  50907. * @param impostor the impostor to add
  50908. */
  50909. addImpostor(impostor: PhysicsImpostor): void;
  50910. /**
  50911. * Remove an impostor from the engine.
  50912. * This impostor and its mesh will not longer be updated by the physics engine.
  50913. * @param impostor the impostor to remove
  50914. */
  50915. removeImpostor(impostor: PhysicsImpostor): void;
  50916. /**
  50917. * Add a joint to the physics engine
  50918. * @param mainImpostor defines the main impostor to which the joint is added.
  50919. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  50920. * @param joint defines the joint that will connect both impostors.
  50921. */
  50922. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  50923. /**
  50924. * Removes a joint from the simulation
  50925. * @param mainImpostor defines the impostor used with the joint
  50926. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  50927. * @param joint defines the joint to remove
  50928. */
  50929. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  50930. /**
  50931. * Called by the scene. No need to call it.
  50932. * @param delta defines the timespam between frames
  50933. */
  50934. _step(delta: number): void;
  50935. /**
  50936. * Gets the current plugin used to run the simulation
  50937. * @returns current plugin
  50938. */
  50939. getPhysicsPlugin(): IPhysicsEnginePlugin;
  50940. /**
  50941. * Gets the list of physic impostors
  50942. * @returns an array of PhysicsImpostor
  50943. */
  50944. getImpostors(): Array<PhysicsImpostor>;
  50945. /**
  50946. * Gets the impostor for a physics enabled object
  50947. * @param object defines the object impersonated by the impostor
  50948. * @returns the PhysicsImpostor or null if not found
  50949. */
  50950. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  50951. /**
  50952. * Gets the impostor for a physics body object
  50953. * @param body defines physics body used by the impostor
  50954. * @returns the PhysicsImpostor or null if not found
  50955. */
  50956. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  50957. /**
  50958. * Does a raycast in the physics world
  50959. * @param from when should the ray start?
  50960. * @param to when should the ray end?
  50961. * @returns PhysicsRaycastResult
  50962. */
  50963. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  50964. }
  50965. }
  50966. declare module BABYLON {
  50967. /** @hidden */
  50968. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  50969. private _useDeltaForWorldStep;
  50970. world: any;
  50971. name: string;
  50972. private _physicsMaterials;
  50973. private _fixedTimeStep;
  50974. private _cannonRaycastResult;
  50975. private _raycastResult;
  50976. private _physicsBodysToRemoveAfterStep;
  50977. BJSCANNON: any;
  50978. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  50979. setGravity(gravity: Vector3): void;
  50980. setTimeStep(timeStep: number): void;
  50981. getTimeStep(): number;
  50982. executeStep(delta: number): void;
  50983. private _removeMarkedPhysicsBodiesFromWorld;
  50984. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50985. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50986. generatePhysicsBody(impostor: PhysicsImpostor): void;
  50987. private _processChildMeshes;
  50988. removePhysicsBody(impostor: PhysicsImpostor): void;
  50989. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  50990. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  50991. private _addMaterial;
  50992. private _checkWithEpsilon;
  50993. private _createShape;
  50994. private _createHeightmap;
  50995. private _minus90X;
  50996. private _plus90X;
  50997. private _tmpPosition;
  50998. private _tmpDeltaPosition;
  50999. private _tmpUnityRotation;
  51000. private _updatePhysicsBodyTransformation;
  51001. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  51002. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  51003. isSupported(): boolean;
  51004. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51005. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51006. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51007. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51008. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  51009. getBodyMass(impostor: PhysicsImpostor): number;
  51010. getBodyFriction(impostor: PhysicsImpostor): number;
  51011. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  51012. getBodyRestitution(impostor: PhysicsImpostor): number;
  51013. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  51014. sleepBody(impostor: PhysicsImpostor): void;
  51015. wakeUpBody(impostor: PhysicsImpostor): void;
  51016. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  51017. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  51018. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  51019. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  51020. getRadius(impostor: PhysicsImpostor): number;
  51021. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  51022. dispose(): void;
  51023. private _extendNamespace;
  51024. /**
  51025. * Does a raycast in the physics world
  51026. * @param from when should the ray start?
  51027. * @param to when should the ray end?
  51028. * @returns PhysicsRaycastResult
  51029. */
  51030. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  51031. }
  51032. }
  51033. declare module BABYLON {
  51034. /** @hidden */
  51035. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  51036. world: any;
  51037. name: string;
  51038. BJSOIMO: any;
  51039. private _raycastResult;
  51040. constructor(iterations?: number, oimoInjection?: any);
  51041. setGravity(gravity: Vector3): void;
  51042. setTimeStep(timeStep: number): void;
  51043. getTimeStep(): number;
  51044. private _tmpImpostorsArray;
  51045. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  51046. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  51047. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  51048. generatePhysicsBody(impostor: PhysicsImpostor): void;
  51049. private _tmpPositionVector;
  51050. removePhysicsBody(impostor: PhysicsImpostor): void;
  51051. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  51052. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  51053. isSupported(): boolean;
  51054. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  51055. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  51056. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51057. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51058. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51059. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51060. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  51061. getBodyMass(impostor: PhysicsImpostor): number;
  51062. getBodyFriction(impostor: PhysicsImpostor): number;
  51063. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  51064. getBodyRestitution(impostor: PhysicsImpostor): number;
  51065. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  51066. sleepBody(impostor: PhysicsImpostor): void;
  51067. wakeUpBody(impostor: PhysicsImpostor): void;
  51068. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  51069. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  51070. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  51071. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  51072. getRadius(impostor: PhysicsImpostor): number;
  51073. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  51074. dispose(): void;
  51075. /**
  51076. * Does a raycast in the physics world
  51077. * @param from when should the ray start?
  51078. * @param to when should the ray end?
  51079. * @returns PhysicsRaycastResult
  51080. */
  51081. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  51082. }
  51083. }
  51084. declare module BABYLON {
  51085. /**
  51086. * Class containing static functions to help procedurally build meshes
  51087. */
  51088. export class RibbonBuilder {
  51089. /**
  51090. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  51091. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  51092. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  51093. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  51094. * * 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
  51095. * * 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
  51096. * * 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
  51097. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51098. * * 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
  51099. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  51100. * * 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
  51101. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  51102. * * 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
  51103. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  51104. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51105. * @param name defines the name of the mesh
  51106. * @param options defines the options used to create the mesh
  51107. * @param scene defines the hosting scene
  51108. * @returns the ribbon mesh
  51109. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  51110. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  51111. */
  51112. static CreateRibbon(name: string, options: {
  51113. pathArray: Vector3[][];
  51114. closeArray?: boolean;
  51115. closePath?: boolean;
  51116. offset?: number;
  51117. updatable?: boolean;
  51118. sideOrientation?: number;
  51119. frontUVs?: Vector4;
  51120. backUVs?: Vector4;
  51121. instance?: Mesh;
  51122. invertUV?: boolean;
  51123. uvs?: Vector2[];
  51124. colors?: Color4[];
  51125. }, scene?: Nullable<Scene>): Mesh;
  51126. }
  51127. }
  51128. declare module BABYLON {
  51129. /**
  51130. * Class containing static functions to help procedurally build meshes
  51131. */
  51132. export class ShapeBuilder {
  51133. /**
  51134. * 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.
  51135. * * 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.
  51136. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  51137. * * 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.
  51138. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  51139. * * 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
  51140. * * 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
  51141. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  51142. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51143. * * 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
  51144. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  51145. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  51146. * @param name defines the name of the mesh
  51147. * @param options defines the options used to create the mesh
  51148. * @param scene defines the hosting scene
  51149. * @returns the extruded shape mesh
  51150. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  51151. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  51152. */
  51153. static ExtrudeShape(name: string, options: {
  51154. shape: Vector3[];
  51155. path: Vector3[];
  51156. scale?: number;
  51157. rotation?: number;
  51158. cap?: number;
  51159. updatable?: boolean;
  51160. sideOrientation?: number;
  51161. frontUVs?: Vector4;
  51162. backUVs?: Vector4;
  51163. instance?: Mesh;
  51164. invertUV?: boolean;
  51165. }, scene?: Nullable<Scene>): Mesh;
  51166. /**
  51167. * Creates an custom extruded shape mesh.
  51168. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  51169. * * 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.
  51170. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  51171. * * 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
  51172. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  51173. * * 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
  51174. * * It must returns a float value that will be the scale value applied to the shape on each path point
  51175. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  51176. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  51177. * * 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
  51178. * * 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
  51179. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  51180. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51181. * * 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
  51182. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  51183. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51184. * @param name defines the name of the mesh
  51185. * @param options defines the options used to create the mesh
  51186. * @param scene defines the hosting scene
  51187. * @returns the custom extruded shape mesh
  51188. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  51189. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  51190. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  51191. */
  51192. static ExtrudeShapeCustom(name: string, options: {
  51193. shape: Vector3[];
  51194. path: Vector3[];
  51195. scaleFunction?: any;
  51196. rotationFunction?: any;
  51197. ribbonCloseArray?: boolean;
  51198. ribbonClosePath?: boolean;
  51199. cap?: number;
  51200. updatable?: boolean;
  51201. sideOrientation?: number;
  51202. frontUVs?: Vector4;
  51203. backUVs?: Vector4;
  51204. instance?: Mesh;
  51205. invertUV?: boolean;
  51206. }, scene?: Nullable<Scene>): Mesh;
  51207. private static _ExtrudeShapeGeneric;
  51208. }
  51209. }
  51210. declare module BABYLON {
  51211. /**
  51212. * AmmoJS Physics plugin
  51213. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  51214. * @see https://github.com/kripken/ammo.js/
  51215. */
  51216. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  51217. private _useDeltaForWorldStep;
  51218. /**
  51219. * Reference to the Ammo library
  51220. */
  51221. bjsAMMO: any;
  51222. /**
  51223. * Created ammoJS world which physics bodies are added to
  51224. */
  51225. world: any;
  51226. /**
  51227. * Name of the plugin
  51228. */
  51229. name: string;
  51230. private _timeStep;
  51231. private _fixedTimeStep;
  51232. private _maxSteps;
  51233. private _tmpQuaternion;
  51234. private _tmpAmmoTransform;
  51235. private _tmpAmmoQuaternion;
  51236. private _tmpAmmoConcreteContactResultCallback;
  51237. private _collisionConfiguration;
  51238. private _dispatcher;
  51239. private _overlappingPairCache;
  51240. private _solver;
  51241. private _softBodySolver;
  51242. private _tmpAmmoVectorA;
  51243. private _tmpAmmoVectorB;
  51244. private _tmpAmmoVectorC;
  51245. private _tmpAmmoVectorD;
  51246. private _tmpContactCallbackResult;
  51247. private _tmpAmmoVectorRCA;
  51248. private _tmpAmmoVectorRCB;
  51249. private _raycastResult;
  51250. private static readonly DISABLE_COLLISION_FLAG;
  51251. private static readonly KINEMATIC_FLAG;
  51252. private static readonly DISABLE_DEACTIVATION_FLAG;
  51253. /**
  51254. * Initializes the ammoJS plugin
  51255. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  51256. * @param ammoInjection can be used to inject your own ammo reference
  51257. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  51258. */
  51259. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  51260. /**
  51261. * Sets the gravity of the physics world (m/(s^2))
  51262. * @param gravity Gravity to set
  51263. */
  51264. setGravity(gravity: Vector3): void;
  51265. /**
  51266. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  51267. * @param timeStep timestep to use in seconds
  51268. */
  51269. setTimeStep(timeStep: number): void;
  51270. /**
  51271. * 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)
  51272. * @param fixedTimeStep fixedTimeStep to use in seconds
  51273. */
  51274. setFixedTimeStep(fixedTimeStep: number): void;
  51275. /**
  51276. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  51277. * @param maxSteps the maximum number of steps by the physics engine per frame
  51278. */
  51279. setMaxSteps(maxSteps: number): void;
  51280. /**
  51281. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  51282. * @returns the current timestep in seconds
  51283. */
  51284. getTimeStep(): number;
  51285. private _isImpostorInContact;
  51286. private _isImpostorPairInContact;
  51287. private _stepSimulation;
  51288. /**
  51289. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  51290. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  51291. * After the step the babylon meshes are set to the position of the physics imposters
  51292. * @param delta amount of time to step forward
  51293. * @param impostors array of imposters to update before/after the step
  51294. */
  51295. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  51296. /**
  51297. * Update babylon mesh to match physics world object
  51298. * @param impostor imposter to match
  51299. */
  51300. private _afterSoftStep;
  51301. /**
  51302. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  51303. * @param impostor imposter to match
  51304. */
  51305. private _ropeStep;
  51306. /**
  51307. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  51308. * @param impostor imposter to match
  51309. */
  51310. private _softbodyOrClothStep;
  51311. private _tmpVector;
  51312. private _tmpMatrix;
  51313. /**
  51314. * Applies an impulse on the imposter
  51315. * @param impostor imposter to apply impulse to
  51316. * @param force amount of force to be applied to the imposter
  51317. * @param contactPoint the location to apply the impulse on the imposter
  51318. */
  51319. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  51320. /**
  51321. * Applies a force on the imposter
  51322. * @param impostor imposter to apply force
  51323. * @param force amount of force to be applied to the imposter
  51324. * @param contactPoint the location to apply the force on the imposter
  51325. */
  51326. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  51327. /**
  51328. * Creates a physics body using the plugin
  51329. * @param impostor the imposter to create the physics body on
  51330. */
  51331. generatePhysicsBody(impostor: PhysicsImpostor): void;
  51332. /**
  51333. * Removes the physics body from the imposter and disposes of the body's memory
  51334. * @param impostor imposter to remove the physics body from
  51335. */
  51336. removePhysicsBody(impostor: PhysicsImpostor): void;
  51337. /**
  51338. * Generates a joint
  51339. * @param impostorJoint the imposter joint to create the joint with
  51340. */
  51341. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  51342. /**
  51343. * Removes a joint
  51344. * @param impostorJoint the imposter joint to remove the joint from
  51345. */
  51346. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  51347. private _addMeshVerts;
  51348. /**
  51349. * Initialise the soft body vertices to match its object's (mesh) vertices
  51350. * Softbody vertices (nodes) are in world space and to match this
  51351. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  51352. * @param impostor to create the softbody for
  51353. */
  51354. private _softVertexData;
  51355. /**
  51356. * Create an impostor's soft body
  51357. * @param impostor to create the softbody for
  51358. */
  51359. private _createSoftbody;
  51360. /**
  51361. * Create cloth for an impostor
  51362. * @param impostor to create the softbody for
  51363. */
  51364. private _createCloth;
  51365. /**
  51366. * Create rope for an impostor
  51367. * @param impostor to create the softbody for
  51368. */
  51369. private _createRope;
  51370. private _addHullVerts;
  51371. private _createShape;
  51372. /**
  51373. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  51374. * @param impostor imposter containing the physics body and babylon object
  51375. */
  51376. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  51377. /**
  51378. * Sets the babylon object's position/rotation from the physics body's position/rotation
  51379. * @param impostor imposter containing the physics body and babylon object
  51380. * @param newPosition new position
  51381. * @param newRotation new rotation
  51382. */
  51383. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  51384. /**
  51385. * If this plugin is supported
  51386. * @returns true if its supported
  51387. */
  51388. isSupported(): boolean;
  51389. /**
  51390. * Sets the linear velocity of the physics body
  51391. * @param impostor imposter to set the velocity on
  51392. * @param velocity velocity to set
  51393. */
  51394. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51395. /**
  51396. * Sets the angular velocity of the physics body
  51397. * @param impostor imposter to set the velocity on
  51398. * @param velocity velocity to set
  51399. */
  51400. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51401. /**
  51402. * gets the linear velocity
  51403. * @param impostor imposter to get linear velocity from
  51404. * @returns linear velocity
  51405. */
  51406. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51407. /**
  51408. * gets the angular velocity
  51409. * @param impostor imposter to get angular velocity from
  51410. * @returns angular velocity
  51411. */
  51412. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51413. /**
  51414. * Sets the mass of physics body
  51415. * @param impostor imposter to set the mass on
  51416. * @param mass mass to set
  51417. */
  51418. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  51419. /**
  51420. * Gets the mass of the physics body
  51421. * @param impostor imposter to get the mass from
  51422. * @returns mass
  51423. */
  51424. getBodyMass(impostor: PhysicsImpostor): number;
  51425. /**
  51426. * Gets friction of the impostor
  51427. * @param impostor impostor to get friction from
  51428. * @returns friction value
  51429. */
  51430. getBodyFriction(impostor: PhysicsImpostor): number;
  51431. /**
  51432. * Sets friction of the impostor
  51433. * @param impostor impostor to set friction on
  51434. * @param friction friction value
  51435. */
  51436. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  51437. /**
  51438. * Gets restitution of the impostor
  51439. * @param impostor impostor to get restitution from
  51440. * @returns restitution value
  51441. */
  51442. getBodyRestitution(impostor: PhysicsImpostor): number;
  51443. /**
  51444. * Sets resitution of the impostor
  51445. * @param impostor impostor to set resitution on
  51446. * @param restitution resitution value
  51447. */
  51448. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  51449. /**
  51450. * Gets pressure inside the impostor
  51451. * @param impostor impostor to get pressure from
  51452. * @returns pressure value
  51453. */
  51454. getBodyPressure(impostor: PhysicsImpostor): number;
  51455. /**
  51456. * Sets pressure inside a soft body impostor
  51457. * Cloth and rope must remain 0 pressure
  51458. * @param impostor impostor to set pressure on
  51459. * @param pressure pressure value
  51460. */
  51461. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  51462. /**
  51463. * Gets stiffness of the impostor
  51464. * @param impostor impostor to get stiffness from
  51465. * @returns pressure value
  51466. */
  51467. getBodyStiffness(impostor: PhysicsImpostor): number;
  51468. /**
  51469. * Sets stiffness of the impostor
  51470. * @param impostor impostor to set stiffness on
  51471. * @param stiffness stiffness value from 0 to 1
  51472. */
  51473. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  51474. /**
  51475. * Gets velocityIterations of the impostor
  51476. * @param impostor impostor to get velocity iterations from
  51477. * @returns velocityIterations value
  51478. */
  51479. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  51480. /**
  51481. * Sets velocityIterations of the impostor
  51482. * @param impostor impostor to set velocity iterations on
  51483. * @param velocityIterations velocityIterations value
  51484. */
  51485. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  51486. /**
  51487. * Gets positionIterations of the impostor
  51488. * @param impostor impostor to get position iterations from
  51489. * @returns positionIterations value
  51490. */
  51491. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  51492. /**
  51493. * Sets positionIterations of the impostor
  51494. * @param impostor impostor to set position on
  51495. * @param positionIterations positionIterations value
  51496. */
  51497. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  51498. /**
  51499. * Append an anchor to a cloth object
  51500. * @param impostor is the cloth impostor to add anchor to
  51501. * @param otherImpostor is the rigid impostor to anchor to
  51502. * @param width ratio across width from 0 to 1
  51503. * @param height ratio up height from 0 to 1
  51504. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  51505. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  51506. */
  51507. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  51508. /**
  51509. * Append an hook to a rope object
  51510. * @param impostor is the rope impostor to add hook to
  51511. * @param otherImpostor is the rigid impostor to hook to
  51512. * @param length ratio along the rope from 0 to 1
  51513. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  51514. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  51515. */
  51516. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  51517. /**
  51518. * Sleeps the physics body and stops it from being active
  51519. * @param impostor impostor to sleep
  51520. */
  51521. sleepBody(impostor: PhysicsImpostor): void;
  51522. /**
  51523. * Activates the physics body
  51524. * @param impostor impostor to activate
  51525. */
  51526. wakeUpBody(impostor: PhysicsImpostor): void;
  51527. /**
  51528. * Updates the distance parameters of the joint
  51529. * @param joint joint to update
  51530. * @param maxDistance maximum distance of the joint
  51531. * @param minDistance minimum distance of the joint
  51532. */
  51533. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  51534. /**
  51535. * Sets a motor on the joint
  51536. * @param joint joint to set motor on
  51537. * @param speed speed of the motor
  51538. * @param maxForce maximum force of the motor
  51539. * @param motorIndex index of the motor
  51540. */
  51541. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  51542. /**
  51543. * Sets the motors limit
  51544. * @param joint joint to set limit on
  51545. * @param upperLimit upper limit
  51546. * @param lowerLimit lower limit
  51547. */
  51548. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  51549. /**
  51550. * Syncs the position and rotation of a mesh with the impostor
  51551. * @param mesh mesh to sync
  51552. * @param impostor impostor to update the mesh with
  51553. */
  51554. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  51555. /**
  51556. * Gets the radius of the impostor
  51557. * @param impostor impostor to get radius from
  51558. * @returns the radius
  51559. */
  51560. getRadius(impostor: PhysicsImpostor): number;
  51561. /**
  51562. * Gets the box size of the impostor
  51563. * @param impostor impostor to get box size from
  51564. * @param result the resulting box size
  51565. */
  51566. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  51567. /**
  51568. * Disposes of the impostor
  51569. */
  51570. dispose(): void;
  51571. /**
  51572. * Does a raycast in the physics world
  51573. * @param from when should the ray start?
  51574. * @param to when should the ray end?
  51575. * @returns PhysicsRaycastResult
  51576. */
  51577. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  51578. }
  51579. }
  51580. declare module BABYLON {
  51581. interface AbstractScene {
  51582. /**
  51583. * The list of reflection probes added to the scene
  51584. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  51585. */
  51586. reflectionProbes: Array<ReflectionProbe>;
  51587. /**
  51588. * Removes the given reflection probe from this scene.
  51589. * @param toRemove The reflection probe to remove
  51590. * @returns The index of the removed reflection probe
  51591. */
  51592. removeReflectionProbe(toRemove: ReflectionProbe): number;
  51593. /**
  51594. * Adds the given reflection probe to this scene.
  51595. * @param newReflectionProbe The reflection probe to add
  51596. */
  51597. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  51598. }
  51599. /**
  51600. * Class used to generate realtime reflection / refraction cube textures
  51601. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  51602. */
  51603. export class ReflectionProbe {
  51604. /** defines the name of the probe */
  51605. name: string;
  51606. private _scene;
  51607. private _renderTargetTexture;
  51608. private _projectionMatrix;
  51609. private _viewMatrix;
  51610. private _target;
  51611. private _add;
  51612. private _attachedMesh;
  51613. private _invertYAxis;
  51614. /** Gets or sets probe position (center of the cube map) */
  51615. position: Vector3;
  51616. /**
  51617. * Creates a new reflection probe
  51618. * @param name defines the name of the probe
  51619. * @param size defines the texture resolution (for each face)
  51620. * @param scene defines the hosting scene
  51621. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  51622. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  51623. */
  51624. constructor(
  51625. /** defines the name of the probe */
  51626. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  51627. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  51628. samples: number;
  51629. /** Gets or sets the refresh rate to use (on every frame by default) */
  51630. refreshRate: number;
  51631. /**
  51632. * Gets the hosting scene
  51633. * @returns a Scene
  51634. */
  51635. getScene(): Scene;
  51636. /** Gets the internal CubeTexture used to render to */
  51637. readonly cubeTexture: RenderTargetTexture;
  51638. /** Gets the list of meshes to render */
  51639. readonly renderList: Nullable<AbstractMesh[]>;
  51640. /**
  51641. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  51642. * @param mesh defines the mesh to attach to
  51643. */
  51644. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  51645. /**
  51646. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  51647. * @param renderingGroupId The rendering group id corresponding to its index
  51648. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  51649. */
  51650. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  51651. /**
  51652. * Clean all associated resources
  51653. */
  51654. dispose(): void;
  51655. /**
  51656. * Converts the reflection probe information to a readable string for debug purpose.
  51657. * @param fullDetails Supports for multiple levels of logging within scene loading
  51658. * @returns the human readable reflection probe info
  51659. */
  51660. toString(fullDetails?: boolean): string;
  51661. /**
  51662. * Get the class name of the relfection probe.
  51663. * @returns "ReflectionProbe"
  51664. */
  51665. getClassName(): string;
  51666. /**
  51667. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  51668. * @returns The JSON representation of the texture
  51669. */
  51670. serialize(): any;
  51671. /**
  51672. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  51673. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  51674. * @param scene Define the scene the parsed reflection probe should be instantiated in
  51675. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  51676. * @returns The parsed reflection probe if successful
  51677. */
  51678. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  51679. }
  51680. }
  51681. declare module BABYLON {
  51682. /** @hidden */
  51683. export var _BabylonLoaderRegistered: boolean;
  51684. }
  51685. declare module BABYLON {
  51686. /**
  51687. * The Physically based simple base material of BJS.
  51688. *
  51689. * This enables better naming and convention enforcements on top of the pbrMaterial.
  51690. * It is used as the base class for both the specGloss and metalRough conventions.
  51691. */
  51692. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  51693. /**
  51694. * Number of Simultaneous lights allowed on the material.
  51695. */
  51696. maxSimultaneousLights: number;
  51697. /**
  51698. * If sets to true, disables all the lights affecting the material.
  51699. */
  51700. disableLighting: boolean;
  51701. /**
  51702. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  51703. */
  51704. environmentTexture: BaseTexture;
  51705. /**
  51706. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  51707. */
  51708. invertNormalMapX: boolean;
  51709. /**
  51710. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  51711. */
  51712. invertNormalMapY: boolean;
  51713. /**
  51714. * Normal map used in the model.
  51715. */
  51716. normalTexture: BaseTexture;
  51717. /**
  51718. * Emissivie color used to self-illuminate the model.
  51719. */
  51720. emissiveColor: Color3;
  51721. /**
  51722. * Emissivie texture used to self-illuminate the model.
  51723. */
  51724. emissiveTexture: BaseTexture;
  51725. /**
  51726. * Occlusion Channel Strenght.
  51727. */
  51728. occlusionStrength: number;
  51729. /**
  51730. * Occlusion Texture of the material (adding extra occlusion effects).
  51731. */
  51732. occlusionTexture: BaseTexture;
  51733. /**
  51734. * Defines the alpha limits in alpha test mode.
  51735. */
  51736. alphaCutOff: number;
  51737. /**
  51738. * Gets the current double sided mode.
  51739. */
  51740. /**
  51741. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  51742. */
  51743. doubleSided: boolean;
  51744. /**
  51745. * Stores the pre-calculated light information of a mesh in a texture.
  51746. */
  51747. lightmapTexture: BaseTexture;
  51748. /**
  51749. * If true, the light map contains occlusion information instead of lighting info.
  51750. */
  51751. useLightmapAsShadowmap: boolean;
  51752. /**
  51753. * Instantiates a new PBRMaterial instance.
  51754. *
  51755. * @param name The material name
  51756. * @param scene The scene the material will be use in.
  51757. */
  51758. constructor(name: string, scene: Scene);
  51759. getClassName(): string;
  51760. }
  51761. }
  51762. declare module BABYLON {
  51763. /**
  51764. * The PBR material of BJS following the metal roughness convention.
  51765. *
  51766. * This fits to the PBR convention in the GLTF definition:
  51767. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  51768. */
  51769. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  51770. /**
  51771. * The base color has two different interpretations depending on the value of metalness.
  51772. * When the material is a metal, the base color is the specific measured reflectance value
  51773. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  51774. * of the material.
  51775. */
  51776. baseColor: Color3;
  51777. /**
  51778. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  51779. * well as opacity information in the alpha channel.
  51780. */
  51781. baseTexture: BaseTexture;
  51782. /**
  51783. * Specifies the metallic scalar value of the material.
  51784. * Can also be used to scale the metalness values of the metallic texture.
  51785. */
  51786. metallic: number;
  51787. /**
  51788. * Specifies the roughness scalar value of the material.
  51789. * Can also be used to scale the roughness values of the metallic texture.
  51790. */
  51791. roughness: number;
  51792. /**
  51793. * Texture containing both the metallic value in the B channel and the
  51794. * roughness value in the G channel to keep better precision.
  51795. */
  51796. metallicRoughnessTexture: BaseTexture;
  51797. /**
  51798. * Instantiates a new PBRMetalRoughnessMaterial instance.
  51799. *
  51800. * @param name The material name
  51801. * @param scene The scene the material will be use in.
  51802. */
  51803. constructor(name: string, scene: Scene);
  51804. /**
  51805. * Return the currrent class name of the material.
  51806. */
  51807. getClassName(): string;
  51808. /**
  51809. * Makes a duplicate of the current material.
  51810. * @param name - name to use for the new material.
  51811. */
  51812. clone(name: string): PBRMetallicRoughnessMaterial;
  51813. /**
  51814. * Serialize the material to a parsable JSON object.
  51815. */
  51816. serialize(): any;
  51817. /**
  51818. * Parses a JSON object correponding to the serialize function.
  51819. */
  51820. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  51821. }
  51822. }
  51823. declare module BABYLON {
  51824. /**
  51825. * The PBR material of BJS following the specular glossiness convention.
  51826. *
  51827. * This fits to the PBR convention in the GLTF definition:
  51828. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  51829. */
  51830. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  51831. /**
  51832. * Specifies the diffuse color of the material.
  51833. */
  51834. diffuseColor: Color3;
  51835. /**
  51836. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  51837. * channel.
  51838. */
  51839. diffuseTexture: BaseTexture;
  51840. /**
  51841. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  51842. */
  51843. specularColor: Color3;
  51844. /**
  51845. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  51846. */
  51847. glossiness: number;
  51848. /**
  51849. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  51850. */
  51851. specularGlossinessTexture: BaseTexture;
  51852. /**
  51853. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  51854. *
  51855. * @param name The material name
  51856. * @param scene The scene the material will be use in.
  51857. */
  51858. constructor(name: string, scene: Scene);
  51859. /**
  51860. * Return the currrent class name of the material.
  51861. */
  51862. getClassName(): string;
  51863. /**
  51864. * Makes a duplicate of the current material.
  51865. * @param name - name to use for the new material.
  51866. */
  51867. clone(name: string): PBRSpecularGlossinessMaterial;
  51868. /**
  51869. * Serialize the material to a parsable JSON object.
  51870. */
  51871. serialize(): any;
  51872. /**
  51873. * Parses a JSON object correponding to the serialize function.
  51874. */
  51875. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  51876. }
  51877. }
  51878. declare module BABYLON {
  51879. /**
  51880. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  51881. * It can help converting any input color in a desired output one. This can then be used to create effects
  51882. * from sepia, black and white to sixties or futuristic rendering...
  51883. *
  51884. * The only supported format is currently 3dl.
  51885. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  51886. */
  51887. export class ColorGradingTexture extends BaseTexture {
  51888. /**
  51889. * The current texture matrix. (will always be identity in color grading texture)
  51890. */
  51891. private _textureMatrix;
  51892. /**
  51893. * The texture URL.
  51894. */
  51895. url: string;
  51896. /**
  51897. * Empty line regex stored for GC.
  51898. */
  51899. private static _noneEmptyLineRegex;
  51900. private _engine;
  51901. /**
  51902. * Instantiates a ColorGradingTexture from the following parameters.
  51903. *
  51904. * @param url The location of the color gradind data (currently only supporting 3dl)
  51905. * @param scene The scene the texture will be used in
  51906. */
  51907. constructor(url: string, scene: Scene);
  51908. /**
  51909. * Returns the texture matrix used in most of the material.
  51910. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  51911. */
  51912. getTextureMatrix(): Matrix;
  51913. /**
  51914. * Occurs when the file being loaded is a .3dl LUT file.
  51915. */
  51916. private load3dlTexture;
  51917. /**
  51918. * Starts the loading process of the texture.
  51919. */
  51920. private loadTexture;
  51921. /**
  51922. * Clones the color gradind texture.
  51923. */
  51924. clone(): ColorGradingTexture;
  51925. /**
  51926. * Called during delayed load for textures.
  51927. */
  51928. delayLoad(): void;
  51929. /**
  51930. * Parses a color grading texture serialized by Babylon.
  51931. * @param parsedTexture The texture information being parsedTexture
  51932. * @param scene The scene to load the texture in
  51933. * @param rootUrl The root url of the data assets to load
  51934. * @return A color gradind texture
  51935. */
  51936. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  51937. /**
  51938. * Serializes the LUT texture to json format.
  51939. */
  51940. serialize(): any;
  51941. }
  51942. }
  51943. declare module BABYLON {
  51944. /**
  51945. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  51946. */
  51947. export class EquiRectangularCubeTexture extends BaseTexture {
  51948. /** The six faces of the cube. */
  51949. private static _FacesMapping;
  51950. private _noMipmap;
  51951. private _onLoad;
  51952. private _onError;
  51953. /** The size of the cubemap. */
  51954. private _size;
  51955. /** The buffer of the image. */
  51956. private _buffer;
  51957. /** The width of the input image. */
  51958. private _width;
  51959. /** The height of the input image. */
  51960. private _height;
  51961. /** The URL to the image. */
  51962. url: string;
  51963. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  51964. coordinatesMode: number;
  51965. /**
  51966. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  51967. * @param url The location of the image
  51968. * @param scene The scene the texture will be used in
  51969. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  51970. * @param noMipmap Forces to not generate the mipmap if true
  51971. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  51972. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  51973. * @param onLoad — defines a callback called when texture is loaded
  51974. * @param onError — defines a callback called if there is an error
  51975. */
  51976. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  51977. /**
  51978. * Load the image data, by putting the image on a canvas and extracting its buffer.
  51979. */
  51980. private loadImage;
  51981. /**
  51982. * Convert the image buffer into a cubemap and create a CubeTexture.
  51983. */
  51984. private loadTexture;
  51985. /**
  51986. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  51987. * @param buffer The ArrayBuffer that should be converted.
  51988. * @returns The buffer as Float32Array.
  51989. */
  51990. private getFloat32ArrayFromArrayBuffer;
  51991. /**
  51992. * Get the current class name of the texture useful for serialization or dynamic coding.
  51993. * @returns "EquiRectangularCubeTexture"
  51994. */
  51995. getClassName(): string;
  51996. /**
  51997. * Create a clone of the current EquiRectangularCubeTexture and return it.
  51998. * @returns A clone of the current EquiRectangularCubeTexture.
  51999. */
  52000. clone(): EquiRectangularCubeTexture;
  52001. }
  52002. }
  52003. declare module BABYLON {
  52004. /**
  52005. * Based on jsTGALoader - Javascript loader for TGA file
  52006. * By Vincent Thibault
  52007. * @see http://blog.robrowser.com/javascript-tga-loader.html
  52008. */
  52009. export class TGATools {
  52010. private static _TYPE_INDEXED;
  52011. private static _TYPE_RGB;
  52012. private static _TYPE_GREY;
  52013. private static _TYPE_RLE_INDEXED;
  52014. private static _TYPE_RLE_RGB;
  52015. private static _TYPE_RLE_GREY;
  52016. private static _ORIGIN_MASK;
  52017. private static _ORIGIN_SHIFT;
  52018. private static _ORIGIN_BL;
  52019. private static _ORIGIN_BR;
  52020. private static _ORIGIN_UL;
  52021. private static _ORIGIN_UR;
  52022. /**
  52023. * Gets the header of a TGA file
  52024. * @param data defines the TGA data
  52025. * @returns the header
  52026. */
  52027. static GetTGAHeader(data: Uint8Array): any;
  52028. /**
  52029. * Uploads TGA content to a Babylon Texture
  52030. * @hidden
  52031. */
  52032. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  52033. /** @hidden */
  52034. 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;
  52035. /** @hidden */
  52036. 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;
  52037. /** @hidden */
  52038. 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;
  52039. /** @hidden */
  52040. 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;
  52041. /** @hidden */
  52042. 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;
  52043. /** @hidden */
  52044. 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;
  52045. }
  52046. }
  52047. declare module BABYLON {
  52048. /**
  52049. * Implementation of the TGA Texture Loader.
  52050. * @hidden
  52051. */
  52052. export class _TGATextureLoader implements IInternalTextureLoader {
  52053. /**
  52054. * Defines wether the loader supports cascade loading the different faces.
  52055. */
  52056. readonly supportCascades: boolean;
  52057. /**
  52058. * This returns if the loader support the current file information.
  52059. * @param extension defines the file extension of the file being loaded
  52060. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52061. * @param fallback defines the fallback internal texture if any
  52062. * @param isBase64 defines whether the texture is encoded as a base64
  52063. * @param isBuffer defines whether the texture data are stored as a buffer
  52064. * @returns true if the loader can load the specified file
  52065. */
  52066. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  52067. /**
  52068. * Transform the url before loading if required.
  52069. * @param rootUrl the url of the texture
  52070. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52071. * @returns the transformed texture
  52072. */
  52073. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  52074. /**
  52075. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  52076. * @param rootUrl the url of the texture
  52077. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52078. * @returns the fallback texture
  52079. */
  52080. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  52081. /**
  52082. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  52083. * @param data contains the texture data
  52084. * @param texture defines the BabylonJS internal texture
  52085. * @param createPolynomials will be true if polynomials have been requested
  52086. * @param onLoad defines the callback to trigger once the texture is ready
  52087. * @param onError defines the callback to trigger in case of error
  52088. */
  52089. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  52090. /**
  52091. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  52092. * @param data contains the texture data
  52093. * @param texture defines the BabylonJS internal texture
  52094. * @param callback defines the method to call once ready to upload
  52095. */
  52096. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  52097. }
  52098. }
  52099. declare module BABYLON {
  52100. /**
  52101. * Info about the .basis files
  52102. */
  52103. class BasisFileInfo {
  52104. /**
  52105. * If the file has alpha
  52106. */
  52107. hasAlpha: boolean;
  52108. /**
  52109. * Info about each image of the basis file
  52110. */
  52111. images: Array<{
  52112. levels: Array<{
  52113. width: number;
  52114. height: number;
  52115. transcodedPixels: ArrayBufferView;
  52116. }>;
  52117. }>;
  52118. }
  52119. /**
  52120. * Result of transcoding a basis file
  52121. */
  52122. class TranscodeResult {
  52123. /**
  52124. * Info about the .basis file
  52125. */
  52126. fileInfo: BasisFileInfo;
  52127. /**
  52128. * Format to use when loading the file
  52129. */
  52130. format: number;
  52131. }
  52132. /**
  52133. * Configuration options for the Basis transcoder
  52134. */
  52135. export class BasisTranscodeConfiguration {
  52136. /**
  52137. * Supported compression formats used to determine the supported output format of the transcoder
  52138. */
  52139. supportedCompressionFormats?: {
  52140. /**
  52141. * etc1 compression format
  52142. */
  52143. etc1?: boolean;
  52144. /**
  52145. * s3tc compression format
  52146. */
  52147. s3tc?: boolean;
  52148. /**
  52149. * pvrtc compression format
  52150. */
  52151. pvrtc?: boolean;
  52152. /**
  52153. * etc2 compression format
  52154. */
  52155. etc2?: boolean;
  52156. };
  52157. /**
  52158. * If mipmap levels should be loaded for transcoded images (Default: true)
  52159. */
  52160. loadMipmapLevels?: boolean;
  52161. /**
  52162. * Index of a single image to load (Default: all images)
  52163. */
  52164. loadSingleImage?: number;
  52165. }
  52166. /**
  52167. * Used to load .Basis files
  52168. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  52169. */
  52170. export class BasisTools {
  52171. private static _IgnoreSupportedFormats;
  52172. /**
  52173. * URL to use when loading the basis transcoder
  52174. */
  52175. static JSModuleURL: string;
  52176. /**
  52177. * URL to use when loading the wasm module for the transcoder
  52178. */
  52179. static WasmModuleURL: string;
  52180. /**
  52181. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  52182. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  52183. * @returns internal format corresponding to the Basis format
  52184. */
  52185. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  52186. private static _WorkerPromise;
  52187. private static _Worker;
  52188. private static _actionId;
  52189. private static _CreateWorkerAsync;
  52190. /**
  52191. * Transcodes a loaded image file to compressed pixel data
  52192. * @param imageData image data to transcode
  52193. * @param config configuration options for the transcoding
  52194. * @returns a promise resulting in the transcoded image
  52195. */
  52196. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  52197. /**
  52198. * Loads a texture from the transcode result
  52199. * @param texture texture load to
  52200. * @param transcodeResult the result of transcoding the basis file to load from
  52201. */
  52202. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  52203. }
  52204. }
  52205. declare module BABYLON {
  52206. /**
  52207. * Loader for .basis file format
  52208. */
  52209. export class _BasisTextureLoader implements IInternalTextureLoader {
  52210. /**
  52211. * Defines whether the loader supports cascade loading the different faces.
  52212. */
  52213. readonly supportCascades: boolean;
  52214. /**
  52215. * This returns if the loader support the current file information.
  52216. * @param extension defines the file extension of the file being loaded
  52217. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52218. * @param fallback defines the fallback internal texture if any
  52219. * @param isBase64 defines whether the texture is encoded as a base64
  52220. * @param isBuffer defines whether the texture data are stored as a buffer
  52221. * @returns true if the loader can load the specified file
  52222. */
  52223. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  52224. /**
  52225. * Transform the url before loading if required.
  52226. * @param rootUrl the url of the texture
  52227. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52228. * @returns the transformed texture
  52229. */
  52230. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  52231. /**
  52232. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  52233. * @param rootUrl the url of the texture
  52234. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52235. * @returns the fallback texture
  52236. */
  52237. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  52238. /**
  52239. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  52240. * @param data contains the texture data
  52241. * @param texture defines the BabylonJS internal texture
  52242. * @param createPolynomials will be true if polynomials have been requested
  52243. * @param onLoad defines the callback to trigger once the texture is ready
  52244. * @param onError defines the callback to trigger in case of error
  52245. */
  52246. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  52247. /**
  52248. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  52249. * @param data contains the texture data
  52250. * @param texture defines the BabylonJS internal texture
  52251. * @param callback defines the method to call once ready to upload
  52252. */
  52253. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  52254. }
  52255. }
  52256. declare module BABYLON {
  52257. /**
  52258. * 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.
  52259. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  52260. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  52261. */
  52262. export class CustomProceduralTexture extends ProceduralTexture {
  52263. private _animate;
  52264. private _time;
  52265. private _config;
  52266. private _texturePath;
  52267. /**
  52268. * Instantiates a new Custom Procedural Texture.
  52269. * 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.
  52270. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  52271. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  52272. * @param name Define the name of the texture
  52273. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  52274. * @param size Define the size of the texture to create
  52275. * @param scene Define the scene the texture belongs to
  52276. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  52277. * @param generateMipMaps Define if the texture should creates mip maps or not
  52278. */
  52279. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  52280. private _loadJson;
  52281. /**
  52282. * Is the texture ready to be used ? (rendered at least once)
  52283. * @returns true if ready, otherwise, false.
  52284. */
  52285. isReady(): boolean;
  52286. /**
  52287. * Render the texture to its associated render target.
  52288. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  52289. */
  52290. render(useCameraPostProcess?: boolean): void;
  52291. /**
  52292. * Update the list of dependant textures samplers in the shader.
  52293. */
  52294. updateTextures(): void;
  52295. /**
  52296. * Update the uniform values of the procedural texture in the shader.
  52297. */
  52298. updateShaderUniforms(): void;
  52299. /**
  52300. * Define if the texture animates or not.
  52301. */
  52302. animate: boolean;
  52303. }
  52304. }
  52305. declare module BABYLON {
  52306. /** @hidden */
  52307. export var noisePixelShader: {
  52308. name: string;
  52309. shader: string;
  52310. };
  52311. }
  52312. declare module BABYLON {
  52313. /**
  52314. * Class used to generate noise procedural textures
  52315. */
  52316. export class NoiseProceduralTexture extends ProceduralTexture {
  52317. private _time;
  52318. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  52319. brightness: number;
  52320. /** Defines the number of octaves to process */
  52321. octaves: number;
  52322. /** Defines the level of persistence (0.8 by default) */
  52323. persistence: number;
  52324. /** Gets or sets animation speed factor (default is 1) */
  52325. animationSpeedFactor: number;
  52326. /**
  52327. * Creates a new NoiseProceduralTexture
  52328. * @param name defines the name fo the texture
  52329. * @param size defines the size of the texture (default is 256)
  52330. * @param scene defines the hosting scene
  52331. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  52332. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  52333. */
  52334. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  52335. private _updateShaderUniforms;
  52336. protected _getDefines(): string;
  52337. /** Generate the current state of the procedural texture */
  52338. render(useCameraPostProcess?: boolean): void;
  52339. /**
  52340. * Serializes this noise procedural texture
  52341. * @returns a serialized noise procedural texture object
  52342. */
  52343. serialize(): any;
  52344. /**
  52345. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  52346. * @param parsedTexture defines parsed texture data
  52347. * @param scene defines the current scene
  52348. * @param rootUrl defines the root URL containing noise procedural texture information
  52349. * @returns a parsed NoiseProceduralTexture
  52350. */
  52351. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  52352. }
  52353. }
  52354. declare module BABYLON {
  52355. /**
  52356. * Raw cube texture where the raw buffers are passed in
  52357. */
  52358. export class RawCubeTexture extends CubeTexture {
  52359. /**
  52360. * Creates a cube texture where the raw buffers are passed in.
  52361. * @param scene defines the scene the texture is attached to
  52362. * @param data defines the array of data to use to create each face
  52363. * @param size defines the size of the textures
  52364. * @param format defines the format of the data
  52365. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  52366. * @param generateMipMaps defines if the engine should generate the mip levels
  52367. * @param invertY defines if data must be stored with Y axis inverted
  52368. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  52369. * @param compression defines the compression used (null by default)
  52370. */
  52371. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  52372. /**
  52373. * Updates the raw cube texture.
  52374. * @param data defines the data to store
  52375. * @param format defines the data format
  52376. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  52377. * @param invertY defines if data must be stored with Y axis inverted
  52378. * @param compression defines the compression used (null by default)
  52379. * @param level defines which level of the texture to update
  52380. */
  52381. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  52382. /**
  52383. * Updates a raw cube texture with RGBD encoded data.
  52384. * @param data defines the array of data [mipmap][face] to use to create each face
  52385. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  52386. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  52387. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  52388. * @returns a promsie that resolves when the operation is complete
  52389. */
  52390. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  52391. /**
  52392. * Clones the raw cube texture.
  52393. * @return a new cube texture
  52394. */
  52395. clone(): CubeTexture;
  52396. /** @hidden */
  52397. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  52398. }
  52399. }
  52400. declare module BABYLON {
  52401. /**
  52402. * Class used to store 3D textures containing user data
  52403. */
  52404. export class RawTexture3D extends Texture {
  52405. /** Gets or sets the texture format to use */
  52406. format: number;
  52407. private _engine;
  52408. /**
  52409. * Create a new RawTexture3D
  52410. * @param data defines the data of the texture
  52411. * @param width defines the width of the texture
  52412. * @param height defines the height of the texture
  52413. * @param depth defines the depth of the texture
  52414. * @param format defines the texture format to use
  52415. * @param scene defines the hosting scene
  52416. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  52417. * @param invertY defines if texture must be stored with Y axis inverted
  52418. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  52419. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  52420. */
  52421. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  52422. /** Gets or sets the texture format to use */
  52423. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  52424. /**
  52425. * Update the texture with new data
  52426. * @param data defines the data to store in the texture
  52427. */
  52428. update(data: ArrayBufferView): void;
  52429. }
  52430. }
  52431. declare module BABYLON {
  52432. /**
  52433. * Creates a refraction texture used by refraction channel of the standard material.
  52434. * It is like a mirror but to see through a material.
  52435. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  52436. */
  52437. export class RefractionTexture extends RenderTargetTexture {
  52438. /**
  52439. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  52440. * 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.
  52441. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  52442. */
  52443. refractionPlane: Plane;
  52444. /**
  52445. * Define how deep under the surface we should see.
  52446. */
  52447. depth: number;
  52448. /**
  52449. * Creates a refraction texture used by refraction channel of the standard material.
  52450. * It is like a mirror but to see through a material.
  52451. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  52452. * @param name Define the texture name
  52453. * @param size Define the size of the underlying texture
  52454. * @param scene Define the scene the refraction belongs to
  52455. * @param generateMipMaps Define if we need to generate mips level for the refraction
  52456. */
  52457. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  52458. /**
  52459. * Clone the refraction texture.
  52460. * @returns the cloned texture
  52461. */
  52462. clone(): RefractionTexture;
  52463. /**
  52464. * Serialize the texture to a JSON representation you could use in Parse later on
  52465. * @returns the serialized JSON representation
  52466. */
  52467. serialize(): any;
  52468. }
  52469. }
  52470. declare module BABYLON {
  52471. /**
  52472. * Defines the options related to the creation of an HtmlElementTexture
  52473. */
  52474. export interface IHtmlElementTextureOptions {
  52475. /**
  52476. * Defines wether mip maps should be created or not.
  52477. */
  52478. generateMipMaps?: boolean;
  52479. /**
  52480. * Defines the sampling mode of the texture.
  52481. */
  52482. samplingMode?: number;
  52483. /**
  52484. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  52485. */
  52486. engine: Nullable<ThinEngine>;
  52487. /**
  52488. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  52489. */
  52490. scene: Nullable<Scene>;
  52491. }
  52492. /**
  52493. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  52494. * To be as efficient as possible depending on your constraints nothing aside the first upload
  52495. * is automatically managed.
  52496. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  52497. * in your application.
  52498. *
  52499. * As the update is not automatic, you need to call them manually.
  52500. */
  52501. export class HtmlElementTexture extends BaseTexture {
  52502. /**
  52503. * The texture URL.
  52504. */
  52505. element: HTMLVideoElement | HTMLCanvasElement;
  52506. private static readonly DefaultOptions;
  52507. private _textureMatrix;
  52508. private _engine;
  52509. private _isVideo;
  52510. private _generateMipMaps;
  52511. private _samplingMode;
  52512. /**
  52513. * Instantiates a HtmlElementTexture from the following parameters.
  52514. *
  52515. * @param name Defines the name of the texture
  52516. * @param element Defines the video or canvas the texture is filled with
  52517. * @param options Defines the other none mandatory texture creation options
  52518. */
  52519. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  52520. private _createInternalTexture;
  52521. /**
  52522. * Returns the texture matrix used in most of the material.
  52523. */
  52524. getTextureMatrix(): Matrix;
  52525. /**
  52526. * Updates the content of the texture.
  52527. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  52528. */
  52529. update(invertY?: Nullable<boolean>): void;
  52530. }
  52531. }
  52532. declare module BABYLON {
  52533. /**
  52534. * Enum used to define the target of a block
  52535. */
  52536. export enum NodeMaterialBlockTargets {
  52537. /** Vertex shader */
  52538. Vertex = 1,
  52539. /** Fragment shader */
  52540. Fragment = 2,
  52541. /** Neutral */
  52542. Neutral = 4,
  52543. /** Vertex and Fragment */
  52544. VertexAndFragment = 3
  52545. }
  52546. }
  52547. declare module BABYLON {
  52548. /**
  52549. * Defines the kind of connection point for node based material
  52550. */
  52551. export enum NodeMaterialBlockConnectionPointTypes {
  52552. /** Float */
  52553. Float = 1,
  52554. /** Int */
  52555. Int = 2,
  52556. /** Vector2 */
  52557. Vector2 = 4,
  52558. /** Vector3 */
  52559. Vector3 = 8,
  52560. /** Vector4 */
  52561. Vector4 = 16,
  52562. /** Color3 */
  52563. Color3 = 32,
  52564. /** Color4 */
  52565. Color4 = 64,
  52566. /** Matrix */
  52567. Matrix = 128,
  52568. /** Detect type based on connection */
  52569. AutoDetect = 1024,
  52570. /** Output type that will be defined by input type */
  52571. BasedOnInput = 2048
  52572. }
  52573. }
  52574. declare module BABYLON {
  52575. /**
  52576. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  52577. */
  52578. export enum NodeMaterialBlockConnectionPointMode {
  52579. /** Value is an uniform */
  52580. Uniform = 0,
  52581. /** Value is a mesh attribute */
  52582. Attribute = 1,
  52583. /** Value is a varying between vertex and fragment shaders */
  52584. Varying = 2,
  52585. /** Mode is undefined */
  52586. Undefined = 3
  52587. }
  52588. }
  52589. declare module BABYLON {
  52590. /**
  52591. * Enum used to define system values e.g. values automatically provided by the system
  52592. */
  52593. export enum NodeMaterialSystemValues {
  52594. /** World */
  52595. World = 1,
  52596. /** View */
  52597. View = 2,
  52598. /** Projection */
  52599. Projection = 3,
  52600. /** ViewProjection */
  52601. ViewProjection = 4,
  52602. /** WorldView */
  52603. WorldView = 5,
  52604. /** WorldViewProjection */
  52605. WorldViewProjection = 6,
  52606. /** CameraPosition */
  52607. CameraPosition = 7,
  52608. /** Fog Color */
  52609. FogColor = 8,
  52610. /** Delta time */
  52611. DeltaTime = 9
  52612. }
  52613. }
  52614. declare module BABYLON {
  52615. /**
  52616. * Root class for all node material optimizers
  52617. */
  52618. export class NodeMaterialOptimizer {
  52619. /**
  52620. * Function used to optimize a NodeMaterial graph
  52621. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  52622. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  52623. */
  52624. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  52625. }
  52626. }
  52627. declare module BABYLON {
  52628. /**
  52629. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  52630. */
  52631. export class TransformBlock extends NodeMaterialBlock {
  52632. /**
  52633. * Defines the value to use to complement W value to transform it to a Vector4
  52634. */
  52635. complementW: number;
  52636. /**
  52637. * Defines the value to use to complement z value to transform it to a Vector4
  52638. */
  52639. complementZ: number;
  52640. /**
  52641. * Creates a new TransformBlock
  52642. * @param name defines the block name
  52643. */
  52644. constructor(name: string);
  52645. /**
  52646. * Gets the current class name
  52647. * @returns the class name
  52648. */
  52649. getClassName(): string;
  52650. /**
  52651. * Gets the vector input
  52652. */
  52653. readonly vector: NodeMaterialConnectionPoint;
  52654. /**
  52655. * Gets the output component
  52656. */
  52657. readonly output: NodeMaterialConnectionPoint;
  52658. /**
  52659. * Gets the matrix transform input
  52660. */
  52661. readonly transform: NodeMaterialConnectionPoint;
  52662. protected _buildBlock(state: NodeMaterialBuildState): this;
  52663. serialize(): any;
  52664. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  52665. protected _dumpPropertiesCode(): string;
  52666. }
  52667. }
  52668. declare module BABYLON {
  52669. /**
  52670. * Block used to output the vertex position
  52671. */
  52672. export class VertexOutputBlock extends NodeMaterialBlock {
  52673. /**
  52674. * Creates a new VertexOutputBlock
  52675. * @param name defines the block name
  52676. */
  52677. constructor(name: string);
  52678. /**
  52679. * Gets the current class name
  52680. * @returns the class name
  52681. */
  52682. getClassName(): string;
  52683. /**
  52684. * Gets the vector input component
  52685. */
  52686. readonly vector: NodeMaterialConnectionPoint;
  52687. protected _buildBlock(state: NodeMaterialBuildState): this;
  52688. }
  52689. }
  52690. declare module BABYLON {
  52691. /**
  52692. * Block used to output the final color
  52693. */
  52694. export class FragmentOutputBlock extends NodeMaterialBlock {
  52695. /**
  52696. * Create a new FragmentOutputBlock
  52697. * @param name defines the block name
  52698. */
  52699. constructor(name: string);
  52700. /**
  52701. * Gets the current class name
  52702. * @returns the class name
  52703. */
  52704. getClassName(): string;
  52705. /**
  52706. * Gets the rgba input component
  52707. */
  52708. readonly rgba: NodeMaterialConnectionPoint;
  52709. /**
  52710. * Gets the rgb input component
  52711. */
  52712. readonly rgb: NodeMaterialConnectionPoint;
  52713. /**
  52714. * Gets the a input component
  52715. */
  52716. readonly a: NodeMaterialConnectionPoint;
  52717. protected _buildBlock(state: NodeMaterialBuildState): this;
  52718. }
  52719. }
  52720. declare module BABYLON {
  52721. /**
  52722. * Block used to read a reflection texture from a sampler
  52723. */
  52724. export class ReflectionTextureBlock extends NodeMaterialBlock {
  52725. private _define3DName;
  52726. private _defineCubicName;
  52727. private _defineExplicitName;
  52728. private _defineProjectionName;
  52729. private _defineLocalCubicName;
  52730. private _defineSphericalName;
  52731. private _definePlanarName;
  52732. private _defineEquirectangularName;
  52733. private _defineMirroredEquirectangularFixedName;
  52734. private _defineEquirectangularFixedName;
  52735. private _defineSkyboxName;
  52736. private _cubeSamplerName;
  52737. private _2DSamplerName;
  52738. private _positionUVWName;
  52739. private _directionWName;
  52740. private _reflectionCoordsName;
  52741. private _reflection2DCoordsName;
  52742. private _reflectionColorName;
  52743. private _reflectionMatrixName;
  52744. /**
  52745. * Gets or sets the texture associated with the node
  52746. */
  52747. texture: Nullable<BaseTexture>;
  52748. /**
  52749. * Create a new TextureBlock
  52750. * @param name defines the block name
  52751. */
  52752. constructor(name: string);
  52753. /**
  52754. * Gets the current class name
  52755. * @returns the class name
  52756. */
  52757. getClassName(): string;
  52758. /**
  52759. * Gets the world position input component
  52760. */
  52761. readonly position: NodeMaterialConnectionPoint;
  52762. /**
  52763. * Gets the world position input component
  52764. */
  52765. readonly worldPosition: NodeMaterialConnectionPoint;
  52766. /**
  52767. * Gets the world normal input component
  52768. */
  52769. readonly worldNormal: NodeMaterialConnectionPoint;
  52770. /**
  52771. * Gets the world input component
  52772. */
  52773. readonly world: NodeMaterialConnectionPoint;
  52774. /**
  52775. * Gets the camera (or eye) position component
  52776. */
  52777. readonly cameraPosition: NodeMaterialConnectionPoint;
  52778. /**
  52779. * Gets the view input component
  52780. */
  52781. readonly view: NodeMaterialConnectionPoint;
  52782. /**
  52783. * Gets the rgb output component
  52784. */
  52785. readonly rgb: NodeMaterialConnectionPoint;
  52786. /**
  52787. * Gets the r output component
  52788. */
  52789. readonly r: NodeMaterialConnectionPoint;
  52790. /**
  52791. * Gets the g output component
  52792. */
  52793. readonly g: NodeMaterialConnectionPoint;
  52794. /**
  52795. * Gets the b output component
  52796. */
  52797. readonly b: NodeMaterialConnectionPoint;
  52798. autoConfigure(material: NodeMaterial): void;
  52799. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  52800. isReady(): boolean;
  52801. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  52802. private _injectVertexCode;
  52803. private _writeOutput;
  52804. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  52805. serialize(): any;
  52806. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  52807. }
  52808. }
  52809. declare module BABYLON {
  52810. /**
  52811. * Interface used to configure the node material editor
  52812. */
  52813. export interface INodeMaterialEditorOptions {
  52814. /** Define the URl to load node editor script */
  52815. editorURL?: string;
  52816. }
  52817. /** @hidden */
  52818. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  52819. /** BONES */
  52820. NUM_BONE_INFLUENCERS: number;
  52821. BonesPerMesh: number;
  52822. BONETEXTURE: boolean;
  52823. /** MORPH TARGETS */
  52824. MORPHTARGETS: boolean;
  52825. MORPHTARGETS_NORMAL: boolean;
  52826. MORPHTARGETS_TANGENT: boolean;
  52827. MORPHTARGETS_UV: boolean;
  52828. NUM_MORPH_INFLUENCERS: number;
  52829. /** IMAGE PROCESSING */
  52830. IMAGEPROCESSING: boolean;
  52831. VIGNETTE: boolean;
  52832. VIGNETTEBLENDMODEMULTIPLY: boolean;
  52833. VIGNETTEBLENDMODEOPAQUE: boolean;
  52834. TONEMAPPING: boolean;
  52835. TONEMAPPING_ACES: boolean;
  52836. CONTRAST: boolean;
  52837. EXPOSURE: boolean;
  52838. COLORCURVES: boolean;
  52839. COLORGRADING: boolean;
  52840. COLORGRADING3D: boolean;
  52841. SAMPLER3DGREENDEPTH: boolean;
  52842. SAMPLER3DBGRMAP: boolean;
  52843. IMAGEPROCESSINGPOSTPROCESS: boolean;
  52844. /** MISC. */
  52845. BUMPDIRECTUV: number;
  52846. constructor();
  52847. setValue(name: string, value: boolean): void;
  52848. }
  52849. /**
  52850. * Class used to configure NodeMaterial
  52851. */
  52852. export interface INodeMaterialOptions {
  52853. /**
  52854. * Defines if blocks should emit comments
  52855. */
  52856. emitComments: boolean;
  52857. }
  52858. /**
  52859. * Class used to create a node based material built by assembling shader blocks
  52860. */
  52861. export class NodeMaterial extends PushMaterial {
  52862. private static _BuildIdGenerator;
  52863. private _options;
  52864. private _vertexCompilationState;
  52865. private _fragmentCompilationState;
  52866. private _sharedData;
  52867. private _buildId;
  52868. private _buildWasSuccessful;
  52869. private _cachedWorldViewMatrix;
  52870. private _cachedWorldViewProjectionMatrix;
  52871. private _optimizers;
  52872. private _animationFrame;
  52873. /** Define the URl to load node editor script */
  52874. static EditorURL: string;
  52875. private BJSNODEMATERIALEDITOR;
  52876. /** Get the inspector from bundle or global */
  52877. private _getGlobalNodeMaterialEditor;
  52878. /**
  52879. * Gets or sets a boolean indicating that alpha value must be ignored (This will turn alpha blending off even if an alpha value is produced by the material)
  52880. */
  52881. ignoreAlpha: boolean;
  52882. /**
  52883. * Defines the maximum number of lights that can be used in the material
  52884. */
  52885. maxSimultaneousLights: number;
  52886. /**
  52887. * Observable raised when the material is built
  52888. */
  52889. onBuildObservable: Observable<NodeMaterial>;
  52890. /**
  52891. * Gets or sets the root nodes of the material vertex shader
  52892. */
  52893. _vertexOutputNodes: NodeMaterialBlock[];
  52894. /**
  52895. * Gets or sets the root nodes of the material fragment (pixel) shader
  52896. */
  52897. _fragmentOutputNodes: NodeMaterialBlock[];
  52898. /** Gets or sets options to control the node material overall behavior */
  52899. options: INodeMaterialOptions;
  52900. /**
  52901. * Default configuration related to image processing available in the standard Material.
  52902. */
  52903. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  52904. /**
  52905. * Gets the image processing configuration used either in this material.
  52906. */
  52907. /**
  52908. * Sets the Default image processing configuration used either in the this material.
  52909. *
  52910. * If sets to null, the scene one is in use.
  52911. */
  52912. imageProcessingConfiguration: ImageProcessingConfiguration;
  52913. /**
  52914. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  52915. */
  52916. attachedBlocks: NodeMaterialBlock[];
  52917. /**
  52918. * Create a new node based material
  52919. * @param name defines the material name
  52920. * @param scene defines the hosting scene
  52921. * @param options defines creation option
  52922. */
  52923. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  52924. /**
  52925. * Gets the current class name of the material e.g. "NodeMaterial"
  52926. * @returns the class name
  52927. */
  52928. getClassName(): string;
  52929. /**
  52930. * Keep track of the image processing observer to allow dispose and replace.
  52931. */
  52932. private _imageProcessingObserver;
  52933. /**
  52934. * Attaches a new image processing configuration to the Standard Material.
  52935. * @param configuration
  52936. */
  52937. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  52938. /**
  52939. * Get a block by its name
  52940. * @param name defines the name of the block to retrieve
  52941. * @returns the required block or null if not found
  52942. */
  52943. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  52944. /**
  52945. * Get a block by its name
  52946. * @param predicate defines the predicate used to find the good candidate
  52947. * @returns the required block or null if not found
  52948. */
  52949. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  52950. /**
  52951. * Get an input block by its name
  52952. * @param predicate defines the predicate used to find the good candidate
  52953. * @returns the required input block or null if not found
  52954. */
  52955. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  52956. /**
  52957. * Gets the list of input blocks attached to this material
  52958. * @returns an array of InputBlocks
  52959. */
  52960. getInputBlocks(): InputBlock[];
  52961. /**
  52962. * Adds a new optimizer to the list of optimizers
  52963. * @param optimizer defines the optimizers to add
  52964. * @returns the current material
  52965. */
  52966. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  52967. /**
  52968. * Remove an optimizer from the list of optimizers
  52969. * @param optimizer defines the optimizers to remove
  52970. * @returns the current material
  52971. */
  52972. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  52973. /**
  52974. * Add a new block to the list of output nodes
  52975. * @param node defines the node to add
  52976. * @returns the current material
  52977. */
  52978. addOutputNode(node: NodeMaterialBlock): this;
  52979. /**
  52980. * Remove a block from the list of root nodes
  52981. * @param node defines the node to remove
  52982. * @returns the current material
  52983. */
  52984. removeOutputNode(node: NodeMaterialBlock): this;
  52985. private _addVertexOutputNode;
  52986. private _removeVertexOutputNode;
  52987. private _addFragmentOutputNode;
  52988. private _removeFragmentOutputNode;
  52989. /**
  52990. * Specifies if the material will require alpha blending
  52991. * @returns a boolean specifying if alpha blending is needed
  52992. */
  52993. needAlphaBlending(): boolean;
  52994. /**
  52995. * Specifies if this material should be rendered in alpha test mode
  52996. * @returns a boolean specifying if an alpha test is needed.
  52997. */
  52998. needAlphaTesting(): boolean;
  52999. private _initializeBlock;
  53000. private _resetDualBlocks;
  53001. /**
  53002. * Build the material and generates the inner effect
  53003. * @param verbose defines if the build should log activity
  53004. */
  53005. build(verbose?: boolean): void;
  53006. /**
  53007. * Runs an otpimization phase to try to improve the shader code
  53008. */
  53009. optimize(): void;
  53010. private _prepareDefinesForAttributes;
  53011. /**
  53012. * Get if the submesh is ready to be used and all its information available.
  53013. * Child classes can use it to update shaders
  53014. * @param mesh defines the mesh to check
  53015. * @param subMesh defines which submesh to check
  53016. * @param useInstances specifies that instances should be used
  53017. * @returns a boolean indicating that the submesh is ready or not
  53018. */
  53019. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  53020. /**
  53021. * Get a string representing the shaders built by the current node graph
  53022. */
  53023. readonly compiledShaders: string;
  53024. /**
  53025. * Binds the world matrix to the material
  53026. * @param world defines the world transformation matrix
  53027. */
  53028. bindOnlyWorldMatrix(world: Matrix): void;
  53029. /**
  53030. * Binds the submesh to this material by preparing the effect and shader to draw
  53031. * @param world defines the world transformation matrix
  53032. * @param mesh defines the mesh containing the submesh
  53033. * @param subMesh defines the submesh to bind the material to
  53034. */
  53035. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  53036. /**
  53037. * Gets the active textures from the material
  53038. * @returns an array of textures
  53039. */
  53040. getActiveTextures(): BaseTexture[];
  53041. /**
  53042. * Gets the list of texture blocks
  53043. * @returns an array of texture blocks
  53044. */
  53045. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  53046. /**
  53047. * Specifies if the material uses a texture
  53048. * @param texture defines the texture to check against the material
  53049. * @returns a boolean specifying if the material uses the texture
  53050. */
  53051. hasTexture(texture: BaseTexture): boolean;
  53052. /**
  53053. * Disposes the material
  53054. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  53055. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  53056. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  53057. */
  53058. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  53059. /** Creates the node editor window. */
  53060. private _createNodeEditor;
  53061. /**
  53062. * Launch the node material editor
  53063. * @param config Define the configuration of the editor
  53064. * @return a promise fulfilled when the node editor is visible
  53065. */
  53066. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  53067. /**
  53068. * Clear the current material
  53069. */
  53070. clear(): void;
  53071. /**
  53072. * Clear the current material and set it to a default state
  53073. */
  53074. setToDefault(): void;
  53075. /**
  53076. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  53077. * @param url defines the url to load from
  53078. * @returns a promise that will fullfil when the material is fully loaded
  53079. */
  53080. loadAsync(url: string): Promise<unknown>;
  53081. private _gatherBlocks;
  53082. /**
  53083. * Generate a string containing the code declaration required to create an equivalent of this material
  53084. * @returns a string
  53085. */
  53086. generateCode(): string;
  53087. /**
  53088. * Serializes this material in a JSON representation
  53089. * @returns the serialized material object
  53090. */
  53091. serialize(): any;
  53092. private _restoreConnections;
  53093. /**
  53094. * Clear the current graph and load a new one from a serialization object
  53095. * @param source defines the JSON representation of the material
  53096. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  53097. */
  53098. loadFromSerialization(source: any, rootUrl?: string): void;
  53099. /**
  53100. * Creates a node material from parsed material data
  53101. * @param source defines the JSON representation of the material
  53102. * @param scene defines the hosting scene
  53103. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  53104. * @returns a new node material
  53105. */
  53106. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  53107. /**
  53108. * Creates a new node material set to default basic configuration
  53109. * @param name defines the name of the material
  53110. * @param scene defines the hosting scene
  53111. * @returns a new NodeMaterial
  53112. */
  53113. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  53114. }
  53115. }
  53116. declare module BABYLON {
  53117. /**
  53118. * Block used to read a texture from a sampler
  53119. */
  53120. export class TextureBlock extends NodeMaterialBlock {
  53121. private _defineName;
  53122. private _linearDefineName;
  53123. private _samplerName;
  53124. private _transformedUVName;
  53125. private _textureTransformName;
  53126. private _textureInfoName;
  53127. private _mainUVName;
  53128. private _mainUVDefineName;
  53129. /**
  53130. * Gets or sets the texture associated with the node
  53131. */
  53132. texture: Nullable<Texture>;
  53133. /**
  53134. * Create a new TextureBlock
  53135. * @param name defines the block name
  53136. */
  53137. constructor(name: string);
  53138. /**
  53139. * Gets the current class name
  53140. * @returns the class name
  53141. */
  53142. getClassName(): string;
  53143. /**
  53144. * Gets the uv input component
  53145. */
  53146. readonly uv: NodeMaterialConnectionPoint;
  53147. /**
  53148. * Gets the rgba output component
  53149. */
  53150. readonly rgba: NodeMaterialConnectionPoint;
  53151. /**
  53152. * Gets the rgb output component
  53153. */
  53154. readonly rgb: NodeMaterialConnectionPoint;
  53155. /**
  53156. * Gets the r output component
  53157. */
  53158. readonly r: NodeMaterialConnectionPoint;
  53159. /**
  53160. * Gets the g output component
  53161. */
  53162. readonly g: NodeMaterialConnectionPoint;
  53163. /**
  53164. * Gets the b output component
  53165. */
  53166. readonly b: NodeMaterialConnectionPoint;
  53167. /**
  53168. * Gets the a output component
  53169. */
  53170. readonly a: NodeMaterialConnectionPoint;
  53171. readonly target: NodeMaterialBlockTargets;
  53172. autoConfigure(material: NodeMaterial): void;
  53173. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  53174. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53175. isReady(): boolean;
  53176. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53177. private readonly _isMixed;
  53178. private _injectVertexCode;
  53179. private _writeOutput;
  53180. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  53181. protected _dumpPropertiesCode(): string;
  53182. serialize(): any;
  53183. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  53184. }
  53185. }
  53186. declare module BABYLON {
  53187. /**
  53188. * Class used to store shared data between 2 NodeMaterialBuildState
  53189. */
  53190. export class NodeMaterialBuildStateSharedData {
  53191. /**
  53192. * Gets the list of emitted varyings
  53193. */
  53194. temps: string[];
  53195. /**
  53196. * Gets the list of emitted varyings
  53197. */
  53198. varyings: string[];
  53199. /**
  53200. * Gets the varying declaration string
  53201. */
  53202. varyingDeclaration: string;
  53203. /**
  53204. * Input blocks
  53205. */
  53206. inputBlocks: InputBlock[];
  53207. /**
  53208. * Input blocks
  53209. */
  53210. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  53211. /**
  53212. * Bindable blocks (Blocks that need to set data to the effect)
  53213. */
  53214. bindableBlocks: NodeMaterialBlock[];
  53215. /**
  53216. * List of blocks that can provide a compilation fallback
  53217. */
  53218. blocksWithFallbacks: NodeMaterialBlock[];
  53219. /**
  53220. * List of blocks that can provide a define update
  53221. */
  53222. blocksWithDefines: NodeMaterialBlock[];
  53223. /**
  53224. * List of blocks that can provide a repeatable content
  53225. */
  53226. repeatableContentBlocks: NodeMaterialBlock[];
  53227. /**
  53228. * List of blocks that can provide a dynamic list of uniforms
  53229. */
  53230. dynamicUniformBlocks: NodeMaterialBlock[];
  53231. /**
  53232. * List of blocks that can block the isReady function for the material
  53233. */
  53234. blockingBlocks: NodeMaterialBlock[];
  53235. /**
  53236. * Gets the list of animated inputs
  53237. */
  53238. animatedInputs: InputBlock[];
  53239. /**
  53240. * Build Id used to avoid multiple recompilations
  53241. */
  53242. buildId: number;
  53243. /** List of emitted variables */
  53244. variableNames: {
  53245. [key: string]: number;
  53246. };
  53247. /** List of emitted defines */
  53248. defineNames: {
  53249. [key: string]: number;
  53250. };
  53251. /** Should emit comments? */
  53252. emitComments: boolean;
  53253. /** Emit build activity */
  53254. verbose: boolean;
  53255. /** Gets or sets the hosting scene */
  53256. scene: Scene;
  53257. /**
  53258. * Gets the compilation hints emitted at compilation time
  53259. */
  53260. hints: {
  53261. needWorldViewMatrix: boolean;
  53262. needWorldViewProjectionMatrix: boolean;
  53263. needAlphaBlending: boolean;
  53264. needAlphaTesting: boolean;
  53265. };
  53266. /**
  53267. * List of compilation checks
  53268. */
  53269. checks: {
  53270. emitVertex: boolean;
  53271. emitFragment: boolean;
  53272. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  53273. };
  53274. /** Creates a new shared data */
  53275. constructor();
  53276. /**
  53277. * Emits console errors and exceptions if there is a failing check
  53278. */
  53279. emitErrors(): void;
  53280. }
  53281. }
  53282. declare module BABYLON {
  53283. /**
  53284. * Class used to store node based material build state
  53285. */
  53286. export class NodeMaterialBuildState {
  53287. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  53288. supportUniformBuffers: boolean;
  53289. /**
  53290. * Gets the list of emitted attributes
  53291. */
  53292. attributes: string[];
  53293. /**
  53294. * Gets the list of emitted uniforms
  53295. */
  53296. uniforms: string[];
  53297. /**
  53298. * Gets the list of emitted constants
  53299. */
  53300. constants: string[];
  53301. /**
  53302. * Gets the list of emitted uniform buffers
  53303. */
  53304. uniformBuffers: string[];
  53305. /**
  53306. * Gets the list of emitted samplers
  53307. */
  53308. samplers: string[];
  53309. /**
  53310. * Gets the list of emitted functions
  53311. */
  53312. functions: {
  53313. [key: string]: string;
  53314. };
  53315. /**
  53316. * Gets the list of emitted extensions
  53317. */
  53318. extensions: {
  53319. [key: string]: string;
  53320. };
  53321. /**
  53322. * Gets the target of the compilation state
  53323. */
  53324. target: NodeMaterialBlockTargets;
  53325. /**
  53326. * Gets the list of emitted counters
  53327. */
  53328. counters: {
  53329. [key: string]: number;
  53330. };
  53331. /**
  53332. * Shared data between multiple NodeMaterialBuildState instances
  53333. */
  53334. sharedData: NodeMaterialBuildStateSharedData;
  53335. /** @hidden */
  53336. _vertexState: NodeMaterialBuildState;
  53337. /** @hidden */
  53338. _attributeDeclaration: string;
  53339. /** @hidden */
  53340. _uniformDeclaration: string;
  53341. /** @hidden */
  53342. _constantDeclaration: string;
  53343. /** @hidden */
  53344. _samplerDeclaration: string;
  53345. /** @hidden */
  53346. _varyingTransfer: string;
  53347. private _repeatableContentAnchorIndex;
  53348. /** @hidden */
  53349. _builtCompilationString: string;
  53350. /**
  53351. * Gets the emitted compilation strings
  53352. */
  53353. compilationString: string;
  53354. /**
  53355. * Finalize the compilation strings
  53356. * @param state defines the current compilation state
  53357. */
  53358. finalize(state: NodeMaterialBuildState): void;
  53359. /** @hidden */
  53360. readonly _repeatableContentAnchor: string;
  53361. /** @hidden */
  53362. _getFreeVariableName(prefix: string): string;
  53363. /** @hidden */
  53364. _getFreeDefineName(prefix: string): string;
  53365. /** @hidden */
  53366. _excludeVariableName(name: string): void;
  53367. /** @hidden */
  53368. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  53369. /** @hidden */
  53370. _emitExtension(name: string, extension: string): void;
  53371. /** @hidden */
  53372. _emitFunction(name: string, code: string, comments: string): void;
  53373. /** @hidden */
  53374. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  53375. replaceStrings?: {
  53376. search: RegExp;
  53377. replace: string;
  53378. }[];
  53379. repeatKey?: string;
  53380. }): string;
  53381. /** @hidden */
  53382. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  53383. repeatKey?: string;
  53384. removeAttributes?: boolean;
  53385. removeUniforms?: boolean;
  53386. removeVaryings?: boolean;
  53387. removeIfDef?: boolean;
  53388. replaceStrings?: {
  53389. search: RegExp;
  53390. replace: string;
  53391. }[];
  53392. }, storeKey?: string): void;
  53393. /** @hidden */
  53394. _registerTempVariable(name: string): boolean;
  53395. /** @hidden */
  53396. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  53397. /** @hidden */
  53398. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  53399. /** @hidden */
  53400. _emitFloat(value: number): string;
  53401. }
  53402. }
  53403. declare module BABYLON {
  53404. /**
  53405. * Defines a block that can be used inside a node based material
  53406. */
  53407. export class NodeMaterialBlock {
  53408. private _buildId;
  53409. private _buildTarget;
  53410. private _target;
  53411. private _isFinalMerger;
  53412. private _isInput;
  53413. /** @hidden */
  53414. _codeVariableName: string;
  53415. /** @hidden */
  53416. _inputs: NodeMaterialConnectionPoint[];
  53417. /** @hidden */
  53418. _outputs: NodeMaterialConnectionPoint[];
  53419. /** @hidden */
  53420. _preparationId: number;
  53421. /**
  53422. * Gets or sets the name of the block
  53423. */
  53424. name: string;
  53425. /**
  53426. * Gets or sets the unique id of the node
  53427. */
  53428. uniqueId: number;
  53429. /**
  53430. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  53431. */
  53432. readonly isFinalMerger: boolean;
  53433. /**
  53434. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  53435. */
  53436. readonly isInput: boolean;
  53437. /**
  53438. * Gets or sets the build Id
  53439. */
  53440. buildId: number;
  53441. /**
  53442. * Gets or sets the target of the block
  53443. */
  53444. target: NodeMaterialBlockTargets;
  53445. /**
  53446. * Gets the list of input points
  53447. */
  53448. readonly inputs: NodeMaterialConnectionPoint[];
  53449. /** Gets the list of output points */
  53450. readonly outputs: NodeMaterialConnectionPoint[];
  53451. /**
  53452. * Find an input by its name
  53453. * @param name defines the name of the input to look for
  53454. * @returns the input or null if not found
  53455. */
  53456. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  53457. /**
  53458. * Find an output by its name
  53459. * @param name defines the name of the outputto look for
  53460. * @returns the output or null if not found
  53461. */
  53462. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  53463. /**
  53464. * Creates a new NodeMaterialBlock
  53465. * @param name defines the block name
  53466. * @param target defines the target of that block (Vertex by default)
  53467. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  53468. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  53469. */
  53470. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  53471. /**
  53472. * Initialize the block and prepare the context for build
  53473. * @param state defines the state that will be used for the build
  53474. */
  53475. initialize(state: NodeMaterialBuildState): void;
  53476. /**
  53477. * Bind data to effect. Will only be called for blocks with isBindable === true
  53478. * @param effect defines the effect to bind data to
  53479. * @param nodeMaterial defines the hosting NodeMaterial
  53480. * @param mesh defines the mesh that will be rendered
  53481. */
  53482. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53483. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  53484. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  53485. protected _writeFloat(value: number): string;
  53486. /**
  53487. * Gets the current class name e.g. "NodeMaterialBlock"
  53488. * @returns the class name
  53489. */
  53490. getClassName(): string;
  53491. /**
  53492. * Register a new input. Must be called inside a block constructor
  53493. * @param name defines the connection point name
  53494. * @param type defines the connection point type
  53495. * @param isOptional defines a boolean indicating that this input can be omitted
  53496. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  53497. * @returns the current block
  53498. */
  53499. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  53500. /**
  53501. * Register a new output. Must be called inside a block constructor
  53502. * @param name defines the connection point name
  53503. * @param type defines the connection point type
  53504. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  53505. * @returns the current block
  53506. */
  53507. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  53508. /**
  53509. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  53510. * @param forOutput defines an optional connection point to check compatibility with
  53511. * @returns the first available input or null
  53512. */
  53513. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  53514. /**
  53515. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  53516. * @param forBlock defines an optional block to check compatibility with
  53517. * @returns the first available input or null
  53518. */
  53519. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  53520. /**
  53521. * Gets the sibling of the given output
  53522. * @param current defines the current output
  53523. * @returns the next output in the list or null
  53524. */
  53525. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  53526. /**
  53527. * Connect current block with another block
  53528. * @param other defines the block to connect with
  53529. * @param options define the various options to help pick the right connections
  53530. * @returns the current block
  53531. */
  53532. connectTo(other: NodeMaterialBlock, options?: {
  53533. input?: string;
  53534. output?: string;
  53535. outputSwizzle?: string;
  53536. }): this | undefined;
  53537. protected _buildBlock(state: NodeMaterialBuildState): void;
  53538. /**
  53539. * Add uniforms, samplers and uniform buffers at compilation time
  53540. * @param state defines the state to update
  53541. * @param nodeMaterial defines the node material requesting the update
  53542. * @param defines defines the material defines to update
  53543. */
  53544. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53545. /**
  53546. * Add potential fallbacks if shader compilation fails
  53547. * @param mesh defines the mesh to be rendered
  53548. * @param fallbacks defines the current prioritized list of fallbacks
  53549. */
  53550. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  53551. /**
  53552. * Initialize defines for shader compilation
  53553. * @param mesh defines the mesh to be rendered
  53554. * @param nodeMaterial defines the node material requesting the update
  53555. * @param defines defines the material defines to update
  53556. * @param useInstances specifies that instances should be used
  53557. */
  53558. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  53559. /**
  53560. * Update defines for shader compilation
  53561. * @param mesh defines the mesh to be rendered
  53562. * @param nodeMaterial defines the node material requesting the update
  53563. * @param defines defines the material defines to update
  53564. * @param useInstances specifies that instances should be used
  53565. */
  53566. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  53567. /**
  53568. * Lets the block try to connect some inputs automatically
  53569. * @param material defines the hosting NodeMaterial
  53570. */
  53571. autoConfigure(material: NodeMaterial): void;
  53572. /**
  53573. * Function called when a block is declared as repeatable content generator
  53574. * @param vertexShaderState defines the current compilation state for the vertex shader
  53575. * @param fragmentShaderState defines the current compilation state for the fragment shader
  53576. * @param mesh defines the mesh to be rendered
  53577. * @param defines defines the material defines to update
  53578. */
  53579. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  53580. /**
  53581. * Checks if the block is ready
  53582. * @param mesh defines the mesh to be rendered
  53583. * @param nodeMaterial defines the node material requesting the update
  53584. * @param defines defines the material defines to update
  53585. * @param useInstances specifies that instances should be used
  53586. * @returns true if the block is ready
  53587. */
  53588. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  53589. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  53590. private _processBuild;
  53591. /**
  53592. * Compile the current node and generate the shader code
  53593. * @param state defines the current compilation state (uniforms, samplers, current string)
  53594. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  53595. * @returns true if already built
  53596. */
  53597. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  53598. protected _inputRename(name: string): string;
  53599. protected _outputRename(name: string): string;
  53600. protected _dumpPropertiesCode(): string;
  53601. /** @hidden */
  53602. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  53603. /**
  53604. * Clone the current block to a new identical block
  53605. * @param scene defines the hosting scene
  53606. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  53607. * @returns a copy of the current block
  53608. */
  53609. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  53610. /**
  53611. * Serializes this block in a JSON representation
  53612. * @returns the serialized block object
  53613. */
  53614. serialize(): any;
  53615. /** @hidden */
  53616. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  53617. }
  53618. }
  53619. declare module BABYLON {
  53620. /**
  53621. * Enum defining the type of animations supported by InputBlock
  53622. */
  53623. export enum AnimatedInputBlockTypes {
  53624. /** No animation */
  53625. None = 0,
  53626. /** Time based animation. Will only work for floats */
  53627. Time = 1
  53628. }
  53629. }
  53630. declare module BABYLON {
  53631. /**
  53632. * Block used to expose an input value
  53633. */
  53634. export class InputBlock extends NodeMaterialBlock {
  53635. private _mode;
  53636. private _associatedVariableName;
  53637. private _storedValue;
  53638. private _valueCallback;
  53639. private _type;
  53640. private _animationType;
  53641. /** Gets or set a value used to limit the range of float values */
  53642. min: number;
  53643. /** Gets or set a value used to limit the range of float values */
  53644. max: number;
  53645. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  53646. matrixMode: number;
  53647. /** @hidden */
  53648. _systemValue: Nullable<NodeMaterialSystemValues>;
  53649. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  53650. visibleInInspector: boolean;
  53651. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  53652. isConstant: boolean;
  53653. /**
  53654. * Gets or sets the connection point type (default is float)
  53655. */
  53656. readonly type: NodeMaterialBlockConnectionPointTypes;
  53657. /**
  53658. * Creates a new InputBlock
  53659. * @param name defines the block name
  53660. * @param target defines the target of that block (Vertex by default)
  53661. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  53662. */
  53663. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  53664. /**
  53665. * Gets the output component
  53666. */
  53667. readonly output: NodeMaterialConnectionPoint;
  53668. /**
  53669. * Set the source of this connection point to a vertex attribute
  53670. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  53671. * @returns the current connection point
  53672. */
  53673. setAsAttribute(attributeName?: string): InputBlock;
  53674. /**
  53675. * Set the source of this connection point to a system value
  53676. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  53677. * @returns the current connection point
  53678. */
  53679. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  53680. /**
  53681. * Gets or sets the value of that point.
  53682. * Please note that this value will be ignored if valueCallback is defined
  53683. */
  53684. value: any;
  53685. /**
  53686. * Gets or sets a callback used to get the value of that point.
  53687. * Please note that setting this value will force the connection point to ignore the value property
  53688. */
  53689. valueCallback: () => any;
  53690. /**
  53691. * Gets or sets the associated variable name in the shader
  53692. */
  53693. associatedVariableName: string;
  53694. /** Gets or sets the type of animation applied to the input */
  53695. animationType: AnimatedInputBlockTypes;
  53696. /**
  53697. * Gets a boolean indicating that this connection point not defined yet
  53698. */
  53699. readonly isUndefined: boolean;
  53700. /**
  53701. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  53702. * In this case the connection point name must be the name of the uniform to use.
  53703. * Can only be set on inputs
  53704. */
  53705. isUniform: boolean;
  53706. /**
  53707. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  53708. * In this case the connection point name must be the name of the attribute to use
  53709. * Can only be set on inputs
  53710. */
  53711. isAttribute: boolean;
  53712. /**
  53713. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  53714. * Can only be set on exit points
  53715. */
  53716. isVarying: boolean;
  53717. /**
  53718. * Gets a boolean indicating that the current connection point is a system value
  53719. */
  53720. readonly isSystemValue: boolean;
  53721. /**
  53722. * Gets or sets the current well known value or null if not defined as a system value
  53723. */
  53724. systemValue: Nullable<NodeMaterialSystemValues>;
  53725. /**
  53726. * Gets the current class name
  53727. * @returns the class name
  53728. */
  53729. getClassName(): string;
  53730. /**
  53731. * Animate the input if animationType !== None
  53732. * @param scene defines the rendering scene
  53733. */
  53734. animate(scene: Scene): void;
  53735. private _emitDefine;
  53736. initialize(state: NodeMaterialBuildState): void;
  53737. /**
  53738. * Set the input block to its default value (based on its type)
  53739. */
  53740. setDefaultValue(): void;
  53741. private _emitConstant;
  53742. private _emit;
  53743. /** @hidden */
  53744. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  53745. /** @hidden */
  53746. _transmit(effect: Effect, scene: Scene): void;
  53747. protected _buildBlock(state: NodeMaterialBuildState): void;
  53748. protected _dumpPropertiesCode(): string;
  53749. serialize(): any;
  53750. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  53751. }
  53752. }
  53753. declare module BABYLON {
  53754. /**
  53755. * Defines a connection point for a block
  53756. */
  53757. export class NodeMaterialConnectionPoint {
  53758. /** @hidden */
  53759. _ownerBlock: NodeMaterialBlock;
  53760. /** @hidden */
  53761. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  53762. private _endpoints;
  53763. private _associatedVariableName;
  53764. /** @hidden */
  53765. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  53766. /** @hidden */
  53767. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  53768. private _type;
  53769. /** @hidden */
  53770. _enforceAssociatedVariableName: boolean;
  53771. /**
  53772. * Gets or sets the additional types supported by this connection point
  53773. */
  53774. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  53775. /**
  53776. * Gets or sets the additional types excluded by this connection point
  53777. */
  53778. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  53779. /**
  53780. * Gets or sets the associated variable name in the shader
  53781. */
  53782. associatedVariableName: string;
  53783. /**
  53784. * Gets or sets the connection point type (default is float)
  53785. */
  53786. type: NodeMaterialBlockConnectionPointTypes;
  53787. /**
  53788. * Gets or sets the connection point name
  53789. */
  53790. name: string;
  53791. /**
  53792. * Gets or sets a boolean indicating that this connection point can be omitted
  53793. */
  53794. isOptional: boolean;
  53795. /**
  53796. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  53797. */
  53798. define: string;
  53799. /** Gets or sets the target of that connection point */
  53800. target: NodeMaterialBlockTargets;
  53801. /**
  53802. * Gets a boolean indicating that the current point is connected
  53803. */
  53804. readonly isConnected: boolean;
  53805. /**
  53806. * Gets a boolean indicating that the current point is connected to an input block
  53807. */
  53808. readonly isConnectedToInputBlock: boolean;
  53809. /**
  53810. * Gets a the connected input block (if any)
  53811. */
  53812. readonly connectInputBlock: Nullable<InputBlock>;
  53813. /** Get the other side of the connection (if any) */
  53814. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  53815. /** Get the block that owns this connection point */
  53816. readonly ownerBlock: NodeMaterialBlock;
  53817. /** Get the block connected on the other side of this connection (if any) */
  53818. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  53819. /** Get the block connected on the endpoints of this connection (if any) */
  53820. readonly connectedBlocks: Array<NodeMaterialBlock>;
  53821. /** Gets the list of connected endpoints */
  53822. readonly endpoints: NodeMaterialConnectionPoint[];
  53823. /** Gets a boolean indicating if that output point is connected to at least one input */
  53824. readonly hasEndpoints: boolean;
  53825. /**
  53826. * Creates a new connection point
  53827. * @param name defines the connection point name
  53828. * @param ownerBlock defines the block hosting this connection point
  53829. */
  53830. constructor(name: string, ownerBlock: NodeMaterialBlock);
  53831. /**
  53832. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  53833. * @returns the class name
  53834. */
  53835. getClassName(): string;
  53836. /**
  53837. * Gets an boolean indicating if the current point can be connected to another point
  53838. * @param connectionPoint defines the other connection point
  53839. * @returns true if the connection is possible
  53840. */
  53841. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  53842. /**
  53843. * Connect this point to another connection point
  53844. * @param connectionPoint defines the other connection point
  53845. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  53846. * @returns the current connection point
  53847. */
  53848. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  53849. /**
  53850. * Disconnect this point from one of his endpoint
  53851. * @param endpoint defines the other connection point
  53852. * @returns the current connection point
  53853. */
  53854. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  53855. /**
  53856. * Serializes this point in a JSON representation
  53857. * @returns the serialized point object
  53858. */
  53859. serialize(): any;
  53860. }
  53861. }
  53862. declare module BABYLON {
  53863. /**
  53864. * Block used to add support for vertex skinning (bones)
  53865. */
  53866. export class BonesBlock extends NodeMaterialBlock {
  53867. /**
  53868. * Creates a new BonesBlock
  53869. * @param name defines the block name
  53870. */
  53871. constructor(name: string);
  53872. /**
  53873. * Initialize the block and prepare the context for build
  53874. * @param state defines the state that will be used for the build
  53875. */
  53876. initialize(state: NodeMaterialBuildState): void;
  53877. /**
  53878. * Gets the current class name
  53879. * @returns the class name
  53880. */
  53881. getClassName(): string;
  53882. /**
  53883. * Gets the matrix indices input component
  53884. */
  53885. readonly matricesIndices: NodeMaterialConnectionPoint;
  53886. /**
  53887. * Gets the matrix weights input component
  53888. */
  53889. readonly matricesWeights: NodeMaterialConnectionPoint;
  53890. /**
  53891. * Gets the extra matrix indices input component
  53892. */
  53893. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  53894. /**
  53895. * Gets the extra matrix weights input component
  53896. */
  53897. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  53898. /**
  53899. * Gets the world input component
  53900. */
  53901. readonly world: NodeMaterialConnectionPoint;
  53902. /**
  53903. * Gets the output component
  53904. */
  53905. readonly output: NodeMaterialConnectionPoint;
  53906. autoConfigure(material: NodeMaterial): void;
  53907. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  53908. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53909. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53910. protected _buildBlock(state: NodeMaterialBuildState): this;
  53911. }
  53912. }
  53913. declare module BABYLON {
  53914. /**
  53915. * Block used to add support for instances
  53916. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  53917. */
  53918. export class InstancesBlock extends NodeMaterialBlock {
  53919. /**
  53920. * Creates a new InstancesBlock
  53921. * @param name defines the block name
  53922. */
  53923. constructor(name: string);
  53924. /**
  53925. * Gets the current class name
  53926. * @returns the class name
  53927. */
  53928. getClassName(): string;
  53929. /**
  53930. * Gets the first world row input component
  53931. */
  53932. readonly world0: NodeMaterialConnectionPoint;
  53933. /**
  53934. * Gets the second world row input component
  53935. */
  53936. readonly world1: NodeMaterialConnectionPoint;
  53937. /**
  53938. * Gets the third world row input component
  53939. */
  53940. readonly world2: NodeMaterialConnectionPoint;
  53941. /**
  53942. * Gets the forth world row input component
  53943. */
  53944. readonly world3: NodeMaterialConnectionPoint;
  53945. /**
  53946. * Gets the world input component
  53947. */
  53948. readonly world: NodeMaterialConnectionPoint;
  53949. /**
  53950. * Gets the output component
  53951. */
  53952. readonly output: NodeMaterialConnectionPoint;
  53953. autoConfigure(material: NodeMaterial): void;
  53954. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  53955. protected _buildBlock(state: NodeMaterialBuildState): this;
  53956. }
  53957. }
  53958. declare module BABYLON {
  53959. /**
  53960. * Block used to add morph targets support to vertex shader
  53961. */
  53962. export class MorphTargetsBlock extends NodeMaterialBlock {
  53963. private _repeatableContentAnchor;
  53964. private _repeatebleContentGenerated;
  53965. /**
  53966. * Create a new MorphTargetsBlock
  53967. * @param name defines the block name
  53968. */
  53969. constructor(name: string);
  53970. /**
  53971. * Gets the current class name
  53972. * @returns the class name
  53973. */
  53974. getClassName(): string;
  53975. /**
  53976. * Gets the position input component
  53977. */
  53978. readonly position: NodeMaterialConnectionPoint;
  53979. /**
  53980. * Gets the normal input component
  53981. */
  53982. readonly normal: NodeMaterialConnectionPoint;
  53983. /**
  53984. * Gets the tangent input component
  53985. */
  53986. readonly tangent: NodeMaterialConnectionPoint;
  53987. /**
  53988. * Gets the tangent input component
  53989. */
  53990. readonly uv: NodeMaterialConnectionPoint;
  53991. /**
  53992. * Gets the position output component
  53993. */
  53994. readonly positionOutput: NodeMaterialConnectionPoint;
  53995. /**
  53996. * Gets the normal output component
  53997. */
  53998. readonly normalOutput: NodeMaterialConnectionPoint;
  53999. /**
  54000. * Gets the tangent output component
  54001. */
  54002. readonly tangentOutput: NodeMaterialConnectionPoint;
  54003. /**
  54004. * Gets the tangent output component
  54005. */
  54006. readonly uvOutput: NodeMaterialConnectionPoint;
  54007. initialize(state: NodeMaterialBuildState): void;
  54008. autoConfigure(material: NodeMaterial): void;
  54009. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54010. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54011. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  54012. protected _buildBlock(state: NodeMaterialBuildState): this;
  54013. }
  54014. }
  54015. declare module BABYLON {
  54016. /**
  54017. * Block used to get data information from a light
  54018. */
  54019. export class LightInformationBlock extends NodeMaterialBlock {
  54020. private _lightDataUniformName;
  54021. private _lightColorUniformName;
  54022. private _lightTypeDefineName;
  54023. /**
  54024. * Gets or sets the light associated with this block
  54025. */
  54026. light: Nullable<Light>;
  54027. /**
  54028. * Creates a new LightInformationBlock
  54029. * @param name defines the block name
  54030. */
  54031. constructor(name: string);
  54032. /**
  54033. * Gets the current class name
  54034. * @returns the class name
  54035. */
  54036. getClassName(): string;
  54037. /**
  54038. * Gets the world position input component
  54039. */
  54040. readonly worldPosition: NodeMaterialConnectionPoint;
  54041. /**
  54042. * Gets the direction output component
  54043. */
  54044. readonly direction: NodeMaterialConnectionPoint;
  54045. /**
  54046. * Gets the direction output component
  54047. */
  54048. readonly color: NodeMaterialConnectionPoint;
  54049. /**
  54050. * Gets the direction output component
  54051. */
  54052. readonly intensity: NodeMaterialConnectionPoint;
  54053. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54054. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54055. protected _buildBlock(state: NodeMaterialBuildState): this;
  54056. serialize(): any;
  54057. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  54058. }
  54059. }
  54060. declare module BABYLON {
  54061. /**
  54062. * Block used to add image processing support to fragment shader
  54063. */
  54064. export class ImageProcessingBlock extends NodeMaterialBlock {
  54065. /**
  54066. * Create a new ImageProcessingBlock
  54067. * @param name defines the block name
  54068. */
  54069. constructor(name: string);
  54070. /**
  54071. * Gets the current class name
  54072. * @returns the class name
  54073. */
  54074. getClassName(): string;
  54075. /**
  54076. * Gets the color input component
  54077. */
  54078. readonly color: NodeMaterialConnectionPoint;
  54079. /**
  54080. * Gets the output component
  54081. */
  54082. readonly output: NodeMaterialConnectionPoint;
  54083. /**
  54084. * Initialize the block and prepare the context for build
  54085. * @param state defines the state that will be used for the build
  54086. */
  54087. initialize(state: NodeMaterialBuildState): void;
  54088. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  54089. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54090. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54091. protected _buildBlock(state: NodeMaterialBuildState): this;
  54092. }
  54093. }
  54094. declare module BABYLON {
  54095. /**
  54096. * Block used to pertub normals based on a normal map
  54097. */
  54098. export class PerturbNormalBlock extends NodeMaterialBlock {
  54099. private _tangentSpaceParameterName;
  54100. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  54101. invertX: boolean;
  54102. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  54103. invertY: boolean;
  54104. /**
  54105. * Create a new PerturbNormalBlock
  54106. * @param name defines the block name
  54107. */
  54108. constructor(name: string);
  54109. /**
  54110. * Gets the current class name
  54111. * @returns the class name
  54112. */
  54113. getClassName(): string;
  54114. /**
  54115. * Gets the world position input component
  54116. */
  54117. readonly worldPosition: NodeMaterialConnectionPoint;
  54118. /**
  54119. * Gets the world normal input component
  54120. */
  54121. readonly worldNormal: NodeMaterialConnectionPoint;
  54122. /**
  54123. * Gets the uv input component
  54124. */
  54125. readonly uv: NodeMaterialConnectionPoint;
  54126. /**
  54127. * Gets the normal map color input component
  54128. */
  54129. readonly normalMapColor: NodeMaterialConnectionPoint;
  54130. /**
  54131. * Gets the strength input component
  54132. */
  54133. readonly strength: NodeMaterialConnectionPoint;
  54134. /**
  54135. * Gets the output component
  54136. */
  54137. readonly output: NodeMaterialConnectionPoint;
  54138. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54139. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54140. autoConfigure(material: NodeMaterial): void;
  54141. protected _buildBlock(state: NodeMaterialBuildState): this;
  54142. protected _dumpPropertiesCode(): string;
  54143. serialize(): any;
  54144. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  54145. }
  54146. }
  54147. declare module BABYLON {
  54148. /**
  54149. * Block used to discard a pixel if a value is smaller than a cutoff
  54150. */
  54151. export class DiscardBlock extends NodeMaterialBlock {
  54152. /**
  54153. * Create a new DiscardBlock
  54154. * @param name defines the block name
  54155. */
  54156. constructor(name: string);
  54157. /**
  54158. * Gets the current class name
  54159. * @returns the class name
  54160. */
  54161. getClassName(): string;
  54162. /**
  54163. * Gets the color input component
  54164. */
  54165. readonly value: NodeMaterialConnectionPoint;
  54166. /**
  54167. * Gets the cutoff input component
  54168. */
  54169. readonly cutoff: NodeMaterialConnectionPoint;
  54170. protected _buildBlock(state: NodeMaterialBuildState): this;
  54171. }
  54172. }
  54173. declare module BABYLON {
  54174. /**
  54175. * Block used to add support for scene fog
  54176. */
  54177. export class FogBlock extends NodeMaterialBlock {
  54178. private _fogDistanceName;
  54179. private _fogParameters;
  54180. /**
  54181. * Create a new FogBlock
  54182. * @param name defines the block name
  54183. */
  54184. constructor(name: string);
  54185. /**
  54186. * Gets the current class name
  54187. * @returns the class name
  54188. */
  54189. getClassName(): string;
  54190. /**
  54191. * Gets the world position input component
  54192. */
  54193. readonly worldPosition: NodeMaterialConnectionPoint;
  54194. /**
  54195. * Gets the view input component
  54196. */
  54197. readonly view: NodeMaterialConnectionPoint;
  54198. /**
  54199. * Gets the color input component
  54200. */
  54201. readonly input: NodeMaterialConnectionPoint;
  54202. /**
  54203. * Gets the fog color input component
  54204. */
  54205. readonly fogColor: NodeMaterialConnectionPoint;
  54206. /**
  54207. * Gets the output component
  54208. */
  54209. readonly output: NodeMaterialConnectionPoint;
  54210. autoConfigure(material: NodeMaterial): void;
  54211. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54212. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54213. protected _buildBlock(state: NodeMaterialBuildState): this;
  54214. }
  54215. }
  54216. declare module BABYLON {
  54217. /**
  54218. * Block used to add light in the fragment shader
  54219. */
  54220. export class LightBlock extends NodeMaterialBlock {
  54221. private _lightId;
  54222. /**
  54223. * Gets or sets the light associated with this block
  54224. */
  54225. light: Nullable<Light>;
  54226. /**
  54227. * Create a new LightBlock
  54228. * @param name defines the block name
  54229. */
  54230. constructor(name: string);
  54231. /**
  54232. * Gets the current class name
  54233. * @returns the class name
  54234. */
  54235. getClassName(): string;
  54236. /**
  54237. * Gets the world position input component
  54238. */
  54239. readonly worldPosition: NodeMaterialConnectionPoint;
  54240. /**
  54241. * Gets the world normal input component
  54242. */
  54243. readonly worldNormal: NodeMaterialConnectionPoint;
  54244. /**
  54245. * Gets the camera (or eye) position component
  54246. */
  54247. readonly cameraPosition: NodeMaterialConnectionPoint;
  54248. /**
  54249. * Gets the glossiness component
  54250. */
  54251. readonly glossiness: NodeMaterialConnectionPoint;
  54252. /**
  54253. * Gets the glossinness power component
  54254. */
  54255. readonly glossPower: NodeMaterialConnectionPoint;
  54256. /**
  54257. * Gets the diffuse color component
  54258. */
  54259. readonly diffuseColor: NodeMaterialConnectionPoint;
  54260. /**
  54261. * Gets the specular color component
  54262. */
  54263. readonly specularColor: NodeMaterialConnectionPoint;
  54264. /**
  54265. * Gets the diffuse output component
  54266. */
  54267. readonly diffuseOutput: NodeMaterialConnectionPoint;
  54268. /**
  54269. * Gets the specular output component
  54270. */
  54271. readonly specularOutput: NodeMaterialConnectionPoint;
  54272. autoConfigure(material: NodeMaterial): void;
  54273. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54274. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54275. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54276. private _injectVertexCode;
  54277. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  54278. serialize(): any;
  54279. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  54280. }
  54281. }
  54282. declare module BABYLON {
  54283. /**
  54284. * Block used to multiply 2 values
  54285. */
  54286. export class MultiplyBlock extends NodeMaterialBlock {
  54287. /**
  54288. * Creates a new MultiplyBlock
  54289. * @param name defines the block name
  54290. */
  54291. constructor(name: string);
  54292. /**
  54293. * Gets the current class name
  54294. * @returns the class name
  54295. */
  54296. getClassName(): string;
  54297. /**
  54298. * Gets the left operand input component
  54299. */
  54300. readonly left: NodeMaterialConnectionPoint;
  54301. /**
  54302. * Gets the right operand input component
  54303. */
  54304. readonly right: NodeMaterialConnectionPoint;
  54305. /**
  54306. * Gets the output component
  54307. */
  54308. readonly output: NodeMaterialConnectionPoint;
  54309. protected _buildBlock(state: NodeMaterialBuildState): this;
  54310. }
  54311. }
  54312. declare module BABYLON {
  54313. /**
  54314. * Block used to add 2 vectors
  54315. */
  54316. export class AddBlock extends NodeMaterialBlock {
  54317. /**
  54318. * Creates a new AddBlock
  54319. * @param name defines the block name
  54320. */
  54321. constructor(name: string);
  54322. /**
  54323. * Gets the current class name
  54324. * @returns the class name
  54325. */
  54326. getClassName(): string;
  54327. /**
  54328. * Gets the left operand input component
  54329. */
  54330. readonly left: NodeMaterialConnectionPoint;
  54331. /**
  54332. * Gets the right operand input component
  54333. */
  54334. readonly right: NodeMaterialConnectionPoint;
  54335. /**
  54336. * Gets the output component
  54337. */
  54338. readonly output: NodeMaterialConnectionPoint;
  54339. protected _buildBlock(state: NodeMaterialBuildState): this;
  54340. }
  54341. }
  54342. declare module BABYLON {
  54343. /**
  54344. * Block used to scale a vector by a float
  54345. */
  54346. export class ScaleBlock extends NodeMaterialBlock {
  54347. /**
  54348. * Creates a new ScaleBlock
  54349. * @param name defines the block name
  54350. */
  54351. constructor(name: string);
  54352. /**
  54353. * Gets the current class name
  54354. * @returns the class name
  54355. */
  54356. getClassName(): string;
  54357. /**
  54358. * Gets the input component
  54359. */
  54360. readonly input: NodeMaterialConnectionPoint;
  54361. /**
  54362. * Gets the factor input component
  54363. */
  54364. readonly factor: NodeMaterialConnectionPoint;
  54365. /**
  54366. * Gets the output component
  54367. */
  54368. readonly output: NodeMaterialConnectionPoint;
  54369. protected _buildBlock(state: NodeMaterialBuildState): this;
  54370. }
  54371. }
  54372. declare module BABYLON {
  54373. /**
  54374. * Block used to clamp a float
  54375. */
  54376. export class ClampBlock extends NodeMaterialBlock {
  54377. /** Gets or sets the minimum range */
  54378. minimum: number;
  54379. /** Gets or sets the maximum range */
  54380. maximum: number;
  54381. /**
  54382. * Creates a new ClampBlock
  54383. * @param name defines the block name
  54384. */
  54385. constructor(name: string);
  54386. /**
  54387. * Gets the current class name
  54388. * @returns the class name
  54389. */
  54390. getClassName(): string;
  54391. /**
  54392. * Gets the value input component
  54393. */
  54394. readonly value: NodeMaterialConnectionPoint;
  54395. /**
  54396. * Gets the output component
  54397. */
  54398. readonly output: NodeMaterialConnectionPoint;
  54399. protected _buildBlock(state: NodeMaterialBuildState): this;
  54400. protected _dumpPropertiesCode(): string;
  54401. serialize(): any;
  54402. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  54403. }
  54404. }
  54405. declare module BABYLON {
  54406. /**
  54407. * Block used to apply a cross product between 2 vectors
  54408. */
  54409. export class CrossBlock extends NodeMaterialBlock {
  54410. /**
  54411. * Creates a new CrossBlock
  54412. * @param name defines the block name
  54413. */
  54414. constructor(name: string);
  54415. /**
  54416. * Gets the current class name
  54417. * @returns the class name
  54418. */
  54419. getClassName(): string;
  54420. /**
  54421. * Gets the left operand input component
  54422. */
  54423. readonly left: NodeMaterialConnectionPoint;
  54424. /**
  54425. * Gets the right operand input component
  54426. */
  54427. readonly right: NodeMaterialConnectionPoint;
  54428. /**
  54429. * Gets the output component
  54430. */
  54431. readonly output: NodeMaterialConnectionPoint;
  54432. protected _buildBlock(state: NodeMaterialBuildState): this;
  54433. }
  54434. }
  54435. declare module BABYLON {
  54436. /**
  54437. * Block used to apply a dot product between 2 vectors
  54438. */
  54439. export class DotBlock extends NodeMaterialBlock {
  54440. /**
  54441. * Creates a new DotBlock
  54442. * @param name defines the block name
  54443. */
  54444. constructor(name: string);
  54445. /**
  54446. * Gets the current class name
  54447. * @returns the class name
  54448. */
  54449. getClassName(): string;
  54450. /**
  54451. * Gets the left operand input component
  54452. */
  54453. readonly left: NodeMaterialConnectionPoint;
  54454. /**
  54455. * Gets the right operand input component
  54456. */
  54457. readonly right: NodeMaterialConnectionPoint;
  54458. /**
  54459. * Gets the output component
  54460. */
  54461. readonly output: NodeMaterialConnectionPoint;
  54462. protected _buildBlock(state: NodeMaterialBuildState): this;
  54463. }
  54464. }
  54465. declare module BABYLON {
  54466. /**
  54467. * Block used to remap a float from a range to a new one
  54468. */
  54469. export class RemapBlock extends NodeMaterialBlock {
  54470. /**
  54471. * Gets or sets the source range
  54472. */
  54473. sourceRange: Vector2;
  54474. /**
  54475. * Gets or sets the target range
  54476. */
  54477. targetRange: Vector2;
  54478. /**
  54479. * Creates a new RemapBlock
  54480. * @param name defines the block name
  54481. */
  54482. constructor(name: string);
  54483. /**
  54484. * Gets the current class name
  54485. * @returns the class name
  54486. */
  54487. getClassName(): string;
  54488. /**
  54489. * Gets the input component
  54490. */
  54491. readonly input: NodeMaterialConnectionPoint;
  54492. /**
  54493. * Gets the source min input component
  54494. */
  54495. readonly sourceMin: NodeMaterialConnectionPoint;
  54496. /**
  54497. * Gets the source max input component
  54498. */
  54499. readonly sourceMax: NodeMaterialConnectionPoint;
  54500. /**
  54501. * Gets the target min input component
  54502. */
  54503. readonly targetMin: NodeMaterialConnectionPoint;
  54504. /**
  54505. * Gets the target max input component
  54506. */
  54507. readonly targetMax: NodeMaterialConnectionPoint;
  54508. /**
  54509. * Gets the output component
  54510. */
  54511. readonly output: NodeMaterialConnectionPoint;
  54512. protected _buildBlock(state: NodeMaterialBuildState): this;
  54513. protected _dumpPropertiesCode(): string;
  54514. serialize(): any;
  54515. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  54516. }
  54517. }
  54518. declare module BABYLON {
  54519. /**
  54520. * Block used to normalize a vector
  54521. */
  54522. export class NormalizeBlock extends NodeMaterialBlock {
  54523. /**
  54524. * Creates a new NormalizeBlock
  54525. * @param name defines the block name
  54526. */
  54527. constructor(name: string);
  54528. /**
  54529. * Gets the current class name
  54530. * @returns the class name
  54531. */
  54532. getClassName(): string;
  54533. /**
  54534. * Gets the input component
  54535. */
  54536. readonly input: NodeMaterialConnectionPoint;
  54537. /**
  54538. * Gets the output component
  54539. */
  54540. readonly output: NodeMaterialConnectionPoint;
  54541. protected _buildBlock(state: NodeMaterialBuildState): this;
  54542. }
  54543. }
  54544. declare module BABYLON {
  54545. /**
  54546. * Operations supported by the Trigonometry block
  54547. */
  54548. export enum TrigonometryBlockOperations {
  54549. /** Cos */
  54550. Cos = 0,
  54551. /** Sin */
  54552. Sin = 1,
  54553. /** Abs */
  54554. Abs = 2,
  54555. /** Exp */
  54556. Exp = 3,
  54557. /** Exp2 */
  54558. Exp2 = 4,
  54559. /** Round */
  54560. Round = 5,
  54561. /** Floor */
  54562. Floor = 6,
  54563. /** Ceiling */
  54564. Ceiling = 7,
  54565. /** Square root */
  54566. Sqrt = 8,
  54567. /** Log */
  54568. Log = 9,
  54569. /** Tangent */
  54570. Tan = 10,
  54571. /** Arc tangent */
  54572. ArcTan = 11,
  54573. /** Arc cosinus */
  54574. ArcCos = 12,
  54575. /** Arc sinus */
  54576. ArcSin = 13,
  54577. /** Fraction */
  54578. Fract = 14,
  54579. /** Sign */
  54580. Sign = 15,
  54581. /** To radians (from degrees) */
  54582. Radians = 16,
  54583. /** To degrees (from radians) */
  54584. Degrees = 17
  54585. }
  54586. /**
  54587. * Block used to apply trigonometry operation to floats
  54588. */
  54589. export class TrigonometryBlock extends NodeMaterialBlock {
  54590. /**
  54591. * Gets or sets the operation applied by the block
  54592. */
  54593. operation: TrigonometryBlockOperations;
  54594. /**
  54595. * Creates a new TrigonometryBlock
  54596. * @param name defines the block name
  54597. */
  54598. constructor(name: string);
  54599. /**
  54600. * Gets the current class name
  54601. * @returns the class name
  54602. */
  54603. getClassName(): string;
  54604. /**
  54605. * Gets the input component
  54606. */
  54607. readonly input: NodeMaterialConnectionPoint;
  54608. /**
  54609. * Gets the output component
  54610. */
  54611. readonly output: NodeMaterialConnectionPoint;
  54612. protected _buildBlock(state: NodeMaterialBuildState): this;
  54613. serialize(): any;
  54614. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  54615. }
  54616. }
  54617. declare module BABYLON {
  54618. /**
  54619. * Block used to create a Color3/4 out of individual inputs (one for each component)
  54620. */
  54621. export class ColorMergerBlock extends NodeMaterialBlock {
  54622. /**
  54623. * Create a new ColorMergerBlock
  54624. * @param name defines the block name
  54625. */
  54626. constructor(name: string);
  54627. /**
  54628. * Gets the current class name
  54629. * @returns the class name
  54630. */
  54631. getClassName(): string;
  54632. /**
  54633. * Gets the r component (input)
  54634. */
  54635. readonly r: NodeMaterialConnectionPoint;
  54636. /**
  54637. * Gets the g component (input)
  54638. */
  54639. readonly g: NodeMaterialConnectionPoint;
  54640. /**
  54641. * Gets the b component (input)
  54642. */
  54643. readonly b: NodeMaterialConnectionPoint;
  54644. /**
  54645. * Gets the a component (input)
  54646. */
  54647. readonly a: NodeMaterialConnectionPoint;
  54648. /**
  54649. * Gets the rgba component (output)
  54650. */
  54651. readonly rgba: NodeMaterialConnectionPoint;
  54652. /**
  54653. * Gets the rgb component (output)
  54654. */
  54655. readonly rgb: NodeMaterialConnectionPoint;
  54656. protected _buildBlock(state: NodeMaterialBuildState): this;
  54657. }
  54658. }
  54659. declare module BABYLON {
  54660. /**
  54661. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  54662. */
  54663. export class VectorMergerBlock extends NodeMaterialBlock {
  54664. /**
  54665. * Create a new VectorMergerBlock
  54666. * @param name defines the block name
  54667. */
  54668. constructor(name: string);
  54669. /**
  54670. * Gets the current class name
  54671. * @returns the class name
  54672. */
  54673. getClassName(): string;
  54674. /**
  54675. * Gets the x component (input)
  54676. */
  54677. readonly x: NodeMaterialConnectionPoint;
  54678. /**
  54679. * Gets the y component (input)
  54680. */
  54681. readonly y: NodeMaterialConnectionPoint;
  54682. /**
  54683. * Gets the z component (input)
  54684. */
  54685. readonly z: NodeMaterialConnectionPoint;
  54686. /**
  54687. * Gets the w component (input)
  54688. */
  54689. readonly w: NodeMaterialConnectionPoint;
  54690. /**
  54691. * Gets the xyzw component (output)
  54692. */
  54693. readonly xyzw: NodeMaterialConnectionPoint;
  54694. /**
  54695. * Gets the xyz component (output)
  54696. */
  54697. readonly xyz: NodeMaterialConnectionPoint;
  54698. /**
  54699. * Gets the xy component (output)
  54700. */
  54701. readonly xy: NodeMaterialConnectionPoint;
  54702. protected _buildBlock(state: NodeMaterialBuildState): this;
  54703. }
  54704. }
  54705. declare module BABYLON {
  54706. /**
  54707. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  54708. */
  54709. export class ColorSplitterBlock extends NodeMaterialBlock {
  54710. /**
  54711. * Create a new ColorSplitterBlock
  54712. * @param name defines the block name
  54713. */
  54714. constructor(name: string);
  54715. /**
  54716. * Gets the current class name
  54717. * @returns the class name
  54718. */
  54719. getClassName(): string;
  54720. /**
  54721. * Gets the rgba component (input)
  54722. */
  54723. readonly rgba: NodeMaterialConnectionPoint;
  54724. /**
  54725. * Gets the rgb component (input)
  54726. */
  54727. readonly rgbIn: NodeMaterialConnectionPoint;
  54728. /**
  54729. * Gets the rgb component (output)
  54730. */
  54731. readonly rgbOut: NodeMaterialConnectionPoint;
  54732. /**
  54733. * Gets the r component (output)
  54734. */
  54735. readonly r: NodeMaterialConnectionPoint;
  54736. /**
  54737. * Gets the g component (output)
  54738. */
  54739. readonly g: NodeMaterialConnectionPoint;
  54740. /**
  54741. * Gets the b component (output)
  54742. */
  54743. readonly b: NodeMaterialConnectionPoint;
  54744. /**
  54745. * Gets the a component (output)
  54746. */
  54747. readonly a: NodeMaterialConnectionPoint;
  54748. protected _inputRename(name: string): string;
  54749. protected _outputRename(name: string): string;
  54750. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  54751. }
  54752. }
  54753. declare module BABYLON {
  54754. /**
  54755. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  54756. */
  54757. export class VectorSplitterBlock extends NodeMaterialBlock {
  54758. /**
  54759. * Create a new VectorSplitterBlock
  54760. * @param name defines the block name
  54761. */
  54762. constructor(name: string);
  54763. /**
  54764. * Gets the current class name
  54765. * @returns the class name
  54766. */
  54767. getClassName(): string;
  54768. /**
  54769. * Gets the xyzw component (input)
  54770. */
  54771. readonly xyzw: NodeMaterialConnectionPoint;
  54772. /**
  54773. * Gets the xyz component (input)
  54774. */
  54775. readonly xyzIn: NodeMaterialConnectionPoint;
  54776. /**
  54777. * Gets the xy component (input)
  54778. */
  54779. readonly xyIn: NodeMaterialConnectionPoint;
  54780. /**
  54781. * Gets the xyz component (output)
  54782. */
  54783. readonly xyzOut: NodeMaterialConnectionPoint;
  54784. /**
  54785. * Gets the xy component (output)
  54786. */
  54787. readonly xyOut: NodeMaterialConnectionPoint;
  54788. /**
  54789. * Gets the x component (output)
  54790. */
  54791. readonly x: NodeMaterialConnectionPoint;
  54792. /**
  54793. * Gets the y component (output)
  54794. */
  54795. readonly y: NodeMaterialConnectionPoint;
  54796. /**
  54797. * Gets the z component (output)
  54798. */
  54799. readonly z: NodeMaterialConnectionPoint;
  54800. /**
  54801. * Gets the w component (output)
  54802. */
  54803. readonly w: NodeMaterialConnectionPoint;
  54804. protected _inputRename(name: string): string;
  54805. protected _outputRename(name: string): string;
  54806. protected _buildBlock(state: NodeMaterialBuildState): this;
  54807. }
  54808. }
  54809. declare module BABYLON {
  54810. /**
  54811. * Block used to lerp between 2 values
  54812. */
  54813. export class LerpBlock extends NodeMaterialBlock {
  54814. /**
  54815. * Creates a new LerpBlock
  54816. * @param name defines the block name
  54817. */
  54818. constructor(name: string);
  54819. /**
  54820. * Gets the current class name
  54821. * @returns the class name
  54822. */
  54823. getClassName(): string;
  54824. /**
  54825. * Gets the left operand input component
  54826. */
  54827. readonly left: NodeMaterialConnectionPoint;
  54828. /**
  54829. * Gets the right operand input component
  54830. */
  54831. readonly right: NodeMaterialConnectionPoint;
  54832. /**
  54833. * Gets the gradient operand input component
  54834. */
  54835. readonly gradient: NodeMaterialConnectionPoint;
  54836. /**
  54837. * Gets the output component
  54838. */
  54839. readonly output: NodeMaterialConnectionPoint;
  54840. protected _buildBlock(state: NodeMaterialBuildState): this;
  54841. }
  54842. }
  54843. declare module BABYLON {
  54844. /**
  54845. * Block used to divide 2 vectors
  54846. */
  54847. export class DivideBlock extends NodeMaterialBlock {
  54848. /**
  54849. * Creates a new DivideBlock
  54850. * @param name defines the block name
  54851. */
  54852. constructor(name: string);
  54853. /**
  54854. * Gets the current class name
  54855. * @returns the class name
  54856. */
  54857. getClassName(): string;
  54858. /**
  54859. * Gets the left operand input component
  54860. */
  54861. readonly left: NodeMaterialConnectionPoint;
  54862. /**
  54863. * Gets the right operand input component
  54864. */
  54865. readonly right: NodeMaterialConnectionPoint;
  54866. /**
  54867. * Gets the output component
  54868. */
  54869. readonly output: NodeMaterialConnectionPoint;
  54870. protected _buildBlock(state: NodeMaterialBuildState): this;
  54871. }
  54872. }
  54873. declare module BABYLON {
  54874. /**
  54875. * Block used to subtract 2 vectors
  54876. */
  54877. export class SubtractBlock extends NodeMaterialBlock {
  54878. /**
  54879. * Creates a new SubtractBlock
  54880. * @param name defines the block name
  54881. */
  54882. constructor(name: string);
  54883. /**
  54884. * Gets the current class name
  54885. * @returns the class name
  54886. */
  54887. getClassName(): string;
  54888. /**
  54889. * Gets the left operand input component
  54890. */
  54891. readonly left: NodeMaterialConnectionPoint;
  54892. /**
  54893. * Gets the right operand input component
  54894. */
  54895. readonly right: NodeMaterialConnectionPoint;
  54896. /**
  54897. * Gets the output component
  54898. */
  54899. readonly output: NodeMaterialConnectionPoint;
  54900. protected _buildBlock(state: NodeMaterialBuildState): this;
  54901. }
  54902. }
  54903. declare module BABYLON {
  54904. /**
  54905. * Block used to step a value
  54906. */
  54907. export class StepBlock extends NodeMaterialBlock {
  54908. /**
  54909. * Creates a new StepBlock
  54910. * @param name defines the block name
  54911. */
  54912. constructor(name: string);
  54913. /**
  54914. * Gets the current class name
  54915. * @returns the class name
  54916. */
  54917. getClassName(): string;
  54918. /**
  54919. * Gets the value operand input component
  54920. */
  54921. readonly value: NodeMaterialConnectionPoint;
  54922. /**
  54923. * Gets the edge operand input component
  54924. */
  54925. readonly edge: NodeMaterialConnectionPoint;
  54926. /**
  54927. * Gets the output component
  54928. */
  54929. readonly output: NodeMaterialConnectionPoint;
  54930. protected _buildBlock(state: NodeMaterialBuildState): this;
  54931. }
  54932. }
  54933. declare module BABYLON {
  54934. /**
  54935. * Block used to get the opposite (1 - x) of a value
  54936. */
  54937. export class OneMinusBlock extends NodeMaterialBlock {
  54938. /**
  54939. * Creates a new OneMinusBlock
  54940. * @param name defines the block name
  54941. */
  54942. constructor(name: string);
  54943. /**
  54944. * Gets the current class name
  54945. * @returns the class name
  54946. */
  54947. getClassName(): string;
  54948. /**
  54949. * Gets the input component
  54950. */
  54951. readonly input: NodeMaterialConnectionPoint;
  54952. /**
  54953. * Gets the output component
  54954. */
  54955. readonly output: NodeMaterialConnectionPoint;
  54956. protected _buildBlock(state: NodeMaterialBuildState): this;
  54957. }
  54958. }
  54959. declare module BABYLON {
  54960. /**
  54961. * Block used to get the view direction
  54962. */
  54963. export class ViewDirectionBlock extends NodeMaterialBlock {
  54964. /**
  54965. * Creates a new ViewDirectionBlock
  54966. * @param name defines the block name
  54967. */
  54968. constructor(name: string);
  54969. /**
  54970. * Gets the current class name
  54971. * @returns the class name
  54972. */
  54973. getClassName(): string;
  54974. /**
  54975. * Gets the world position component
  54976. */
  54977. readonly worldPosition: NodeMaterialConnectionPoint;
  54978. /**
  54979. * Gets the camera position component
  54980. */
  54981. readonly cameraPosition: NodeMaterialConnectionPoint;
  54982. /**
  54983. * Gets the output component
  54984. */
  54985. readonly output: NodeMaterialConnectionPoint;
  54986. autoConfigure(material: NodeMaterial): void;
  54987. protected _buildBlock(state: NodeMaterialBuildState): this;
  54988. }
  54989. }
  54990. declare module BABYLON {
  54991. /**
  54992. * Block used to compute fresnel value
  54993. */
  54994. export class FresnelBlock extends NodeMaterialBlock {
  54995. /**
  54996. * Create a new FresnelBlock
  54997. * @param name defines the block name
  54998. */
  54999. constructor(name: string);
  55000. /**
  55001. * Gets the current class name
  55002. * @returns the class name
  55003. */
  55004. getClassName(): string;
  55005. /**
  55006. * Gets the world normal input component
  55007. */
  55008. readonly worldNormal: NodeMaterialConnectionPoint;
  55009. /**
  55010. * Gets the view direction input component
  55011. */
  55012. readonly viewDirection: NodeMaterialConnectionPoint;
  55013. /**
  55014. * Gets the bias input component
  55015. */
  55016. readonly bias: NodeMaterialConnectionPoint;
  55017. /**
  55018. * Gets the camera (or eye) position component
  55019. */
  55020. readonly power: NodeMaterialConnectionPoint;
  55021. /**
  55022. * Gets the fresnel output component
  55023. */
  55024. readonly fresnel: NodeMaterialConnectionPoint;
  55025. autoConfigure(material: NodeMaterial): void;
  55026. protected _buildBlock(state: NodeMaterialBuildState): this;
  55027. }
  55028. }
  55029. declare module BABYLON {
  55030. /**
  55031. * Block used to get the max of 2 values
  55032. */
  55033. export class MaxBlock extends NodeMaterialBlock {
  55034. /**
  55035. * Creates a new MaxBlock
  55036. * @param name defines the block name
  55037. */
  55038. constructor(name: string);
  55039. /**
  55040. * Gets the current class name
  55041. * @returns the class name
  55042. */
  55043. getClassName(): string;
  55044. /**
  55045. * Gets the left operand input component
  55046. */
  55047. readonly left: NodeMaterialConnectionPoint;
  55048. /**
  55049. * Gets the right operand input component
  55050. */
  55051. readonly right: NodeMaterialConnectionPoint;
  55052. /**
  55053. * Gets the output component
  55054. */
  55055. readonly output: NodeMaterialConnectionPoint;
  55056. protected _buildBlock(state: NodeMaterialBuildState): this;
  55057. }
  55058. }
  55059. declare module BABYLON {
  55060. /**
  55061. * Block used to get the min of 2 values
  55062. */
  55063. export class MinBlock extends NodeMaterialBlock {
  55064. /**
  55065. * Creates a new MinBlock
  55066. * @param name defines the block name
  55067. */
  55068. constructor(name: string);
  55069. /**
  55070. * Gets the current class name
  55071. * @returns the class name
  55072. */
  55073. getClassName(): string;
  55074. /**
  55075. * Gets the left operand input component
  55076. */
  55077. readonly left: NodeMaterialConnectionPoint;
  55078. /**
  55079. * Gets the right operand input component
  55080. */
  55081. readonly right: NodeMaterialConnectionPoint;
  55082. /**
  55083. * Gets the output component
  55084. */
  55085. readonly output: NodeMaterialConnectionPoint;
  55086. protected _buildBlock(state: NodeMaterialBuildState): this;
  55087. }
  55088. }
  55089. declare module BABYLON {
  55090. /**
  55091. * Block used to get the distance between 2 values
  55092. */
  55093. export class DistanceBlock extends NodeMaterialBlock {
  55094. /**
  55095. * Creates a new DistanceBlock
  55096. * @param name defines the block name
  55097. */
  55098. constructor(name: string);
  55099. /**
  55100. * Gets the current class name
  55101. * @returns the class name
  55102. */
  55103. getClassName(): string;
  55104. /**
  55105. * Gets the left operand input component
  55106. */
  55107. readonly left: NodeMaterialConnectionPoint;
  55108. /**
  55109. * Gets the right operand input component
  55110. */
  55111. readonly right: NodeMaterialConnectionPoint;
  55112. /**
  55113. * Gets the output component
  55114. */
  55115. readonly output: NodeMaterialConnectionPoint;
  55116. protected _buildBlock(state: NodeMaterialBuildState): this;
  55117. }
  55118. }
  55119. declare module BABYLON {
  55120. /**
  55121. * Block used to get the length of a vector
  55122. */
  55123. export class LengthBlock extends NodeMaterialBlock {
  55124. /**
  55125. * Creates a new LengthBlock
  55126. * @param name defines the block name
  55127. */
  55128. constructor(name: string);
  55129. /**
  55130. * Gets the current class name
  55131. * @returns the class name
  55132. */
  55133. getClassName(): string;
  55134. /**
  55135. * Gets the value input component
  55136. */
  55137. readonly value: NodeMaterialConnectionPoint;
  55138. /**
  55139. * Gets the output component
  55140. */
  55141. readonly output: NodeMaterialConnectionPoint;
  55142. protected _buildBlock(state: NodeMaterialBuildState): this;
  55143. }
  55144. }
  55145. declare module BABYLON {
  55146. /**
  55147. * Block used to get negative version of a value (i.e. x * -1)
  55148. */
  55149. export class NegateBlock extends NodeMaterialBlock {
  55150. /**
  55151. * Creates a new NegateBlock
  55152. * @param name defines the block name
  55153. */
  55154. constructor(name: string);
  55155. /**
  55156. * Gets the current class name
  55157. * @returns the class name
  55158. */
  55159. getClassName(): string;
  55160. /**
  55161. * Gets the value input component
  55162. */
  55163. readonly value: NodeMaterialConnectionPoint;
  55164. /**
  55165. * Gets the output component
  55166. */
  55167. readonly output: NodeMaterialConnectionPoint;
  55168. protected _buildBlock(state: NodeMaterialBuildState): this;
  55169. }
  55170. }
  55171. declare module BABYLON {
  55172. /**
  55173. * Block used to get the value of the first parameter raised to the power of the second
  55174. */
  55175. export class PowBlock extends NodeMaterialBlock {
  55176. /**
  55177. * Creates a new PowBlock
  55178. * @param name defines the block name
  55179. */
  55180. constructor(name: string);
  55181. /**
  55182. * Gets the current class name
  55183. * @returns the class name
  55184. */
  55185. getClassName(): string;
  55186. /**
  55187. * Gets the value operand input component
  55188. */
  55189. readonly value: NodeMaterialConnectionPoint;
  55190. /**
  55191. * Gets the power operand input component
  55192. */
  55193. readonly power: NodeMaterialConnectionPoint;
  55194. /**
  55195. * Gets the output component
  55196. */
  55197. readonly output: NodeMaterialConnectionPoint;
  55198. protected _buildBlock(state: NodeMaterialBuildState): this;
  55199. }
  55200. }
  55201. declare module BABYLON {
  55202. /**
  55203. * Block used to get a random number
  55204. */
  55205. export class RandomNumberBlock extends NodeMaterialBlock {
  55206. /**
  55207. * Creates a new RandomNumberBlock
  55208. * @param name defines the block name
  55209. */
  55210. constructor(name: string);
  55211. /**
  55212. * Gets the current class name
  55213. * @returns the class name
  55214. */
  55215. getClassName(): string;
  55216. /**
  55217. * Gets the seed input component
  55218. */
  55219. readonly seed: NodeMaterialConnectionPoint;
  55220. /**
  55221. * Gets the output component
  55222. */
  55223. readonly output: NodeMaterialConnectionPoint;
  55224. protected _buildBlock(state: NodeMaterialBuildState): this;
  55225. }
  55226. }
  55227. declare module BABYLON {
  55228. /**
  55229. * Block used to compute arc tangent of 2 values
  55230. */
  55231. export class ArcTan2Block extends NodeMaterialBlock {
  55232. /**
  55233. * Creates a new ArcTan2Block
  55234. * @param name defines the block name
  55235. */
  55236. constructor(name: string);
  55237. /**
  55238. * Gets the current class name
  55239. * @returns the class name
  55240. */
  55241. getClassName(): string;
  55242. /**
  55243. * Gets the x operand input component
  55244. */
  55245. readonly x: NodeMaterialConnectionPoint;
  55246. /**
  55247. * Gets the y operand input component
  55248. */
  55249. readonly y: NodeMaterialConnectionPoint;
  55250. /**
  55251. * Gets the output component
  55252. */
  55253. readonly output: NodeMaterialConnectionPoint;
  55254. protected _buildBlock(state: NodeMaterialBuildState): this;
  55255. }
  55256. }
  55257. declare module BABYLON {
  55258. /**
  55259. * Block used to smooth step a value
  55260. */
  55261. export class SmoothStepBlock extends NodeMaterialBlock {
  55262. /**
  55263. * Creates a new SmoothStepBlock
  55264. * @param name defines the block name
  55265. */
  55266. constructor(name: string);
  55267. /**
  55268. * Gets the current class name
  55269. * @returns the class name
  55270. */
  55271. getClassName(): string;
  55272. /**
  55273. * Gets the value operand input component
  55274. */
  55275. readonly value: NodeMaterialConnectionPoint;
  55276. /**
  55277. * Gets the first edge operand input component
  55278. */
  55279. readonly edge0: NodeMaterialConnectionPoint;
  55280. /**
  55281. * Gets the second edge operand input component
  55282. */
  55283. readonly edge1: NodeMaterialConnectionPoint;
  55284. /**
  55285. * Gets the output component
  55286. */
  55287. readonly output: NodeMaterialConnectionPoint;
  55288. protected _buildBlock(state: NodeMaterialBuildState): this;
  55289. }
  55290. }
  55291. declare module BABYLON {
  55292. /**
  55293. * Block used to get the reciprocal (1 / x) of a value
  55294. */
  55295. export class ReciprocalBlock extends NodeMaterialBlock {
  55296. /**
  55297. * Creates a new ReciprocalBlock
  55298. * @param name defines the block name
  55299. */
  55300. constructor(name: string);
  55301. /**
  55302. * Gets the current class name
  55303. * @returns the class name
  55304. */
  55305. getClassName(): string;
  55306. /**
  55307. * Gets the input component
  55308. */
  55309. readonly input: NodeMaterialConnectionPoint;
  55310. /**
  55311. * Gets the output component
  55312. */
  55313. readonly output: NodeMaterialConnectionPoint;
  55314. protected _buildBlock(state: NodeMaterialBuildState): this;
  55315. }
  55316. }
  55317. declare module BABYLON {
  55318. /**
  55319. * Block used to replace a color by another one
  55320. */
  55321. export class ReplaceColorBlock extends NodeMaterialBlock {
  55322. /**
  55323. * Creates a new ReplaceColorBlock
  55324. * @param name defines the block name
  55325. */
  55326. constructor(name: string);
  55327. /**
  55328. * Gets the current class name
  55329. * @returns the class name
  55330. */
  55331. getClassName(): string;
  55332. /**
  55333. * Gets the value input component
  55334. */
  55335. readonly value: NodeMaterialConnectionPoint;
  55336. /**
  55337. * Gets the reference input component
  55338. */
  55339. readonly reference: NodeMaterialConnectionPoint;
  55340. /**
  55341. * Gets the distance input component
  55342. */
  55343. readonly distance: NodeMaterialConnectionPoint;
  55344. /**
  55345. * Gets the replacement input component
  55346. */
  55347. readonly replacement: NodeMaterialConnectionPoint;
  55348. /**
  55349. * Gets the output component
  55350. */
  55351. readonly output: NodeMaterialConnectionPoint;
  55352. protected _buildBlock(state: NodeMaterialBuildState): this;
  55353. }
  55354. }
  55355. declare module BABYLON {
  55356. /**
  55357. * Block used to posterize a value
  55358. * @see https://en.wikipedia.org/wiki/Posterization
  55359. */
  55360. export class PosterizeBlock extends NodeMaterialBlock {
  55361. /**
  55362. * Creates a new PosterizeBlock
  55363. * @param name defines the block name
  55364. */
  55365. constructor(name: string);
  55366. /**
  55367. * Gets the current class name
  55368. * @returns the class name
  55369. */
  55370. getClassName(): string;
  55371. /**
  55372. * Gets the value input component
  55373. */
  55374. readonly value: NodeMaterialConnectionPoint;
  55375. /**
  55376. * Gets the steps input component
  55377. */
  55378. readonly steps: NodeMaterialConnectionPoint;
  55379. /**
  55380. * Gets the output component
  55381. */
  55382. readonly output: NodeMaterialConnectionPoint;
  55383. protected _buildBlock(state: NodeMaterialBuildState): this;
  55384. }
  55385. }
  55386. declare module BABYLON {
  55387. /**
  55388. * Operations supported by the Wave block
  55389. */
  55390. export enum WaveBlockKind {
  55391. /** SawTooth */
  55392. SawTooth = 0,
  55393. /** Square */
  55394. Square = 1,
  55395. /** Triangle */
  55396. Triangle = 2
  55397. }
  55398. /**
  55399. * Block used to apply wave operation to floats
  55400. */
  55401. export class WaveBlock extends NodeMaterialBlock {
  55402. /**
  55403. * Gets or sets the kibnd of wave to be applied by the block
  55404. */
  55405. kind: WaveBlockKind;
  55406. /**
  55407. * Creates a new WaveBlock
  55408. * @param name defines the block name
  55409. */
  55410. constructor(name: string);
  55411. /**
  55412. * Gets the current class name
  55413. * @returns the class name
  55414. */
  55415. getClassName(): string;
  55416. /**
  55417. * Gets the input component
  55418. */
  55419. readonly input: NodeMaterialConnectionPoint;
  55420. /**
  55421. * Gets the output component
  55422. */
  55423. readonly output: NodeMaterialConnectionPoint;
  55424. protected _buildBlock(state: NodeMaterialBuildState): this;
  55425. serialize(): any;
  55426. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55427. }
  55428. }
  55429. declare module BABYLON {
  55430. /**
  55431. * Class used to store a color step for the GradientBlock
  55432. */
  55433. export class GradientBlockColorStep {
  55434. /**
  55435. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  55436. */
  55437. step: number;
  55438. /**
  55439. * Gets or sets the color associated with this step
  55440. */
  55441. color: Color3;
  55442. /**
  55443. * Creates a new GradientBlockColorStep
  55444. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  55445. * @param color defines the color associated with this step
  55446. */
  55447. constructor(
  55448. /**
  55449. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  55450. */
  55451. step: number,
  55452. /**
  55453. * Gets or sets the color associated with this step
  55454. */
  55455. color: Color3);
  55456. }
  55457. /**
  55458. * Block used to return a color from a gradient based on an input value between 0 and 1
  55459. */
  55460. export class GradientBlock extends NodeMaterialBlock {
  55461. /**
  55462. * Gets or sets the list of color steps
  55463. */
  55464. colorSteps: GradientBlockColorStep[];
  55465. /**
  55466. * Creates a new GradientBlock
  55467. * @param name defines the block name
  55468. */
  55469. constructor(name: string);
  55470. /**
  55471. * Gets the current class name
  55472. * @returns the class name
  55473. */
  55474. getClassName(): string;
  55475. /**
  55476. * Gets the gradient input component
  55477. */
  55478. readonly gradient: NodeMaterialConnectionPoint;
  55479. /**
  55480. * Gets the output component
  55481. */
  55482. readonly output: NodeMaterialConnectionPoint;
  55483. private _writeColorConstant;
  55484. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  55485. serialize(): any;
  55486. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55487. protected _dumpPropertiesCode(): string;
  55488. }
  55489. }
  55490. declare module BABYLON {
  55491. /**
  55492. * Block used to normalize lerp between 2 values
  55493. */
  55494. export class NLerpBlock extends NodeMaterialBlock {
  55495. /**
  55496. * Creates a new NLerpBlock
  55497. * @param name defines the block name
  55498. */
  55499. constructor(name: string);
  55500. /**
  55501. * Gets the current class name
  55502. * @returns the class name
  55503. */
  55504. getClassName(): string;
  55505. /**
  55506. * Gets the left operand input component
  55507. */
  55508. readonly left: NodeMaterialConnectionPoint;
  55509. /**
  55510. * Gets the right operand input component
  55511. */
  55512. readonly right: NodeMaterialConnectionPoint;
  55513. /**
  55514. * Gets the gradient operand input component
  55515. */
  55516. readonly gradient: NodeMaterialConnectionPoint;
  55517. /**
  55518. * Gets the output component
  55519. */
  55520. readonly output: NodeMaterialConnectionPoint;
  55521. protected _buildBlock(state: NodeMaterialBuildState): this;
  55522. }
  55523. }
  55524. declare module BABYLON {
  55525. /**
  55526. * Effect Render Options
  55527. */
  55528. export interface IEffectRendererOptions {
  55529. /**
  55530. * Defines the vertices positions.
  55531. */
  55532. positions?: number[];
  55533. /**
  55534. * Defines the indices.
  55535. */
  55536. indices?: number[];
  55537. }
  55538. /**
  55539. * Helper class to render one or more effects
  55540. */
  55541. export class EffectRenderer {
  55542. private engine;
  55543. private static _DefaultOptions;
  55544. private _vertexBuffers;
  55545. private _indexBuffer;
  55546. private _ringBufferIndex;
  55547. private _ringScreenBuffer;
  55548. private _fullscreenViewport;
  55549. private _getNextFrameBuffer;
  55550. /**
  55551. * Creates an effect renderer
  55552. * @param engine the engine to use for rendering
  55553. * @param options defines the options of the effect renderer
  55554. */
  55555. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  55556. /**
  55557. * Sets the current viewport in normalized coordinates 0-1
  55558. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  55559. */
  55560. setViewport(viewport?: Viewport): void;
  55561. /**
  55562. * Binds the embedded attributes buffer to the effect.
  55563. * @param effect Defines the effect to bind the attributes for
  55564. */
  55565. bindBuffers(effect: Effect): void;
  55566. /**
  55567. * Sets the current effect wrapper to use during draw.
  55568. * The effect needs to be ready before calling this api.
  55569. * This also sets the default full screen position attribute.
  55570. * @param effectWrapper Defines the effect to draw with
  55571. */
  55572. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  55573. /**
  55574. * Draws a full screen quad.
  55575. */
  55576. draw(): void;
  55577. /**
  55578. * renders one or more effects to a specified texture
  55579. * @param effectWrappers list of effects to renderer
  55580. * @param outputTexture texture to draw to, if null it will render to the screen
  55581. */
  55582. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  55583. /**
  55584. * Disposes of the effect renderer
  55585. */
  55586. dispose(): void;
  55587. }
  55588. /**
  55589. * Options to create an EffectWrapper
  55590. */
  55591. interface EffectWrapperCreationOptions {
  55592. /**
  55593. * Engine to use to create the effect
  55594. */
  55595. engine: ThinEngine;
  55596. /**
  55597. * Fragment shader for the effect
  55598. */
  55599. fragmentShader: string;
  55600. /**
  55601. * Vertex shader for the effect
  55602. */
  55603. vertexShader?: string;
  55604. /**
  55605. * Attributes to use in the shader
  55606. */
  55607. attributeNames?: Array<string>;
  55608. /**
  55609. * Uniforms to use in the shader
  55610. */
  55611. uniformNames?: Array<string>;
  55612. /**
  55613. * Texture sampler names to use in the shader
  55614. */
  55615. samplerNames?: Array<string>;
  55616. /**
  55617. * The friendly name of the effect displayed in Spector.
  55618. */
  55619. name?: string;
  55620. }
  55621. /**
  55622. * Wraps an effect to be used for rendering
  55623. */
  55624. export class EffectWrapper {
  55625. /**
  55626. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  55627. */
  55628. onApplyObservable: Observable<{}>;
  55629. /**
  55630. * The underlying effect
  55631. */
  55632. effect: Effect;
  55633. /**
  55634. * Creates an effect to be renderer
  55635. * @param creationOptions options to create the effect
  55636. */
  55637. constructor(creationOptions: EffectWrapperCreationOptions);
  55638. /**
  55639. * Disposes of the effect wrapper
  55640. */
  55641. dispose(): void;
  55642. }
  55643. }
  55644. declare module BABYLON {
  55645. /**
  55646. * Helper class to push actions to a pool of workers.
  55647. */
  55648. export class WorkerPool implements IDisposable {
  55649. private _workerInfos;
  55650. private _pendingActions;
  55651. /**
  55652. * Constructor
  55653. * @param workers Array of workers to use for actions
  55654. */
  55655. constructor(workers: Array<Worker>);
  55656. /**
  55657. * Terminates all workers and clears any pending actions.
  55658. */
  55659. dispose(): void;
  55660. /**
  55661. * Pushes an action to the worker pool. If all the workers are active, the action will be
  55662. * pended until a worker has completed its action.
  55663. * @param action The action to perform. Call onComplete when the action is complete.
  55664. */
  55665. push(action: (worker: Worker, onComplete: () => void) => void): void;
  55666. private _execute;
  55667. }
  55668. }
  55669. declare module BABYLON {
  55670. /**
  55671. * Configuration for Draco compression
  55672. */
  55673. export interface IDracoCompressionConfiguration {
  55674. /**
  55675. * Configuration for the decoder.
  55676. */
  55677. decoder: {
  55678. /**
  55679. * The url to the WebAssembly module.
  55680. */
  55681. wasmUrl?: string;
  55682. /**
  55683. * The url to the WebAssembly binary.
  55684. */
  55685. wasmBinaryUrl?: string;
  55686. /**
  55687. * The url to the fallback JavaScript module.
  55688. */
  55689. fallbackUrl?: string;
  55690. };
  55691. }
  55692. /**
  55693. * Draco compression (https://google.github.io/draco/)
  55694. *
  55695. * This class wraps the Draco module.
  55696. *
  55697. * **Encoder**
  55698. *
  55699. * The encoder is not currently implemented.
  55700. *
  55701. * **Decoder**
  55702. *
  55703. * 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.
  55704. *
  55705. * To update the configuration, use the following code:
  55706. * ```javascript
  55707. * DracoCompression.Configuration = {
  55708. * decoder: {
  55709. * wasmUrl: "<url to the WebAssembly library>",
  55710. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  55711. * fallbackUrl: "<url to the fallback JavaScript library>",
  55712. * }
  55713. * };
  55714. * ```
  55715. *
  55716. * 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.
  55717. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  55718. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  55719. *
  55720. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  55721. * ```javascript
  55722. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  55723. * ```
  55724. *
  55725. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  55726. */
  55727. export class DracoCompression implements IDisposable {
  55728. private _workerPoolPromise?;
  55729. private _decoderModulePromise?;
  55730. /**
  55731. * The configuration. Defaults to the following urls:
  55732. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  55733. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  55734. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  55735. */
  55736. static Configuration: IDracoCompressionConfiguration;
  55737. /**
  55738. * Returns true if the decoder configuration is available.
  55739. */
  55740. static readonly DecoderAvailable: boolean;
  55741. /**
  55742. * Default number of workers to create when creating the draco compression object.
  55743. */
  55744. static DefaultNumWorkers: number;
  55745. private static GetDefaultNumWorkers;
  55746. private static _Default;
  55747. /**
  55748. * Default instance for the draco compression object.
  55749. */
  55750. static readonly Default: DracoCompression;
  55751. /**
  55752. * Constructor
  55753. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  55754. */
  55755. constructor(numWorkers?: number);
  55756. /**
  55757. * Stop all async operations and release resources.
  55758. */
  55759. dispose(): void;
  55760. /**
  55761. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  55762. * @returns a promise that resolves when ready
  55763. */
  55764. whenReadyAsync(): Promise<void>;
  55765. /**
  55766. * Decode Draco compressed mesh data to vertex data.
  55767. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  55768. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  55769. * @returns A promise that resolves with the decoded vertex data
  55770. */
  55771. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  55772. [kind: string]: number;
  55773. }): Promise<VertexData>;
  55774. }
  55775. }
  55776. declare module BABYLON {
  55777. /**
  55778. * Class for building Constructive Solid Geometry
  55779. */
  55780. export class CSG {
  55781. private polygons;
  55782. /**
  55783. * The world matrix
  55784. */
  55785. matrix: Matrix;
  55786. /**
  55787. * Stores the position
  55788. */
  55789. position: Vector3;
  55790. /**
  55791. * Stores the rotation
  55792. */
  55793. rotation: Vector3;
  55794. /**
  55795. * Stores the rotation quaternion
  55796. */
  55797. rotationQuaternion: Nullable<Quaternion>;
  55798. /**
  55799. * Stores the scaling vector
  55800. */
  55801. scaling: Vector3;
  55802. /**
  55803. * Convert the Mesh to CSG
  55804. * @param mesh The Mesh to convert to CSG
  55805. * @returns A new CSG from the Mesh
  55806. */
  55807. static FromMesh(mesh: Mesh): CSG;
  55808. /**
  55809. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  55810. * @param polygons Polygons used to construct a CSG solid
  55811. */
  55812. private static FromPolygons;
  55813. /**
  55814. * Clones, or makes a deep copy, of the CSG
  55815. * @returns A new CSG
  55816. */
  55817. clone(): CSG;
  55818. /**
  55819. * Unions this CSG with another CSG
  55820. * @param csg The CSG to union against this CSG
  55821. * @returns The unioned CSG
  55822. */
  55823. union(csg: CSG): CSG;
  55824. /**
  55825. * Unions this CSG with another CSG in place
  55826. * @param csg The CSG to union against this CSG
  55827. */
  55828. unionInPlace(csg: CSG): void;
  55829. /**
  55830. * Subtracts this CSG with another CSG
  55831. * @param csg The CSG to subtract against this CSG
  55832. * @returns A new CSG
  55833. */
  55834. subtract(csg: CSG): CSG;
  55835. /**
  55836. * Subtracts this CSG with another CSG in place
  55837. * @param csg The CSG to subtact against this CSG
  55838. */
  55839. subtractInPlace(csg: CSG): void;
  55840. /**
  55841. * Intersect this CSG with another CSG
  55842. * @param csg The CSG to intersect against this CSG
  55843. * @returns A new CSG
  55844. */
  55845. intersect(csg: CSG): CSG;
  55846. /**
  55847. * Intersects this CSG with another CSG in place
  55848. * @param csg The CSG to intersect against this CSG
  55849. */
  55850. intersectInPlace(csg: CSG): void;
  55851. /**
  55852. * Return a new CSG solid with solid and empty space switched. This solid is
  55853. * not modified.
  55854. * @returns A new CSG solid with solid and empty space switched
  55855. */
  55856. inverse(): CSG;
  55857. /**
  55858. * Inverses the CSG in place
  55859. */
  55860. inverseInPlace(): void;
  55861. /**
  55862. * This is used to keep meshes transformations so they can be restored
  55863. * when we build back a Babylon Mesh
  55864. * NB : All CSG operations are performed in world coordinates
  55865. * @param csg The CSG to copy the transform attributes from
  55866. * @returns This CSG
  55867. */
  55868. copyTransformAttributes(csg: CSG): CSG;
  55869. /**
  55870. * Build Raw mesh from CSG
  55871. * Coordinates here are in world space
  55872. * @param name The name of the mesh geometry
  55873. * @param scene The Scene
  55874. * @param keepSubMeshes Specifies if the submeshes should be kept
  55875. * @returns A new Mesh
  55876. */
  55877. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  55878. /**
  55879. * Build Mesh from CSG taking material and transforms into account
  55880. * @param name The name of the Mesh
  55881. * @param material The material of the Mesh
  55882. * @param scene The Scene
  55883. * @param keepSubMeshes Specifies if submeshes should be kept
  55884. * @returns The new Mesh
  55885. */
  55886. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  55887. }
  55888. }
  55889. declare module BABYLON {
  55890. /**
  55891. * Class used to create a trail following a mesh
  55892. */
  55893. export class TrailMesh extends Mesh {
  55894. private _generator;
  55895. private _autoStart;
  55896. private _running;
  55897. private _diameter;
  55898. private _length;
  55899. private _sectionPolygonPointsCount;
  55900. private _sectionVectors;
  55901. private _sectionNormalVectors;
  55902. private _beforeRenderObserver;
  55903. /**
  55904. * @constructor
  55905. * @param name The value used by scene.getMeshByName() to do a lookup.
  55906. * @param generator The mesh to generate a trail.
  55907. * @param scene The scene to add this mesh to.
  55908. * @param diameter Diameter of trailing mesh. Default is 1.
  55909. * @param length Length of trailing mesh. Default is 60.
  55910. * @param autoStart Automatically start trailing mesh. Default true.
  55911. */
  55912. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  55913. /**
  55914. * "TrailMesh"
  55915. * @returns "TrailMesh"
  55916. */
  55917. getClassName(): string;
  55918. private _createMesh;
  55919. /**
  55920. * Start trailing mesh.
  55921. */
  55922. start(): void;
  55923. /**
  55924. * Stop trailing mesh.
  55925. */
  55926. stop(): void;
  55927. /**
  55928. * Update trailing mesh geometry.
  55929. */
  55930. update(): void;
  55931. /**
  55932. * Returns a new TrailMesh object.
  55933. * @param name is a string, the name given to the new mesh
  55934. * @param newGenerator use new generator object for cloned trail mesh
  55935. * @returns a new mesh
  55936. */
  55937. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  55938. /**
  55939. * Serializes this trail mesh
  55940. * @param serializationObject object to write serialization to
  55941. */
  55942. serialize(serializationObject: any): void;
  55943. /**
  55944. * Parses a serialized trail mesh
  55945. * @param parsedMesh the serialized mesh
  55946. * @param scene the scene to create the trail mesh in
  55947. * @returns the created trail mesh
  55948. */
  55949. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  55950. }
  55951. }
  55952. declare module BABYLON {
  55953. /**
  55954. * Class containing static functions to help procedurally build meshes
  55955. */
  55956. export class TiledBoxBuilder {
  55957. /**
  55958. * Creates a box mesh
  55959. * 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)
  55960. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  55961. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55962. * * 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
  55963. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55964. * @param name defines the name of the mesh
  55965. * @param options defines the options used to create the mesh
  55966. * @param scene defines the hosting scene
  55967. * @returns the box mesh
  55968. */
  55969. static CreateTiledBox(name: string, options: {
  55970. pattern?: number;
  55971. width?: number;
  55972. height?: number;
  55973. depth?: number;
  55974. tileSize?: number;
  55975. tileWidth?: number;
  55976. tileHeight?: number;
  55977. alignHorizontal?: number;
  55978. alignVertical?: number;
  55979. faceUV?: Vector4[];
  55980. faceColors?: Color4[];
  55981. sideOrientation?: number;
  55982. updatable?: boolean;
  55983. }, scene?: Nullable<Scene>): Mesh;
  55984. }
  55985. }
  55986. declare module BABYLON {
  55987. /**
  55988. * Class containing static functions to help procedurally build meshes
  55989. */
  55990. export class TorusKnotBuilder {
  55991. /**
  55992. * Creates a torus knot mesh
  55993. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  55994. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  55995. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  55996. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  55997. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55998. * * 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
  55999. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  56000. * @param name defines the name of the mesh
  56001. * @param options defines the options used to create the mesh
  56002. * @param scene defines the hosting scene
  56003. * @returns the torus knot mesh
  56004. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  56005. */
  56006. static CreateTorusKnot(name: string, options: {
  56007. radius?: number;
  56008. tube?: number;
  56009. radialSegments?: number;
  56010. tubularSegments?: number;
  56011. p?: number;
  56012. q?: number;
  56013. updatable?: boolean;
  56014. sideOrientation?: number;
  56015. frontUVs?: Vector4;
  56016. backUVs?: Vector4;
  56017. }, scene: any): Mesh;
  56018. }
  56019. }
  56020. declare module BABYLON {
  56021. /**
  56022. * Polygon
  56023. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  56024. */
  56025. export class Polygon {
  56026. /**
  56027. * Creates a rectangle
  56028. * @param xmin bottom X coord
  56029. * @param ymin bottom Y coord
  56030. * @param xmax top X coord
  56031. * @param ymax top Y coord
  56032. * @returns points that make the resulting rectation
  56033. */
  56034. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  56035. /**
  56036. * Creates a circle
  56037. * @param radius radius of circle
  56038. * @param cx scale in x
  56039. * @param cy scale in y
  56040. * @param numberOfSides number of sides that make up the circle
  56041. * @returns points that make the resulting circle
  56042. */
  56043. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  56044. /**
  56045. * Creates a polygon from input string
  56046. * @param input Input polygon data
  56047. * @returns the parsed points
  56048. */
  56049. static Parse(input: string): Vector2[];
  56050. /**
  56051. * Starts building a polygon from x and y coordinates
  56052. * @param x x coordinate
  56053. * @param y y coordinate
  56054. * @returns the started path2
  56055. */
  56056. static StartingAt(x: number, y: number): Path2;
  56057. }
  56058. /**
  56059. * Builds a polygon
  56060. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  56061. */
  56062. export class PolygonMeshBuilder {
  56063. private _points;
  56064. private _outlinepoints;
  56065. private _holes;
  56066. private _name;
  56067. private _scene;
  56068. private _epoints;
  56069. private _eholes;
  56070. private _addToepoint;
  56071. /**
  56072. * Babylon reference to the earcut plugin.
  56073. */
  56074. bjsEarcut: any;
  56075. /**
  56076. * Creates a PolygonMeshBuilder
  56077. * @param name name of the builder
  56078. * @param contours Path of the polygon
  56079. * @param scene scene to add to when creating the mesh
  56080. * @param earcutInjection can be used to inject your own earcut reference
  56081. */
  56082. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  56083. /**
  56084. * Adds a whole within the polygon
  56085. * @param hole Array of points defining the hole
  56086. * @returns this
  56087. */
  56088. addHole(hole: Vector2[]): PolygonMeshBuilder;
  56089. /**
  56090. * Creates the polygon
  56091. * @param updatable If the mesh should be updatable
  56092. * @param depth The depth of the mesh created
  56093. * @returns the created mesh
  56094. */
  56095. build(updatable?: boolean, depth?: number): Mesh;
  56096. /**
  56097. * Creates the polygon
  56098. * @param depth The depth of the mesh created
  56099. * @returns the created VertexData
  56100. */
  56101. buildVertexData(depth?: number): VertexData;
  56102. /**
  56103. * Adds a side to the polygon
  56104. * @param positions points that make the polygon
  56105. * @param normals normals of the polygon
  56106. * @param uvs uvs of the polygon
  56107. * @param indices indices of the polygon
  56108. * @param bounds bounds of the polygon
  56109. * @param points points of the polygon
  56110. * @param depth depth of the polygon
  56111. * @param flip flip of the polygon
  56112. */
  56113. private addSide;
  56114. }
  56115. }
  56116. declare module BABYLON {
  56117. /**
  56118. * Class containing static functions to help procedurally build meshes
  56119. */
  56120. export class PolygonBuilder {
  56121. /**
  56122. * Creates a polygon mesh
  56123. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  56124. * * 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
  56125. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  56126. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56127. * * 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)
  56128. * * Remember you can only change the shape positions, not their number when updating a polygon
  56129. * @param name defines the name of the mesh
  56130. * @param options defines the options used to create the mesh
  56131. * @param scene defines the hosting scene
  56132. * @param earcutInjection can be used to inject your own earcut reference
  56133. * @returns the polygon mesh
  56134. */
  56135. static CreatePolygon(name: string, options: {
  56136. shape: Vector3[];
  56137. holes?: Vector3[][];
  56138. depth?: number;
  56139. faceUV?: Vector4[];
  56140. faceColors?: Color4[];
  56141. updatable?: boolean;
  56142. sideOrientation?: number;
  56143. frontUVs?: Vector4;
  56144. backUVs?: Vector4;
  56145. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  56146. /**
  56147. * Creates an extruded polygon mesh, with depth in the Y direction.
  56148. * * 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)
  56149. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  56150. * @param name defines the name of the mesh
  56151. * @param options defines the options used to create the mesh
  56152. * @param scene defines the hosting scene
  56153. * @param earcutInjection can be used to inject your own earcut reference
  56154. * @returns the polygon mesh
  56155. */
  56156. static ExtrudePolygon(name: string, options: {
  56157. shape: Vector3[];
  56158. holes?: Vector3[][];
  56159. depth?: number;
  56160. faceUV?: Vector4[];
  56161. faceColors?: Color4[];
  56162. updatable?: boolean;
  56163. sideOrientation?: number;
  56164. frontUVs?: Vector4;
  56165. backUVs?: Vector4;
  56166. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  56167. }
  56168. }
  56169. declare module BABYLON {
  56170. /**
  56171. * Class containing static functions to help procedurally build meshes
  56172. */
  56173. export class LatheBuilder {
  56174. /**
  56175. * Creates lathe mesh.
  56176. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  56177. * * 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
  56178. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  56179. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  56180. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  56181. * * 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
  56182. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  56183. * * 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
  56184. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56185. * * 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
  56186. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  56187. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56188. * @param name defines the name of the mesh
  56189. * @param options defines the options used to create the mesh
  56190. * @param scene defines the hosting scene
  56191. * @returns the lathe mesh
  56192. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  56193. */
  56194. static CreateLathe(name: string, options: {
  56195. shape: Vector3[];
  56196. radius?: number;
  56197. tessellation?: number;
  56198. clip?: number;
  56199. arc?: number;
  56200. closed?: boolean;
  56201. updatable?: boolean;
  56202. sideOrientation?: number;
  56203. frontUVs?: Vector4;
  56204. backUVs?: Vector4;
  56205. cap?: number;
  56206. invertUV?: boolean;
  56207. }, scene?: Nullable<Scene>): Mesh;
  56208. }
  56209. }
  56210. declare module BABYLON {
  56211. /**
  56212. * Class containing static functions to help procedurally build meshes
  56213. */
  56214. export class TiledPlaneBuilder {
  56215. /**
  56216. * Creates a tiled plane mesh
  56217. * * The parameter `pattern` will, depending on value, do nothing or
  56218. * * * flip (reflect about central vertical) alternate tiles across and up
  56219. * * * flip every tile on alternate rows
  56220. * * * rotate (180 degs) alternate tiles across and up
  56221. * * * rotate every tile on alternate rows
  56222. * * * flip and rotate alternate tiles across and up
  56223. * * * flip and rotate every tile on alternate rows
  56224. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  56225. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  56226. * * 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
  56227. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  56228. * * 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)
  56229. * * 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)
  56230. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  56231. * @param name defines the name of the mesh
  56232. * @param options defines the options used to create the mesh
  56233. * @param scene defines the hosting scene
  56234. * @returns the box mesh
  56235. */
  56236. static CreateTiledPlane(name: string, options: {
  56237. pattern?: number;
  56238. tileSize?: number;
  56239. tileWidth?: number;
  56240. tileHeight?: number;
  56241. size?: number;
  56242. width?: number;
  56243. height?: number;
  56244. alignHorizontal?: number;
  56245. alignVertical?: number;
  56246. sideOrientation?: number;
  56247. frontUVs?: Vector4;
  56248. backUVs?: Vector4;
  56249. updatable?: boolean;
  56250. }, scene?: Nullable<Scene>): Mesh;
  56251. }
  56252. }
  56253. declare module BABYLON {
  56254. /**
  56255. * Class containing static functions to help procedurally build meshes
  56256. */
  56257. export class TubeBuilder {
  56258. /**
  56259. * Creates a tube mesh.
  56260. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  56261. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  56262. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  56263. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  56264. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  56265. * * 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)
  56266. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  56267. * * 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
  56268. * * 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
  56269. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56270. * * 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
  56271. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  56272. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56273. * @param name defines the name of the mesh
  56274. * @param options defines the options used to create the mesh
  56275. * @param scene defines the hosting scene
  56276. * @returns the tube mesh
  56277. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  56278. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  56279. */
  56280. static CreateTube(name: string, options: {
  56281. path: Vector3[];
  56282. radius?: number;
  56283. tessellation?: number;
  56284. radiusFunction?: {
  56285. (i: number, distance: number): number;
  56286. };
  56287. cap?: number;
  56288. arc?: number;
  56289. updatable?: boolean;
  56290. sideOrientation?: number;
  56291. frontUVs?: Vector4;
  56292. backUVs?: Vector4;
  56293. instance?: Mesh;
  56294. invertUV?: boolean;
  56295. }, scene?: Nullable<Scene>): Mesh;
  56296. }
  56297. }
  56298. declare module BABYLON {
  56299. /**
  56300. * Class containing static functions to help procedurally build meshes
  56301. */
  56302. export class IcoSphereBuilder {
  56303. /**
  56304. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  56305. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  56306. * * 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`)
  56307. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  56308. * * 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
  56309. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56310. * * 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
  56311. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56312. * @param name defines the name of the mesh
  56313. * @param options defines the options used to create the mesh
  56314. * @param scene defines the hosting scene
  56315. * @returns the icosahedron mesh
  56316. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  56317. */
  56318. static CreateIcoSphere(name: string, options: {
  56319. radius?: number;
  56320. radiusX?: number;
  56321. radiusY?: number;
  56322. radiusZ?: number;
  56323. flat?: boolean;
  56324. subdivisions?: number;
  56325. sideOrientation?: number;
  56326. frontUVs?: Vector4;
  56327. backUVs?: Vector4;
  56328. updatable?: boolean;
  56329. }, scene?: Nullable<Scene>): Mesh;
  56330. }
  56331. }
  56332. declare module BABYLON {
  56333. /**
  56334. * Class containing static functions to help procedurally build meshes
  56335. */
  56336. export class DecalBuilder {
  56337. /**
  56338. * Creates a decal mesh.
  56339. * 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
  56340. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  56341. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  56342. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  56343. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  56344. * @param name defines the name of the mesh
  56345. * @param sourceMesh defines the mesh where the decal must be applied
  56346. * @param options defines the options used to create the mesh
  56347. * @param scene defines the hosting scene
  56348. * @returns the decal mesh
  56349. * @see https://doc.babylonjs.com/how_to/decals
  56350. */
  56351. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  56352. position?: Vector3;
  56353. normal?: Vector3;
  56354. size?: Vector3;
  56355. angle?: number;
  56356. }): Mesh;
  56357. }
  56358. }
  56359. declare module BABYLON {
  56360. /**
  56361. * Class containing static functions to help procedurally build meshes
  56362. */
  56363. export class MeshBuilder {
  56364. /**
  56365. * Creates a box mesh
  56366. * * The parameter `size` sets the size (float) of each box side (default 1)
  56367. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  56368. * * 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)
  56369. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  56370. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56371. * * 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
  56372. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56373. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  56374. * @param name defines the name of the mesh
  56375. * @param options defines the options used to create the mesh
  56376. * @param scene defines the hosting scene
  56377. * @returns the box mesh
  56378. */
  56379. static CreateBox(name: string, options: {
  56380. size?: number;
  56381. width?: number;
  56382. height?: number;
  56383. depth?: number;
  56384. faceUV?: Vector4[];
  56385. faceColors?: Color4[];
  56386. sideOrientation?: number;
  56387. frontUVs?: Vector4;
  56388. backUVs?: Vector4;
  56389. updatable?: boolean;
  56390. }, scene?: Nullable<Scene>): Mesh;
  56391. /**
  56392. * Creates a tiled box mesh
  56393. * * faceTiles sets the pattern, tile size and number of tiles for a face
  56394. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56395. * @param name defines the name of the mesh
  56396. * @param options defines the options used to create the mesh
  56397. * @param scene defines the hosting scene
  56398. * @returns the tiled box mesh
  56399. */
  56400. static CreateTiledBox(name: string, options: {
  56401. pattern?: number;
  56402. size?: number;
  56403. width?: number;
  56404. height?: number;
  56405. depth: number;
  56406. tileSize?: number;
  56407. tileWidth?: number;
  56408. tileHeight?: number;
  56409. faceUV?: Vector4[];
  56410. faceColors?: Color4[];
  56411. alignHorizontal?: number;
  56412. alignVertical?: number;
  56413. sideOrientation?: number;
  56414. updatable?: boolean;
  56415. }, scene?: Nullable<Scene>): Mesh;
  56416. /**
  56417. * Creates a sphere mesh
  56418. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  56419. * * 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`)
  56420. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  56421. * * 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
  56422. * * 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)
  56423. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56424. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56425. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56426. * @param name defines the name of the mesh
  56427. * @param options defines the options used to create the mesh
  56428. * @param scene defines the hosting scene
  56429. * @returns the sphere mesh
  56430. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  56431. */
  56432. static CreateSphere(name: string, options: {
  56433. segments?: number;
  56434. diameter?: number;
  56435. diameterX?: number;
  56436. diameterY?: number;
  56437. diameterZ?: number;
  56438. arc?: number;
  56439. slice?: number;
  56440. sideOrientation?: number;
  56441. frontUVs?: Vector4;
  56442. backUVs?: Vector4;
  56443. updatable?: boolean;
  56444. }, scene?: Nullable<Scene>): Mesh;
  56445. /**
  56446. * Creates a plane polygonal mesh. By default, this is a disc
  56447. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  56448. * * 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
  56449. * * 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
  56450. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56451. * * 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
  56452. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56453. * @param name defines the name of the mesh
  56454. * @param options defines the options used to create the mesh
  56455. * @param scene defines the hosting scene
  56456. * @returns the plane polygonal mesh
  56457. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  56458. */
  56459. static CreateDisc(name: string, options: {
  56460. radius?: number;
  56461. tessellation?: number;
  56462. arc?: number;
  56463. updatable?: boolean;
  56464. sideOrientation?: number;
  56465. frontUVs?: Vector4;
  56466. backUVs?: Vector4;
  56467. }, scene?: Nullable<Scene>): Mesh;
  56468. /**
  56469. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  56470. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  56471. * * 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`)
  56472. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  56473. * * 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
  56474. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56475. * * 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
  56476. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56477. * @param name defines the name of the mesh
  56478. * @param options defines the options used to create the mesh
  56479. * @param scene defines the hosting scene
  56480. * @returns the icosahedron mesh
  56481. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  56482. */
  56483. static CreateIcoSphere(name: string, options: {
  56484. radius?: number;
  56485. radiusX?: number;
  56486. radiusY?: number;
  56487. radiusZ?: number;
  56488. flat?: boolean;
  56489. subdivisions?: number;
  56490. sideOrientation?: number;
  56491. frontUVs?: Vector4;
  56492. backUVs?: Vector4;
  56493. updatable?: boolean;
  56494. }, scene?: Nullable<Scene>): Mesh;
  56495. /**
  56496. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  56497. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  56498. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  56499. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  56500. * * 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
  56501. * * 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
  56502. * * 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
  56503. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56504. * * 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
  56505. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  56506. * * 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
  56507. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  56508. * * 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
  56509. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  56510. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56511. * @param name defines the name of the mesh
  56512. * @param options defines the options used to create the mesh
  56513. * @param scene defines the hosting scene
  56514. * @returns the ribbon mesh
  56515. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  56516. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  56517. */
  56518. static CreateRibbon(name: string, options: {
  56519. pathArray: Vector3[][];
  56520. closeArray?: boolean;
  56521. closePath?: boolean;
  56522. offset?: number;
  56523. updatable?: boolean;
  56524. sideOrientation?: number;
  56525. frontUVs?: Vector4;
  56526. backUVs?: Vector4;
  56527. instance?: Mesh;
  56528. invertUV?: boolean;
  56529. uvs?: Vector2[];
  56530. colors?: Color4[];
  56531. }, scene?: Nullable<Scene>): Mesh;
  56532. /**
  56533. * Creates a cylinder or a cone mesh
  56534. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  56535. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  56536. * * 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.
  56537. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  56538. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  56539. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  56540. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  56541. * * 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).
  56542. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  56543. * * 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).
  56544. * * 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
  56545. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  56546. * * 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
  56547. * * 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.
  56548. * * If `enclose` is false, a ring surface is one element.
  56549. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  56550. * * 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
  56551. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56552. * * 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
  56553. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  56554. * @param name defines the name of the mesh
  56555. * @param options defines the options used to create the mesh
  56556. * @param scene defines the hosting scene
  56557. * @returns the cylinder mesh
  56558. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  56559. */
  56560. static CreateCylinder(name: string, options: {
  56561. height?: number;
  56562. diameterTop?: number;
  56563. diameterBottom?: number;
  56564. diameter?: number;
  56565. tessellation?: number;
  56566. subdivisions?: number;
  56567. arc?: number;
  56568. faceColors?: Color4[];
  56569. faceUV?: Vector4[];
  56570. updatable?: boolean;
  56571. hasRings?: boolean;
  56572. enclose?: boolean;
  56573. cap?: number;
  56574. sideOrientation?: number;
  56575. frontUVs?: Vector4;
  56576. backUVs?: Vector4;
  56577. }, scene?: Nullable<Scene>): Mesh;
  56578. /**
  56579. * Creates a torus mesh
  56580. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  56581. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  56582. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  56583. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56584. * * 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
  56585. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  56586. * @param name defines the name of the mesh
  56587. * @param options defines the options used to create the mesh
  56588. * @param scene defines the hosting scene
  56589. * @returns the torus mesh
  56590. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  56591. */
  56592. static CreateTorus(name: string, options: {
  56593. diameter?: number;
  56594. thickness?: number;
  56595. tessellation?: number;
  56596. updatable?: boolean;
  56597. sideOrientation?: number;
  56598. frontUVs?: Vector4;
  56599. backUVs?: Vector4;
  56600. }, scene?: Nullable<Scene>): Mesh;
  56601. /**
  56602. * Creates a torus knot mesh
  56603. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  56604. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  56605. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  56606. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  56607. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56608. * * 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
  56609. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  56610. * @param name defines the name of the mesh
  56611. * @param options defines the options used to create the mesh
  56612. * @param scene defines the hosting scene
  56613. * @returns the torus knot mesh
  56614. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  56615. */
  56616. static CreateTorusKnot(name: string, options: {
  56617. radius?: number;
  56618. tube?: number;
  56619. radialSegments?: number;
  56620. tubularSegments?: number;
  56621. p?: number;
  56622. q?: number;
  56623. updatable?: boolean;
  56624. sideOrientation?: number;
  56625. frontUVs?: Vector4;
  56626. backUVs?: Vector4;
  56627. }, scene?: Nullable<Scene>): Mesh;
  56628. /**
  56629. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  56630. * * 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
  56631. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  56632. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  56633. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  56634. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  56635. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  56636. * * 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
  56637. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  56638. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56639. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  56640. * @param name defines the name of the new line system
  56641. * @param options defines the options used to create the line system
  56642. * @param scene defines the hosting scene
  56643. * @returns a new line system mesh
  56644. */
  56645. static CreateLineSystem(name: string, options: {
  56646. lines: Vector3[][];
  56647. updatable?: boolean;
  56648. instance?: Nullable<LinesMesh>;
  56649. colors?: Nullable<Color4[][]>;
  56650. useVertexAlpha?: boolean;
  56651. }, scene: Nullable<Scene>): LinesMesh;
  56652. /**
  56653. * Creates a line mesh
  56654. * 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
  56655. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  56656. * * The parameter `points` is an array successive Vector3
  56657. * * 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
  56658. * * The optional parameter `colors` is an array of successive Color4, one per line point
  56659. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  56660. * * When updating an instance, remember that only point positions can change, not the number of points
  56661. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56662. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  56663. * @param name defines the name of the new line system
  56664. * @param options defines the options used to create the line system
  56665. * @param scene defines the hosting scene
  56666. * @returns a new line mesh
  56667. */
  56668. static CreateLines(name: string, options: {
  56669. points: Vector3[];
  56670. updatable?: boolean;
  56671. instance?: Nullable<LinesMesh>;
  56672. colors?: Color4[];
  56673. useVertexAlpha?: boolean;
  56674. }, scene?: Nullable<Scene>): LinesMesh;
  56675. /**
  56676. * Creates a dashed line mesh
  56677. * * 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
  56678. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  56679. * * The parameter `points` is an array successive Vector3
  56680. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  56681. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  56682. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  56683. * * 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
  56684. * * When updating an instance, remember that only point positions can change, not the number of points
  56685. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56686. * @param name defines the name of the mesh
  56687. * @param options defines the options used to create the mesh
  56688. * @param scene defines the hosting scene
  56689. * @returns the dashed line mesh
  56690. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  56691. */
  56692. static CreateDashedLines(name: string, options: {
  56693. points: Vector3[];
  56694. dashSize?: number;
  56695. gapSize?: number;
  56696. dashNb?: number;
  56697. updatable?: boolean;
  56698. instance?: LinesMesh;
  56699. }, scene?: Nullable<Scene>): LinesMesh;
  56700. /**
  56701. * 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.
  56702. * * 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.
  56703. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  56704. * * 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.
  56705. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  56706. * * 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
  56707. * * 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
  56708. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  56709. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56710. * * 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
  56711. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  56712. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  56713. * @param name defines the name of the mesh
  56714. * @param options defines the options used to create the mesh
  56715. * @param scene defines the hosting scene
  56716. * @returns the extruded shape mesh
  56717. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  56718. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  56719. */
  56720. static ExtrudeShape(name: string, options: {
  56721. shape: Vector3[];
  56722. path: Vector3[];
  56723. scale?: number;
  56724. rotation?: number;
  56725. cap?: number;
  56726. updatable?: boolean;
  56727. sideOrientation?: number;
  56728. frontUVs?: Vector4;
  56729. backUVs?: Vector4;
  56730. instance?: Mesh;
  56731. invertUV?: boolean;
  56732. }, scene?: Nullable<Scene>): Mesh;
  56733. /**
  56734. * Creates an custom extruded shape mesh.
  56735. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  56736. * * 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.
  56737. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  56738. * * 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
  56739. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  56740. * * 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
  56741. * * It must returns a float value that will be the scale value applied to the shape on each path point
  56742. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  56743. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  56744. * * 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
  56745. * * 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
  56746. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  56747. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56748. * * 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
  56749. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  56750. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56751. * @param name defines the name of the mesh
  56752. * @param options defines the options used to create the mesh
  56753. * @param scene defines the hosting scene
  56754. * @returns the custom extruded shape mesh
  56755. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  56756. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  56757. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  56758. */
  56759. static ExtrudeShapeCustom(name: string, options: {
  56760. shape: Vector3[];
  56761. path: Vector3[];
  56762. scaleFunction?: any;
  56763. rotationFunction?: any;
  56764. ribbonCloseArray?: boolean;
  56765. ribbonClosePath?: boolean;
  56766. cap?: number;
  56767. updatable?: boolean;
  56768. sideOrientation?: number;
  56769. frontUVs?: Vector4;
  56770. backUVs?: Vector4;
  56771. instance?: Mesh;
  56772. invertUV?: boolean;
  56773. }, scene?: Nullable<Scene>): Mesh;
  56774. /**
  56775. * Creates lathe mesh.
  56776. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  56777. * * 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
  56778. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  56779. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  56780. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  56781. * * 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
  56782. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  56783. * * 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
  56784. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56785. * * 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
  56786. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  56787. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56788. * @param name defines the name of the mesh
  56789. * @param options defines the options used to create the mesh
  56790. * @param scene defines the hosting scene
  56791. * @returns the lathe mesh
  56792. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  56793. */
  56794. static CreateLathe(name: string, options: {
  56795. shape: Vector3[];
  56796. radius?: number;
  56797. tessellation?: number;
  56798. clip?: number;
  56799. arc?: number;
  56800. closed?: boolean;
  56801. updatable?: boolean;
  56802. sideOrientation?: number;
  56803. frontUVs?: Vector4;
  56804. backUVs?: Vector4;
  56805. cap?: number;
  56806. invertUV?: boolean;
  56807. }, scene?: Nullable<Scene>): Mesh;
  56808. /**
  56809. * Creates a tiled plane mesh
  56810. * * You can set a limited pattern arrangement with the tiles
  56811. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56812. * * 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
  56813. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56814. * @param name defines the name of the mesh
  56815. * @param options defines the options used to create the mesh
  56816. * @param scene defines the hosting scene
  56817. * @returns the plane mesh
  56818. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  56819. */
  56820. static CreateTiledPlane(name: string, options: {
  56821. pattern?: number;
  56822. tileSize?: number;
  56823. tileWidth?: number;
  56824. tileHeight?: number;
  56825. size?: number;
  56826. width?: number;
  56827. height?: number;
  56828. alignHorizontal?: number;
  56829. alignVertical?: number;
  56830. sideOrientation?: number;
  56831. frontUVs?: Vector4;
  56832. backUVs?: Vector4;
  56833. updatable?: boolean;
  56834. }, scene?: Nullable<Scene>): Mesh;
  56835. /**
  56836. * Creates a plane mesh
  56837. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  56838. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  56839. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  56840. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56841. * * 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
  56842. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56843. * @param name defines the name of the mesh
  56844. * @param options defines the options used to create the mesh
  56845. * @param scene defines the hosting scene
  56846. * @returns the plane mesh
  56847. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  56848. */
  56849. static CreatePlane(name: string, options: {
  56850. size?: number;
  56851. width?: number;
  56852. height?: number;
  56853. sideOrientation?: number;
  56854. frontUVs?: Vector4;
  56855. backUVs?: Vector4;
  56856. updatable?: boolean;
  56857. sourcePlane?: Plane;
  56858. }, scene?: Nullable<Scene>): Mesh;
  56859. /**
  56860. * Creates a ground mesh
  56861. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  56862. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  56863. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56864. * @param name defines the name of the mesh
  56865. * @param options defines the options used to create the mesh
  56866. * @param scene defines the hosting scene
  56867. * @returns the ground mesh
  56868. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  56869. */
  56870. static CreateGround(name: string, options: {
  56871. width?: number;
  56872. height?: number;
  56873. subdivisions?: number;
  56874. subdivisionsX?: number;
  56875. subdivisionsY?: number;
  56876. updatable?: boolean;
  56877. }, scene?: Nullable<Scene>): Mesh;
  56878. /**
  56879. * Creates a tiled ground mesh
  56880. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  56881. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  56882. * * 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
  56883. * * 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
  56884. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  56885. * @param name defines the name of the mesh
  56886. * @param options defines the options used to create the mesh
  56887. * @param scene defines the hosting scene
  56888. * @returns the tiled ground mesh
  56889. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  56890. */
  56891. static CreateTiledGround(name: string, options: {
  56892. xmin: number;
  56893. zmin: number;
  56894. xmax: number;
  56895. zmax: number;
  56896. subdivisions?: {
  56897. w: number;
  56898. h: number;
  56899. };
  56900. precision?: {
  56901. w: number;
  56902. h: number;
  56903. };
  56904. updatable?: boolean;
  56905. }, scene?: Nullable<Scene>): Mesh;
  56906. /**
  56907. * Creates a ground mesh from a height map
  56908. * * The parameter `url` sets the URL of the height map image resource.
  56909. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  56910. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  56911. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  56912. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  56913. * * 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.
  56914. * * 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).
  56915. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  56916. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  56917. * @param name defines the name of the mesh
  56918. * @param url defines the url to the height map
  56919. * @param options defines the options used to create the mesh
  56920. * @param scene defines the hosting scene
  56921. * @returns the ground mesh
  56922. * @see https://doc.babylonjs.com/babylon101/height_map
  56923. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  56924. */
  56925. static CreateGroundFromHeightMap(name: string, url: string, options: {
  56926. width?: number;
  56927. height?: number;
  56928. subdivisions?: number;
  56929. minHeight?: number;
  56930. maxHeight?: number;
  56931. colorFilter?: Color3;
  56932. alphaFilter?: number;
  56933. updatable?: boolean;
  56934. onReady?: (mesh: GroundMesh) => void;
  56935. }, scene?: Nullable<Scene>): GroundMesh;
  56936. /**
  56937. * Creates a polygon mesh
  56938. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  56939. * * 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
  56940. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  56941. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56942. * * 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)
  56943. * * Remember you can only change the shape positions, not their number when updating a polygon
  56944. * @param name defines the name of the mesh
  56945. * @param options defines the options used to create the mesh
  56946. * @param scene defines the hosting scene
  56947. * @param earcutInjection can be used to inject your own earcut reference
  56948. * @returns the polygon mesh
  56949. */
  56950. static CreatePolygon(name: string, options: {
  56951. shape: Vector3[];
  56952. holes?: Vector3[][];
  56953. depth?: number;
  56954. faceUV?: Vector4[];
  56955. faceColors?: Color4[];
  56956. updatable?: boolean;
  56957. sideOrientation?: number;
  56958. frontUVs?: Vector4;
  56959. backUVs?: Vector4;
  56960. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  56961. /**
  56962. * Creates an extruded polygon mesh, with depth in the Y direction.
  56963. * * 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)
  56964. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  56965. * @param name defines the name of the mesh
  56966. * @param options defines the options used to create the mesh
  56967. * @param scene defines the hosting scene
  56968. * @param earcutInjection can be used to inject your own earcut reference
  56969. * @returns the polygon mesh
  56970. */
  56971. static ExtrudePolygon(name: string, options: {
  56972. shape: Vector3[];
  56973. holes?: Vector3[][];
  56974. depth?: number;
  56975. faceUV?: Vector4[];
  56976. faceColors?: Color4[];
  56977. updatable?: boolean;
  56978. sideOrientation?: number;
  56979. frontUVs?: Vector4;
  56980. backUVs?: Vector4;
  56981. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  56982. /**
  56983. * Creates a tube mesh.
  56984. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  56985. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  56986. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  56987. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  56988. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  56989. * * 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)
  56990. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  56991. * * 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
  56992. * * 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
  56993. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56994. * * 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
  56995. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  56996. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56997. * @param name defines the name of the mesh
  56998. * @param options defines the options used to create the mesh
  56999. * @param scene defines the hosting scene
  57000. * @returns the tube mesh
  57001. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  57002. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  57003. */
  57004. static CreateTube(name: string, options: {
  57005. path: Vector3[];
  57006. radius?: number;
  57007. tessellation?: number;
  57008. radiusFunction?: {
  57009. (i: number, distance: number): number;
  57010. };
  57011. cap?: number;
  57012. arc?: number;
  57013. updatable?: boolean;
  57014. sideOrientation?: number;
  57015. frontUVs?: Vector4;
  57016. backUVs?: Vector4;
  57017. instance?: Mesh;
  57018. invertUV?: boolean;
  57019. }, scene?: Nullable<Scene>): Mesh;
  57020. /**
  57021. * Creates a polyhedron mesh
  57022. * * 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
  57023. * * The parameter `size` (positive float, default 1) sets the polygon size
  57024. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  57025. * * 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`
  57026. * * 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
  57027. * * 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)`)
  57028. * * 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
  57029. * * 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
  57030. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57031. * * 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
  57032. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57033. * @param name defines the name of the mesh
  57034. * @param options defines the options used to create the mesh
  57035. * @param scene defines the hosting scene
  57036. * @returns the polyhedron mesh
  57037. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  57038. */
  57039. static CreatePolyhedron(name: string, options: {
  57040. type?: number;
  57041. size?: number;
  57042. sizeX?: number;
  57043. sizeY?: number;
  57044. sizeZ?: number;
  57045. custom?: any;
  57046. faceUV?: Vector4[];
  57047. faceColors?: Color4[];
  57048. flat?: boolean;
  57049. updatable?: boolean;
  57050. sideOrientation?: number;
  57051. frontUVs?: Vector4;
  57052. backUVs?: Vector4;
  57053. }, scene?: Nullable<Scene>): Mesh;
  57054. /**
  57055. * Creates a decal mesh.
  57056. * 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
  57057. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  57058. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  57059. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  57060. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  57061. * @param name defines the name of the mesh
  57062. * @param sourceMesh defines the mesh where the decal must be applied
  57063. * @param options defines the options used to create the mesh
  57064. * @param scene defines the hosting scene
  57065. * @returns the decal mesh
  57066. * @see https://doc.babylonjs.com/how_to/decals
  57067. */
  57068. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  57069. position?: Vector3;
  57070. normal?: Vector3;
  57071. size?: Vector3;
  57072. angle?: number;
  57073. }): Mesh;
  57074. }
  57075. }
  57076. declare module BABYLON {
  57077. /**
  57078. * A simplifier interface for future simplification implementations
  57079. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  57080. */
  57081. export interface ISimplifier {
  57082. /**
  57083. * Simplification of a given mesh according to the given settings.
  57084. * Since this requires computation, it is assumed that the function runs async.
  57085. * @param settings The settings of the simplification, including quality and distance
  57086. * @param successCallback A callback that will be called after the mesh was simplified.
  57087. * @param errorCallback in case of an error, this callback will be called. optional.
  57088. */
  57089. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  57090. }
  57091. /**
  57092. * Expected simplification settings.
  57093. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  57094. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  57095. */
  57096. export interface ISimplificationSettings {
  57097. /**
  57098. * Gets or sets the expected quality
  57099. */
  57100. quality: number;
  57101. /**
  57102. * Gets or sets the distance when this optimized version should be used
  57103. */
  57104. distance: number;
  57105. /**
  57106. * Gets an already optimized mesh
  57107. */
  57108. optimizeMesh?: boolean;
  57109. }
  57110. /**
  57111. * Class used to specify simplification options
  57112. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  57113. */
  57114. export class SimplificationSettings implements ISimplificationSettings {
  57115. /** expected quality */
  57116. quality: number;
  57117. /** distance when this optimized version should be used */
  57118. distance: number;
  57119. /** already optimized mesh */
  57120. optimizeMesh?: boolean | undefined;
  57121. /**
  57122. * Creates a SimplificationSettings
  57123. * @param quality expected quality
  57124. * @param distance distance when this optimized version should be used
  57125. * @param optimizeMesh already optimized mesh
  57126. */
  57127. constructor(
  57128. /** expected quality */
  57129. quality: number,
  57130. /** distance when this optimized version should be used */
  57131. distance: number,
  57132. /** already optimized mesh */
  57133. optimizeMesh?: boolean | undefined);
  57134. }
  57135. /**
  57136. * Interface used to define a simplification task
  57137. */
  57138. export interface ISimplificationTask {
  57139. /**
  57140. * Array of settings
  57141. */
  57142. settings: Array<ISimplificationSettings>;
  57143. /**
  57144. * Simplification type
  57145. */
  57146. simplificationType: SimplificationType;
  57147. /**
  57148. * Mesh to simplify
  57149. */
  57150. mesh: Mesh;
  57151. /**
  57152. * Callback called on success
  57153. */
  57154. successCallback?: () => void;
  57155. /**
  57156. * Defines if parallel processing can be used
  57157. */
  57158. parallelProcessing: boolean;
  57159. }
  57160. /**
  57161. * Queue used to order the simplification tasks
  57162. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  57163. */
  57164. export class SimplificationQueue {
  57165. private _simplificationArray;
  57166. /**
  57167. * Gets a boolean indicating that the process is still running
  57168. */
  57169. running: boolean;
  57170. /**
  57171. * Creates a new queue
  57172. */
  57173. constructor();
  57174. /**
  57175. * Adds a new simplification task
  57176. * @param task defines a task to add
  57177. */
  57178. addTask(task: ISimplificationTask): void;
  57179. /**
  57180. * Execute next task
  57181. */
  57182. executeNext(): void;
  57183. /**
  57184. * Execute a simplification task
  57185. * @param task defines the task to run
  57186. */
  57187. runSimplification(task: ISimplificationTask): void;
  57188. private getSimplifier;
  57189. }
  57190. /**
  57191. * The implemented types of simplification
  57192. * At the moment only Quadratic Error Decimation is implemented
  57193. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  57194. */
  57195. export enum SimplificationType {
  57196. /** Quadratic error decimation */
  57197. QUADRATIC = 0
  57198. }
  57199. }
  57200. declare module BABYLON {
  57201. interface Scene {
  57202. /** @hidden (Backing field) */
  57203. _simplificationQueue: SimplificationQueue;
  57204. /**
  57205. * Gets or sets the simplification queue attached to the scene
  57206. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  57207. */
  57208. simplificationQueue: SimplificationQueue;
  57209. }
  57210. interface Mesh {
  57211. /**
  57212. * Simplify the mesh according to the given array of settings.
  57213. * Function will return immediately and will simplify async
  57214. * @param settings a collection of simplification settings
  57215. * @param parallelProcessing should all levels calculate parallel or one after the other
  57216. * @param simplificationType the type of simplification to run
  57217. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  57218. * @returns the current mesh
  57219. */
  57220. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  57221. }
  57222. /**
  57223. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  57224. * created in a scene
  57225. */
  57226. export class SimplicationQueueSceneComponent implements ISceneComponent {
  57227. /**
  57228. * The component name helpfull to identify the component in the list of scene components.
  57229. */
  57230. readonly name: string;
  57231. /**
  57232. * The scene the component belongs to.
  57233. */
  57234. scene: Scene;
  57235. /**
  57236. * Creates a new instance of the component for the given scene
  57237. * @param scene Defines the scene to register the component in
  57238. */
  57239. constructor(scene: Scene);
  57240. /**
  57241. * Registers the component in a given scene
  57242. */
  57243. register(): void;
  57244. /**
  57245. * Rebuilds the elements related to this component in case of
  57246. * context lost for instance.
  57247. */
  57248. rebuild(): void;
  57249. /**
  57250. * Disposes the component and the associated ressources
  57251. */
  57252. dispose(): void;
  57253. private _beforeCameraUpdate;
  57254. }
  57255. }
  57256. declare module BABYLON {
  57257. /**
  57258. * Navigation plugin interface to add navigation constrained by a navigation mesh
  57259. */
  57260. export interface INavigationEnginePlugin {
  57261. /**
  57262. * plugin name
  57263. */
  57264. name: string;
  57265. /**
  57266. * Creates a navigation mesh
  57267. * @param meshes array of all the geometry used to compute the navigatio mesh
  57268. * @param parameters bunch of parameters used to filter geometry
  57269. */
  57270. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  57271. /**
  57272. * Create a navigation mesh debug mesh
  57273. * @param scene is where the mesh will be added
  57274. * @returns debug display mesh
  57275. */
  57276. createDebugNavMesh(scene: Scene): Mesh;
  57277. /**
  57278. * Get a navigation mesh constrained position, closest to the parameter position
  57279. * @param position world position
  57280. * @returns the closest point to position constrained by the navigation mesh
  57281. */
  57282. getClosestPoint(position: Vector3): Vector3;
  57283. /**
  57284. * Get a navigation mesh constrained position, within a particular radius
  57285. * @param position world position
  57286. * @param maxRadius the maximum distance to the constrained world position
  57287. * @returns the closest point to position constrained by the navigation mesh
  57288. */
  57289. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  57290. /**
  57291. * Compute the final position from a segment made of destination-position
  57292. * @param position world position
  57293. * @param destination world position
  57294. * @returns the resulting point along the navmesh
  57295. */
  57296. moveAlong(position: Vector3, destination: Vector3): Vector3;
  57297. /**
  57298. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  57299. * @param start world position
  57300. * @param end world position
  57301. * @returns array containing world position composing the path
  57302. */
  57303. computePath(start: Vector3, end: Vector3): Vector3[];
  57304. /**
  57305. * If this plugin is supported
  57306. * @returns true if plugin is supported
  57307. */
  57308. isSupported(): boolean;
  57309. /**
  57310. * Create a new Crowd so you can add agents
  57311. * @param maxAgents the maximum agent count in the crowd
  57312. * @param maxAgentRadius the maximum radius an agent can have
  57313. * @param scene to attach the crowd to
  57314. * @returns the crowd you can add agents to
  57315. */
  57316. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  57317. /**
  57318. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  57319. * The queries will try to find a solution within those bounds
  57320. * default is (1,1,1)
  57321. * @param extent x,y,z value that define the extent around the queries point of reference
  57322. */
  57323. setDefaultQueryExtent(extent: Vector3): void;
  57324. /**
  57325. * Get the Bounding box extent specified by setDefaultQueryExtent
  57326. * @returns the box extent values
  57327. */
  57328. getDefaultQueryExtent(): Vector3;
  57329. /**
  57330. * Release all resources
  57331. */
  57332. dispose(): void;
  57333. }
  57334. /**
  57335. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  57336. */
  57337. export interface ICrowd {
  57338. /**
  57339. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  57340. * You can attach anything to that node. The node position is updated in the scene update tick.
  57341. * @param pos world position that will be constrained by the navigation mesh
  57342. * @param parameters agent parameters
  57343. * @param transform hooked to the agent that will be update by the scene
  57344. * @returns agent index
  57345. */
  57346. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  57347. /**
  57348. * Returns the agent position in world space
  57349. * @param index agent index returned by addAgent
  57350. * @returns world space position
  57351. */
  57352. getAgentPosition(index: number): Vector3;
  57353. /**
  57354. * Gets the agent velocity in world space
  57355. * @param index agent index returned by addAgent
  57356. * @returns world space velocity
  57357. */
  57358. getAgentVelocity(index: number): Vector3;
  57359. /**
  57360. * remove a particular agent previously created
  57361. * @param index agent index returned by addAgent
  57362. */
  57363. removeAgent(index: number): void;
  57364. /**
  57365. * get the list of all agents attached to this crowd
  57366. * @returns list of agent indices
  57367. */
  57368. getAgents(): number[];
  57369. /**
  57370. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  57371. * @param deltaTime in seconds
  57372. */
  57373. update(deltaTime: number): void;
  57374. /**
  57375. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  57376. * @param index agent index returned by addAgent
  57377. * @param destination targeted world position
  57378. */
  57379. agentGoto(index: number, destination: Vector3): void;
  57380. /**
  57381. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  57382. * The queries will try to find a solution within those bounds
  57383. * default is (1,1,1)
  57384. * @param extent x,y,z value that define the extent around the queries point of reference
  57385. */
  57386. setDefaultQueryExtent(extent: Vector3): void;
  57387. /**
  57388. * Get the Bounding box extent specified by setDefaultQueryExtent
  57389. * @returns the box extent values
  57390. */
  57391. getDefaultQueryExtent(): Vector3;
  57392. /**
  57393. * Release all resources
  57394. */
  57395. dispose(): void;
  57396. }
  57397. /**
  57398. * Configures an agent
  57399. */
  57400. export interface IAgentParameters {
  57401. /**
  57402. * Agent radius. [Limit: >= 0]
  57403. */
  57404. radius: number;
  57405. /**
  57406. * Agent height. [Limit: > 0]
  57407. */
  57408. height: number;
  57409. /**
  57410. * Maximum allowed acceleration. [Limit: >= 0]
  57411. */
  57412. maxAcceleration: number;
  57413. /**
  57414. * Maximum allowed speed. [Limit: >= 0]
  57415. */
  57416. maxSpeed: number;
  57417. /**
  57418. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  57419. */
  57420. collisionQueryRange: number;
  57421. /**
  57422. * The path visibility optimization range. [Limit: > 0]
  57423. */
  57424. pathOptimizationRange: number;
  57425. /**
  57426. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  57427. */
  57428. separationWeight: number;
  57429. }
  57430. /**
  57431. * Configures the navigation mesh creation
  57432. */
  57433. export interface INavMeshParameters {
  57434. /**
  57435. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  57436. */
  57437. cs: number;
  57438. /**
  57439. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  57440. */
  57441. ch: number;
  57442. /**
  57443. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  57444. */
  57445. walkableSlopeAngle: number;
  57446. /**
  57447. * Minimum floor to 'ceiling' height that will still allow the floor area to
  57448. * be considered walkable. [Limit: >= 3] [Units: vx]
  57449. */
  57450. walkableHeight: number;
  57451. /**
  57452. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  57453. */
  57454. walkableClimb: number;
  57455. /**
  57456. * The distance to erode/shrink the walkable area of the heightfield away from
  57457. * obstructions. [Limit: >=0] [Units: vx]
  57458. */
  57459. walkableRadius: number;
  57460. /**
  57461. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  57462. */
  57463. maxEdgeLen: number;
  57464. /**
  57465. * The maximum distance a simplfied contour's border edges should deviate
  57466. * the original raw contour. [Limit: >=0] [Units: vx]
  57467. */
  57468. maxSimplificationError: number;
  57469. /**
  57470. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  57471. */
  57472. minRegionArea: number;
  57473. /**
  57474. * Any regions with a span count smaller than this value will, if possible,
  57475. * be merged with larger regions. [Limit: >=0] [Units: vx]
  57476. */
  57477. mergeRegionArea: number;
  57478. /**
  57479. * The maximum number of vertices allowed for polygons generated during the
  57480. * contour to polygon conversion process. [Limit: >= 3]
  57481. */
  57482. maxVertsPerPoly: number;
  57483. /**
  57484. * Sets the sampling distance to use when generating the detail mesh.
  57485. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  57486. */
  57487. detailSampleDist: number;
  57488. /**
  57489. * The maximum distance the detail mesh surface should deviate from heightfield
  57490. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  57491. */
  57492. detailSampleMaxError: number;
  57493. }
  57494. }
  57495. declare module BABYLON {
  57496. /**
  57497. * RecastJS navigation plugin
  57498. */
  57499. export class RecastJSPlugin implements INavigationEnginePlugin {
  57500. /**
  57501. * Reference to the Recast library
  57502. */
  57503. bjsRECAST: any;
  57504. /**
  57505. * plugin name
  57506. */
  57507. name: string;
  57508. /**
  57509. * the first navmesh created. We might extend this to support multiple navmeshes
  57510. */
  57511. navMesh: any;
  57512. /**
  57513. * Initializes the recastJS plugin
  57514. * @param recastInjection can be used to inject your own recast reference
  57515. */
  57516. constructor(recastInjection?: any);
  57517. /**
  57518. * Creates a navigation mesh
  57519. * @param meshes array of all the geometry used to compute the navigatio mesh
  57520. * @param parameters bunch of parameters used to filter geometry
  57521. */
  57522. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  57523. /**
  57524. * Create a navigation mesh debug mesh
  57525. * @param scene is where the mesh will be added
  57526. * @returns debug display mesh
  57527. */
  57528. createDebugNavMesh(scene: Scene): Mesh;
  57529. /**
  57530. * Get a navigation mesh constrained position, closest to the parameter position
  57531. * @param position world position
  57532. * @returns the closest point to position constrained by the navigation mesh
  57533. */
  57534. getClosestPoint(position: Vector3): Vector3;
  57535. /**
  57536. * Get a navigation mesh constrained position, within a particular radius
  57537. * @param position world position
  57538. * @param maxRadius the maximum distance to the constrained world position
  57539. * @returns the closest point to position constrained by the navigation mesh
  57540. */
  57541. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  57542. /**
  57543. * Compute the final position from a segment made of destination-position
  57544. * @param position world position
  57545. * @param destination world position
  57546. * @returns the resulting point along the navmesh
  57547. */
  57548. moveAlong(position: Vector3, destination: Vector3): Vector3;
  57549. /**
  57550. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  57551. * @param start world position
  57552. * @param end world position
  57553. * @returns array containing world position composing the path
  57554. */
  57555. computePath(start: Vector3, end: Vector3): Vector3[];
  57556. /**
  57557. * Create a new Crowd so you can add agents
  57558. * @param maxAgents the maximum agent count in the crowd
  57559. * @param maxAgentRadius the maximum radius an agent can have
  57560. * @param scene to attach the crowd to
  57561. * @returns the crowd you can add agents to
  57562. */
  57563. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  57564. /**
  57565. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  57566. * The queries will try to find a solution within those bounds
  57567. * default is (1,1,1)
  57568. * @param extent x,y,z value that define the extent around the queries point of reference
  57569. */
  57570. setDefaultQueryExtent(extent: Vector3): void;
  57571. /**
  57572. * Get the Bounding box extent specified by setDefaultQueryExtent
  57573. * @returns the box extent values
  57574. */
  57575. getDefaultQueryExtent(): Vector3;
  57576. /**
  57577. * Disposes
  57578. */
  57579. dispose(): void;
  57580. /**
  57581. * If this plugin is supported
  57582. * @returns true if plugin is supported
  57583. */
  57584. isSupported(): boolean;
  57585. }
  57586. /**
  57587. * Recast detour crowd implementation
  57588. */
  57589. export class RecastJSCrowd implements ICrowd {
  57590. /**
  57591. * Recast/detour plugin
  57592. */
  57593. bjsRECASTPlugin: RecastJSPlugin;
  57594. /**
  57595. * Link to the detour crowd
  57596. */
  57597. recastCrowd: any;
  57598. /**
  57599. * One transform per agent
  57600. */
  57601. transforms: TransformNode[];
  57602. /**
  57603. * All agents created
  57604. */
  57605. agents: number[];
  57606. /**
  57607. * Link to the scene is kept to unregister the crowd from the scene
  57608. */
  57609. private _scene;
  57610. /**
  57611. * Observer for crowd updates
  57612. */
  57613. private _onBeforeAnimationsObserver;
  57614. /**
  57615. * Constructor
  57616. * @param plugin recastJS plugin
  57617. * @param maxAgents the maximum agent count in the crowd
  57618. * @param maxAgentRadius the maximum radius an agent can have
  57619. * @param scene to attach the crowd to
  57620. * @returns the crowd you can add agents to
  57621. */
  57622. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  57623. /**
  57624. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  57625. * You can attach anything to that node. The node position is updated in the scene update tick.
  57626. * @param pos world position that will be constrained by the navigation mesh
  57627. * @param parameters agent parameters
  57628. * @param transform hooked to the agent that will be update by the scene
  57629. * @returns agent index
  57630. */
  57631. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  57632. /**
  57633. * Returns the agent position in world space
  57634. * @param index agent index returned by addAgent
  57635. * @returns world space position
  57636. */
  57637. getAgentPosition(index: number): Vector3;
  57638. /**
  57639. * Returns the agent velocity in world space
  57640. * @param index agent index returned by addAgent
  57641. * @returns world space velocity
  57642. */
  57643. getAgentVelocity(index: number): Vector3;
  57644. /**
  57645. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  57646. * @param index agent index returned by addAgent
  57647. * @param destination targeted world position
  57648. */
  57649. agentGoto(index: number, destination: Vector3): void;
  57650. /**
  57651. * remove a particular agent previously created
  57652. * @param index agent index returned by addAgent
  57653. */
  57654. removeAgent(index: number): void;
  57655. /**
  57656. * get the list of all agents attached to this crowd
  57657. * @returns list of agent indices
  57658. */
  57659. getAgents(): number[];
  57660. /**
  57661. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  57662. * @param deltaTime in seconds
  57663. */
  57664. update(deltaTime: number): void;
  57665. /**
  57666. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  57667. * The queries will try to find a solution within those bounds
  57668. * default is (1,1,1)
  57669. * @param extent x,y,z value that define the extent around the queries point of reference
  57670. */
  57671. setDefaultQueryExtent(extent: Vector3): void;
  57672. /**
  57673. * Get the Bounding box extent specified by setDefaultQueryExtent
  57674. * @returns the box extent values
  57675. */
  57676. getDefaultQueryExtent(): Vector3;
  57677. /**
  57678. * Release all resources
  57679. */
  57680. dispose(): void;
  57681. }
  57682. }
  57683. declare module BABYLON {
  57684. /**
  57685. * Class used to enable access to IndexedDB
  57686. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  57687. */
  57688. export class Database implements IOfflineProvider {
  57689. private _callbackManifestChecked;
  57690. private _currentSceneUrl;
  57691. private _db;
  57692. private _enableSceneOffline;
  57693. private _enableTexturesOffline;
  57694. private _manifestVersionFound;
  57695. private _mustUpdateRessources;
  57696. private _hasReachedQuota;
  57697. private _isSupported;
  57698. private _idbFactory;
  57699. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  57700. private static IsUASupportingBlobStorage;
  57701. /**
  57702. * Gets a boolean indicating if Database storate is enabled (off by default)
  57703. */
  57704. static IDBStorageEnabled: boolean;
  57705. /**
  57706. * Gets a boolean indicating if scene must be saved in the database
  57707. */
  57708. readonly enableSceneOffline: boolean;
  57709. /**
  57710. * Gets a boolean indicating if textures must be saved in the database
  57711. */
  57712. readonly enableTexturesOffline: boolean;
  57713. /**
  57714. * Creates a new Database
  57715. * @param urlToScene defines the url to load the scene
  57716. * @param callbackManifestChecked defines the callback to use when manifest is checked
  57717. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  57718. */
  57719. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  57720. private static _ParseURL;
  57721. private static _ReturnFullUrlLocation;
  57722. private _checkManifestFile;
  57723. /**
  57724. * Open the database and make it available
  57725. * @param successCallback defines the callback to call on success
  57726. * @param errorCallback defines the callback to call on error
  57727. */
  57728. open(successCallback: () => void, errorCallback: () => void): void;
  57729. /**
  57730. * Loads an image from the database
  57731. * @param url defines the url to load from
  57732. * @param image defines the target DOM image
  57733. */
  57734. loadImage(url: string, image: HTMLImageElement): void;
  57735. private _loadImageFromDBAsync;
  57736. private _saveImageIntoDBAsync;
  57737. private _checkVersionFromDB;
  57738. private _loadVersionFromDBAsync;
  57739. private _saveVersionIntoDBAsync;
  57740. /**
  57741. * Loads a file from database
  57742. * @param url defines the URL to load from
  57743. * @param sceneLoaded defines a callback to call on success
  57744. * @param progressCallBack defines a callback to call when progress changed
  57745. * @param errorCallback defines a callback to call on error
  57746. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  57747. */
  57748. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  57749. private _loadFileAsync;
  57750. private _saveFileAsync;
  57751. /**
  57752. * Validates if xhr data is correct
  57753. * @param xhr defines the request to validate
  57754. * @param dataType defines the expected data type
  57755. * @returns true if data is correct
  57756. */
  57757. private static _ValidateXHRData;
  57758. }
  57759. }
  57760. declare module BABYLON {
  57761. /** @hidden */
  57762. export var gpuUpdateParticlesPixelShader: {
  57763. name: string;
  57764. shader: string;
  57765. };
  57766. }
  57767. declare module BABYLON {
  57768. /** @hidden */
  57769. export var gpuUpdateParticlesVertexShader: {
  57770. name: string;
  57771. shader: string;
  57772. };
  57773. }
  57774. declare module BABYLON {
  57775. /** @hidden */
  57776. export var clipPlaneFragmentDeclaration2: {
  57777. name: string;
  57778. shader: string;
  57779. };
  57780. }
  57781. declare module BABYLON {
  57782. /** @hidden */
  57783. export var gpuRenderParticlesPixelShader: {
  57784. name: string;
  57785. shader: string;
  57786. };
  57787. }
  57788. declare module BABYLON {
  57789. /** @hidden */
  57790. export var clipPlaneVertexDeclaration2: {
  57791. name: string;
  57792. shader: string;
  57793. };
  57794. }
  57795. declare module BABYLON {
  57796. /** @hidden */
  57797. export var gpuRenderParticlesVertexShader: {
  57798. name: string;
  57799. shader: string;
  57800. };
  57801. }
  57802. declare module BABYLON {
  57803. /**
  57804. * This represents a GPU particle system in Babylon
  57805. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  57806. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  57807. */
  57808. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  57809. /**
  57810. * The layer mask we are rendering the particles through.
  57811. */
  57812. layerMask: number;
  57813. private _capacity;
  57814. private _activeCount;
  57815. private _currentActiveCount;
  57816. private _accumulatedCount;
  57817. private _renderEffect;
  57818. private _updateEffect;
  57819. private _buffer0;
  57820. private _buffer1;
  57821. private _spriteBuffer;
  57822. private _updateVAO;
  57823. private _renderVAO;
  57824. private _targetIndex;
  57825. private _sourceBuffer;
  57826. private _targetBuffer;
  57827. private _engine;
  57828. private _currentRenderId;
  57829. private _started;
  57830. private _stopped;
  57831. private _timeDelta;
  57832. private _randomTexture;
  57833. private _randomTexture2;
  57834. private _attributesStrideSize;
  57835. private _updateEffectOptions;
  57836. private _randomTextureSize;
  57837. private _actualFrame;
  57838. private readonly _rawTextureWidth;
  57839. /**
  57840. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  57841. */
  57842. static readonly IsSupported: boolean;
  57843. /**
  57844. * An event triggered when the system is disposed.
  57845. */
  57846. onDisposeObservable: Observable<GPUParticleSystem>;
  57847. /**
  57848. * Gets the maximum number of particles active at the same time.
  57849. * @returns The max number of active particles.
  57850. */
  57851. getCapacity(): number;
  57852. /**
  57853. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  57854. * to override the particles.
  57855. */
  57856. forceDepthWrite: boolean;
  57857. /**
  57858. * Gets or set the number of active particles
  57859. */
  57860. activeParticleCount: number;
  57861. private _preWarmDone;
  57862. /**
  57863. * Is this system ready to be used/rendered
  57864. * @return true if the system is ready
  57865. */
  57866. isReady(): boolean;
  57867. /**
  57868. * Gets if the system has been started. (Note: this will still be true after stop is called)
  57869. * @returns True if it has been started, otherwise false.
  57870. */
  57871. isStarted(): boolean;
  57872. /**
  57873. * Starts the particle system and begins to emit
  57874. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  57875. */
  57876. start(delay?: number): void;
  57877. /**
  57878. * Stops the particle system.
  57879. */
  57880. stop(): void;
  57881. /**
  57882. * Remove all active particles
  57883. */
  57884. reset(): void;
  57885. /**
  57886. * Returns the string "GPUParticleSystem"
  57887. * @returns a string containing the class name
  57888. */
  57889. getClassName(): string;
  57890. private _colorGradientsTexture;
  57891. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  57892. /**
  57893. * Adds a new color gradient
  57894. * @param gradient defines the gradient to use (between 0 and 1)
  57895. * @param color1 defines the color to affect to the specified gradient
  57896. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  57897. * @returns the current particle system
  57898. */
  57899. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  57900. /**
  57901. * Remove a specific color gradient
  57902. * @param gradient defines the gradient to remove
  57903. * @returns the current particle system
  57904. */
  57905. removeColorGradient(gradient: number): GPUParticleSystem;
  57906. private _angularSpeedGradientsTexture;
  57907. private _sizeGradientsTexture;
  57908. private _velocityGradientsTexture;
  57909. private _limitVelocityGradientsTexture;
  57910. private _dragGradientsTexture;
  57911. private _addFactorGradient;
  57912. /**
  57913. * Adds a new size gradient
  57914. * @param gradient defines the gradient to use (between 0 and 1)
  57915. * @param factor defines the size factor to affect to the specified gradient
  57916. * @returns the current particle system
  57917. */
  57918. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  57919. /**
  57920. * Remove a specific size gradient
  57921. * @param gradient defines the gradient to remove
  57922. * @returns the current particle system
  57923. */
  57924. removeSizeGradient(gradient: number): GPUParticleSystem;
  57925. /**
  57926. * Adds a new angular speed gradient
  57927. * @param gradient defines the gradient to use (between 0 and 1)
  57928. * @param factor defines the angular speed to affect to the specified gradient
  57929. * @returns the current particle system
  57930. */
  57931. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  57932. /**
  57933. * Remove a specific angular speed gradient
  57934. * @param gradient defines the gradient to remove
  57935. * @returns the current particle system
  57936. */
  57937. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  57938. /**
  57939. * Adds a new velocity gradient
  57940. * @param gradient defines the gradient to use (between 0 and 1)
  57941. * @param factor defines the velocity to affect to the specified gradient
  57942. * @returns the current particle system
  57943. */
  57944. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  57945. /**
  57946. * Remove a specific velocity gradient
  57947. * @param gradient defines the gradient to remove
  57948. * @returns the current particle system
  57949. */
  57950. removeVelocityGradient(gradient: number): GPUParticleSystem;
  57951. /**
  57952. * Adds a new limit velocity gradient
  57953. * @param gradient defines the gradient to use (between 0 and 1)
  57954. * @param factor defines the limit velocity value to affect to the specified gradient
  57955. * @returns the current particle system
  57956. */
  57957. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  57958. /**
  57959. * Remove a specific limit velocity gradient
  57960. * @param gradient defines the gradient to remove
  57961. * @returns the current particle system
  57962. */
  57963. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  57964. /**
  57965. * Adds a new drag gradient
  57966. * @param gradient defines the gradient to use (between 0 and 1)
  57967. * @param factor defines the drag value to affect to the specified gradient
  57968. * @returns the current particle system
  57969. */
  57970. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  57971. /**
  57972. * Remove a specific drag gradient
  57973. * @param gradient defines the gradient to remove
  57974. * @returns the current particle system
  57975. */
  57976. removeDragGradient(gradient: number): GPUParticleSystem;
  57977. /**
  57978. * Not supported by GPUParticleSystem
  57979. * @param gradient defines the gradient to use (between 0 and 1)
  57980. * @param factor defines the emit rate value to affect to the specified gradient
  57981. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  57982. * @returns the current particle system
  57983. */
  57984. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  57985. /**
  57986. * Not supported by GPUParticleSystem
  57987. * @param gradient defines the gradient to remove
  57988. * @returns the current particle system
  57989. */
  57990. removeEmitRateGradient(gradient: number): IParticleSystem;
  57991. /**
  57992. * Not supported by GPUParticleSystem
  57993. * @param gradient defines the gradient to use (between 0 and 1)
  57994. * @param factor defines the start size value to affect to the specified gradient
  57995. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  57996. * @returns the current particle system
  57997. */
  57998. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  57999. /**
  58000. * Not supported by GPUParticleSystem
  58001. * @param gradient defines the gradient to remove
  58002. * @returns the current particle system
  58003. */
  58004. removeStartSizeGradient(gradient: number): IParticleSystem;
  58005. /**
  58006. * Not supported by GPUParticleSystem
  58007. * @param gradient defines the gradient to use (between 0 and 1)
  58008. * @param min defines the color remap minimal range
  58009. * @param max defines the color remap maximal range
  58010. * @returns the current particle system
  58011. */
  58012. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  58013. /**
  58014. * Not supported by GPUParticleSystem
  58015. * @param gradient defines the gradient to remove
  58016. * @returns the current particle system
  58017. */
  58018. removeColorRemapGradient(): IParticleSystem;
  58019. /**
  58020. * Not supported by GPUParticleSystem
  58021. * @param gradient defines the gradient to use (between 0 and 1)
  58022. * @param min defines the alpha remap minimal range
  58023. * @param max defines the alpha remap maximal range
  58024. * @returns the current particle system
  58025. */
  58026. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  58027. /**
  58028. * Not supported by GPUParticleSystem
  58029. * @param gradient defines the gradient to remove
  58030. * @returns the current particle system
  58031. */
  58032. removeAlphaRemapGradient(): IParticleSystem;
  58033. /**
  58034. * Not supported by GPUParticleSystem
  58035. * @param gradient defines the gradient to use (between 0 and 1)
  58036. * @param color defines the color to affect to the specified gradient
  58037. * @returns the current particle system
  58038. */
  58039. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  58040. /**
  58041. * Not supported by GPUParticleSystem
  58042. * @param gradient defines the gradient to remove
  58043. * @returns the current particle system
  58044. */
  58045. removeRampGradient(): IParticleSystem;
  58046. /**
  58047. * Not supported by GPUParticleSystem
  58048. * @returns the list of ramp gradients
  58049. */
  58050. getRampGradients(): Nullable<Array<Color3Gradient>>;
  58051. /**
  58052. * Not supported by GPUParticleSystem
  58053. * Gets or sets a boolean indicating that ramp gradients must be used
  58054. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  58055. */
  58056. useRampGradients: boolean;
  58057. /**
  58058. * Not supported by GPUParticleSystem
  58059. * @param gradient defines the gradient to use (between 0 and 1)
  58060. * @param factor defines the life time factor to affect to the specified gradient
  58061. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  58062. * @returns the current particle system
  58063. */
  58064. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  58065. /**
  58066. * Not supported by GPUParticleSystem
  58067. * @param gradient defines the gradient to remove
  58068. * @returns the current particle system
  58069. */
  58070. removeLifeTimeGradient(gradient: number): IParticleSystem;
  58071. /**
  58072. * Instantiates a GPU particle system.
  58073. * 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.
  58074. * @param name The name of the particle system
  58075. * @param options The options used to create the system
  58076. * @param scene The scene the particle system belongs to
  58077. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  58078. */
  58079. constructor(name: string, options: Partial<{
  58080. capacity: number;
  58081. randomTextureSize: number;
  58082. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  58083. protected _reset(): void;
  58084. private _createUpdateVAO;
  58085. private _createRenderVAO;
  58086. private _initialize;
  58087. /** @hidden */
  58088. _recreateUpdateEffect(): void;
  58089. /** @hidden */
  58090. _recreateRenderEffect(): void;
  58091. /**
  58092. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  58093. * @param preWarm defines if we are in the pre-warmimg phase
  58094. */
  58095. animate(preWarm?: boolean): void;
  58096. private _createFactorGradientTexture;
  58097. private _createSizeGradientTexture;
  58098. private _createAngularSpeedGradientTexture;
  58099. private _createVelocityGradientTexture;
  58100. private _createLimitVelocityGradientTexture;
  58101. private _createDragGradientTexture;
  58102. private _createColorGradientTexture;
  58103. /**
  58104. * Renders the particle system in its current state
  58105. * @param preWarm defines if the system should only update the particles but not render them
  58106. * @returns the current number of particles
  58107. */
  58108. render(preWarm?: boolean): number;
  58109. /**
  58110. * Rebuilds the particle system
  58111. */
  58112. rebuild(): void;
  58113. private _releaseBuffers;
  58114. private _releaseVAOs;
  58115. /**
  58116. * Disposes the particle system and free the associated resources
  58117. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  58118. */
  58119. dispose(disposeTexture?: boolean): void;
  58120. /**
  58121. * Clones the particle system.
  58122. * @param name The name of the cloned object
  58123. * @param newEmitter The new emitter to use
  58124. * @returns the cloned particle system
  58125. */
  58126. clone(name: string, newEmitter: any): GPUParticleSystem;
  58127. /**
  58128. * Serializes the particle system to a JSON object.
  58129. * @returns the JSON object
  58130. */
  58131. serialize(): any;
  58132. /**
  58133. * Parses a JSON object to create a GPU particle system.
  58134. * @param parsedParticleSystem The JSON object to parse
  58135. * @param scene The scene to create the particle system in
  58136. * @param rootUrl The root url to use to load external dependencies like texture
  58137. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  58138. * @returns the parsed GPU particle system
  58139. */
  58140. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  58141. }
  58142. }
  58143. declare module BABYLON {
  58144. /**
  58145. * Represents a set of particle systems working together to create a specific effect
  58146. */
  58147. export class ParticleSystemSet implements IDisposable {
  58148. private _emitterCreationOptions;
  58149. private _emitterNode;
  58150. /**
  58151. * Gets the particle system list
  58152. */
  58153. systems: IParticleSystem[];
  58154. /**
  58155. * Gets the emitter node used with this set
  58156. */
  58157. readonly emitterNode: Nullable<TransformNode>;
  58158. /**
  58159. * Creates a new emitter mesh as a sphere
  58160. * @param options defines the options used to create the sphere
  58161. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  58162. * @param scene defines the hosting scene
  58163. */
  58164. setEmitterAsSphere(options: {
  58165. diameter: number;
  58166. segments: number;
  58167. color: Color3;
  58168. }, renderingGroupId: number, scene: Scene): void;
  58169. /**
  58170. * Starts all particle systems of the set
  58171. * @param emitter defines an optional mesh to use as emitter for the particle systems
  58172. */
  58173. start(emitter?: AbstractMesh): void;
  58174. /**
  58175. * Release all associated resources
  58176. */
  58177. dispose(): void;
  58178. /**
  58179. * Serialize the set into a JSON compatible object
  58180. * @returns a JSON compatible representation of the set
  58181. */
  58182. serialize(): any;
  58183. /**
  58184. * Parse a new ParticleSystemSet from a serialized source
  58185. * @param data defines a JSON compatible representation of the set
  58186. * @param scene defines the hosting scene
  58187. * @param gpu defines if we want GPU particles or CPU particles
  58188. * @returns a new ParticleSystemSet
  58189. */
  58190. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  58191. }
  58192. }
  58193. declare module BABYLON {
  58194. /**
  58195. * This class is made for on one-liner static method to help creating particle system set.
  58196. */
  58197. export class ParticleHelper {
  58198. /**
  58199. * Gets or sets base Assets URL
  58200. */
  58201. static BaseAssetsUrl: string;
  58202. /**
  58203. * Create a default particle system that you can tweak
  58204. * @param emitter defines the emitter to use
  58205. * @param capacity defines the system capacity (default is 500 particles)
  58206. * @param scene defines the hosting scene
  58207. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  58208. * @returns the new Particle system
  58209. */
  58210. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  58211. /**
  58212. * This is the main static method (one-liner) of this helper to create different particle systems
  58213. * @param type This string represents the type to the particle system to create
  58214. * @param scene The scene where the particle system should live
  58215. * @param gpu If the system will use gpu
  58216. * @returns the ParticleSystemSet created
  58217. */
  58218. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  58219. /**
  58220. * Static function used to export a particle system to a ParticleSystemSet variable.
  58221. * Please note that the emitter shape is not exported
  58222. * @param systems defines the particle systems to export
  58223. * @returns the created particle system set
  58224. */
  58225. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  58226. }
  58227. }
  58228. declare module BABYLON {
  58229. interface Engine {
  58230. /**
  58231. * Create an effect to use with particle systems.
  58232. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  58233. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  58234. * @param uniformsNames defines a list of attribute names
  58235. * @param samplers defines an array of string used to represent textures
  58236. * @param defines defines the string containing the defines to use to compile the shaders
  58237. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  58238. * @param onCompiled defines a function to call when the effect creation is successful
  58239. * @param onError defines a function to call when the effect creation has failed
  58240. * @returns the new Effect
  58241. */
  58242. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  58243. }
  58244. interface Mesh {
  58245. /**
  58246. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  58247. * @returns an array of IParticleSystem
  58248. */
  58249. getEmittedParticleSystems(): IParticleSystem[];
  58250. /**
  58251. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  58252. * @returns an array of IParticleSystem
  58253. */
  58254. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  58255. }
  58256. /**
  58257. * @hidden
  58258. */
  58259. export var _IDoNeedToBeInTheBuild: number;
  58260. }
  58261. declare module BABYLON {
  58262. interface Scene {
  58263. /** @hidden (Backing field) */
  58264. _physicsEngine: Nullable<IPhysicsEngine>;
  58265. /**
  58266. * Gets the current physics engine
  58267. * @returns a IPhysicsEngine or null if none attached
  58268. */
  58269. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  58270. /**
  58271. * Enables physics to the current scene
  58272. * @param gravity defines the scene's gravity for the physics engine
  58273. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  58274. * @return a boolean indicating if the physics engine was initialized
  58275. */
  58276. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  58277. /**
  58278. * Disables and disposes the physics engine associated with the scene
  58279. */
  58280. disablePhysicsEngine(): void;
  58281. /**
  58282. * Gets a boolean indicating if there is an active physics engine
  58283. * @returns a boolean indicating if there is an active physics engine
  58284. */
  58285. isPhysicsEnabled(): boolean;
  58286. /**
  58287. * Deletes a physics compound impostor
  58288. * @param compound defines the compound to delete
  58289. */
  58290. deleteCompoundImpostor(compound: any): void;
  58291. /**
  58292. * An event triggered when physic simulation is about to be run
  58293. */
  58294. onBeforePhysicsObservable: Observable<Scene>;
  58295. /**
  58296. * An event triggered when physic simulation has been done
  58297. */
  58298. onAfterPhysicsObservable: Observable<Scene>;
  58299. }
  58300. interface AbstractMesh {
  58301. /** @hidden */
  58302. _physicsImpostor: Nullable<PhysicsImpostor>;
  58303. /**
  58304. * Gets or sets impostor used for physic simulation
  58305. * @see http://doc.babylonjs.com/features/physics_engine
  58306. */
  58307. physicsImpostor: Nullable<PhysicsImpostor>;
  58308. /**
  58309. * Gets the current physics impostor
  58310. * @see http://doc.babylonjs.com/features/physics_engine
  58311. * @returns a physics impostor or null
  58312. */
  58313. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  58314. /** Apply a physic impulse to the mesh
  58315. * @param force defines the force to apply
  58316. * @param contactPoint defines where to apply the force
  58317. * @returns the current mesh
  58318. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  58319. */
  58320. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  58321. /**
  58322. * Creates a physic joint between two meshes
  58323. * @param otherMesh defines the other mesh to use
  58324. * @param pivot1 defines the pivot to use on this mesh
  58325. * @param pivot2 defines the pivot to use on the other mesh
  58326. * @param options defines additional options (can be plugin dependent)
  58327. * @returns the current mesh
  58328. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  58329. */
  58330. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  58331. /** @hidden */
  58332. _disposePhysicsObserver: Nullable<Observer<Node>>;
  58333. }
  58334. /**
  58335. * Defines the physics engine scene component responsible to manage a physics engine
  58336. */
  58337. export class PhysicsEngineSceneComponent implements ISceneComponent {
  58338. /**
  58339. * The component name helpful to identify the component in the list of scene components.
  58340. */
  58341. readonly name: string;
  58342. /**
  58343. * The scene the component belongs to.
  58344. */
  58345. scene: Scene;
  58346. /**
  58347. * Creates a new instance of the component for the given scene
  58348. * @param scene Defines the scene to register the component in
  58349. */
  58350. constructor(scene: Scene);
  58351. /**
  58352. * Registers the component in a given scene
  58353. */
  58354. register(): void;
  58355. /**
  58356. * Rebuilds the elements related to this component in case of
  58357. * context lost for instance.
  58358. */
  58359. rebuild(): void;
  58360. /**
  58361. * Disposes the component and the associated ressources
  58362. */
  58363. dispose(): void;
  58364. }
  58365. }
  58366. declare module BABYLON {
  58367. /**
  58368. * A helper for physics simulations
  58369. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  58370. */
  58371. export class PhysicsHelper {
  58372. private _scene;
  58373. private _physicsEngine;
  58374. /**
  58375. * Initializes the Physics helper
  58376. * @param scene Babylon.js scene
  58377. */
  58378. constructor(scene: Scene);
  58379. /**
  58380. * Applies a radial explosion impulse
  58381. * @param origin the origin of the explosion
  58382. * @param radiusOrEventOptions the radius or the options of radial explosion
  58383. * @param strength the explosion strength
  58384. * @param falloff possible options: Constant & Linear. Defaults to Constant
  58385. * @returns A physics radial explosion event, or null
  58386. */
  58387. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  58388. /**
  58389. * Applies a radial explosion force
  58390. * @param origin the origin of the explosion
  58391. * @param radiusOrEventOptions the radius or the options of radial explosion
  58392. * @param strength the explosion strength
  58393. * @param falloff possible options: Constant & Linear. Defaults to Constant
  58394. * @returns A physics radial explosion event, or null
  58395. */
  58396. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  58397. /**
  58398. * Creates a gravitational field
  58399. * @param origin the origin of the explosion
  58400. * @param radiusOrEventOptions the radius or the options of radial explosion
  58401. * @param strength the explosion strength
  58402. * @param falloff possible options: Constant & Linear. Defaults to Constant
  58403. * @returns A physics gravitational field event, or null
  58404. */
  58405. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  58406. /**
  58407. * Creates a physics updraft event
  58408. * @param origin the origin of the updraft
  58409. * @param radiusOrEventOptions the radius or the options of the updraft
  58410. * @param strength the strength of the updraft
  58411. * @param height the height of the updraft
  58412. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  58413. * @returns A physics updraft event, or null
  58414. */
  58415. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  58416. /**
  58417. * Creates a physics vortex event
  58418. * @param origin the of the vortex
  58419. * @param radiusOrEventOptions the radius or the options of the vortex
  58420. * @param strength the strength of the vortex
  58421. * @param height the height of the vortex
  58422. * @returns a Physics vortex event, or null
  58423. * A physics vortex event or null
  58424. */
  58425. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  58426. }
  58427. /**
  58428. * Represents a physics radial explosion event
  58429. */
  58430. class PhysicsRadialExplosionEvent {
  58431. private _scene;
  58432. private _options;
  58433. private _sphere;
  58434. private _dataFetched;
  58435. /**
  58436. * Initializes a radial explosioin event
  58437. * @param _scene BabylonJS scene
  58438. * @param _options The options for the vortex event
  58439. */
  58440. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  58441. /**
  58442. * Returns the data related to the radial explosion event (sphere).
  58443. * @returns The radial explosion event data
  58444. */
  58445. getData(): PhysicsRadialExplosionEventData;
  58446. /**
  58447. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  58448. * @param impostor A physics imposter
  58449. * @param origin the origin of the explosion
  58450. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  58451. */
  58452. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  58453. /**
  58454. * Triggers affecterd impostors callbacks
  58455. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  58456. */
  58457. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  58458. /**
  58459. * Disposes the sphere.
  58460. * @param force Specifies if the sphere should be disposed by force
  58461. */
  58462. dispose(force?: boolean): void;
  58463. /*** Helpers ***/
  58464. private _prepareSphere;
  58465. private _intersectsWithSphere;
  58466. }
  58467. /**
  58468. * Represents a gravitational field event
  58469. */
  58470. class PhysicsGravitationalFieldEvent {
  58471. private _physicsHelper;
  58472. private _scene;
  58473. private _origin;
  58474. private _options;
  58475. private _tickCallback;
  58476. private _sphere;
  58477. private _dataFetched;
  58478. /**
  58479. * Initializes the physics gravitational field event
  58480. * @param _physicsHelper A physics helper
  58481. * @param _scene BabylonJS scene
  58482. * @param _origin The origin position of the gravitational field event
  58483. * @param _options The options for the vortex event
  58484. */
  58485. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  58486. /**
  58487. * Returns the data related to the gravitational field event (sphere).
  58488. * @returns A gravitational field event
  58489. */
  58490. getData(): PhysicsGravitationalFieldEventData;
  58491. /**
  58492. * Enables the gravitational field.
  58493. */
  58494. enable(): void;
  58495. /**
  58496. * Disables the gravitational field.
  58497. */
  58498. disable(): void;
  58499. /**
  58500. * Disposes the sphere.
  58501. * @param force The force to dispose from the gravitational field event
  58502. */
  58503. dispose(force?: boolean): void;
  58504. private _tick;
  58505. }
  58506. /**
  58507. * Represents a physics updraft event
  58508. */
  58509. class PhysicsUpdraftEvent {
  58510. private _scene;
  58511. private _origin;
  58512. private _options;
  58513. private _physicsEngine;
  58514. private _originTop;
  58515. private _originDirection;
  58516. private _tickCallback;
  58517. private _cylinder;
  58518. private _cylinderPosition;
  58519. private _dataFetched;
  58520. /**
  58521. * Initializes the physics updraft event
  58522. * @param _scene BabylonJS scene
  58523. * @param _origin The origin position of the updraft
  58524. * @param _options The options for the updraft event
  58525. */
  58526. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  58527. /**
  58528. * Returns the data related to the updraft event (cylinder).
  58529. * @returns A physics updraft event
  58530. */
  58531. getData(): PhysicsUpdraftEventData;
  58532. /**
  58533. * Enables the updraft.
  58534. */
  58535. enable(): void;
  58536. /**
  58537. * Disables the updraft.
  58538. */
  58539. disable(): void;
  58540. /**
  58541. * Disposes the cylinder.
  58542. * @param force Specifies if the updraft should be disposed by force
  58543. */
  58544. dispose(force?: boolean): void;
  58545. private getImpostorHitData;
  58546. private _tick;
  58547. /*** Helpers ***/
  58548. private _prepareCylinder;
  58549. private _intersectsWithCylinder;
  58550. }
  58551. /**
  58552. * Represents a physics vortex event
  58553. */
  58554. class PhysicsVortexEvent {
  58555. private _scene;
  58556. private _origin;
  58557. private _options;
  58558. private _physicsEngine;
  58559. private _originTop;
  58560. private _tickCallback;
  58561. private _cylinder;
  58562. private _cylinderPosition;
  58563. private _dataFetched;
  58564. /**
  58565. * Initializes the physics vortex event
  58566. * @param _scene The BabylonJS scene
  58567. * @param _origin The origin position of the vortex
  58568. * @param _options The options for the vortex event
  58569. */
  58570. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  58571. /**
  58572. * Returns the data related to the vortex event (cylinder).
  58573. * @returns The physics vortex event data
  58574. */
  58575. getData(): PhysicsVortexEventData;
  58576. /**
  58577. * Enables the vortex.
  58578. */
  58579. enable(): void;
  58580. /**
  58581. * Disables the cortex.
  58582. */
  58583. disable(): void;
  58584. /**
  58585. * Disposes the sphere.
  58586. * @param force
  58587. */
  58588. dispose(force?: boolean): void;
  58589. private getImpostorHitData;
  58590. private _tick;
  58591. /*** Helpers ***/
  58592. private _prepareCylinder;
  58593. private _intersectsWithCylinder;
  58594. }
  58595. /**
  58596. * Options fot the radial explosion event
  58597. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  58598. */
  58599. export class PhysicsRadialExplosionEventOptions {
  58600. /**
  58601. * The radius of the sphere for the radial explosion.
  58602. */
  58603. radius: number;
  58604. /**
  58605. * The strenth of the explosion.
  58606. */
  58607. strength: number;
  58608. /**
  58609. * The strenght of the force in correspondence to the distance of the affected object
  58610. */
  58611. falloff: PhysicsRadialImpulseFalloff;
  58612. /**
  58613. * Sphere options for the radial explosion.
  58614. */
  58615. sphere: {
  58616. segments: number;
  58617. diameter: number;
  58618. };
  58619. /**
  58620. * Sphere options for the radial explosion.
  58621. */
  58622. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  58623. }
  58624. /**
  58625. * Options fot the updraft event
  58626. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  58627. */
  58628. export class PhysicsUpdraftEventOptions {
  58629. /**
  58630. * The radius of the cylinder for the vortex
  58631. */
  58632. radius: number;
  58633. /**
  58634. * The strenth of the updraft.
  58635. */
  58636. strength: number;
  58637. /**
  58638. * The height of the cylinder for the updraft.
  58639. */
  58640. height: number;
  58641. /**
  58642. * The mode for the the updraft.
  58643. */
  58644. updraftMode: PhysicsUpdraftMode;
  58645. }
  58646. /**
  58647. * Options fot the vortex event
  58648. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  58649. */
  58650. export class PhysicsVortexEventOptions {
  58651. /**
  58652. * The radius of the cylinder for the vortex
  58653. */
  58654. radius: number;
  58655. /**
  58656. * The strenth of the vortex.
  58657. */
  58658. strength: number;
  58659. /**
  58660. * The height of the cylinder for the vortex.
  58661. */
  58662. height: number;
  58663. /**
  58664. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  58665. */
  58666. centripetalForceThreshold: number;
  58667. /**
  58668. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  58669. */
  58670. centripetalForceMultiplier: number;
  58671. /**
  58672. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  58673. */
  58674. centrifugalForceMultiplier: number;
  58675. /**
  58676. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  58677. */
  58678. updraftForceMultiplier: number;
  58679. }
  58680. /**
  58681. * The strenght of the force in correspondence to the distance of the affected object
  58682. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  58683. */
  58684. export enum PhysicsRadialImpulseFalloff {
  58685. /** Defines that impulse is constant in strength across it's whole radius */
  58686. Constant = 0,
  58687. /** Defines that impulse gets weaker if it's further from the origin */
  58688. Linear = 1
  58689. }
  58690. /**
  58691. * The strength of the force in correspondence to the distance of the affected object
  58692. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  58693. */
  58694. export enum PhysicsUpdraftMode {
  58695. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  58696. Center = 0,
  58697. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  58698. Perpendicular = 1
  58699. }
  58700. /**
  58701. * Interface for a physics hit data
  58702. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  58703. */
  58704. export interface PhysicsHitData {
  58705. /**
  58706. * The force applied at the contact point
  58707. */
  58708. force: Vector3;
  58709. /**
  58710. * The contact point
  58711. */
  58712. contactPoint: Vector3;
  58713. /**
  58714. * The distance from the origin to the contact point
  58715. */
  58716. distanceFromOrigin: number;
  58717. }
  58718. /**
  58719. * Interface for radial explosion event data
  58720. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  58721. */
  58722. export interface PhysicsRadialExplosionEventData {
  58723. /**
  58724. * A sphere used for the radial explosion event
  58725. */
  58726. sphere: Mesh;
  58727. }
  58728. /**
  58729. * Interface for gravitational field event data
  58730. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  58731. */
  58732. export interface PhysicsGravitationalFieldEventData {
  58733. /**
  58734. * A sphere mesh used for the gravitational field event
  58735. */
  58736. sphere: Mesh;
  58737. }
  58738. /**
  58739. * Interface for updraft event data
  58740. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  58741. */
  58742. export interface PhysicsUpdraftEventData {
  58743. /**
  58744. * A cylinder used for the updraft event
  58745. */
  58746. cylinder: Mesh;
  58747. }
  58748. /**
  58749. * Interface for vortex event data
  58750. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  58751. */
  58752. export interface PhysicsVortexEventData {
  58753. /**
  58754. * A cylinder used for the vortex event
  58755. */
  58756. cylinder: Mesh;
  58757. }
  58758. /**
  58759. * Interface for an affected physics impostor
  58760. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  58761. */
  58762. export interface PhysicsAffectedImpostorWithData {
  58763. /**
  58764. * The impostor affected by the effect
  58765. */
  58766. impostor: PhysicsImpostor;
  58767. /**
  58768. * The data about the hit/horce from the explosion
  58769. */
  58770. hitData: PhysicsHitData;
  58771. }
  58772. }
  58773. declare module BABYLON {
  58774. /** @hidden */
  58775. export var blackAndWhitePixelShader: {
  58776. name: string;
  58777. shader: string;
  58778. };
  58779. }
  58780. declare module BABYLON {
  58781. /**
  58782. * Post process used to render in black and white
  58783. */
  58784. export class BlackAndWhitePostProcess extends PostProcess {
  58785. /**
  58786. * Linear about to convert he result to black and white (default: 1)
  58787. */
  58788. degree: number;
  58789. /**
  58790. * Creates a black and white post process
  58791. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  58792. * @param name The name of the effect.
  58793. * @param options The required width/height ratio to downsize to before computing the render pass.
  58794. * @param camera The camera to apply the render pass to.
  58795. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58796. * @param engine The engine which the post process will be applied. (default: current engine)
  58797. * @param reusable If the post process can be reused on the same frame. (default: false)
  58798. */
  58799. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  58800. }
  58801. }
  58802. declare module BABYLON {
  58803. /**
  58804. * This represents a set of one or more post processes in Babylon.
  58805. * A post process can be used to apply a shader to a texture after it is rendered.
  58806. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  58807. */
  58808. export class PostProcessRenderEffect {
  58809. private _postProcesses;
  58810. private _getPostProcesses;
  58811. private _singleInstance;
  58812. private _cameras;
  58813. private _indicesForCamera;
  58814. /**
  58815. * Name of the effect
  58816. * @hidden
  58817. */
  58818. _name: string;
  58819. /**
  58820. * Instantiates a post process render effect.
  58821. * A post process can be used to apply a shader to a texture after it is rendered.
  58822. * @param engine The engine the effect is tied to
  58823. * @param name The name of the effect
  58824. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  58825. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  58826. */
  58827. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  58828. /**
  58829. * Checks if all the post processes in the effect are supported.
  58830. */
  58831. readonly isSupported: boolean;
  58832. /**
  58833. * Updates the current state of the effect
  58834. * @hidden
  58835. */
  58836. _update(): void;
  58837. /**
  58838. * Attaches the effect on cameras
  58839. * @param cameras The camera to attach to.
  58840. * @hidden
  58841. */
  58842. _attachCameras(cameras: Camera): void;
  58843. /**
  58844. * Attaches the effect on cameras
  58845. * @param cameras The camera to attach to.
  58846. * @hidden
  58847. */
  58848. _attachCameras(cameras: Camera[]): void;
  58849. /**
  58850. * Detaches the effect on cameras
  58851. * @param cameras The camera to detatch from.
  58852. * @hidden
  58853. */
  58854. _detachCameras(cameras: Camera): void;
  58855. /**
  58856. * Detatches the effect on cameras
  58857. * @param cameras The camera to detatch from.
  58858. * @hidden
  58859. */
  58860. _detachCameras(cameras: Camera[]): void;
  58861. /**
  58862. * Enables the effect on given cameras
  58863. * @param cameras The camera to enable.
  58864. * @hidden
  58865. */
  58866. _enable(cameras: Camera): void;
  58867. /**
  58868. * Enables the effect on given cameras
  58869. * @param cameras The camera to enable.
  58870. * @hidden
  58871. */
  58872. _enable(cameras: Nullable<Camera[]>): void;
  58873. /**
  58874. * Disables the effect on the given cameras
  58875. * @param cameras The camera to disable.
  58876. * @hidden
  58877. */
  58878. _disable(cameras: Camera): void;
  58879. /**
  58880. * Disables the effect on the given cameras
  58881. * @param cameras The camera to disable.
  58882. * @hidden
  58883. */
  58884. _disable(cameras: Nullable<Camera[]>): void;
  58885. /**
  58886. * Gets a list of the post processes contained in the effect.
  58887. * @param camera The camera to get the post processes on.
  58888. * @returns The list of the post processes in the effect.
  58889. */
  58890. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  58891. }
  58892. }
  58893. declare module BABYLON {
  58894. /** @hidden */
  58895. export var extractHighlightsPixelShader: {
  58896. name: string;
  58897. shader: string;
  58898. };
  58899. }
  58900. declare module BABYLON {
  58901. /**
  58902. * 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.
  58903. */
  58904. export class ExtractHighlightsPostProcess extends PostProcess {
  58905. /**
  58906. * The luminance threshold, pixels below this value will be set to black.
  58907. */
  58908. threshold: number;
  58909. /** @hidden */
  58910. _exposure: number;
  58911. /**
  58912. * Post process which has the input texture to be used when performing highlight extraction
  58913. * @hidden
  58914. */
  58915. _inputPostProcess: Nullable<PostProcess>;
  58916. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  58917. }
  58918. }
  58919. declare module BABYLON {
  58920. /** @hidden */
  58921. export var bloomMergePixelShader: {
  58922. name: string;
  58923. shader: string;
  58924. };
  58925. }
  58926. declare module BABYLON {
  58927. /**
  58928. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  58929. */
  58930. export class BloomMergePostProcess extends PostProcess {
  58931. /** Weight of the bloom to be added to the original input. */
  58932. weight: number;
  58933. /**
  58934. * Creates a new instance of @see BloomMergePostProcess
  58935. * @param name The name of the effect.
  58936. * @param originalFromInput Post process which's input will be used for the merge.
  58937. * @param blurred Blurred highlights post process which's output will be used.
  58938. * @param weight Weight of the bloom to be added to the original input.
  58939. * @param options The required width/height ratio to downsize to before computing the render pass.
  58940. * @param camera The camera to apply the render pass to.
  58941. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58942. * @param engine The engine which the post process will be applied. (default: current engine)
  58943. * @param reusable If the post process can be reused on the same frame. (default: false)
  58944. * @param textureType Type of textures used when performing the post process. (default: 0)
  58945. * @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)
  58946. */
  58947. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  58948. /** Weight of the bloom to be added to the original input. */
  58949. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  58950. }
  58951. }
  58952. declare module BABYLON {
  58953. /**
  58954. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  58955. */
  58956. export class BloomEffect extends PostProcessRenderEffect {
  58957. private bloomScale;
  58958. /**
  58959. * @hidden Internal
  58960. */
  58961. _effects: Array<PostProcess>;
  58962. /**
  58963. * @hidden Internal
  58964. */
  58965. _downscale: ExtractHighlightsPostProcess;
  58966. private _blurX;
  58967. private _blurY;
  58968. private _merge;
  58969. /**
  58970. * The luminance threshold to find bright areas of the image to bloom.
  58971. */
  58972. threshold: number;
  58973. /**
  58974. * The strength of the bloom.
  58975. */
  58976. weight: number;
  58977. /**
  58978. * Specifies the size of the bloom blur kernel, relative to the final output size
  58979. */
  58980. kernel: number;
  58981. /**
  58982. * Creates a new instance of @see BloomEffect
  58983. * @param scene The scene the effect belongs to.
  58984. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  58985. * @param bloomKernel The size of the kernel to be used when applying the blur.
  58986. * @param bloomWeight The the strength of bloom.
  58987. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  58988. * @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)
  58989. */
  58990. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  58991. /**
  58992. * Disposes each of the internal effects for a given camera.
  58993. * @param camera The camera to dispose the effect on.
  58994. */
  58995. disposeEffects(camera: Camera): void;
  58996. /**
  58997. * @hidden Internal
  58998. */
  58999. _updateEffects(): void;
  59000. /**
  59001. * Internal
  59002. * @returns if all the contained post processes are ready.
  59003. * @hidden
  59004. */
  59005. _isReady(): boolean;
  59006. }
  59007. }
  59008. declare module BABYLON {
  59009. /** @hidden */
  59010. export var chromaticAberrationPixelShader: {
  59011. name: string;
  59012. shader: string;
  59013. };
  59014. }
  59015. declare module BABYLON {
  59016. /**
  59017. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  59018. */
  59019. export class ChromaticAberrationPostProcess extends PostProcess {
  59020. /**
  59021. * The amount of seperation of rgb channels (default: 30)
  59022. */
  59023. aberrationAmount: number;
  59024. /**
  59025. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  59026. */
  59027. radialIntensity: number;
  59028. /**
  59029. * 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))
  59030. */
  59031. direction: Vector2;
  59032. /**
  59033. * 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))
  59034. */
  59035. centerPosition: Vector2;
  59036. /**
  59037. * Creates a new instance ChromaticAberrationPostProcess
  59038. * @param name The name of the effect.
  59039. * @param screenWidth The width of the screen to apply the effect on.
  59040. * @param screenHeight The height of the screen to apply the effect on.
  59041. * @param options The required width/height ratio to downsize to before computing the render pass.
  59042. * @param camera The camera to apply the render pass to.
  59043. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59044. * @param engine The engine which the post process will be applied. (default: current engine)
  59045. * @param reusable If the post process can be reused on the same frame. (default: false)
  59046. * @param textureType Type of textures used when performing the post process. (default: 0)
  59047. * @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)
  59048. */
  59049. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  59050. }
  59051. }
  59052. declare module BABYLON {
  59053. /** @hidden */
  59054. export var circleOfConfusionPixelShader: {
  59055. name: string;
  59056. shader: string;
  59057. };
  59058. }
  59059. declare module BABYLON {
  59060. /**
  59061. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  59062. */
  59063. export class CircleOfConfusionPostProcess extends PostProcess {
  59064. /**
  59065. * 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.
  59066. */
  59067. lensSize: number;
  59068. /**
  59069. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  59070. */
  59071. fStop: number;
  59072. /**
  59073. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  59074. */
  59075. focusDistance: number;
  59076. /**
  59077. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  59078. */
  59079. focalLength: number;
  59080. private _depthTexture;
  59081. /**
  59082. * Creates a new instance CircleOfConfusionPostProcess
  59083. * @param name The name of the effect.
  59084. * @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.
  59085. * @param options The required width/height ratio to downsize to before computing the render pass.
  59086. * @param camera The camera to apply the render pass to.
  59087. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59088. * @param engine The engine which the post process will be applied. (default: current engine)
  59089. * @param reusable If the post process can be reused on the same frame. (default: false)
  59090. * @param textureType Type of textures used when performing the post process. (default: 0)
  59091. * @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)
  59092. */
  59093. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  59094. /**
  59095. * 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.
  59096. */
  59097. depthTexture: RenderTargetTexture;
  59098. }
  59099. }
  59100. declare module BABYLON {
  59101. /** @hidden */
  59102. export var colorCorrectionPixelShader: {
  59103. name: string;
  59104. shader: string;
  59105. };
  59106. }
  59107. declare module BABYLON {
  59108. /**
  59109. *
  59110. * This post-process allows the modification of rendered colors by using
  59111. * a 'look-up table' (LUT). This effect is also called Color Grading.
  59112. *
  59113. * The object needs to be provided an url to a texture containing the color
  59114. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  59115. * Use an image editing software to tweak the LUT to match your needs.
  59116. *
  59117. * For an example of a color LUT, see here:
  59118. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  59119. * For explanations on color grading, see here:
  59120. * @see http://udn.epicgames.com/Three/ColorGrading.html
  59121. *
  59122. */
  59123. export class ColorCorrectionPostProcess extends PostProcess {
  59124. private _colorTableTexture;
  59125. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  59126. }
  59127. }
  59128. declare module BABYLON {
  59129. /** @hidden */
  59130. export var convolutionPixelShader: {
  59131. name: string;
  59132. shader: string;
  59133. };
  59134. }
  59135. declare module BABYLON {
  59136. /**
  59137. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  59138. * input texture to perform effects such as edge detection or sharpening
  59139. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  59140. */
  59141. export class ConvolutionPostProcess extends PostProcess {
  59142. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  59143. kernel: number[];
  59144. /**
  59145. * Creates a new instance ConvolutionPostProcess
  59146. * @param name The name of the effect.
  59147. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  59148. * @param options The required width/height ratio to downsize to before computing the render pass.
  59149. * @param camera The camera to apply the render pass to.
  59150. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59151. * @param engine The engine which the post process will be applied. (default: current engine)
  59152. * @param reusable If the post process can be reused on the same frame. (default: false)
  59153. * @param textureType Type of textures used when performing the post process. (default: 0)
  59154. */
  59155. constructor(name: string,
  59156. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  59157. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  59158. /**
  59159. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  59160. */
  59161. static EdgeDetect0Kernel: number[];
  59162. /**
  59163. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  59164. */
  59165. static EdgeDetect1Kernel: number[];
  59166. /**
  59167. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  59168. */
  59169. static EdgeDetect2Kernel: number[];
  59170. /**
  59171. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  59172. */
  59173. static SharpenKernel: number[];
  59174. /**
  59175. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  59176. */
  59177. static EmbossKernel: number[];
  59178. /**
  59179. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  59180. */
  59181. static GaussianKernel: number[];
  59182. }
  59183. }
  59184. declare module BABYLON {
  59185. /**
  59186. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  59187. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  59188. * based on samples that have a large difference in distance than the center pixel.
  59189. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  59190. */
  59191. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  59192. direction: Vector2;
  59193. /**
  59194. * Creates a new instance CircleOfConfusionPostProcess
  59195. * @param name The name of the effect.
  59196. * @param scene The scene the effect belongs to.
  59197. * @param direction The direction the blur should be applied.
  59198. * @param kernel The size of the kernel used to blur.
  59199. * @param options The required width/height ratio to downsize to before computing the render pass.
  59200. * @param camera The camera to apply the render pass to.
  59201. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  59202. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  59203. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59204. * @param engine The engine which the post process will be applied. (default: current engine)
  59205. * @param reusable If the post process can be reused on the same frame. (default: false)
  59206. * @param textureType Type of textures used when performing the post process. (default: 0)
  59207. * @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)
  59208. */
  59209. 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);
  59210. }
  59211. }
  59212. declare module BABYLON {
  59213. /** @hidden */
  59214. export var depthOfFieldMergePixelShader: {
  59215. name: string;
  59216. shader: string;
  59217. };
  59218. }
  59219. declare module BABYLON {
  59220. /**
  59221. * Options to be set when merging outputs from the default pipeline.
  59222. */
  59223. export class DepthOfFieldMergePostProcessOptions {
  59224. /**
  59225. * The original image to merge on top of
  59226. */
  59227. originalFromInput: PostProcess;
  59228. /**
  59229. * Parameters to perform the merge of the depth of field effect
  59230. */
  59231. depthOfField?: {
  59232. circleOfConfusion: PostProcess;
  59233. blurSteps: Array<PostProcess>;
  59234. };
  59235. /**
  59236. * Parameters to perform the merge of bloom effect
  59237. */
  59238. bloom?: {
  59239. blurred: PostProcess;
  59240. weight: number;
  59241. };
  59242. }
  59243. /**
  59244. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  59245. */
  59246. export class DepthOfFieldMergePostProcess extends PostProcess {
  59247. private blurSteps;
  59248. /**
  59249. * Creates a new instance of DepthOfFieldMergePostProcess
  59250. * @param name The name of the effect.
  59251. * @param originalFromInput Post process which's input will be used for the merge.
  59252. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  59253. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  59254. * @param options The required width/height ratio to downsize to before computing the render pass.
  59255. * @param camera The camera to apply the render pass to.
  59256. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59257. * @param engine The engine which the post process will be applied. (default: current engine)
  59258. * @param reusable If the post process can be reused on the same frame. (default: false)
  59259. * @param textureType Type of textures used when performing the post process. (default: 0)
  59260. * @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)
  59261. */
  59262. 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);
  59263. /**
  59264. * Updates the effect with the current post process compile time values and recompiles the shader.
  59265. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  59266. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  59267. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  59268. * @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
  59269. * @param onCompiled Called when the shader has been compiled.
  59270. * @param onError Called if there is an error when compiling a shader.
  59271. */
  59272. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  59273. }
  59274. }
  59275. declare module BABYLON {
  59276. /**
  59277. * Specifies the level of max blur that should be applied when using the depth of field effect
  59278. */
  59279. export enum DepthOfFieldEffectBlurLevel {
  59280. /**
  59281. * Subtle blur
  59282. */
  59283. Low = 0,
  59284. /**
  59285. * Medium blur
  59286. */
  59287. Medium = 1,
  59288. /**
  59289. * Large blur
  59290. */
  59291. High = 2
  59292. }
  59293. /**
  59294. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  59295. */
  59296. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  59297. private _circleOfConfusion;
  59298. /**
  59299. * @hidden Internal, blurs from high to low
  59300. */
  59301. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  59302. private _depthOfFieldBlurY;
  59303. private _dofMerge;
  59304. /**
  59305. * @hidden Internal post processes in depth of field effect
  59306. */
  59307. _effects: Array<PostProcess>;
  59308. /**
  59309. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  59310. */
  59311. focalLength: number;
  59312. /**
  59313. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  59314. */
  59315. fStop: number;
  59316. /**
  59317. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  59318. */
  59319. focusDistance: number;
  59320. /**
  59321. * 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.
  59322. */
  59323. lensSize: number;
  59324. /**
  59325. * Creates a new instance DepthOfFieldEffect
  59326. * @param scene The scene the effect belongs to.
  59327. * @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.
  59328. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  59329. * @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)
  59330. */
  59331. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  59332. /**
  59333. * Get the current class name of the current effet
  59334. * @returns "DepthOfFieldEffect"
  59335. */
  59336. getClassName(): string;
  59337. /**
  59338. * 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.
  59339. */
  59340. depthTexture: RenderTargetTexture;
  59341. /**
  59342. * Disposes each of the internal effects for a given camera.
  59343. * @param camera The camera to dispose the effect on.
  59344. */
  59345. disposeEffects(camera: Camera): void;
  59346. /**
  59347. * @hidden Internal
  59348. */
  59349. _updateEffects(): void;
  59350. /**
  59351. * Internal
  59352. * @returns if all the contained post processes are ready.
  59353. * @hidden
  59354. */
  59355. _isReady(): boolean;
  59356. }
  59357. }
  59358. declare module BABYLON {
  59359. /** @hidden */
  59360. export var displayPassPixelShader: {
  59361. name: string;
  59362. shader: string;
  59363. };
  59364. }
  59365. declare module BABYLON {
  59366. /**
  59367. * DisplayPassPostProcess which produces an output the same as it's input
  59368. */
  59369. export class DisplayPassPostProcess extends PostProcess {
  59370. /**
  59371. * Creates the DisplayPassPostProcess
  59372. * @param name The name of the effect.
  59373. * @param options The required width/height ratio to downsize to before computing the render pass.
  59374. * @param camera The camera to apply the render pass to.
  59375. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59376. * @param engine The engine which the post process will be applied. (default: current engine)
  59377. * @param reusable If the post process can be reused on the same frame. (default: false)
  59378. */
  59379. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  59380. }
  59381. }
  59382. declare module BABYLON {
  59383. /** @hidden */
  59384. export var filterPixelShader: {
  59385. name: string;
  59386. shader: string;
  59387. };
  59388. }
  59389. declare module BABYLON {
  59390. /**
  59391. * Applies a kernel filter to the image
  59392. */
  59393. export class FilterPostProcess extends PostProcess {
  59394. /** The matrix to be applied to the image */
  59395. kernelMatrix: Matrix;
  59396. /**
  59397. *
  59398. * @param name The name of the effect.
  59399. * @param kernelMatrix The matrix to be applied to the image
  59400. * @param options The required width/height ratio to downsize to before computing the render pass.
  59401. * @param camera The camera to apply the render pass to.
  59402. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59403. * @param engine The engine which the post process will be applied. (default: current engine)
  59404. * @param reusable If the post process can be reused on the same frame. (default: false)
  59405. */
  59406. constructor(name: string,
  59407. /** The matrix to be applied to the image */
  59408. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  59409. }
  59410. }
  59411. declare module BABYLON {
  59412. /** @hidden */
  59413. export var fxaaPixelShader: {
  59414. name: string;
  59415. shader: string;
  59416. };
  59417. }
  59418. declare module BABYLON {
  59419. /** @hidden */
  59420. export var fxaaVertexShader: {
  59421. name: string;
  59422. shader: string;
  59423. };
  59424. }
  59425. declare module BABYLON {
  59426. /**
  59427. * Fxaa post process
  59428. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  59429. */
  59430. export class FxaaPostProcess extends PostProcess {
  59431. /** @hidden */
  59432. texelWidth: number;
  59433. /** @hidden */
  59434. texelHeight: number;
  59435. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  59436. private _getDefines;
  59437. }
  59438. }
  59439. declare module BABYLON {
  59440. /** @hidden */
  59441. export var grainPixelShader: {
  59442. name: string;
  59443. shader: string;
  59444. };
  59445. }
  59446. declare module BABYLON {
  59447. /**
  59448. * The GrainPostProcess adds noise to the image at mid luminance levels
  59449. */
  59450. export class GrainPostProcess extends PostProcess {
  59451. /**
  59452. * The intensity of the grain added (default: 30)
  59453. */
  59454. intensity: number;
  59455. /**
  59456. * If the grain should be randomized on every frame
  59457. */
  59458. animated: boolean;
  59459. /**
  59460. * Creates a new instance of @see GrainPostProcess
  59461. * @param name The name of the effect.
  59462. * @param options The required width/height ratio to downsize to before computing the render pass.
  59463. * @param camera The camera to apply the render pass to.
  59464. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59465. * @param engine The engine which the post process will be applied. (default: current engine)
  59466. * @param reusable If the post process can be reused on the same frame. (default: false)
  59467. * @param textureType Type of textures used when performing the post process. (default: 0)
  59468. * @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)
  59469. */
  59470. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  59471. }
  59472. }
  59473. declare module BABYLON {
  59474. /** @hidden */
  59475. export var highlightsPixelShader: {
  59476. name: string;
  59477. shader: string;
  59478. };
  59479. }
  59480. declare module BABYLON {
  59481. /**
  59482. * Extracts highlights from the image
  59483. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  59484. */
  59485. export class HighlightsPostProcess extends PostProcess {
  59486. /**
  59487. * Extracts highlights from the image
  59488. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  59489. * @param name The name of the effect.
  59490. * @param options The required width/height ratio to downsize to before computing the render pass.
  59491. * @param camera The camera to apply the render pass to.
  59492. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59493. * @param engine The engine which the post process will be applied. (default: current engine)
  59494. * @param reusable If the post process can be reused on the same frame. (default: false)
  59495. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  59496. */
  59497. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  59498. }
  59499. }
  59500. declare module BABYLON {
  59501. /** @hidden */
  59502. export var mrtFragmentDeclaration: {
  59503. name: string;
  59504. shader: string;
  59505. };
  59506. }
  59507. declare module BABYLON {
  59508. /** @hidden */
  59509. export var geometryPixelShader: {
  59510. name: string;
  59511. shader: string;
  59512. };
  59513. }
  59514. declare module BABYLON {
  59515. /** @hidden */
  59516. export var geometryVertexShader: {
  59517. name: string;
  59518. shader: string;
  59519. };
  59520. }
  59521. declare module BABYLON {
  59522. /** @hidden */
  59523. interface ISavedTransformationMatrix {
  59524. world: Matrix;
  59525. viewProjection: Matrix;
  59526. }
  59527. /**
  59528. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  59529. */
  59530. export class GeometryBufferRenderer {
  59531. /**
  59532. * Constant used to retrieve the position texture index in the G-Buffer textures array
  59533. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  59534. */
  59535. static readonly POSITION_TEXTURE_TYPE: number;
  59536. /**
  59537. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  59538. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  59539. */
  59540. static readonly VELOCITY_TEXTURE_TYPE: number;
  59541. /**
  59542. * Dictionary used to store the previous transformation matrices of each rendered mesh
  59543. * in order to compute objects velocities when enableVelocity is set to "true"
  59544. * @hidden
  59545. */
  59546. _previousTransformationMatrices: {
  59547. [index: number]: ISavedTransformationMatrix;
  59548. };
  59549. /**
  59550. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  59551. * in order to compute objects velocities when enableVelocity is set to "true"
  59552. * @hidden
  59553. */
  59554. _previousBonesTransformationMatrices: {
  59555. [index: number]: Float32Array;
  59556. };
  59557. /**
  59558. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  59559. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  59560. */
  59561. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  59562. private _scene;
  59563. private _multiRenderTarget;
  59564. private _ratio;
  59565. private _enablePosition;
  59566. private _enableVelocity;
  59567. private _positionIndex;
  59568. private _velocityIndex;
  59569. protected _effect: Effect;
  59570. protected _cachedDefines: string;
  59571. /**
  59572. * Set the render list (meshes to be rendered) used in the G buffer.
  59573. */
  59574. renderList: Mesh[];
  59575. /**
  59576. * Gets wether or not G buffer are supported by the running hardware.
  59577. * This requires draw buffer supports
  59578. */
  59579. readonly isSupported: boolean;
  59580. /**
  59581. * Returns the index of the given texture type in the G-Buffer textures array
  59582. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  59583. * @returns the index of the given texture type in the G-Buffer textures array
  59584. */
  59585. getTextureIndex(textureType: number): number;
  59586. /**
  59587. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  59588. */
  59589. /**
  59590. * Sets whether or not objects positions are enabled for the G buffer.
  59591. */
  59592. enablePosition: boolean;
  59593. /**
  59594. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  59595. */
  59596. /**
  59597. * Sets wether or not objects velocities are enabled for the G buffer.
  59598. */
  59599. enableVelocity: boolean;
  59600. /**
  59601. * Gets the scene associated with the buffer.
  59602. */
  59603. readonly scene: Scene;
  59604. /**
  59605. * Gets the ratio used by the buffer during its creation.
  59606. * How big is the buffer related to the main canvas.
  59607. */
  59608. readonly ratio: number;
  59609. /** @hidden */
  59610. static _SceneComponentInitialization: (scene: Scene) => void;
  59611. /**
  59612. * Creates a new G Buffer for the scene
  59613. * @param scene The scene the buffer belongs to
  59614. * @param ratio How big is the buffer related to the main canvas.
  59615. */
  59616. constructor(scene: Scene, ratio?: number);
  59617. /**
  59618. * Checks wether everything is ready to render a submesh to the G buffer.
  59619. * @param subMesh the submesh to check readiness for
  59620. * @param useInstances is the mesh drawn using instance or not
  59621. * @returns true if ready otherwise false
  59622. */
  59623. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  59624. /**
  59625. * Gets the current underlying G Buffer.
  59626. * @returns the buffer
  59627. */
  59628. getGBuffer(): MultiRenderTarget;
  59629. /**
  59630. * Gets the number of samples used to render the buffer (anti aliasing).
  59631. */
  59632. /**
  59633. * Sets the number of samples used to render the buffer (anti aliasing).
  59634. */
  59635. samples: number;
  59636. /**
  59637. * Disposes the renderer and frees up associated resources.
  59638. */
  59639. dispose(): void;
  59640. protected _createRenderTargets(): void;
  59641. private _copyBonesTransformationMatrices;
  59642. }
  59643. }
  59644. declare module BABYLON {
  59645. interface Scene {
  59646. /** @hidden (Backing field) */
  59647. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  59648. /**
  59649. * Gets or Sets the current geometry buffer associated to the scene.
  59650. */
  59651. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  59652. /**
  59653. * Enables a GeometryBufferRender and associates it with the scene
  59654. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  59655. * @returns the GeometryBufferRenderer
  59656. */
  59657. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  59658. /**
  59659. * Disables the GeometryBufferRender associated with the scene
  59660. */
  59661. disableGeometryBufferRenderer(): void;
  59662. }
  59663. /**
  59664. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  59665. * in several rendering techniques.
  59666. */
  59667. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  59668. /**
  59669. * The component name helpful to identify the component in the list of scene components.
  59670. */
  59671. readonly name: string;
  59672. /**
  59673. * The scene the component belongs to.
  59674. */
  59675. scene: Scene;
  59676. /**
  59677. * Creates a new instance of the component for the given scene
  59678. * @param scene Defines the scene to register the component in
  59679. */
  59680. constructor(scene: Scene);
  59681. /**
  59682. * Registers the component in a given scene
  59683. */
  59684. register(): void;
  59685. /**
  59686. * Rebuilds the elements related to this component in case of
  59687. * context lost for instance.
  59688. */
  59689. rebuild(): void;
  59690. /**
  59691. * Disposes the component and the associated ressources
  59692. */
  59693. dispose(): void;
  59694. private _gatherRenderTargets;
  59695. }
  59696. }
  59697. declare module BABYLON {
  59698. /** @hidden */
  59699. export var motionBlurPixelShader: {
  59700. name: string;
  59701. shader: string;
  59702. };
  59703. }
  59704. declare module BABYLON {
  59705. /**
  59706. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  59707. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  59708. * As an example, all you have to do is to create the post-process:
  59709. * var mb = new BABYLON.MotionBlurPostProcess(
  59710. * 'mb', // The name of the effect.
  59711. * scene, // The scene containing the objects to blur according to their velocity.
  59712. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  59713. * camera // The camera to apply the render pass to.
  59714. * );
  59715. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  59716. */
  59717. export class MotionBlurPostProcess extends PostProcess {
  59718. /**
  59719. * Defines how much the image is blurred by the movement. Default value is equal to 1
  59720. */
  59721. motionStrength: number;
  59722. /**
  59723. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  59724. */
  59725. /**
  59726. * Sets the number of iterations to be used for motion blur quality
  59727. */
  59728. motionBlurSamples: number;
  59729. private _motionBlurSamples;
  59730. private _geometryBufferRenderer;
  59731. /**
  59732. * Creates a new instance MotionBlurPostProcess
  59733. * @param name The name of the effect.
  59734. * @param scene The scene containing the objects to blur according to their velocity.
  59735. * @param options The required width/height ratio to downsize to before computing the render pass.
  59736. * @param camera The camera to apply the render pass to.
  59737. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59738. * @param engine The engine which the post process will be applied. (default: current engine)
  59739. * @param reusable If the post process can be reused on the same frame. (default: false)
  59740. * @param textureType Type of textures used when performing the post process. (default: 0)
  59741. * @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)
  59742. */
  59743. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  59744. /**
  59745. * Excludes the given skinned mesh from computing bones velocities.
  59746. * 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.
  59747. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  59748. */
  59749. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  59750. /**
  59751. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  59752. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  59753. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  59754. */
  59755. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  59756. /**
  59757. * Disposes the post process.
  59758. * @param camera The camera to dispose the post process on.
  59759. */
  59760. dispose(camera?: Camera): void;
  59761. }
  59762. }
  59763. declare module BABYLON {
  59764. /** @hidden */
  59765. export var refractionPixelShader: {
  59766. name: string;
  59767. shader: string;
  59768. };
  59769. }
  59770. declare module BABYLON {
  59771. /**
  59772. * Post process which applies a refractin texture
  59773. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  59774. */
  59775. export class RefractionPostProcess extends PostProcess {
  59776. /** the base color of the refraction (used to taint the rendering) */
  59777. color: Color3;
  59778. /** simulated refraction depth */
  59779. depth: number;
  59780. /** the coefficient of the base color (0 to remove base color tainting) */
  59781. colorLevel: number;
  59782. private _refTexture;
  59783. private _ownRefractionTexture;
  59784. /**
  59785. * Gets or sets the refraction texture
  59786. * Please note that you are responsible for disposing the texture if you set it manually
  59787. */
  59788. refractionTexture: Texture;
  59789. /**
  59790. * Initializes the RefractionPostProcess
  59791. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  59792. * @param name The name of the effect.
  59793. * @param refractionTextureUrl Url of the refraction texture to use
  59794. * @param color the base color of the refraction (used to taint the rendering)
  59795. * @param depth simulated refraction depth
  59796. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  59797. * @param camera The camera to apply the render pass to.
  59798. * @param options The required width/height ratio to downsize to before computing the render pass.
  59799. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59800. * @param engine The engine which the post process will be applied. (default: current engine)
  59801. * @param reusable If the post process can be reused on the same frame. (default: false)
  59802. */
  59803. constructor(name: string, refractionTextureUrl: string,
  59804. /** the base color of the refraction (used to taint the rendering) */
  59805. color: Color3,
  59806. /** simulated refraction depth */
  59807. depth: number,
  59808. /** the coefficient of the base color (0 to remove base color tainting) */
  59809. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  59810. /**
  59811. * Disposes of the post process
  59812. * @param camera Camera to dispose post process on
  59813. */
  59814. dispose(camera: Camera): void;
  59815. }
  59816. }
  59817. declare module BABYLON {
  59818. /** @hidden */
  59819. export var sharpenPixelShader: {
  59820. name: string;
  59821. shader: string;
  59822. };
  59823. }
  59824. declare module BABYLON {
  59825. /**
  59826. * The SharpenPostProcess applies a sharpen kernel to every pixel
  59827. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  59828. */
  59829. export class SharpenPostProcess extends PostProcess {
  59830. /**
  59831. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  59832. */
  59833. colorAmount: number;
  59834. /**
  59835. * How much sharpness should be applied (default: 0.3)
  59836. */
  59837. edgeAmount: number;
  59838. /**
  59839. * Creates a new instance ConvolutionPostProcess
  59840. * @param name The name of the effect.
  59841. * @param options The required width/height ratio to downsize to before computing the render pass.
  59842. * @param camera The camera to apply the render pass to.
  59843. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59844. * @param engine The engine which the post process will be applied. (default: current engine)
  59845. * @param reusable If the post process can be reused on the same frame. (default: false)
  59846. * @param textureType Type of textures used when performing the post process. (default: 0)
  59847. * @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)
  59848. */
  59849. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  59850. }
  59851. }
  59852. declare module BABYLON {
  59853. /**
  59854. * PostProcessRenderPipeline
  59855. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  59856. */
  59857. export class PostProcessRenderPipeline {
  59858. private engine;
  59859. private _renderEffects;
  59860. private _renderEffectsForIsolatedPass;
  59861. /**
  59862. * List of inspectable custom properties (used by the Inspector)
  59863. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  59864. */
  59865. inspectableCustomProperties: IInspectable[];
  59866. /**
  59867. * @hidden
  59868. */
  59869. protected _cameras: Camera[];
  59870. /** @hidden */
  59871. _name: string;
  59872. /**
  59873. * Gets pipeline name
  59874. */
  59875. readonly name: string;
  59876. /**
  59877. * Initializes a PostProcessRenderPipeline
  59878. * @param engine engine to add the pipeline to
  59879. * @param name name of the pipeline
  59880. */
  59881. constructor(engine: Engine, name: string);
  59882. /**
  59883. * Gets the class name
  59884. * @returns "PostProcessRenderPipeline"
  59885. */
  59886. getClassName(): string;
  59887. /**
  59888. * If all the render effects in the pipeline are supported
  59889. */
  59890. readonly isSupported: boolean;
  59891. /**
  59892. * Adds an effect to the pipeline
  59893. * @param renderEffect the effect to add
  59894. */
  59895. addEffect(renderEffect: PostProcessRenderEffect): void;
  59896. /** @hidden */
  59897. _rebuild(): void;
  59898. /** @hidden */
  59899. _enableEffect(renderEffectName: string, cameras: Camera): void;
  59900. /** @hidden */
  59901. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  59902. /** @hidden */
  59903. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  59904. /** @hidden */
  59905. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  59906. /** @hidden */
  59907. _attachCameras(cameras: Camera, unique: boolean): void;
  59908. /** @hidden */
  59909. _attachCameras(cameras: Camera[], unique: boolean): void;
  59910. /** @hidden */
  59911. _detachCameras(cameras: Camera): void;
  59912. /** @hidden */
  59913. _detachCameras(cameras: Nullable<Camera[]>): void;
  59914. /** @hidden */
  59915. _update(): void;
  59916. /** @hidden */
  59917. _reset(): void;
  59918. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  59919. /**
  59920. * Disposes of the pipeline
  59921. */
  59922. dispose(): void;
  59923. }
  59924. }
  59925. declare module BABYLON {
  59926. /**
  59927. * PostProcessRenderPipelineManager class
  59928. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  59929. */
  59930. export class PostProcessRenderPipelineManager {
  59931. private _renderPipelines;
  59932. /**
  59933. * Initializes a PostProcessRenderPipelineManager
  59934. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  59935. */
  59936. constructor();
  59937. /**
  59938. * Gets the list of supported render pipelines
  59939. */
  59940. readonly supportedPipelines: PostProcessRenderPipeline[];
  59941. /**
  59942. * Adds a pipeline to the manager
  59943. * @param renderPipeline The pipeline to add
  59944. */
  59945. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  59946. /**
  59947. * Attaches a camera to the pipeline
  59948. * @param renderPipelineName The name of the pipeline to attach to
  59949. * @param cameras the camera to attach
  59950. * @param unique if the camera can be attached multiple times to the pipeline
  59951. */
  59952. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  59953. /**
  59954. * Detaches a camera from the pipeline
  59955. * @param renderPipelineName The name of the pipeline to detach from
  59956. * @param cameras the camera to detach
  59957. */
  59958. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  59959. /**
  59960. * Enables an effect by name on a pipeline
  59961. * @param renderPipelineName the name of the pipeline to enable the effect in
  59962. * @param renderEffectName the name of the effect to enable
  59963. * @param cameras the cameras that the effect should be enabled on
  59964. */
  59965. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  59966. /**
  59967. * Disables an effect by name on a pipeline
  59968. * @param renderPipelineName the name of the pipeline to disable the effect in
  59969. * @param renderEffectName the name of the effect to disable
  59970. * @param cameras the cameras that the effect should be disabled on
  59971. */
  59972. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  59973. /**
  59974. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  59975. */
  59976. update(): void;
  59977. /** @hidden */
  59978. _rebuild(): void;
  59979. /**
  59980. * Disposes of the manager and pipelines
  59981. */
  59982. dispose(): void;
  59983. }
  59984. }
  59985. declare module BABYLON {
  59986. interface Scene {
  59987. /** @hidden (Backing field) */
  59988. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  59989. /**
  59990. * Gets the postprocess render pipeline manager
  59991. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  59992. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  59993. */
  59994. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  59995. }
  59996. /**
  59997. * Defines the Render Pipeline scene component responsible to rendering pipelines
  59998. */
  59999. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  60000. /**
  60001. * The component name helpfull to identify the component in the list of scene components.
  60002. */
  60003. readonly name: string;
  60004. /**
  60005. * The scene the component belongs to.
  60006. */
  60007. scene: Scene;
  60008. /**
  60009. * Creates a new instance of the component for the given scene
  60010. * @param scene Defines the scene to register the component in
  60011. */
  60012. constructor(scene: Scene);
  60013. /**
  60014. * Registers the component in a given scene
  60015. */
  60016. register(): void;
  60017. /**
  60018. * Rebuilds the elements related to this component in case of
  60019. * context lost for instance.
  60020. */
  60021. rebuild(): void;
  60022. /**
  60023. * Disposes the component and the associated ressources
  60024. */
  60025. dispose(): void;
  60026. private _gatherRenderTargets;
  60027. }
  60028. }
  60029. declare module BABYLON {
  60030. /**
  60031. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  60032. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  60033. */
  60034. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  60035. private _scene;
  60036. private _camerasToBeAttached;
  60037. /**
  60038. * ID of the sharpen post process,
  60039. */
  60040. private readonly SharpenPostProcessId;
  60041. /**
  60042. * @ignore
  60043. * ID of the image processing post process;
  60044. */
  60045. readonly ImageProcessingPostProcessId: string;
  60046. /**
  60047. * @ignore
  60048. * ID of the Fast Approximate Anti-Aliasing post process;
  60049. */
  60050. readonly FxaaPostProcessId: string;
  60051. /**
  60052. * ID of the chromatic aberration post process,
  60053. */
  60054. private readonly ChromaticAberrationPostProcessId;
  60055. /**
  60056. * ID of the grain post process
  60057. */
  60058. private readonly GrainPostProcessId;
  60059. /**
  60060. * Sharpen post process which will apply a sharpen convolution to enhance edges
  60061. */
  60062. sharpen: SharpenPostProcess;
  60063. private _sharpenEffect;
  60064. private bloom;
  60065. /**
  60066. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  60067. */
  60068. depthOfField: DepthOfFieldEffect;
  60069. /**
  60070. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  60071. */
  60072. fxaa: FxaaPostProcess;
  60073. /**
  60074. * Image post processing pass used to perform operations such as tone mapping or color grading.
  60075. */
  60076. imageProcessing: ImageProcessingPostProcess;
  60077. /**
  60078. * Chromatic aberration post process which will shift rgb colors in the image
  60079. */
  60080. chromaticAberration: ChromaticAberrationPostProcess;
  60081. private _chromaticAberrationEffect;
  60082. /**
  60083. * Grain post process which add noise to the image
  60084. */
  60085. grain: GrainPostProcess;
  60086. private _grainEffect;
  60087. /**
  60088. * Glow post process which adds a glow to emissive areas of the image
  60089. */
  60090. private _glowLayer;
  60091. /**
  60092. * Animations which can be used to tweak settings over a period of time
  60093. */
  60094. animations: Animation[];
  60095. private _imageProcessingConfigurationObserver;
  60096. private _sharpenEnabled;
  60097. private _bloomEnabled;
  60098. private _depthOfFieldEnabled;
  60099. private _depthOfFieldBlurLevel;
  60100. private _fxaaEnabled;
  60101. private _imageProcessingEnabled;
  60102. private _defaultPipelineTextureType;
  60103. private _bloomScale;
  60104. private _chromaticAberrationEnabled;
  60105. private _grainEnabled;
  60106. private _buildAllowed;
  60107. /**
  60108. * Gets active scene
  60109. */
  60110. readonly scene: Scene;
  60111. /**
  60112. * Enable or disable the sharpen process from the pipeline
  60113. */
  60114. sharpenEnabled: boolean;
  60115. private _resizeObserver;
  60116. private _hardwareScaleLevel;
  60117. private _bloomKernel;
  60118. /**
  60119. * Specifies the size of the bloom blur kernel, relative to the final output size
  60120. */
  60121. bloomKernel: number;
  60122. /**
  60123. * Specifies the weight of the bloom in the final rendering
  60124. */
  60125. private _bloomWeight;
  60126. /**
  60127. * Specifies the luma threshold for the area that will be blurred by the bloom
  60128. */
  60129. private _bloomThreshold;
  60130. private _hdr;
  60131. /**
  60132. * The strength of the bloom.
  60133. */
  60134. bloomWeight: number;
  60135. /**
  60136. * The strength of the bloom.
  60137. */
  60138. bloomThreshold: number;
  60139. /**
  60140. * The scale of the bloom, lower value will provide better performance.
  60141. */
  60142. bloomScale: number;
  60143. /**
  60144. * Enable or disable the bloom from the pipeline
  60145. */
  60146. bloomEnabled: boolean;
  60147. private _rebuildBloom;
  60148. /**
  60149. * If the depth of field is enabled.
  60150. */
  60151. depthOfFieldEnabled: boolean;
  60152. /**
  60153. * Blur level of the depth of field effect. (Higher blur will effect performance)
  60154. */
  60155. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  60156. /**
  60157. * If the anti aliasing is enabled.
  60158. */
  60159. fxaaEnabled: boolean;
  60160. private _samples;
  60161. /**
  60162. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  60163. */
  60164. samples: number;
  60165. /**
  60166. * If image processing is enabled.
  60167. */
  60168. imageProcessingEnabled: boolean;
  60169. /**
  60170. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  60171. */
  60172. glowLayerEnabled: boolean;
  60173. /**
  60174. * Gets the glow layer (or null if not defined)
  60175. */
  60176. readonly glowLayer: Nullable<GlowLayer>;
  60177. /**
  60178. * Enable or disable the chromaticAberration process from the pipeline
  60179. */
  60180. chromaticAberrationEnabled: boolean;
  60181. /**
  60182. * Enable or disable the grain process from the pipeline
  60183. */
  60184. grainEnabled: boolean;
  60185. /**
  60186. * @constructor
  60187. * @param name - The rendering pipeline name (default: "")
  60188. * @param hdr - If high dynamic range textures should be used (default: true)
  60189. * @param scene - The scene linked to this pipeline (default: the last created scene)
  60190. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  60191. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  60192. */
  60193. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  60194. /**
  60195. * Get the class name
  60196. * @returns "DefaultRenderingPipeline"
  60197. */
  60198. getClassName(): string;
  60199. /**
  60200. * Force the compilation of the entire pipeline.
  60201. */
  60202. prepare(): void;
  60203. private _hasCleared;
  60204. private _prevPostProcess;
  60205. private _prevPrevPostProcess;
  60206. private _setAutoClearAndTextureSharing;
  60207. private _depthOfFieldSceneObserver;
  60208. private _buildPipeline;
  60209. private _disposePostProcesses;
  60210. /**
  60211. * Adds a camera to the pipeline
  60212. * @param camera the camera to be added
  60213. */
  60214. addCamera(camera: Camera): void;
  60215. /**
  60216. * Removes a camera from the pipeline
  60217. * @param camera the camera to remove
  60218. */
  60219. removeCamera(camera: Camera): void;
  60220. /**
  60221. * Dispose of the pipeline and stop all post processes
  60222. */
  60223. dispose(): void;
  60224. /**
  60225. * Serialize the rendering pipeline (Used when exporting)
  60226. * @returns the serialized object
  60227. */
  60228. serialize(): any;
  60229. /**
  60230. * Parse the serialized pipeline
  60231. * @param source Source pipeline.
  60232. * @param scene The scene to load the pipeline to.
  60233. * @param rootUrl The URL of the serialized pipeline.
  60234. * @returns An instantiated pipeline from the serialized object.
  60235. */
  60236. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  60237. }
  60238. }
  60239. declare module BABYLON {
  60240. /** @hidden */
  60241. export var lensHighlightsPixelShader: {
  60242. name: string;
  60243. shader: string;
  60244. };
  60245. }
  60246. declare module BABYLON {
  60247. /** @hidden */
  60248. export var depthOfFieldPixelShader: {
  60249. name: string;
  60250. shader: string;
  60251. };
  60252. }
  60253. declare module BABYLON {
  60254. /**
  60255. * BABYLON.JS Chromatic Aberration GLSL Shader
  60256. * Author: Olivier Guyot
  60257. * Separates very slightly R, G and B colors on the edges of the screen
  60258. * Inspired by Francois Tarlier & Martins Upitis
  60259. */
  60260. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  60261. /**
  60262. * @ignore
  60263. * The chromatic aberration PostProcess id in the pipeline
  60264. */
  60265. LensChromaticAberrationEffect: string;
  60266. /**
  60267. * @ignore
  60268. * The highlights enhancing PostProcess id in the pipeline
  60269. */
  60270. HighlightsEnhancingEffect: string;
  60271. /**
  60272. * @ignore
  60273. * The depth-of-field PostProcess id in the pipeline
  60274. */
  60275. LensDepthOfFieldEffect: string;
  60276. private _scene;
  60277. private _depthTexture;
  60278. private _grainTexture;
  60279. private _chromaticAberrationPostProcess;
  60280. private _highlightsPostProcess;
  60281. private _depthOfFieldPostProcess;
  60282. private _edgeBlur;
  60283. private _grainAmount;
  60284. private _chromaticAberration;
  60285. private _distortion;
  60286. private _highlightsGain;
  60287. private _highlightsThreshold;
  60288. private _dofDistance;
  60289. private _dofAperture;
  60290. private _dofDarken;
  60291. private _dofPentagon;
  60292. private _blurNoise;
  60293. /**
  60294. * @constructor
  60295. *
  60296. * Effect parameters are as follow:
  60297. * {
  60298. * chromatic_aberration: number; // from 0 to x (1 for realism)
  60299. * edge_blur: number; // from 0 to x (1 for realism)
  60300. * distortion: number; // from 0 to x (1 for realism)
  60301. * grain_amount: number; // from 0 to 1
  60302. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  60303. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  60304. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  60305. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  60306. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  60307. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  60308. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  60309. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  60310. * }
  60311. * Note: if an effect parameter is unset, effect is disabled
  60312. *
  60313. * @param name The rendering pipeline name
  60314. * @param parameters - An object containing all parameters (see above)
  60315. * @param scene The scene linked to this pipeline
  60316. * @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)
  60317. * @param cameras The array of cameras that the rendering pipeline will be attached to
  60318. */
  60319. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  60320. /**
  60321. * Get the class name
  60322. * @returns "LensRenderingPipeline"
  60323. */
  60324. getClassName(): string;
  60325. /**
  60326. * Gets associated scene
  60327. */
  60328. readonly scene: Scene;
  60329. /**
  60330. * Gets or sets the edge blur
  60331. */
  60332. edgeBlur: number;
  60333. /**
  60334. * Gets or sets the grain amount
  60335. */
  60336. grainAmount: number;
  60337. /**
  60338. * Gets or sets the chromatic aberration amount
  60339. */
  60340. chromaticAberration: number;
  60341. /**
  60342. * Gets or sets the depth of field aperture
  60343. */
  60344. dofAperture: number;
  60345. /**
  60346. * Gets or sets the edge distortion
  60347. */
  60348. edgeDistortion: number;
  60349. /**
  60350. * Gets or sets the depth of field distortion
  60351. */
  60352. dofDistortion: number;
  60353. /**
  60354. * Gets or sets the darken out of focus amount
  60355. */
  60356. darkenOutOfFocus: number;
  60357. /**
  60358. * Gets or sets a boolean indicating if blur noise is enabled
  60359. */
  60360. blurNoise: boolean;
  60361. /**
  60362. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  60363. */
  60364. pentagonBokeh: boolean;
  60365. /**
  60366. * Gets or sets the highlight grain amount
  60367. */
  60368. highlightsGain: number;
  60369. /**
  60370. * Gets or sets the highlight threshold
  60371. */
  60372. highlightsThreshold: number;
  60373. /**
  60374. * Sets the amount of blur at the edges
  60375. * @param amount blur amount
  60376. */
  60377. setEdgeBlur(amount: number): void;
  60378. /**
  60379. * Sets edge blur to 0
  60380. */
  60381. disableEdgeBlur(): void;
  60382. /**
  60383. * Sets the amout of grain
  60384. * @param amount Amount of grain
  60385. */
  60386. setGrainAmount(amount: number): void;
  60387. /**
  60388. * Set grain amount to 0
  60389. */
  60390. disableGrain(): void;
  60391. /**
  60392. * Sets the chromatic aberration amount
  60393. * @param amount amount of chromatic aberration
  60394. */
  60395. setChromaticAberration(amount: number): void;
  60396. /**
  60397. * Sets chromatic aberration amount to 0
  60398. */
  60399. disableChromaticAberration(): void;
  60400. /**
  60401. * Sets the EdgeDistortion amount
  60402. * @param amount amount of EdgeDistortion
  60403. */
  60404. setEdgeDistortion(amount: number): void;
  60405. /**
  60406. * Sets edge distortion to 0
  60407. */
  60408. disableEdgeDistortion(): void;
  60409. /**
  60410. * Sets the FocusDistance amount
  60411. * @param amount amount of FocusDistance
  60412. */
  60413. setFocusDistance(amount: number): void;
  60414. /**
  60415. * Disables depth of field
  60416. */
  60417. disableDepthOfField(): void;
  60418. /**
  60419. * Sets the Aperture amount
  60420. * @param amount amount of Aperture
  60421. */
  60422. setAperture(amount: number): void;
  60423. /**
  60424. * Sets the DarkenOutOfFocus amount
  60425. * @param amount amount of DarkenOutOfFocus
  60426. */
  60427. setDarkenOutOfFocus(amount: number): void;
  60428. private _pentagonBokehIsEnabled;
  60429. /**
  60430. * Creates a pentagon bokeh effect
  60431. */
  60432. enablePentagonBokeh(): void;
  60433. /**
  60434. * Disables the pentagon bokeh effect
  60435. */
  60436. disablePentagonBokeh(): void;
  60437. /**
  60438. * Enables noise blur
  60439. */
  60440. enableNoiseBlur(): void;
  60441. /**
  60442. * Disables noise blur
  60443. */
  60444. disableNoiseBlur(): void;
  60445. /**
  60446. * Sets the HighlightsGain amount
  60447. * @param amount amount of HighlightsGain
  60448. */
  60449. setHighlightsGain(amount: number): void;
  60450. /**
  60451. * Sets the HighlightsThreshold amount
  60452. * @param amount amount of HighlightsThreshold
  60453. */
  60454. setHighlightsThreshold(amount: number): void;
  60455. /**
  60456. * Disables highlights
  60457. */
  60458. disableHighlights(): void;
  60459. /**
  60460. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  60461. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  60462. */
  60463. dispose(disableDepthRender?: boolean): void;
  60464. private _createChromaticAberrationPostProcess;
  60465. private _createHighlightsPostProcess;
  60466. private _createDepthOfFieldPostProcess;
  60467. private _createGrainTexture;
  60468. }
  60469. }
  60470. declare module BABYLON {
  60471. /** @hidden */
  60472. export var ssao2PixelShader: {
  60473. name: string;
  60474. shader: string;
  60475. };
  60476. }
  60477. declare module BABYLON {
  60478. /** @hidden */
  60479. export var ssaoCombinePixelShader: {
  60480. name: string;
  60481. shader: string;
  60482. };
  60483. }
  60484. declare module BABYLON {
  60485. /**
  60486. * Render pipeline to produce ssao effect
  60487. */
  60488. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  60489. /**
  60490. * @ignore
  60491. * The PassPostProcess id in the pipeline that contains the original scene color
  60492. */
  60493. SSAOOriginalSceneColorEffect: string;
  60494. /**
  60495. * @ignore
  60496. * The SSAO PostProcess id in the pipeline
  60497. */
  60498. SSAORenderEffect: string;
  60499. /**
  60500. * @ignore
  60501. * The horizontal blur PostProcess id in the pipeline
  60502. */
  60503. SSAOBlurHRenderEffect: string;
  60504. /**
  60505. * @ignore
  60506. * The vertical blur PostProcess id in the pipeline
  60507. */
  60508. SSAOBlurVRenderEffect: string;
  60509. /**
  60510. * @ignore
  60511. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  60512. */
  60513. SSAOCombineRenderEffect: string;
  60514. /**
  60515. * The output strength of the SSAO post-process. Default value is 1.0.
  60516. */
  60517. totalStrength: number;
  60518. /**
  60519. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  60520. */
  60521. maxZ: number;
  60522. /**
  60523. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  60524. */
  60525. minZAspect: number;
  60526. private _samples;
  60527. /**
  60528. * Number of samples used for the SSAO calculations. Default value is 8
  60529. */
  60530. samples: number;
  60531. private _textureSamples;
  60532. /**
  60533. * Number of samples to use for antialiasing
  60534. */
  60535. textureSamples: number;
  60536. /**
  60537. * Ratio object used for SSAO ratio and blur ratio
  60538. */
  60539. private _ratio;
  60540. /**
  60541. * Dynamically generated sphere sampler.
  60542. */
  60543. private _sampleSphere;
  60544. /**
  60545. * Blur filter offsets
  60546. */
  60547. private _samplerOffsets;
  60548. private _expensiveBlur;
  60549. /**
  60550. * If bilateral blur should be used
  60551. */
  60552. expensiveBlur: boolean;
  60553. /**
  60554. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  60555. */
  60556. radius: number;
  60557. /**
  60558. * The base color of the SSAO post-process
  60559. * The final result is "base + ssao" between [0, 1]
  60560. */
  60561. base: number;
  60562. /**
  60563. * Support test.
  60564. */
  60565. static readonly IsSupported: boolean;
  60566. private _scene;
  60567. private _depthTexture;
  60568. private _normalTexture;
  60569. private _randomTexture;
  60570. private _originalColorPostProcess;
  60571. private _ssaoPostProcess;
  60572. private _blurHPostProcess;
  60573. private _blurVPostProcess;
  60574. private _ssaoCombinePostProcess;
  60575. private _firstUpdate;
  60576. /**
  60577. * Gets active scene
  60578. */
  60579. readonly scene: Scene;
  60580. /**
  60581. * @constructor
  60582. * @param name The rendering pipeline name
  60583. * @param scene The scene linked to this pipeline
  60584. * @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 }
  60585. * @param cameras The array of cameras that the rendering pipeline will be attached to
  60586. */
  60587. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  60588. /**
  60589. * Get the class name
  60590. * @returns "SSAO2RenderingPipeline"
  60591. */
  60592. getClassName(): string;
  60593. /**
  60594. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  60595. */
  60596. dispose(disableGeometryBufferRenderer?: boolean): void;
  60597. private _createBlurPostProcess;
  60598. /** @hidden */
  60599. _rebuild(): void;
  60600. private _bits;
  60601. private _radicalInverse_VdC;
  60602. private _hammersley;
  60603. private _hemisphereSample_uniform;
  60604. private _generateHemisphere;
  60605. private _createSSAOPostProcess;
  60606. private _createSSAOCombinePostProcess;
  60607. private _createRandomTexture;
  60608. /**
  60609. * Serialize the rendering pipeline (Used when exporting)
  60610. * @returns the serialized object
  60611. */
  60612. serialize(): any;
  60613. /**
  60614. * Parse the serialized pipeline
  60615. * @param source Source pipeline.
  60616. * @param scene The scene to load the pipeline to.
  60617. * @param rootUrl The URL of the serialized pipeline.
  60618. * @returns An instantiated pipeline from the serialized object.
  60619. */
  60620. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  60621. }
  60622. }
  60623. declare module BABYLON {
  60624. /** @hidden */
  60625. export var ssaoPixelShader: {
  60626. name: string;
  60627. shader: string;
  60628. };
  60629. }
  60630. declare module BABYLON {
  60631. /**
  60632. * Render pipeline to produce ssao effect
  60633. */
  60634. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  60635. /**
  60636. * @ignore
  60637. * The PassPostProcess id in the pipeline that contains the original scene color
  60638. */
  60639. SSAOOriginalSceneColorEffect: string;
  60640. /**
  60641. * @ignore
  60642. * The SSAO PostProcess id in the pipeline
  60643. */
  60644. SSAORenderEffect: string;
  60645. /**
  60646. * @ignore
  60647. * The horizontal blur PostProcess id in the pipeline
  60648. */
  60649. SSAOBlurHRenderEffect: string;
  60650. /**
  60651. * @ignore
  60652. * The vertical blur PostProcess id in the pipeline
  60653. */
  60654. SSAOBlurVRenderEffect: string;
  60655. /**
  60656. * @ignore
  60657. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  60658. */
  60659. SSAOCombineRenderEffect: string;
  60660. /**
  60661. * The output strength of the SSAO post-process. Default value is 1.0.
  60662. */
  60663. totalStrength: number;
  60664. /**
  60665. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  60666. */
  60667. radius: number;
  60668. /**
  60669. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  60670. * Must not be equal to fallOff and superior to fallOff.
  60671. * Default value is 0.0075
  60672. */
  60673. area: number;
  60674. /**
  60675. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  60676. * Must not be equal to area and inferior to area.
  60677. * Default value is 0.000001
  60678. */
  60679. fallOff: number;
  60680. /**
  60681. * The base color of the SSAO post-process
  60682. * The final result is "base + ssao" between [0, 1]
  60683. */
  60684. base: number;
  60685. private _scene;
  60686. private _depthTexture;
  60687. private _randomTexture;
  60688. private _originalColorPostProcess;
  60689. private _ssaoPostProcess;
  60690. private _blurHPostProcess;
  60691. private _blurVPostProcess;
  60692. private _ssaoCombinePostProcess;
  60693. private _firstUpdate;
  60694. /**
  60695. * Gets active scene
  60696. */
  60697. readonly scene: Scene;
  60698. /**
  60699. * @constructor
  60700. * @param name - The rendering pipeline name
  60701. * @param scene - The scene linked to this pipeline
  60702. * @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 }
  60703. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  60704. */
  60705. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  60706. /**
  60707. * Get the class name
  60708. * @returns "SSAORenderingPipeline"
  60709. */
  60710. getClassName(): string;
  60711. /**
  60712. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  60713. */
  60714. dispose(disableDepthRender?: boolean): void;
  60715. private _createBlurPostProcess;
  60716. /** @hidden */
  60717. _rebuild(): void;
  60718. private _createSSAOPostProcess;
  60719. private _createSSAOCombinePostProcess;
  60720. private _createRandomTexture;
  60721. }
  60722. }
  60723. declare module BABYLON {
  60724. /** @hidden */
  60725. export var standardPixelShader: {
  60726. name: string;
  60727. shader: string;
  60728. };
  60729. }
  60730. declare module BABYLON {
  60731. /**
  60732. * Standard rendering pipeline
  60733. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  60734. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  60735. */
  60736. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  60737. /**
  60738. * Public members
  60739. */
  60740. /**
  60741. * Post-process which contains the original scene color before the pipeline applies all the effects
  60742. */
  60743. originalPostProcess: Nullable<PostProcess>;
  60744. /**
  60745. * Post-process used to down scale an image x4
  60746. */
  60747. downSampleX4PostProcess: Nullable<PostProcess>;
  60748. /**
  60749. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  60750. */
  60751. brightPassPostProcess: Nullable<PostProcess>;
  60752. /**
  60753. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  60754. */
  60755. blurHPostProcesses: PostProcess[];
  60756. /**
  60757. * Post-process array storing all the vertical blur post-processes used by the pipeline
  60758. */
  60759. blurVPostProcesses: PostProcess[];
  60760. /**
  60761. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  60762. */
  60763. textureAdderPostProcess: Nullable<PostProcess>;
  60764. /**
  60765. * Post-process used to create volumetric lighting effect
  60766. */
  60767. volumetricLightPostProcess: Nullable<PostProcess>;
  60768. /**
  60769. * Post-process used to smooth the previous volumetric light post-process on the X axis
  60770. */
  60771. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  60772. /**
  60773. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  60774. */
  60775. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  60776. /**
  60777. * Post-process used to merge the volumetric light effect and the real scene color
  60778. */
  60779. volumetricLightMergePostProces: Nullable<PostProcess>;
  60780. /**
  60781. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  60782. */
  60783. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  60784. /**
  60785. * Base post-process used to calculate the average luminance of the final image for HDR
  60786. */
  60787. luminancePostProcess: Nullable<PostProcess>;
  60788. /**
  60789. * Post-processes used to create down sample post-processes in order to get
  60790. * the average luminance of the final image for HDR
  60791. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  60792. */
  60793. luminanceDownSamplePostProcesses: PostProcess[];
  60794. /**
  60795. * Post-process used to create a HDR effect (light adaptation)
  60796. */
  60797. hdrPostProcess: Nullable<PostProcess>;
  60798. /**
  60799. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  60800. */
  60801. textureAdderFinalPostProcess: Nullable<PostProcess>;
  60802. /**
  60803. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  60804. */
  60805. lensFlareFinalPostProcess: Nullable<PostProcess>;
  60806. /**
  60807. * Post-process used to merge the final HDR post-process and the real scene color
  60808. */
  60809. hdrFinalPostProcess: Nullable<PostProcess>;
  60810. /**
  60811. * Post-process used to create a lens flare effect
  60812. */
  60813. lensFlarePostProcess: Nullable<PostProcess>;
  60814. /**
  60815. * Post-process that merges the result of the lens flare post-process and the real scene color
  60816. */
  60817. lensFlareComposePostProcess: Nullable<PostProcess>;
  60818. /**
  60819. * Post-process used to create a motion blur effect
  60820. */
  60821. motionBlurPostProcess: Nullable<PostProcess>;
  60822. /**
  60823. * Post-process used to create a depth of field effect
  60824. */
  60825. depthOfFieldPostProcess: Nullable<PostProcess>;
  60826. /**
  60827. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  60828. */
  60829. fxaaPostProcess: Nullable<FxaaPostProcess>;
  60830. /**
  60831. * Represents the brightness threshold in order to configure the illuminated surfaces
  60832. */
  60833. brightThreshold: number;
  60834. /**
  60835. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  60836. */
  60837. blurWidth: number;
  60838. /**
  60839. * Sets if the blur for highlighted surfaces must be only horizontal
  60840. */
  60841. horizontalBlur: boolean;
  60842. /**
  60843. * Gets the overall exposure used by the pipeline
  60844. */
  60845. /**
  60846. * Sets the overall exposure used by the pipeline
  60847. */
  60848. exposure: number;
  60849. /**
  60850. * Texture used typically to simulate "dirty" on camera lens
  60851. */
  60852. lensTexture: Nullable<Texture>;
  60853. /**
  60854. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  60855. */
  60856. volumetricLightCoefficient: number;
  60857. /**
  60858. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  60859. */
  60860. volumetricLightPower: number;
  60861. /**
  60862. * Used the set the blur intensity to smooth the volumetric lights
  60863. */
  60864. volumetricLightBlurScale: number;
  60865. /**
  60866. * Light (spot or directional) used to generate the volumetric lights rays
  60867. * The source light must have a shadow generate so the pipeline can get its
  60868. * depth map
  60869. */
  60870. sourceLight: Nullable<SpotLight | DirectionalLight>;
  60871. /**
  60872. * For eye adaptation, represents the minimum luminance the eye can see
  60873. */
  60874. hdrMinimumLuminance: number;
  60875. /**
  60876. * For eye adaptation, represents the decrease luminance speed
  60877. */
  60878. hdrDecreaseRate: number;
  60879. /**
  60880. * For eye adaptation, represents the increase luminance speed
  60881. */
  60882. hdrIncreaseRate: number;
  60883. /**
  60884. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  60885. */
  60886. /**
  60887. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  60888. */
  60889. hdrAutoExposure: boolean;
  60890. /**
  60891. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  60892. */
  60893. lensColorTexture: Nullable<Texture>;
  60894. /**
  60895. * The overall strengh for the lens flare effect
  60896. */
  60897. lensFlareStrength: number;
  60898. /**
  60899. * Dispersion coefficient for lens flare ghosts
  60900. */
  60901. lensFlareGhostDispersal: number;
  60902. /**
  60903. * Main lens flare halo width
  60904. */
  60905. lensFlareHaloWidth: number;
  60906. /**
  60907. * Based on the lens distortion effect, defines how much the lens flare result
  60908. * is distorted
  60909. */
  60910. lensFlareDistortionStrength: number;
  60911. /**
  60912. * Configures the blur intensity used for for lens flare (halo)
  60913. */
  60914. lensFlareBlurWidth: number;
  60915. /**
  60916. * Lens star texture must be used to simulate rays on the flares and is available
  60917. * in the documentation
  60918. */
  60919. lensStarTexture: Nullable<Texture>;
  60920. /**
  60921. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  60922. * flare effect by taking account of the dirt texture
  60923. */
  60924. lensFlareDirtTexture: Nullable<Texture>;
  60925. /**
  60926. * Represents the focal length for the depth of field effect
  60927. */
  60928. depthOfFieldDistance: number;
  60929. /**
  60930. * Represents the blur intensity for the blurred part of the depth of field effect
  60931. */
  60932. depthOfFieldBlurWidth: number;
  60933. /**
  60934. * Gets how much the image is blurred by the movement while using the motion blur post-process
  60935. */
  60936. /**
  60937. * Sets how much the image is blurred by the movement while using the motion blur post-process
  60938. */
  60939. motionStrength: number;
  60940. /**
  60941. * Gets wether or not the motion blur post-process is object based or screen based.
  60942. */
  60943. /**
  60944. * Sets wether or not the motion blur post-process should be object based or screen based
  60945. */
  60946. objectBasedMotionBlur: boolean;
  60947. /**
  60948. * List of animations for the pipeline (IAnimatable implementation)
  60949. */
  60950. animations: Animation[];
  60951. /**
  60952. * Private members
  60953. */
  60954. private _scene;
  60955. private _currentDepthOfFieldSource;
  60956. private _basePostProcess;
  60957. private _fixedExposure;
  60958. private _currentExposure;
  60959. private _hdrAutoExposure;
  60960. private _hdrCurrentLuminance;
  60961. private _motionStrength;
  60962. private _isObjectBasedMotionBlur;
  60963. private _floatTextureType;
  60964. private _camerasToBeAttached;
  60965. private _ratio;
  60966. private _bloomEnabled;
  60967. private _depthOfFieldEnabled;
  60968. private _vlsEnabled;
  60969. private _lensFlareEnabled;
  60970. private _hdrEnabled;
  60971. private _motionBlurEnabled;
  60972. private _fxaaEnabled;
  60973. private _motionBlurSamples;
  60974. private _volumetricLightStepsCount;
  60975. private _samples;
  60976. /**
  60977. * @ignore
  60978. * Specifies if the bloom pipeline is enabled
  60979. */
  60980. BloomEnabled: boolean;
  60981. /**
  60982. * @ignore
  60983. * Specifies if the depth of field pipeline is enabed
  60984. */
  60985. DepthOfFieldEnabled: boolean;
  60986. /**
  60987. * @ignore
  60988. * Specifies if the lens flare pipeline is enabed
  60989. */
  60990. LensFlareEnabled: boolean;
  60991. /**
  60992. * @ignore
  60993. * Specifies if the HDR pipeline is enabled
  60994. */
  60995. HDREnabled: boolean;
  60996. /**
  60997. * @ignore
  60998. * Specifies if the volumetric lights scattering effect is enabled
  60999. */
  61000. VLSEnabled: boolean;
  61001. /**
  61002. * @ignore
  61003. * Specifies if the motion blur effect is enabled
  61004. */
  61005. MotionBlurEnabled: boolean;
  61006. /**
  61007. * Specifies if anti-aliasing is enabled
  61008. */
  61009. fxaaEnabled: boolean;
  61010. /**
  61011. * Specifies the number of steps used to calculate the volumetric lights
  61012. * Typically in interval [50, 200]
  61013. */
  61014. volumetricLightStepsCount: number;
  61015. /**
  61016. * Specifies the number of samples used for the motion blur effect
  61017. * Typically in interval [16, 64]
  61018. */
  61019. motionBlurSamples: number;
  61020. /**
  61021. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  61022. */
  61023. samples: number;
  61024. /**
  61025. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  61026. * @constructor
  61027. * @param name The rendering pipeline name
  61028. * @param scene The scene linked to this pipeline
  61029. * @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)
  61030. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  61031. * @param cameras The array of cameras that the rendering pipeline will be attached to
  61032. */
  61033. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  61034. private _buildPipeline;
  61035. private _createDownSampleX4PostProcess;
  61036. private _createBrightPassPostProcess;
  61037. private _createBlurPostProcesses;
  61038. private _createTextureAdderPostProcess;
  61039. private _createVolumetricLightPostProcess;
  61040. private _createLuminancePostProcesses;
  61041. private _createHdrPostProcess;
  61042. private _createLensFlarePostProcess;
  61043. private _createDepthOfFieldPostProcess;
  61044. private _createMotionBlurPostProcess;
  61045. private _getDepthTexture;
  61046. private _disposePostProcesses;
  61047. /**
  61048. * Dispose of the pipeline and stop all post processes
  61049. */
  61050. dispose(): void;
  61051. /**
  61052. * Serialize the rendering pipeline (Used when exporting)
  61053. * @returns the serialized object
  61054. */
  61055. serialize(): any;
  61056. /**
  61057. * Parse the serialized pipeline
  61058. * @param source Source pipeline.
  61059. * @param scene The scene to load the pipeline to.
  61060. * @param rootUrl The URL of the serialized pipeline.
  61061. * @returns An instantiated pipeline from the serialized object.
  61062. */
  61063. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  61064. /**
  61065. * Luminance steps
  61066. */
  61067. static LuminanceSteps: number;
  61068. }
  61069. }
  61070. declare module BABYLON {
  61071. /** @hidden */
  61072. export var tonemapPixelShader: {
  61073. name: string;
  61074. shader: string;
  61075. };
  61076. }
  61077. declare module BABYLON {
  61078. /** Defines operator used for tonemapping */
  61079. export enum TonemappingOperator {
  61080. /** Hable */
  61081. Hable = 0,
  61082. /** Reinhard */
  61083. Reinhard = 1,
  61084. /** HejiDawson */
  61085. HejiDawson = 2,
  61086. /** Photographic */
  61087. Photographic = 3
  61088. }
  61089. /**
  61090. * Defines a post process to apply tone mapping
  61091. */
  61092. export class TonemapPostProcess extends PostProcess {
  61093. private _operator;
  61094. /** Defines the required exposure adjustement */
  61095. exposureAdjustment: number;
  61096. /**
  61097. * Creates a new TonemapPostProcess
  61098. * @param name defines the name of the postprocess
  61099. * @param _operator defines the operator to use
  61100. * @param exposureAdjustment defines the required exposure adjustement
  61101. * @param camera defines the camera to use (can be null)
  61102. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  61103. * @param engine defines the hosting engine (can be ignore if camera is set)
  61104. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  61105. */
  61106. constructor(name: string, _operator: TonemappingOperator,
  61107. /** Defines the required exposure adjustement */
  61108. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  61109. }
  61110. }
  61111. declare module BABYLON {
  61112. /** @hidden */
  61113. export var depthVertexShader: {
  61114. name: string;
  61115. shader: string;
  61116. };
  61117. }
  61118. declare module BABYLON {
  61119. /** @hidden */
  61120. export var volumetricLightScatteringPixelShader: {
  61121. name: string;
  61122. shader: string;
  61123. };
  61124. }
  61125. declare module BABYLON {
  61126. /** @hidden */
  61127. export var volumetricLightScatteringPassVertexShader: {
  61128. name: string;
  61129. shader: string;
  61130. };
  61131. }
  61132. declare module BABYLON {
  61133. /** @hidden */
  61134. export var volumetricLightScatteringPassPixelShader: {
  61135. name: string;
  61136. shader: string;
  61137. };
  61138. }
  61139. declare module BABYLON {
  61140. /**
  61141. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  61142. */
  61143. export class VolumetricLightScatteringPostProcess extends PostProcess {
  61144. private _volumetricLightScatteringPass;
  61145. private _volumetricLightScatteringRTT;
  61146. private _viewPort;
  61147. private _screenCoordinates;
  61148. private _cachedDefines;
  61149. /**
  61150. * If not undefined, the mesh position is computed from the attached node position
  61151. */
  61152. attachedNode: {
  61153. position: Vector3;
  61154. };
  61155. /**
  61156. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  61157. */
  61158. customMeshPosition: Vector3;
  61159. /**
  61160. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  61161. */
  61162. useCustomMeshPosition: boolean;
  61163. /**
  61164. * If the post-process should inverse the light scattering direction
  61165. */
  61166. invert: boolean;
  61167. /**
  61168. * The internal mesh used by the post-process
  61169. */
  61170. mesh: Mesh;
  61171. /**
  61172. * @hidden
  61173. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  61174. */
  61175. useDiffuseColor: boolean;
  61176. /**
  61177. * Array containing the excluded meshes not rendered in the internal pass
  61178. */
  61179. excludedMeshes: AbstractMesh[];
  61180. /**
  61181. * Controls the overall intensity of the post-process
  61182. */
  61183. exposure: number;
  61184. /**
  61185. * Dissipates each sample's contribution in range [0, 1]
  61186. */
  61187. decay: number;
  61188. /**
  61189. * Controls the overall intensity of each sample
  61190. */
  61191. weight: number;
  61192. /**
  61193. * Controls the density of each sample
  61194. */
  61195. density: number;
  61196. /**
  61197. * @constructor
  61198. * @param name The post-process name
  61199. * @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)
  61200. * @param camera The camera that the post-process will be attached to
  61201. * @param mesh The mesh used to create the light scattering
  61202. * @param samples The post-process quality, default 100
  61203. * @param samplingModeThe post-process filtering mode
  61204. * @param engine The babylon engine
  61205. * @param reusable If the post-process is reusable
  61206. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  61207. */
  61208. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  61209. /**
  61210. * Returns the string "VolumetricLightScatteringPostProcess"
  61211. * @returns "VolumetricLightScatteringPostProcess"
  61212. */
  61213. getClassName(): string;
  61214. private _isReady;
  61215. /**
  61216. * Sets the new light position for light scattering effect
  61217. * @param position The new custom light position
  61218. */
  61219. setCustomMeshPosition(position: Vector3): void;
  61220. /**
  61221. * Returns the light position for light scattering effect
  61222. * @return Vector3 The custom light position
  61223. */
  61224. getCustomMeshPosition(): Vector3;
  61225. /**
  61226. * Disposes the internal assets and detaches the post-process from the camera
  61227. */
  61228. dispose(camera: Camera): void;
  61229. /**
  61230. * Returns the render target texture used by the post-process
  61231. * @return the render target texture used by the post-process
  61232. */
  61233. getPass(): RenderTargetTexture;
  61234. private _meshExcluded;
  61235. private _createPass;
  61236. private _updateMeshScreenCoordinates;
  61237. /**
  61238. * Creates a default mesh for the Volumeric Light Scattering post-process
  61239. * @param name The mesh name
  61240. * @param scene The scene where to create the mesh
  61241. * @return the default mesh
  61242. */
  61243. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  61244. }
  61245. }
  61246. declare module BABYLON {
  61247. interface Scene {
  61248. /** @hidden (Backing field) */
  61249. _boundingBoxRenderer: BoundingBoxRenderer;
  61250. /** @hidden (Backing field) */
  61251. _forceShowBoundingBoxes: boolean;
  61252. /**
  61253. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  61254. */
  61255. forceShowBoundingBoxes: boolean;
  61256. /**
  61257. * Gets the bounding box renderer associated with the scene
  61258. * @returns a BoundingBoxRenderer
  61259. */
  61260. getBoundingBoxRenderer(): BoundingBoxRenderer;
  61261. }
  61262. interface AbstractMesh {
  61263. /** @hidden (Backing field) */
  61264. _showBoundingBox: boolean;
  61265. /**
  61266. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  61267. */
  61268. showBoundingBox: boolean;
  61269. }
  61270. /**
  61271. * Component responsible of rendering the bounding box of the meshes in a scene.
  61272. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  61273. */
  61274. export class BoundingBoxRenderer implements ISceneComponent {
  61275. /**
  61276. * The component name helpfull to identify the component in the list of scene components.
  61277. */
  61278. readonly name: string;
  61279. /**
  61280. * The scene the component belongs to.
  61281. */
  61282. scene: Scene;
  61283. /**
  61284. * Color of the bounding box lines placed in front of an object
  61285. */
  61286. frontColor: Color3;
  61287. /**
  61288. * Color of the bounding box lines placed behind an object
  61289. */
  61290. backColor: Color3;
  61291. /**
  61292. * Defines if the renderer should show the back lines or not
  61293. */
  61294. showBackLines: boolean;
  61295. /**
  61296. * @hidden
  61297. */
  61298. renderList: SmartArray<BoundingBox>;
  61299. private _colorShader;
  61300. private _vertexBuffers;
  61301. private _indexBuffer;
  61302. private _fillIndexBuffer;
  61303. private _fillIndexData;
  61304. /**
  61305. * Instantiates a new bounding box renderer in a scene.
  61306. * @param scene the scene the renderer renders in
  61307. */
  61308. constructor(scene: Scene);
  61309. /**
  61310. * Registers the component in a given scene
  61311. */
  61312. register(): void;
  61313. private _evaluateSubMesh;
  61314. private _activeMesh;
  61315. private _prepareRessources;
  61316. private _createIndexBuffer;
  61317. /**
  61318. * Rebuilds the elements related to this component in case of
  61319. * context lost for instance.
  61320. */
  61321. rebuild(): void;
  61322. /**
  61323. * @hidden
  61324. */
  61325. reset(): void;
  61326. /**
  61327. * Render the bounding boxes of a specific rendering group
  61328. * @param renderingGroupId defines the rendering group to render
  61329. */
  61330. render(renderingGroupId: number): void;
  61331. /**
  61332. * In case of occlusion queries, we can render the occlusion bounding box through this method
  61333. * @param mesh Define the mesh to render the occlusion bounding box for
  61334. */
  61335. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  61336. /**
  61337. * Dispose and release the resources attached to this renderer.
  61338. */
  61339. dispose(): void;
  61340. }
  61341. }
  61342. declare module BABYLON {
  61343. /** @hidden */
  61344. export var depthPixelShader: {
  61345. name: string;
  61346. shader: string;
  61347. };
  61348. }
  61349. declare module BABYLON {
  61350. /**
  61351. * This represents a depth renderer in Babylon.
  61352. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  61353. */
  61354. export class DepthRenderer {
  61355. private _scene;
  61356. private _depthMap;
  61357. private _effect;
  61358. private readonly _storeNonLinearDepth;
  61359. private readonly _clearColor;
  61360. /** Get if the depth renderer is using packed depth or not */
  61361. readonly isPacked: boolean;
  61362. private _cachedDefines;
  61363. private _camera;
  61364. /**
  61365. * Specifiess that the depth renderer will only be used within
  61366. * the camera it is created for.
  61367. * This can help forcing its rendering during the camera processing.
  61368. */
  61369. useOnlyInActiveCamera: boolean;
  61370. /** @hidden */
  61371. static _SceneComponentInitialization: (scene: Scene) => void;
  61372. /**
  61373. * Instantiates a depth renderer
  61374. * @param scene The scene the renderer belongs to
  61375. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  61376. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  61377. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  61378. */
  61379. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  61380. /**
  61381. * Creates the depth rendering effect and checks if the effect is ready.
  61382. * @param subMesh The submesh to be used to render the depth map of
  61383. * @param useInstances If multiple world instances should be used
  61384. * @returns if the depth renderer is ready to render the depth map
  61385. */
  61386. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  61387. /**
  61388. * Gets the texture which the depth map will be written to.
  61389. * @returns The depth map texture
  61390. */
  61391. getDepthMap(): RenderTargetTexture;
  61392. /**
  61393. * Disposes of the depth renderer.
  61394. */
  61395. dispose(): void;
  61396. }
  61397. }
  61398. declare module BABYLON {
  61399. interface Scene {
  61400. /** @hidden (Backing field) */
  61401. _depthRenderer: {
  61402. [id: string]: DepthRenderer;
  61403. };
  61404. /**
  61405. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  61406. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  61407. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  61408. * @returns the created depth renderer
  61409. */
  61410. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  61411. /**
  61412. * Disables a depth renderer for a given camera
  61413. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  61414. */
  61415. disableDepthRenderer(camera?: Nullable<Camera>): void;
  61416. }
  61417. /**
  61418. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  61419. * in several rendering techniques.
  61420. */
  61421. export class DepthRendererSceneComponent implements ISceneComponent {
  61422. /**
  61423. * The component name helpfull to identify the component in the list of scene components.
  61424. */
  61425. readonly name: string;
  61426. /**
  61427. * The scene the component belongs to.
  61428. */
  61429. scene: Scene;
  61430. /**
  61431. * Creates a new instance of the component for the given scene
  61432. * @param scene Defines the scene to register the component in
  61433. */
  61434. constructor(scene: Scene);
  61435. /**
  61436. * Registers the component in a given scene
  61437. */
  61438. register(): void;
  61439. /**
  61440. * Rebuilds the elements related to this component in case of
  61441. * context lost for instance.
  61442. */
  61443. rebuild(): void;
  61444. /**
  61445. * Disposes the component and the associated ressources
  61446. */
  61447. dispose(): void;
  61448. private _gatherRenderTargets;
  61449. private _gatherActiveCameraRenderTargets;
  61450. }
  61451. }
  61452. declare module BABYLON {
  61453. /** @hidden */
  61454. export var outlinePixelShader: {
  61455. name: string;
  61456. shader: string;
  61457. };
  61458. }
  61459. declare module BABYLON {
  61460. /** @hidden */
  61461. export var outlineVertexShader: {
  61462. name: string;
  61463. shader: string;
  61464. };
  61465. }
  61466. declare module BABYLON {
  61467. interface Scene {
  61468. /** @hidden */
  61469. _outlineRenderer: OutlineRenderer;
  61470. /**
  61471. * Gets the outline renderer associated with the scene
  61472. * @returns a OutlineRenderer
  61473. */
  61474. getOutlineRenderer(): OutlineRenderer;
  61475. }
  61476. interface AbstractMesh {
  61477. /** @hidden (Backing field) */
  61478. _renderOutline: boolean;
  61479. /**
  61480. * Gets or sets a boolean indicating if the outline must be rendered as well
  61481. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  61482. */
  61483. renderOutline: boolean;
  61484. /** @hidden (Backing field) */
  61485. _renderOverlay: boolean;
  61486. /**
  61487. * Gets or sets a boolean indicating if the overlay must be rendered as well
  61488. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  61489. */
  61490. renderOverlay: boolean;
  61491. }
  61492. /**
  61493. * This class is responsible to draw bothe outline/overlay of meshes.
  61494. * It should not be used directly but through the available method on mesh.
  61495. */
  61496. export class OutlineRenderer implements ISceneComponent {
  61497. /**
  61498. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  61499. */
  61500. private static _StencilReference;
  61501. /**
  61502. * The name of the component. Each component must have a unique name.
  61503. */
  61504. name: string;
  61505. /**
  61506. * The scene the component belongs to.
  61507. */
  61508. scene: Scene;
  61509. /**
  61510. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  61511. */
  61512. zOffset: number;
  61513. private _engine;
  61514. private _effect;
  61515. private _cachedDefines;
  61516. private _savedDepthWrite;
  61517. /**
  61518. * Instantiates a new outline renderer. (There could be only one per scene).
  61519. * @param scene Defines the scene it belongs to
  61520. */
  61521. constructor(scene: Scene);
  61522. /**
  61523. * Register the component to one instance of a scene.
  61524. */
  61525. register(): void;
  61526. /**
  61527. * Rebuilds the elements related to this component in case of
  61528. * context lost for instance.
  61529. */
  61530. rebuild(): void;
  61531. /**
  61532. * Disposes the component and the associated ressources.
  61533. */
  61534. dispose(): void;
  61535. /**
  61536. * Renders the outline in the canvas.
  61537. * @param subMesh Defines the sumesh to render
  61538. * @param batch Defines the batch of meshes in case of instances
  61539. * @param useOverlay Defines if the rendering is for the overlay or the outline
  61540. */
  61541. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  61542. /**
  61543. * Returns whether or not the outline renderer is ready for a given submesh.
  61544. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  61545. * @param subMesh Defines the submesh to check readyness for
  61546. * @param useInstances Defines wheter wee are trying to render instances or not
  61547. * @returns true if ready otherwise false
  61548. */
  61549. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  61550. private _beforeRenderingMesh;
  61551. private _afterRenderingMesh;
  61552. }
  61553. }
  61554. declare module BABYLON {
  61555. /**
  61556. * Class used to manage multiple sprites of different sizes on the same spritesheet
  61557. * @see http://doc.babylonjs.com/babylon101/sprites
  61558. */
  61559. export class SpritePackedManager extends SpriteManager {
  61560. /** defines the packed manager's name */
  61561. name: string;
  61562. /**
  61563. * Creates a new sprite manager from a packed sprite sheet
  61564. * @param name defines the manager's name
  61565. * @param imgUrl defines the sprite sheet url
  61566. * @param capacity defines the maximum allowed number of sprites
  61567. * @param scene defines the hosting scene
  61568. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  61569. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  61570. * @param samplingMode defines the smapling mode to use with spritesheet
  61571. * @param fromPacked set to true; do not alter
  61572. */
  61573. constructor(
  61574. /** defines the packed manager's name */
  61575. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  61576. }
  61577. }
  61578. declare module BABYLON {
  61579. /**
  61580. * Defines the list of states available for a task inside a AssetsManager
  61581. */
  61582. export enum AssetTaskState {
  61583. /**
  61584. * Initialization
  61585. */
  61586. INIT = 0,
  61587. /**
  61588. * Running
  61589. */
  61590. RUNNING = 1,
  61591. /**
  61592. * Done
  61593. */
  61594. DONE = 2,
  61595. /**
  61596. * Error
  61597. */
  61598. ERROR = 3
  61599. }
  61600. /**
  61601. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  61602. */
  61603. export abstract class AbstractAssetTask {
  61604. /**
  61605. * Task name
  61606. */ name: string;
  61607. /**
  61608. * Callback called when the task is successful
  61609. */
  61610. onSuccess: (task: any) => void;
  61611. /**
  61612. * Callback called when the task is not successful
  61613. */
  61614. onError: (task: any, message?: string, exception?: any) => void;
  61615. /**
  61616. * Creates a new AssetsManager
  61617. * @param name defines the name of the task
  61618. */
  61619. constructor(
  61620. /**
  61621. * Task name
  61622. */ name: string);
  61623. private _isCompleted;
  61624. private _taskState;
  61625. private _errorObject;
  61626. /**
  61627. * Get if the task is completed
  61628. */
  61629. readonly isCompleted: boolean;
  61630. /**
  61631. * Gets the current state of the task
  61632. */
  61633. readonly taskState: AssetTaskState;
  61634. /**
  61635. * Gets the current error object (if task is in error)
  61636. */
  61637. readonly errorObject: {
  61638. message?: string;
  61639. exception?: any;
  61640. };
  61641. /**
  61642. * Internal only
  61643. * @hidden
  61644. */
  61645. _setErrorObject(message?: string, exception?: any): void;
  61646. /**
  61647. * Execute the current task
  61648. * @param scene defines the scene where you want your assets to be loaded
  61649. * @param onSuccess is a callback called when the task is successfully executed
  61650. * @param onError is a callback called if an error occurs
  61651. */
  61652. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  61653. /**
  61654. * Execute the current task
  61655. * @param scene defines the scene where you want your assets to be loaded
  61656. * @param onSuccess is a callback called when the task is successfully executed
  61657. * @param onError is a callback called if an error occurs
  61658. */
  61659. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  61660. /**
  61661. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  61662. * This can be used with failed tasks that have the reason for failure fixed.
  61663. */
  61664. reset(): void;
  61665. private onErrorCallback;
  61666. private onDoneCallback;
  61667. }
  61668. /**
  61669. * Define the interface used by progress events raised during assets loading
  61670. */
  61671. export interface IAssetsProgressEvent {
  61672. /**
  61673. * Defines the number of remaining tasks to process
  61674. */
  61675. remainingCount: number;
  61676. /**
  61677. * Defines the total number of tasks
  61678. */
  61679. totalCount: number;
  61680. /**
  61681. * Defines the task that was just processed
  61682. */
  61683. task: AbstractAssetTask;
  61684. }
  61685. /**
  61686. * Class used to share progress information about assets loading
  61687. */
  61688. export class AssetsProgressEvent implements IAssetsProgressEvent {
  61689. /**
  61690. * Defines the number of remaining tasks to process
  61691. */
  61692. remainingCount: number;
  61693. /**
  61694. * Defines the total number of tasks
  61695. */
  61696. totalCount: number;
  61697. /**
  61698. * Defines the task that was just processed
  61699. */
  61700. task: AbstractAssetTask;
  61701. /**
  61702. * Creates a AssetsProgressEvent
  61703. * @param remainingCount defines the number of remaining tasks to process
  61704. * @param totalCount defines the total number of tasks
  61705. * @param task defines the task that was just processed
  61706. */
  61707. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  61708. }
  61709. /**
  61710. * Define a task used by AssetsManager to load meshes
  61711. */
  61712. export class MeshAssetTask extends AbstractAssetTask {
  61713. /**
  61714. * Defines the name of the task
  61715. */
  61716. name: string;
  61717. /**
  61718. * Defines the list of mesh's names you want to load
  61719. */
  61720. meshesNames: any;
  61721. /**
  61722. * Defines the root url to use as a base to load your meshes and associated resources
  61723. */
  61724. rootUrl: string;
  61725. /**
  61726. * Defines the filename of the scene to load from
  61727. */
  61728. sceneFilename: string;
  61729. /**
  61730. * Gets the list of loaded meshes
  61731. */
  61732. loadedMeshes: Array<AbstractMesh>;
  61733. /**
  61734. * Gets the list of loaded particle systems
  61735. */
  61736. loadedParticleSystems: Array<IParticleSystem>;
  61737. /**
  61738. * Gets the list of loaded skeletons
  61739. */
  61740. loadedSkeletons: Array<Skeleton>;
  61741. /**
  61742. * Gets the list of loaded animation groups
  61743. */
  61744. loadedAnimationGroups: Array<AnimationGroup>;
  61745. /**
  61746. * Callback called when the task is successful
  61747. */
  61748. onSuccess: (task: MeshAssetTask) => void;
  61749. /**
  61750. * Callback called when the task is successful
  61751. */
  61752. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  61753. /**
  61754. * Creates a new MeshAssetTask
  61755. * @param name defines the name of the task
  61756. * @param meshesNames defines the list of mesh's names you want to load
  61757. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  61758. * @param sceneFilename defines the filename of the scene to load from
  61759. */
  61760. constructor(
  61761. /**
  61762. * Defines the name of the task
  61763. */
  61764. name: string,
  61765. /**
  61766. * Defines the list of mesh's names you want to load
  61767. */
  61768. meshesNames: any,
  61769. /**
  61770. * Defines the root url to use as a base to load your meshes and associated resources
  61771. */
  61772. rootUrl: string,
  61773. /**
  61774. * Defines the filename of the scene to load from
  61775. */
  61776. sceneFilename: string);
  61777. /**
  61778. * Execute the current task
  61779. * @param scene defines the scene where you want your assets to be loaded
  61780. * @param onSuccess is a callback called when the task is successfully executed
  61781. * @param onError is a callback called if an error occurs
  61782. */
  61783. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  61784. }
  61785. /**
  61786. * Define a task used by AssetsManager to load text content
  61787. */
  61788. export class TextFileAssetTask extends AbstractAssetTask {
  61789. /**
  61790. * Defines the name of the task
  61791. */
  61792. name: string;
  61793. /**
  61794. * Defines the location of the file to load
  61795. */
  61796. url: string;
  61797. /**
  61798. * Gets the loaded text string
  61799. */
  61800. text: string;
  61801. /**
  61802. * Callback called when the task is successful
  61803. */
  61804. onSuccess: (task: TextFileAssetTask) => void;
  61805. /**
  61806. * Callback called when the task is successful
  61807. */
  61808. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  61809. /**
  61810. * Creates a new TextFileAssetTask object
  61811. * @param name defines the name of the task
  61812. * @param url defines the location of the file to load
  61813. */
  61814. constructor(
  61815. /**
  61816. * Defines the name of the task
  61817. */
  61818. name: string,
  61819. /**
  61820. * Defines the location of the file to load
  61821. */
  61822. url: string);
  61823. /**
  61824. * Execute the current task
  61825. * @param scene defines the scene where you want your assets to be loaded
  61826. * @param onSuccess is a callback called when the task is successfully executed
  61827. * @param onError is a callback called if an error occurs
  61828. */
  61829. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  61830. }
  61831. /**
  61832. * Define a task used by AssetsManager to load binary data
  61833. */
  61834. export class BinaryFileAssetTask extends AbstractAssetTask {
  61835. /**
  61836. * Defines the name of the task
  61837. */
  61838. name: string;
  61839. /**
  61840. * Defines the location of the file to load
  61841. */
  61842. url: string;
  61843. /**
  61844. * Gets the lodaded data (as an array buffer)
  61845. */
  61846. data: ArrayBuffer;
  61847. /**
  61848. * Callback called when the task is successful
  61849. */
  61850. onSuccess: (task: BinaryFileAssetTask) => void;
  61851. /**
  61852. * Callback called when the task is successful
  61853. */
  61854. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  61855. /**
  61856. * Creates a new BinaryFileAssetTask object
  61857. * @param name defines the name of the new task
  61858. * @param url defines the location of the file to load
  61859. */
  61860. constructor(
  61861. /**
  61862. * Defines the name of the task
  61863. */
  61864. name: string,
  61865. /**
  61866. * Defines the location of the file to load
  61867. */
  61868. url: string);
  61869. /**
  61870. * Execute the current task
  61871. * @param scene defines the scene where you want your assets to be loaded
  61872. * @param onSuccess is a callback called when the task is successfully executed
  61873. * @param onError is a callback called if an error occurs
  61874. */
  61875. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  61876. }
  61877. /**
  61878. * Define a task used by AssetsManager to load images
  61879. */
  61880. export class ImageAssetTask extends AbstractAssetTask {
  61881. /**
  61882. * Defines the name of the task
  61883. */
  61884. name: string;
  61885. /**
  61886. * Defines the location of the image to load
  61887. */
  61888. url: string;
  61889. /**
  61890. * Gets the loaded images
  61891. */
  61892. image: HTMLImageElement;
  61893. /**
  61894. * Callback called when the task is successful
  61895. */
  61896. onSuccess: (task: ImageAssetTask) => void;
  61897. /**
  61898. * Callback called when the task is successful
  61899. */
  61900. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  61901. /**
  61902. * Creates a new ImageAssetTask
  61903. * @param name defines the name of the task
  61904. * @param url defines the location of the image to load
  61905. */
  61906. constructor(
  61907. /**
  61908. * Defines the name of the task
  61909. */
  61910. name: string,
  61911. /**
  61912. * Defines the location of the image to load
  61913. */
  61914. url: string);
  61915. /**
  61916. * Execute the current task
  61917. * @param scene defines the scene where you want your assets to be loaded
  61918. * @param onSuccess is a callback called when the task is successfully executed
  61919. * @param onError is a callback called if an error occurs
  61920. */
  61921. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  61922. }
  61923. /**
  61924. * Defines the interface used by texture loading tasks
  61925. */
  61926. export interface ITextureAssetTask<TEX extends BaseTexture> {
  61927. /**
  61928. * Gets the loaded texture
  61929. */
  61930. texture: TEX;
  61931. }
  61932. /**
  61933. * Define a task used by AssetsManager to load 2D textures
  61934. */
  61935. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  61936. /**
  61937. * Defines the name of the task
  61938. */
  61939. name: string;
  61940. /**
  61941. * Defines the location of the file to load
  61942. */
  61943. url: string;
  61944. /**
  61945. * Defines if mipmap should not be generated (default is false)
  61946. */
  61947. noMipmap?: boolean | undefined;
  61948. /**
  61949. * Defines if texture must be inverted on Y axis (default is false)
  61950. */
  61951. invertY?: boolean | undefined;
  61952. /**
  61953. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  61954. */
  61955. samplingMode: number;
  61956. /**
  61957. * Gets the loaded texture
  61958. */
  61959. texture: Texture;
  61960. /**
  61961. * Callback called when the task is successful
  61962. */
  61963. onSuccess: (task: TextureAssetTask) => void;
  61964. /**
  61965. * Callback called when the task is successful
  61966. */
  61967. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  61968. /**
  61969. * Creates a new TextureAssetTask object
  61970. * @param name defines the name of the task
  61971. * @param url defines the location of the file to load
  61972. * @param noMipmap defines if mipmap should not be generated (default is false)
  61973. * @param invertY defines if texture must be inverted on Y axis (default is false)
  61974. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  61975. */
  61976. constructor(
  61977. /**
  61978. * Defines the name of the task
  61979. */
  61980. name: string,
  61981. /**
  61982. * Defines the location of the file to load
  61983. */
  61984. url: string,
  61985. /**
  61986. * Defines if mipmap should not be generated (default is false)
  61987. */
  61988. noMipmap?: boolean | undefined,
  61989. /**
  61990. * Defines if texture must be inverted on Y axis (default is false)
  61991. */
  61992. invertY?: boolean | undefined,
  61993. /**
  61994. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  61995. */
  61996. samplingMode?: number);
  61997. /**
  61998. * Execute the current task
  61999. * @param scene defines the scene where you want your assets to be loaded
  62000. * @param onSuccess is a callback called when the task is successfully executed
  62001. * @param onError is a callback called if an error occurs
  62002. */
  62003. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  62004. }
  62005. /**
  62006. * Define a task used by AssetsManager to load cube textures
  62007. */
  62008. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  62009. /**
  62010. * Defines the name of the task
  62011. */
  62012. name: string;
  62013. /**
  62014. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  62015. */
  62016. url: string;
  62017. /**
  62018. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  62019. */
  62020. extensions?: string[] | undefined;
  62021. /**
  62022. * Defines if mipmaps should not be generated (default is false)
  62023. */
  62024. noMipmap?: boolean | undefined;
  62025. /**
  62026. * Defines the explicit list of files (undefined by default)
  62027. */
  62028. files?: string[] | undefined;
  62029. /**
  62030. * Gets the loaded texture
  62031. */
  62032. texture: CubeTexture;
  62033. /**
  62034. * Callback called when the task is successful
  62035. */
  62036. onSuccess: (task: CubeTextureAssetTask) => void;
  62037. /**
  62038. * Callback called when the task is successful
  62039. */
  62040. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  62041. /**
  62042. * Creates a new CubeTextureAssetTask
  62043. * @param name defines the name of the task
  62044. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  62045. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  62046. * @param noMipmap defines if mipmaps should not be generated (default is false)
  62047. * @param files defines the explicit list of files (undefined by default)
  62048. */
  62049. constructor(
  62050. /**
  62051. * Defines the name of the task
  62052. */
  62053. name: string,
  62054. /**
  62055. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  62056. */
  62057. url: string,
  62058. /**
  62059. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  62060. */
  62061. extensions?: string[] | undefined,
  62062. /**
  62063. * Defines if mipmaps should not be generated (default is false)
  62064. */
  62065. noMipmap?: boolean | undefined,
  62066. /**
  62067. * Defines the explicit list of files (undefined by default)
  62068. */
  62069. files?: string[] | undefined);
  62070. /**
  62071. * Execute the current task
  62072. * @param scene defines the scene where you want your assets to be loaded
  62073. * @param onSuccess is a callback called when the task is successfully executed
  62074. * @param onError is a callback called if an error occurs
  62075. */
  62076. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  62077. }
  62078. /**
  62079. * Define a task used by AssetsManager to load HDR cube textures
  62080. */
  62081. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  62082. /**
  62083. * Defines the name of the task
  62084. */
  62085. name: string;
  62086. /**
  62087. * Defines the location of the file to load
  62088. */
  62089. url: string;
  62090. /**
  62091. * Defines the desired size (the more it increases the longer the generation will be)
  62092. */
  62093. size: number;
  62094. /**
  62095. * Defines if mipmaps should not be generated (default is false)
  62096. */
  62097. noMipmap: boolean;
  62098. /**
  62099. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  62100. */
  62101. generateHarmonics: boolean;
  62102. /**
  62103. * 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)
  62104. */
  62105. gammaSpace: boolean;
  62106. /**
  62107. * Internal Use Only
  62108. */
  62109. reserved: boolean;
  62110. /**
  62111. * Gets the loaded texture
  62112. */
  62113. texture: HDRCubeTexture;
  62114. /**
  62115. * Callback called when the task is successful
  62116. */
  62117. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  62118. /**
  62119. * Callback called when the task is successful
  62120. */
  62121. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  62122. /**
  62123. * Creates a new HDRCubeTextureAssetTask object
  62124. * @param name defines the name of the task
  62125. * @param url defines the location of the file to load
  62126. * @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.
  62127. * @param noMipmap defines if mipmaps should not be generated (default is false)
  62128. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  62129. * @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)
  62130. * @param reserved Internal use only
  62131. */
  62132. constructor(
  62133. /**
  62134. * Defines the name of the task
  62135. */
  62136. name: string,
  62137. /**
  62138. * Defines the location of the file to load
  62139. */
  62140. url: string,
  62141. /**
  62142. * Defines the desired size (the more it increases the longer the generation will be)
  62143. */
  62144. size: number,
  62145. /**
  62146. * Defines if mipmaps should not be generated (default is false)
  62147. */
  62148. noMipmap?: boolean,
  62149. /**
  62150. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  62151. */
  62152. generateHarmonics?: boolean,
  62153. /**
  62154. * 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)
  62155. */
  62156. gammaSpace?: boolean,
  62157. /**
  62158. * Internal Use Only
  62159. */
  62160. reserved?: boolean);
  62161. /**
  62162. * Execute the current task
  62163. * @param scene defines the scene where you want your assets to be loaded
  62164. * @param onSuccess is a callback called when the task is successfully executed
  62165. * @param onError is a callback called if an error occurs
  62166. */
  62167. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  62168. }
  62169. /**
  62170. * Define a task used by AssetsManager to load Equirectangular cube textures
  62171. */
  62172. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  62173. /**
  62174. * Defines the name of the task
  62175. */
  62176. name: string;
  62177. /**
  62178. * Defines the location of the file to load
  62179. */
  62180. url: string;
  62181. /**
  62182. * Defines the desired size (the more it increases the longer the generation will be)
  62183. */
  62184. size: number;
  62185. /**
  62186. * Defines if mipmaps should not be generated (default is false)
  62187. */
  62188. noMipmap: boolean;
  62189. /**
  62190. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  62191. * but the standard material would require them in Gamma space) (default is true)
  62192. */
  62193. gammaSpace: boolean;
  62194. /**
  62195. * Gets the loaded texture
  62196. */
  62197. texture: EquiRectangularCubeTexture;
  62198. /**
  62199. * Callback called when the task is successful
  62200. */
  62201. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  62202. /**
  62203. * Callback called when the task is successful
  62204. */
  62205. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  62206. /**
  62207. * Creates a new EquiRectangularCubeTextureAssetTask object
  62208. * @param name defines the name of the task
  62209. * @param url defines the location of the file to load
  62210. * @param size defines the desired size (the more it increases the longer the generation will be)
  62211. * If the size is omitted this implies you are using a preprocessed cubemap.
  62212. * @param noMipmap defines if mipmaps should not be generated (default is false)
  62213. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  62214. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  62215. * (default is true)
  62216. */
  62217. constructor(
  62218. /**
  62219. * Defines the name of the task
  62220. */
  62221. name: string,
  62222. /**
  62223. * Defines the location of the file to load
  62224. */
  62225. url: string,
  62226. /**
  62227. * Defines the desired size (the more it increases the longer the generation will be)
  62228. */
  62229. size: number,
  62230. /**
  62231. * Defines if mipmaps should not be generated (default is false)
  62232. */
  62233. noMipmap?: boolean,
  62234. /**
  62235. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  62236. * but the standard material would require them in Gamma space) (default is true)
  62237. */
  62238. gammaSpace?: boolean);
  62239. /**
  62240. * Execute the current task
  62241. * @param scene defines the scene where you want your assets to be loaded
  62242. * @param onSuccess is a callback called when the task is successfully executed
  62243. * @param onError is a callback called if an error occurs
  62244. */
  62245. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  62246. }
  62247. /**
  62248. * This class can be used to easily import assets into a scene
  62249. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  62250. */
  62251. export class AssetsManager {
  62252. private _scene;
  62253. private _isLoading;
  62254. protected _tasks: AbstractAssetTask[];
  62255. protected _waitingTasksCount: number;
  62256. protected _totalTasksCount: number;
  62257. /**
  62258. * Callback called when all tasks are processed
  62259. */
  62260. onFinish: (tasks: AbstractAssetTask[]) => void;
  62261. /**
  62262. * Callback called when a task is successful
  62263. */
  62264. onTaskSuccess: (task: AbstractAssetTask) => void;
  62265. /**
  62266. * Callback called when a task had an error
  62267. */
  62268. onTaskError: (task: AbstractAssetTask) => void;
  62269. /**
  62270. * Callback called when a task is done (whatever the result is)
  62271. */
  62272. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  62273. /**
  62274. * Observable called when all tasks are processed
  62275. */
  62276. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  62277. /**
  62278. * Observable called when a task had an error
  62279. */
  62280. onTaskErrorObservable: Observable<AbstractAssetTask>;
  62281. /**
  62282. * Observable called when all tasks were executed
  62283. */
  62284. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  62285. /**
  62286. * Observable called when a task is done (whatever the result is)
  62287. */
  62288. onProgressObservable: Observable<IAssetsProgressEvent>;
  62289. /**
  62290. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  62291. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  62292. */
  62293. useDefaultLoadingScreen: boolean;
  62294. /**
  62295. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  62296. * when all assets have been downloaded.
  62297. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  62298. */
  62299. autoHideLoadingUI: boolean;
  62300. /**
  62301. * Creates a new AssetsManager
  62302. * @param scene defines the scene to work on
  62303. */
  62304. constructor(scene: Scene);
  62305. /**
  62306. * Add a MeshAssetTask to the list of active tasks
  62307. * @param taskName defines the name of the new task
  62308. * @param meshesNames defines the name of meshes to load
  62309. * @param rootUrl defines the root url to use to locate files
  62310. * @param sceneFilename defines the filename of the scene file
  62311. * @returns a new MeshAssetTask object
  62312. */
  62313. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  62314. /**
  62315. * Add a TextFileAssetTask to the list of active tasks
  62316. * @param taskName defines the name of the new task
  62317. * @param url defines the url of the file to load
  62318. * @returns a new TextFileAssetTask object
  62319. */
  62320. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  62321. /**
  62322. * Add a BinaryFileAssetTask to the list of active tasks
  62323. * @param taskName defines the name of the new task
  62324. * @param url defines the url of the file to load
  62325. * @returns a new BinaryFileAssetTask object
  62326. */
  62327. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  62328. /**
  62329. * Add a ImageAssetTask to the list of active tasks
  62330. * @param taskName defines the name of the new task
  62331. * @param url defines the url of the file to load
  62332. * @returns a new ImageAssetTask object
  62333. */
  62334. addImageTask(taskName: string, url: string): ImageAssetTask;
  62335. /**
  62336. * Add a TextureAssetTask to the list of active tasks
  62337. * @param taskName defines the name of the new task
  62338. * @param url defines the url of the file to load
  62339. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  62340. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  62341. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  62342. * @returns a new TextureAssetTask object
  62343. */
  62344. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  62345. /**
  62346. * Add a CubeTextureAssetTask to the list of active tasks
  62347. * @param taskName defines the name of the new task
  62348. * @param url defines the url of the file to load
  62349. * @param extensions defines the extension to use to load the cube map (can be null)
  62350. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  62351. * @param files defines the list of files to load (can be null)
  62352. * @returns a new CubeTextureAssetTask object
  62353. */
  62354. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  62355. /**
  62356. *
  62357. * Add a HDRCubeTextureAssetTask to the list of active tasks
  62358. * @param taskName defines the name of the new task
  62359. * @param url defines the url of the file to load
  62360. * @param size defines the size you want for the cubemap (can be null)
  62361. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  62362. * @param generateHarmonics defines if you want to automatically generate (true by default)
  62363. * @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)
  62364. * @param reserved Internal use only
  62365. * @returns a new HDRCubeTextureAssetTask object
  62366. */
  62367. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  62368. /**
  62369. *
  62370. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  62371. * @param taskName defines the name of the new task
  62372. * @param url defines the url of the file to load
  62373. * @param size defines the size you want for the cubemap (can be null)
  62374. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  62375. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  62376. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  62377. * @returns a new EquiRectangularCubeTextureAssetTask object
  62378. */
  62379. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  62380. /**
  62381. * Remove a task from the assets manager.
  62382. * @param task the task to remove
  62383. */
  62384. removeTask(task: AbstractAssetTask): void;
  62385. private _decreaseWaitingTasksCount;
  62386. private _runTask;
  62387. /**
  62388. * Reset the AssetsManager and remove all tasks
  62389. * @return the current instance of the AssetsManager
  62390. */
  62391. reset(): AssetsManager;
  62392. /**
  62393. * Start the loading process
  62394. * @return the current instance of the AssetsManager
  62395. */
  62396. load(): AssetsManager;
  62397. /**
  62398. * Start the loading process as an async operation
  62399. * @return a promise returning the list of failed tasks
  62400. */
  62401. loadAsync(): Promise<void>;
  62402. }
  62403. }
  62404. declare module BABYLON {
  62405. /**
  62406. * Wrapper class for promise with external resolve and reject.
  62407. */
  62408. export class Deferred<T> {
  62409. /**
  62410. * The promise associated with this deferred object.
  62411. */
  62412. readonly promise: Promise<T>;
  62413. private _resolve;
  62414. private _reject;
  62415. /**
  62416. * The resolve method of the promise associated with this deferred object.
  62417. */
  62418. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  62419. /**
  62420. * The reject method of the promise associated with this deferred object.
  62421. */
  62422. readonly reject: (reason?: any) => void;
  62423. /**
  62424. * Constructor for this deferred object.
  62425. */
  62426. constructor();
  62427. }
  62428. }
  62429. declare module BABYLON {
  62430. /**
  62431. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  62432. */
  62433. export class MeshExploder {
  62434. private _centerMesh;
  62435. private _meshes;
  62436. private _meshesOrigins;
  62437. private _toCenterVectors;
  62438. private _scaledDirection;
  62439. private _newPosition;
  62440. private _centerPosition;
  62441. /**
  62442. * Explodes meshes from a center mesh.
  62443. * @param meshes The meshes to explode.
  62444. * @param centerMesh The mesh to be center of explosion.
  62445. */
  62446. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  62447. private _setCenterMesh;
  62448. /**
  62449. * Get class name
  62450. * @returns "MeshExploder"
  62451. */
  62452. getClassName(): string;
  62453. /**
  62454. * "Exploded meshes"
  62455. * @returns Array of meshes with the centerMesh at index 0.
  62456. */
  62457. getMeshes(): Array<Mesh>;
  62458. /**
  62459. * Explodes meshes giving a specific direction
  62460. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  62461. */
  62462. explode(direction?: number): void;
  62463. }
  62464. }
  62465. declare module BABYLON {
  62466. /**
  62467. * Class used to help managing file picking and drag'n'drop
  62468. */
  62469. export class FilesInput {
  62470. /**
  62471. * List of files ready to be loaded
  62472. */
  62473. static readonly FilesToLoad: {
  62474. [key: string]: File;
  62475. };
  62476. /**
  62477. * Callback called when a file is processed
  62478. */
  62479. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  62480. private _engine;
  62481. private _currentScene;
  62482. private _sceneLoadedCallback;
  62483. private _progressCallback;
  62484. private _additionalRenderLoopLogicCallback;
  62485. private _textureLoadingCallback;
  62486. private _startingProcessingFilesCallback;
  62487. private _onReloadCallback;
  62488. private _errorCallback;
  62489. private _elementToMonitor;
  62490. private _sceneFileToLoad;
  62491. private _filesToLoad;
  62492. /**
  62493. * Creates a new FilesInput
  62494. * @param engine defines the rendering engine
  62495. * @param scene defines the hosting scene
  62496. * @param sceneLoadedCallback callback called when scene is loaded
  62497. * @param progressCallback callback called to track progress
  62498. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  62499. * @param textureLoadingCallback callback called when a texture is loading
  62500. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  62501. * @param onReloadCallback callback called when a reload is requested
  62502. * @param errorCallback callback call if an error occurs
  62503. */
  62504. 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);
  62505. private _dragEnterHandler;
  62506. private _dragOverHandler;
  62507. private _dropHandler;
  62508. /**
  62509. * Calls this function to listen to drag'n'drop events on a specific DOM element
  62510. * @param elementToMonitor defines the DOM element to track
  62511. */
  62512. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  62513. /**
  62514. * Release all associated resources
  62515. */
  62516. dispose(): void;
  62517. private renderFunction;
  62518. private drag;
  62519. private drop;
  62520. private _traverseFolder;
  62521. private _processFiles;
  62522. /**
  62523. * Load files from a drop event
  62524. * @param event defines the drop event to use as source
  62525. */
  62526. loadFiles(event: any): void;
  62527. private _processReload;
  62528. /**
  62529. * Reload the current scene from the loaded files
  62530. */
  62531. reload(): void;
  62532. }
  62533. }
  62534. declare module BABYLON {
  62535. /**
  62536. * Defines the root class used to create scene optimization to use with SceneOptimizer
  62537. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  62538. */
  62539. export class SceneOptimization {
  62540. /**
  62541. * Defines the priority of this optimization (0 by default which means first in the list)
  62542. */
  62543. priority: number;
  62544. /**
  62545. * Gets a string describing the action executed by the current optimization
  62546. * @returns description string
  62547. */
  62548. getDescription(): string;
  62549. /**
  62550. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  62551. * @param scene defines the current scene where to apply this optimization
  62552. * @param optimizer defines the current optimizer
  62553. * @returns true if everything that can be done was applied
  62554. */
  62555. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  62556. /**
  62557. * Creates the SceneOptimization object
  62558. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  62559. * @param desc defines the description associated with the optimization
  62560. */
  62561. constructor(
  62562. /**
  62563. * Defines the priority of this optimization (0 by default which means first in the list)
  62564. */
  62565. priority?: number);
  62566. }
  62567. /**
  62568. * Defines an optimization used to reduce the size of render target textures
  62569. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  62570. */
  62571. export class TextureOptimization extends SceneOptimization {
  62572. /**
  62573. * Defines the priority of this optimization (0 by default which means first in the list)
  62574. */
  62575. priority: number;
  62576. /**
  62577. * 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
  62578. */
  62579. maximumSize: number;
  62580. /**
  62581. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  62582. */
  62583. step: number;
  62584. /**
  62585. * Gets a string describing the action executed by the current optimization
  62586. * @returns description string
  62587. */
  62588. getDescription(): string;
  62589. /**
  62590. * Creates the TextureOptimization object
  62591. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  62592. * @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
  62593. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  62594. */
  62595. constructor(
  62596. /**
  62597. * Defines the priority of this optimization (0 by default which means first in the list)
  62598. */
  62599. priority?: number,
  62600. /**
  62601. * 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
  62602. */
  62603. maximumSize?: number,
  62604. /**
  62605. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  62606. */
  62607. step?: number);
  62608. /**
  62609. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  62610. * @param scene defines the current scene where to apply this optimization
  62611. * @param optimizer defines the current optimizer
  62612. * @returns true if everything that can be done was applied
  62613. */
  62614. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  62615. }
  62616. /**
  62617. * Defines an optimization used to increase or decrease the rendering resolution
  62618. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  62619. */
  62620. export class HardwareScalingOptimization extends SceneOptimization {
  62621. /**
  62622. * Defines the priority of this optimization (0 by default which means first in the list)
  62623. */
  62624. priority: number;
  62625. /**
  62626. * Defines the maximum scale to use (2 by default)
  62627. */
  62628. maximumScale: number;
  62629. /**
  62630. * Defines the step to use between two passes (0.5 by default)
  62631. */
  62632. step: number;
  62633. private _currentScale;
  62634. private _directionOffset;
  62635. /**
  62636. * Gets a string describing the action executed by the current optimization
  62637. * @return description string
  62638. */
  62639. getDescription(): string;
  62640. /**
  62641. * Creates the HardwareScalingOptimization object
  62642. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  62643. * @param maximumScale defines the maximum scale to use (2 by default)
  62644. * @param step defines the step to use between two passes (0.5 by default)
  62645. */
  62646. constructor(
  62647. /**
  62648. * Defines the priority of this optimization (0 by default which means first in the list)
  62649. */
  62650. priority?: number,
  62651. /**
  62652. * Defines the maximum scale to use (2 by default)
  62653. */
  62654. maximumScale?: number,
  62655. /**
  62656. * Defines the step to use between two passes (0.5 by default)
  62657. */
  62658. step?: number);
  62659. /**
  62660. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  62661. * @param scene defines the current scene where to apply this optimization
  62662. * @param optimizer defines the current optimizer
  62663. * @returns true if everything that can be done was applied
  62664. */
  62665. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  62666. }
  62667. /**
  62668. * Defines an optimization used to remove shadows
  62669. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  62670. */
  62671. export class ShadowsOptimization extends SceneOptimization {
  62672. /**
  62673. * Gets a string describing the action executed by the current optimization
  62674. * @return description string
  62675. */
  62676. getDescription(): string;
  62677. /**
  62678. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  62679. * @param scene defines the current scene where to apply this optimization
  62680. * @param optimizer defines the current optimizer
  62681. * @returns true if everything that can be done was applied
  62682. */
  62683. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  62684. }
  62685. /**
  62686. * Defines an optimization used to turn post-processes off
  62687. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  62688. */
  62689. export class PostProcessesOptimization extends SceneOptimization {
  62690. /**
  62691. * Gets a string describing the action executed by the current optimization
  62692. * @return description string
  62693. */
  62694. getDescription(): string;
  62695. /**
  62696. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  62697. * @param scene defines the current scene where to apply this optimization
  62698. * @param optimizer defines the current optimizer
  62699. * @returns true if everything that can be done was applied
  62700. */
  62701. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  62702. }
  62703. /**
  62704. * Defines an optimization used to turn lens flares off
  62705. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  62706. */
  62707. export class LensFlaresOptimization extends SceneOptimization {
  62708. /**
  62709. * Gets a string describing the action executed by the current optimization
  62710. * @return description string
  62711. */
  62712. getDescription(): string;
  62713. /**
  62714. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  62715. * @param scene defines the current scene where to apply this optimization
  62716. * @param optimizer defines the current optimizer
  62717. * @returns true if everything that can be done was applied
  62718. */
  62719. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  62720. }
  62721. /**
  62722. * Defines an optimization based on user defined callback.
  62723. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  62724. */
  62725. export class CustomOptimization extends SceneOptimization {
  62726. /**
  62727. * Callback called to apply the custom optimization.
  62728. */
  62729. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  62730. /**
  62731. * Callback called to get custom description
  62732. */
  62733. onGetDescription: () => string;
  62734. /**
  62735. * Gets a string describing the action executed by the current optimization
  62736. * @returns description string
  62737. */
  62738. getDescription(): string;
  62739. /**
  62740. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  62741. * @param scene defines the current scene where to apply this optimization
  62742. * @param optimizer defines the current optimizer
  62743. * @returns true if everything that can be done was applied
  62744. */
  62745. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  62746. }
  62747. /**
  62748. * Defines an optimization used to turn particles off
  62749. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  62750. */
  62751. export class ParticlesOptimization extends SceneOptimization {
  62752. /**
  62753. * Gets a string describing the action executed by the current optimization
  62754. * @return description string
  62755. */
  62756. getDescription(): string;
  62757. /**
  62758. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  62759. * @param scene defines the current scene where to apply this optimization
  62760. * @param optimizer defines the current optimizer
  62761. * @returns true if everything that can be done was applied
  62762. */
  62763. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  62764. }
  62765. /**
  62766. * Defines an optimization used to turn render targets off
  62767. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  62768. */
  62769. export class RenderTargetsOptimization extends SceneOptimization {
  62770. /**
  62771. * Gets a string describing the action executed by the current optimization
  62772. * @return description string
  62773. */
  62774. getDescription(): string;
  62775. /**
  62776. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  62777. * @param scene defines the current scene where to apply this optimization
  62778. * @param optimizer defines the current optimizer
  62779. * @returns true if everything that can be done was applied
  62780. */
  62781. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  62782. }
  62783. /**
  62784. * Defines an optimization used to merge meshes with compatible materials
  62785. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  62786. */
  62787. export class MergeMeshesOptimization extends SceneOptimization {
  62788. private static _UpdateSelectionTree;
  62789. /**
  62790. * Gets or sets a boolean which defines if optimization octree has to be updated
  62791. */
  62792. /**
  62793. * Gets or sets a boolean which defines if optimization octree has to be updated
  62794. */
  62795. static UpdateSelectionTree: boolean;
  62796. /**
  62797. * Gets a string describing the action executed by the current optimization
  62798. * @return description string
  62799. */
  62800. getDescription(): string;
  62801. private _canBeMerged;
  62802. /**
  62803. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  62804. * @param scene defines the current scene where to apply this optimization
  62805. * @param optimizer defines the current optimizer
  62806. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  62807. * @returns true if everything that can be done was applied
  62808. */
  62809. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  62810. }
  62811. /**
  62812. * Defines a list of options used by SceneOptimizer
  62813. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  62814. */
  62815. export class SceneOptimizerOptions {
  62816. /**
  62817. * Defines the target frame rate to reach (60 by default)
  62818. */
  62819. targetFrameRate: number;
  62820. /**
  62821. * Defines the interval between two checkes (2000ms by default)
  62822. */
  62823. trackerDuration: number;
  62824. /**
  62825. * Gets the list of optimizations to apply
  62826. */
  62827. optimizations: SceneOptimization[];
  62828. /**
  62829. * Creates a new list of options used by SceneOptimizer
  62830. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  62831. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  62832. */
  62833. constructor(
  62834. /**
  62835. * Defines the target frame rate to reach (60 by default)
  62836. */
  62837. targetFrameRate?: number,
  62838. /**
  62839. * Defines the interval between two checkes (2000ms by default)
  62840. */
  62841. trackerDuration?: number);
  62842. /**
  62843. * Add a new optimization
  62844. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  62845. * @returns the current SceneOptimizerOptions
  62846. */
  62847. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  62848. /**
  62849. * Add a new custom optimization
  62850. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  62851. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  62852. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  62853. * @returns the current SceneOptimizerOptions
  62854. */
  62855. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  62856. /**
  62857. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  62858. * @param targetFrameRate defines the target frame rate (60 by default)
  62859. * @returns a SceneOptimizerOptions object
  62860. */
  62861. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  62862. /**
  62863. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  62864. * @param targetFrameRate defines the target frame rate (60 by default)
  62865. * @returns a SceneOptimizerOptions object
  62866. */
  62867. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  62868. /**
  62869. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  62870. * @param targetFrameRate defines the target frame rate (60 by default)
  62871. * @returns a SceneOptimizerOptions object
  62872. */
  62873. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  62874. }
  62875. /**
  62876. * Class used to run optimizations in order to reach a target frame rate
  62877. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  62878. */
  62879. export class SceneOptimizer implements IDisposable {
  62880. private _isRunning;
  62881. private _options;
  62882. private _scene;
  62883. private _currentPriorityLevel;
  62884. private _targetFrameRate;
  62885. private _trackerDuration;
  62886. private _currentFrameRate;
  62887. private _sceneDisposeObserver;
  62888. private _improvementMode;
  62889. /**
  62890. * Defines an observable called when the optimizer reaches the target frame rate
  62891. */
  62892. onSuccessObservable: Observable<SceneOptimizer>;
  62893. /**
  62894. * Defines an observable called when the optimizer enables an optimization
  62895. */
  62896. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  62897. /**
  62898. * Defines an observable called when the optimizer is not able to reach the target frame rate
  62899. */
  62900. onFailureObservable: Observable<SceneOptimizer>;
  62901. /**
  62902. * Gets a boolean indicating if the optimizer is in improvement mode
  62903. */
  62904. readonly isInImprovementMode: boolean;
  62905. /**
  62906. * Gets the current priority level (0 at start)
  62907. */
  62908. readonly currentPriorityLevel: number;
  62909. /**
  62910. * Gets the current frame rate checked by the SceneOptimizer
  62911. */
  62912. readonly currentFrameRate: number;
  62913. /**
  62914. * Gets or sets the current target frame rate (60 by default)
  62915. */
  62916. /**
  62917. * Gets or sets the current target frame rate (60 by default)
  62918. */
  62919. targetFrameRate: number;
  62920. /**
  62921. * Gets or sets the current interval between two checks (every 2000ms by default)
  62922. */
  62923. /**
  62924. * Gets or sets the current interval between two checks (every 2000ms by default)
  62925. */
  62926. trackerDuration: number;
  62927. /**
  62928. * Gets the list of active optimizations
  62929. */
  62930. readonly optimizations: SceneOptimization[];
  62931. /**
  62932. * Creates a new SceneOptimizer
  62933. * @param scene defines the scene to work on
  62934. * @param options defines the options to use with the SceneOptimizer
  62935. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  62936. * @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)
  62937. */
  62938. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  62939. /**
  62940. * Stops the current optimizer
  62941. */
  62942. stop(): void;
  62943. /**
  62944. * Reset the optimizer to initial step (current priority level = 0)
  62945. */
  62946. reset(): void;
  62947. /**
  62948. * Start the optimizer. By default it will try to reach a specific framerate
  62949. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  62950. */
  62951. start(): void;
  62952. private _checkCurrentState;
  62953. /**
  62954. * Release all resources
  62955. */
  62956. dispose(): void;
  62957. /**
  62958. * Helper function to create a SceneOptimizer with one single line of code
  62959. * @param scene defines the scene to work on
  62960. * @param options defines the options to use with the SceneOptimizer
  62961. * @param onSuccess defines a callback to call on success
  62962. * @param onFailure defines a callback to call on failure
  62963. * @returns the new SceneOptimizer object
  62964. */
  62965. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  62966. }
  62967. }
  62968. declare module BABYLON {
  62969. /**
  62970. * Class used to serialize a scene into a string
  62971. */
  62972. export class SceneSerializer {
  62973. /**
  62974. * Clear cache used by a previous serialization
  62975. */
  62976. static ClearCache(): void;
  62977. /**
  62978. * Serialize a scene into a JSON compatible object
  62979. * @param scene defines the scene to serialize
  62980. * @returns a JSON compatible object
  62981. */
  62982. static Serialize(scene: Scene): any;
  62983. /**
  62984. * Serialize a mesh into a JSON compatible object
  62985. * @param toSerialize defines the mesh to serialize
  62986. * @param withParents defines if parents must be serialized as well
  62987. * @param withChildren defines if children must be serialized as well
  62988. * @returns a JSON compatible object
  62989. */
  62990. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  62991. }
  62992. }
  62993. declare module BABYLON {
  62994. /**
  62995. * Class used to host texture specific utilities
  62996. */
  62997. export class TextureTools {
  62998. /**
  62999. * Uses the GPU to create a copy texture rescaled at a given size
  63000. * @param texture Texture to copy from
  63001. * @param width defines the desired width
  63002. * @param height defines the desired height
  63003. * @param useBilinearMode defines if bilinear mode has to be used
  63004. * @return the generated texture
  63005. */
  63006. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  63007. }
  63008. }
  63009. declare module BABYLON {
  63010. /**
  63011. * This represents the different options available for the video capture.
  63012. */
  63013. export interface VideoRecorderOptions {
  63014. /** Defines the mime type of the video. */
  63015. mimeType: string;
  63016. /** Defines the FPS the video should be recorded at. */
  63017. fps: number;
  63018. /** Defines the chunk size for the recording data. */
  63019. recordChunckSize: number;
  63020. /** The audio tracks to attach to the recording. */
  63021. audioTracks?: MediaStreamTrack[];
  63022. }
  63023. /**
  63024. * This can help with recording videos from BabylonJS.
  63025. * This is based on the available WebRTC functionalities of the browser.
  63026. *
  63027. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  63028. */
  63029. export class VideoRecorder {
  63030. private static readonly _defaultOptions;
  63031. /**
  63032. * Returns whether or not the VideoRecorder is available in your browser.
  63033. * @param engine Defines the Babylon Engine.
  63034. * @returns true if supported otherwise false.
  63035. */
  63036. static IsSupported(engine: Engine): boolean;
  63037. private readonly _options;
  63038. private _canvas;
  63039. private _mediaRecorder;
  63040. private _recordedChunks;
  63041. private _fileName;
  63042. private _resolve;
  63043. private _reject;
  63044. /**
  63045. * True when a recording is already in progress.
  63046. */
  63047. readonly isRecording: boolean;
  63048. /**
  63049. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  63050. * @param engine Defines the BabylonJS Engine you wish to record.
  63051. * @param options Defines options that can be used to customize the capture.
  63052. */
  63053. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  63054. /**
  63055. * Stops the current recording before the default capture timeout passed in the startRecording function.
  63056. */
  63057. stopRecording(): void;
  63058. /**
  63059. * Starts recording the canvas for a max duration specified in parameters.
  63060. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  63061. * If null no automatic download will start and you can rely on the promise to get the data back.
  63062. * @param maxDuration Defines the maximum recording time in seconds.
  63063. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  63064. * @return A promise callback at the end of the recording with the video data in Blob.
  63065. */
  63066. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  63067. /**
  63068. * Releases internal resources used during the recording.
  63069. */
  63070. dispose(): void;
  63071. private _handleDataAvailable;
  63072. private _handleError;
  63073. private _handleStop;
  63074. }
  63075. }
  63076. declare module BABYLON {
  63077. /**
  63078. * Class containing a set of static utilities functions for screenshots
  63079. */
  63080. export class ScreenshotTools {
  63081. /**
  63082. * Captures a screenshot of the current rendering
  63083. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  63084. * @param engine defines the rendering engine
  63085. * @param camera defines the source camera
  63086. * @param size This parameter can be set to a single number or to an object with the
  63087. * following (optional) properties: precision, width, height. If a single number is passed,
  63088. * it will be used for both width and height. If an object is passed, the screenshot size
  63089. * will be derived from the parameters. The precision property is a multiplier allowing
  63090. * rendering at a higher or lower resolution
  63091. * @param successCallback defines the callback receives a single parameter which contains the
  63092. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  63093. * src parameter of an <img> to display it
  63094. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  63095. * Check your browser for supported MIME types
  63096. */
  63097. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  63098. /**
  63099. * Captures a screenshot of the current rendering
  63100. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  63101. * @param engine defines the rendering engine
  63102. * @param camera defines the source camera
  63103. * @param size This parameter can be set to a single number or to an object with the
  63104. * following (optional) properties: precision, width, height. If a single number is passed,
  63105. * it will be used for both width and height. If an object is passed, the screenshot size
  63106. * will be derived from the parameters. The precision property is a multiplier allowing
  63107. * rendering at a higher or lower resolution
  63108. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  63109. * Check your browser for supported MIME types
  63110. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  63111. * to the src parameter of an <img> to display it
  63112. */
  63113. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  63114. /**
  63115. * Generates an image screenshot from the specified camera.
  63116. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  63117. * @param engine The engine to use for rendering
  63118. * @param camera The camera to use for rendering
  63119. * @param size This parameter can be set to a single number or to an object with the
  63120. * following (optional) properties: precision, width, height. If a single number is passed,
  63121. * it will be used for both width and height. If an object is passed, the screenshot size
  63122. * will be derived from the parameters. The precision property is a multiplier allowing
  63123. * rendering at a higher or lower resolution
  63124. * @param successCallback The callback receives a single parameter which contains the
  63125. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  63126. * src parameter of an <img> to display it
  63127. * @param mimeType The MIME type of the screenshot image (default: image/png).
  63128. * Check your browser for supported MIME types
  63129. * @param samples Texture samples (default: 1)
  63130. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  63131. * @param fileName A name for for the downloaded file.
  63132. */
  63133. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  63134. /**
  63135. * Generates an image screenshot from the specified camera.
  63136. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  63137. * @param engine The engine to use for rendering
  63138. * @param camera The camera to use for rendering
  63139. * @param size This parameter can be set to a single number or to an object with the
  63140. * following (optional) properties: precision, width, height. If a single number is passed,
  63141. * it will be used for both width and height. If an object is passed, the screenshot size
  63142. * will be derived from the parameters. The precision property is a multiplier allowing
  63143. * rendering at a higher or lower resolution
  63144. * @param mimeType The MIME type of the screenshot image (default: image/png).
  63145. * Check your browser for supported MIME types
  63146. * @param samples Texture samples (default: 1)
  63147. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  63148. * @param fileName A name for for the downloaded file.
  63149. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  63150. * to the src parameter of an <img> to display it
  63151. */
  63152. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  63153. /**
  63154. * Gets height and width for screenshot size
  63155. * @private
  63156. */
  63157. private static _getScreenshotSize;
  63158. }
  63159. }
  63160. declare module BABYLON {
  63161. /**
  63162. * A cursor which tracks a point on a path
  63163. */
  63164. export class PathCursor {
  63165. private path;
  63166. /**
  63167. * Stores path cursor callbacks for when an onchange event is triggered
  63168. */
  63169. private _onchange;
  63170. /**
  63171. * The value of the path cursor
  63172. */
  63173. value: number;
  63174. /**
  63175. * The animation array of the path cursor
  63176. */
  63177. animations: Animation[];
  63178. /**
  63179. * Initializes the path cursor
  63180. * @param path The path to track
  63181. */
  63182. constructor(path: Path2);
  63183. /**
  63184. * Gets the cursor point on the path
  63185. * @returns A point on the path cursor at the cursor location
  63186. */
  63187. getPoint(): Vector3;
  63188. /**
  63189. * Moves the cursor ahead by the step amount
  63190. * @param step The amount to move the cursor forward
  63191. * @returns This path cursor
  63192. */
  63193. moveAhead(step?: number): PathCursor;
  63194. /**
  63195. * Moves the cursor behind by the step amount
  63196. * @param step The amount to move the cursor back
  63197. * @returns This path cursor
  63198. */
  63199. moveBack(step?: number): PathCursor;
  63200. /**
  63201. * Moves the cursor by the step amount
  63202. * If the step amount is greater than one, an exception is thrown
  63203. * @param step The amount to move the cursor
  63204. * @returns This path cursor
  63205. */
  63206. move(step: number): PathCursor;
  63207. /**
  63208. * Ensures that the value is limited between zero and one
  63209. * @returns This path cursor
  63210. */
  63211. private ensureLimits;
  63212. /**
  63213. * Runs onchange callbacks on change (used by the animation engine)
  63214. * @returns This path cursor
  63215. */
  63216. private raiseOnChange;
  63217. /**
  63218. * Executes a function on change
  63219. * @param f A path cursor onchange callback
  63220. * @returns This path cursor
  63221. */
  63222. onchange(f: (cursor: PathCursor) => void): PathCursor;
  63223. }
  63224. }
  63225. declare module BABYLON {
  63226. /** @hidden */
  63227. export var blurPixelShader: {
  63228. name: string;
  63229. shader: string;
  63230. };
  63231. }
  63232. declare module BABYLON {
  63233. /** @hidden */
  63234. export var pointCloudVertexDeclaration: {
  63235. name: string;
  63236. shader: string;
  63237. };
  63238. }
  63239. // Mixins
  63240. interface Window {
  63241. mozIndexedDB: IDBFactory;
  63242. webkitIndexedDB: IDBFactory;
  63243. msIndexedDB: IDBFactory;
  63244. webkitURL: typeof URL;
  63245. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  63246. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  63247. WebGLRenderingContext: WebGLRenderingContext;
  63248. MSGesture: MSGesture;
  63249. CANNON: any;
  63250. AudioContext: AudioContext;
  63251. webkitAudioContext: AudioContext;
  63252. PointerEvent: any;
  63253. Math: Math;
  63254. Uint8Array: Uint8ArrayConstructor;
  63255. Float32Array: Float32ArrayConstructor;
  63256. mozURL: typeof URL;
  63257. msURL: typeof URL;
  63258. VRFrameData: any; // WebVR, from specs 1.1
  63259. DracoDecoderModule: any;
  63260. setImmediate(handler: (...args: any[]) => void): number;
  63261. }
  63262. interface HTMLCanvasElement {
  63263. requestPointerLock(): void;
  63264. msRequestPointerLock?(): void;
  63265. mozRequestPointerLock?(): void;
  63266. webkitRequestPointerLock?(): void;
  63267. /** Track wether a record is in progress */
  63268. isRecording: boolean;
  63269. /** Capture Stream method defined by some browsers */
  63270. captureStream(fps?: number): MediaStream;
  63271. }
  63272. interface CanvasRenderingContext2D {
  63273. msImageSmoothingEnabled: boolean;
  63274. }
  63275. interface MouseEvent {
  63276. mozMovementX: number;
  63277. mozMovementY: number;
  63278. webkitMovementX: number;
  63279. webkitMovementY: number;
  63280. msMovementX: number;
  63281. msMovementY: number;
  63282. }
  63283. interface Navigator {
  63284. mozGetVRDevices: (any: any) => any;
  63285. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  63286. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  63287. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  63288. webkitGetGamepads(): Gamepad[];
  63289. msGetGamepads(): Gamepad[];
  63290. webkitGamepads(): Gamepad[];
  63291. }
  63292. interface HTMLVideoElement {
  63293. mozSrcObject: any;
  63294. }
  63295. interface Math {
  63296. fround(x: number): number;
  63297. imul(a: number, b: number): number;
  63298. }
  63299. interface WebGLRenderingContext {
  63300. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  63301. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  63302. vertexAttribDivisor(index: number, divisor: number): void;
  63303. createVertexArray(): any;
  63304. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  63305. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  63306. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  63307. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  63308. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  63309. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  63310. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  63311. // Queries
  63312. createQuery(): WebGLQuery;
  63313. deleteQuery(query: WebGLQuery): void;
  63314. beginQuery(target: number, query: WebGLQuery): void;
  63315. endQuery(target: number): void;
  63316. getQueryParameter(query: WebGLQuery, pname: number): any;
  63317. getQuery(target: number, pname: number): any;
  63318. MAX_SAMPLES: number;
  63319. RGBA8: number;
  63320. READ_FRAMEBUFFER: number;
  63321. DRAW_FRAMEBUFFER: number;
  63322. UNIFORM_BUFFER: number;
  63323. HALF_FLOAT_OES: number;
  63324. RGBA16F: number;
  63325. RGBA32F: number;
  63326. R32F: number;
  63327. RG32F: number;
  63328. RGB32F: number;
  63329. R16F: number;
  63330. RG16F: number;
  63331. RGB16F: number;
  63332. RED: number;
  63333. RG: number;
  63334. R8: number;
  63335. RG8: number;
  63336. UNSIGNED_INT_24_8: number;
  63337. DEPTH24_STENCIL8: number;
  63338. MIN: number;
  63339. MAX: number;
  63340. /* Multiple Render Targets */
  63341. drawBuffers(buffers: number[]): void;
  63342. readBuffer(src: number): void;
  63343. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  63344. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  63345. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  63346. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  63347. // Occlusion Query
  63348. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  63349. ANY_SAMPLES_PASSED: number;
  63350. QUERY_RESULT_AVAILABLE: number;
  63351. QUERY_RESULT: number;
  63352. }
  63353. interface WebGLProgram {
  63354. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  63355. }
  63356. interface EXT_disjoint_timer_query {
  63357. QUERY_COUNTER_BITS_EXT: number;
  63358. TIME_ELAPSED_EXT: number;
  63359. TIMESTAMP_EXT: number;
  63360. GPU_DISJOINT_EXT: number;
  63361. QUERY_RESULT_EXT: number;
  63362. QUERY_RESULT_AVAILABLE_EXT: number;
  63363. queryCounterEXT(query: WebGLQuery, target: number): void;
  63364. createQueryEXT(): WebGLQuery;
  63365. beginQueryEXT(target: number, query: WebGLQuery): void;
  63366. endQueryEXT(target: number): void;
  63367. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  63368. deleteQueryEXT(query: WebGLQuery): void;
  63369. }
  63370. interface WebGLUniformLocation {
  63371. _currentState: any;
  63372. }
  63373. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  63374. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  63375. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  63376. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  63377. interface WebGLRenderingContext {
  63378. readonly RASTERIZER_DISCARD: number;
  63379. readonly DEPTH_COMPONENT24: number;
  63380. readonly TEXTURE_3D: number;
  63381. readonly TEXTURE_2D_ARRAY: number;
  63382. readonly TEXTURE_COMPARE_FUNC: number;
  63383. readonly TEXTURE_COMPARE_MODE: number;
  63384. readonly COMPARE_REF_TO_TEXTURE: number;
  63385. readonly TEXTURE_WRAP_R: number;
  63386. readonly HALF_FLOAT: number;
  63387. readonly RGB8: number;
  63388. readonly RED_INTEGER: number;
  63389. readonly RG_INTEGER: number;
  63390. readonly RGB_INTEGER: number;
  63391. readonly RGBA_INTEGER: number;
  63392. readonly R8_SNORM: number;
  63393. readonly RG8_SNORM: number;
  63394. readonly RGB8_SNORM: number;
  63395. readonly RGBA8_SNORM: number;
  63396. readonly R8I: number;
  63397. readonly RG8I: number;
  63398. readonly RGB8I: number;
  63399. readonly RGBA8I: number;
  63400. readonly R8UI: number;
  63401. readonly RG8UI: number;
  63402. readonly RGB8UI: number;
  63403. readonly RGBA8UI: number;
  63404. readonly R16I: number;
  63405. readonly RG16I: number;
  63406. readonly RGB16I: number;
  63407. readonly RGBA16I: number;
  63408. readonly R16UI: number;
  63409. readonly RG16UI: number;
  63410. readonly RGB16UI: number;
  63411. readonly RGBA16UI: number;
  63412. readonly R32I: number;
  63413. readonly RG32I: number;
  63414. readonly RGB32I: number;
  63415. readonly RGBA32I: number;
  63416. readonly R32UI: number;
  63417. readonly RG32UI: number;
  63418. readonly RGB32UI: number;
  63419. readonly RGBA32UI: number;
  63420. readonly RGB10_A2UI: number;
  63421. readonly R11F_G11F_B10F: number;
  63422. readonly RGB9_E5: number;
  63423. readonly RGB10_A2: number;
  63424. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  63425. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  63426. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  63427. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  63428. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  63429. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  63430. 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;
  63431. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  63432. readonly TRANSFORM_FEEDBACK: number;
  63433. readonly INTERLEAVED_ATTRIBS: number;
  63434. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  63435. createTransformFeedback(): WebGLTransformFeedback;
  63436. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  63437. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  63438. beginTransformFeedback(primitiveMode: number): void;
  63439. endTransformFeedback(): void;
  63440. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  63441. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  63442. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  63443. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  63444. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  63445. }
  63446. interface ImageBitmap {
  63447. readonly width: number;
  63448. readonly height: number;
  63449. close(): void;
  63450. }
  63451. interface WebGLQuery extends WebGLObject {
  63452. }
  63453. declare var WebGLQuery: {
  63454. prototype: WebGLQuery;
  63455. new(): WebGLQuery;
  63456. };
  63457. interface WebGLSampler extends WebGLObject {
  63458. }
  63459. declare var WebGLSampler: {
  63460. prototype: WebGLSampler;
  63461. new(): WebGLSampler;
  63462. };
  63463. interface WebGLSync extends WebGLObject {
  63464. }
  63465. declare var WebGLSync: {
  63466. prototype: WebGLSync;
  63467. new(): WebGLSync;
  63468. };
  63469. interface WebGLTransformFeedback extends WebGLObject {
  63470. }
  63471. declare var WebGLTransformFeedback: {
  63472. prototype: WebGLTransformFeedback;
  63473. new(): WebGLTransformFeedback;
  63474. };
  63475. interface WebGLVertexArrayObject extends WebGLObject {
  63476. }
  63477. declare var WebGLVertexArrayObject: {
  63478. prototype: WebGLVertexArrayObject;
  63479. new(): WebGLVertexArrayObject;
  63480. };
  63481. // Type definitions for WebVR API
  63482. // Project: https://w3c.github.io/webvr/
  63483. // Definitions by: six a <https://github.com/lostfictions>
  63484. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  63485. interface VRDisplay extends EventTarget {
  63486. /**
  63487. * Dictionary of capabilities describing the VRDisplay.
  63488. */
  63489. readonly capabilities: VRDisplayCapabilities;
  63490. /**
  63491. * z-depth defining the far plane of the eye view frustum
  63492. * enables mapping of values in the render target depth
  63493. * attachment to scene coordinates. Initially set to 10000.0.
  63494. */
  63495. depthFar: number;
  63496. /**
  63497. * z-depth defining the near plane of the eye view frustum
  63498. * enables mapping of values in the render target depth
  63499. * attachment to scene coordinates. Initially set to 0.01.
  63500. */
  63501. depthNear: number;
  63502. /**
  63503. * An identifier for this distinct VRDisplay. Used as an
  63504. * association point in the Gamepad API.
  63505. */
  63506. readonly displayId: number;
  63507. /**
  63508. * A display name, a user-readable name identifying it.
  63509. */
  63510. readonly displayName: string;
  63511. readonly isConnected: boolean;
  63512. readonly isPresenting: boolean;
  63513. /**
  63514. * If this VRDisplay supports room-scale experiences, the optional
  63515. * stage attribute contains details on the room-scale parameters.
  63516. */
  63517. readonly stageParameters: VRStageParameters | null;
  63518. /**
  63519. * Passing the value returned by `requestAnimationFrame` to
  63520. * `cancelAnimationFrame` will unregister the callback.
  63521. * @param handle Define the hanle of the request to cancel
  63522. */
  63523. cancelAnimationFrame(handle: number): void;
  63524. /**
  63525. * Stops presenting to the VRDisplay.
  63526. * @returns a promise to know when it stopped
  63527. */
  63528. exitPresent(): Promise<void>;
  63529. /**
  63530. * Return the current VREyeParameters for the given eye.
  63531. * @param whichEye Define the eye we want the parameter for
  63532. * @returns the eye parameters
  63533. */
  63534. getEyeParameters(whichEye: string): VREyeParameters;
  63535. /**
  63536. * Populates the passed VRFrameData with the information required to render
  63537. * the current frame.
  63538. * @param frameData Define the data structure to populate
  63539. * @returns true if ok otherwise false
  63540. */
  63541. getFrameData(frameData: VRFrameData): boolean;
  63542. /**
  63543. * Get the layers currently being presented.
  63544. * @returns the list of VR layers
  63545. */
  63546. getLayers(): VRLayer[];
  63547. /**
  63548. * Return a VRPose containing the future predicted pose of the VRDisplay
  63549. * when the current frame will be presented. The value returned will not
  63550. * change until JavaScript has returned control to the browser.
  63551. *
  63552. * The VRPose will contain the position, orientation, velocity,
  63553. * and acceleration of each of these properties.
  63554. * @returns the pose object
  63555. */
  63556. getPose(): VRPose;
  63557. /**
  63558. * Return the current instantaneous pose of the VRDisplay, with no
  63559. * prediction applied.
  63560. * @returns the current instantaneous pose
  63561. */
  63562. getImmediatePose(): VRPose;
  63563. /**
  63564. * The callback passed to `requestAnimationFrame` will be called
  63565. * any time a new frame should be rendered. When the VRDisplay is
  63566. * presenting the callback will be called at the native refresh
  63567. * rate of the HMD. When not presenting this function acts
  63568. * identically to how window.requestAnimationFrame acts. Content should
  63569. * make no assumptions of frame rate or vsync behavior as the HMD runs
  63570. * asynchronously from other displays and at differing refresh rates.
  63571. * @param callback Define the eaction to run next frame
  63572. * @returns the request handle it
  63573. */
  63574. requestAnimationFrame(callback: FrameRequestCallback): number;
  63575. /**
  63576. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  63577. * Repeat calls while already presenting will update the VRLayers being displayed.
  63578. * @param layers Define the list of layer to present
  63579. * @returns a promise to know when the request has been fulfilled
  63580. */
  63581. requestPresent(layers: VRLayer[]): Promise<void>;
  63582. /**
  63583. * Reset the pose for this display, treating its current position and
  63584. * orientation as the "origin/zero" values. VRPose.position,
  63585. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  63586. * updated when calling resetPose(). This should be called in only
  63587. * sitting-space experiences.
  63588. */
  63589. resetPose(): void;
  63590. /**
  63591. * The VRLayer provided to the VRDisplay will be captured and presented
  63592. * in the HMD. Calling this function has the same effect on the source
  63593. * canvas as any other operation that uses its source image, and canvases
  63594. * created without preserveDrawingBuffer set to true will be cleared.
  63595. * @param pose Define the pose to submit
  63596. */
  63597. submitFrame(pose?: VRPose): void;
  63598. }
  63599. declare var VRDisplay: {
  63600. prototype: VRDisplay;
  63601. new(): VRDisplay;
  63602. };
  63603. interface VRLayer {
  63604. leftBounds?: number[] | Float32Array | null;
  63605. rightBounds?: number[] | Float32Array | null;
  63606. source?: HTMLCanvasElement | null;
  63607. }
  63608. interface VRDisplayCapabilities {
  63609. readonly canPresent: boolean;
  63610. readonly hasExternalDisplay: boolean;
  63611. readonly hasOrientation: boolean;
  63612. readonly hasPosition: boolean;
  63613. readonly maxLayers: number;
  63614. }
  63615. interface VREyeParameters {
  63616. /** @deprecated */
  63617. readonly fieldOfView: VRFieldOfView;
  63618. readonly offset: Float32Array;
  63619. readonly renderHeight: number;
  63620. readonly renderWidth: number;
  63621. }
  63622. interface VRFieldOfView {
  63623. readonly downDegrees: number;
  63624. readonly leftDegrees: number;
  63625. readonly rightDegrees: number;
  63626. readonly upDegrees: number;
  63627. }
  63628. interface VRFrameData {
  63629. readonly leftProjectionMatrix: Float32Array;
  63630. readonly leftViewMatrix: Float32Array;
  63631. readonly pose: VRPose;
  63632. readonly rightProjectionMatrix: Float32Array;
  63633. readonly rightViewMatrix: Float32Array;
  63634. readonly timestamp: number;
  63635. }
  63636. interface VRPose {
  63637. readonly angularAcceleration: Float32Array | null;
  63638. readonly angularVelocity: Float32Array | null;
  63639. readonly linearAcceleration: Float32Array | null;
  63640. readonly linearVelocity: Float32Array | null;
  63641. readonly orientation: Float32Array | null;
  63642. readonly position: Float32Array | null;
  63643. readonly timestamp: number;
  63644. }
  63645. interface VRStageParameters {
  63646. sittingToStandingTransform?: Float32Array;
  63647. sizeX?: number;
  63648. sizeY?: number;
  63649. }
  63650. interface Navigator {
  63651. getVRDisplays(): Promise<VRDisplay[]>;
  63652. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  63653. }
  63654. interface Window {
  63655. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  63656. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  63657. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  63658. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  63659. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  63660. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  63661. }
  63662. interface Gamepad {
  63663. readonly displayId: number;
  63664. }
  63665. type XRSessionMode =
  63666. | "inline"
  63667. | "immersive-vr"
  63668. | "immersive-ar";
  63669. type XRReferenceSpaceType =
  63670. | "viewer"
  63671. | "local"
  63672. | "local-floor"
  63673. | "bounded-floor"
  63674. | "unbounded";
  63675. type XREnvironmentBlendMode =
  63676. | "opaque"
  63677. | "additive"
  63678. | "alpha-blend";
  63679. type XRVisibilityState =
  63680. | "visible"
  63681. | "visible-blurred"
  63682. | "hidden";
  63683. type XRHandedness =
  63684. | "none"
  63685. | "left"
  63686. | "right";
  63687. type XRTargetRayMode =
  63688. | "gaze"
  63689. | "tracked-pointer"
  63690. | "screen";
  63691. type XREye =
  63692. | "none"
  63693. | "left"
  63694. | "right";
  63695. interface XRSpace extends EventTarget {
  63696. }
  63697. interface XRRenderState {
  63698. depthNear?: number;
  63699. depthFar?: number;
  63700. inlineVerticalFieldOfView?: number;
  63701. baseLayer?: XRWebGLLayer;
  63702. }
  63703. interface XRInputSource {
  63704. handedness: XRHandedness;
  63705. targetRayMode: XRTargetRayMode;
  63706. targetRaySpace: XRSpace;
  63707. gripSpace: XRSpace | undefined;
  63708. gamepad: Gamepad | undefined;
  63709. profiles: Array<string>;
  63710. }
  63711. interface XRSession {
  63712. addEventListener: Function;
  63713. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  63714. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  63715. requestAnimationFrame: Function;
  63716. end(): Promise<void>;
  63717. renderState: XRRenderState;
  63718. inputSources: Array<XRInputSource>;
  63719. }
  63720. interface XRReferenceSpace extends XRSpace {
  63721. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  63722. onreset: any;
  63723. }
  63724. interface XRFrame {
  63725. session: XRSession;
  63726. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  63727. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  63728. }
  63729. interface XRViewerPose extends XRPose {
  63730. views: Array<XRView>;
  63731. }
  63732. interface XRPose {
  63733. transform: XRRigidTransform;
  63734. emulatedPosition: boolean;
  63735. }
  63736. declare var XRWebGLLayer: {
  63737. prototype: XRWebGLLayer;
  63738. new(session: XRSession, context: WebGLRenderingContext | undefined): XRWebGLLayer;
  63739. };
  63740. interface XRWebGLLayer {
  63741. framebuffer: WebGLFramebuffer;
  63742. framebufferWidth: number;
  63743. framebufferHeight: number;
  63744. getViewport: Function;
  63745. }
  63746. interface XRRigidTransform {
  63747. position: DOMPointReadOnly;
  63748. orientation: DOMPointReadOnly;
  63749. matrix: Float32Array;
  63750. inverse: XRRigidTransform;
  63751. }
  63752. interface XRView {
  63753. eye: XREye;
  63754. projectionMatrix: Float32Array;
  63755. transform: XRRigidTransform;
  63756. }
  63757. interface XRInputSourceChangeEvent {
  63758. session: XRSession;
  63759. removed: Array<XRInputSource>;
  63760. added: Array<XRInputSource>;
  63761. }
  63762. /**
  63763. * @ignore
  63764. */
  63765. declare module BABYLON.GLTF2.Exporter {
  63766. }
  63767. /**
  63768. * @ignore
  63769. */
  63770. declare module BABYLON.GLTF1 {
  63771. }
  63772. declare module BABYLON.GUI {
  63773. /**
  63774. * Class used to specific a value and its associated unit
  63775. */
  63776. export class ValueAndUnit {
  63777. /** defines the unit to store */
  63778. unit: number;
  63779. /** defines a boolean indicating if the value can be negative */
  63780. negativeValueAllowed: boolean;
  63781. private _value;
  63782. private _originalUnit;
  63783. /**
  63784. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  63785. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  63786. */
  63787. ignoreAdaptiveScaling: boolean;
  63788. /**
  63789. * Creates a new ValueAndUnit
  63790. * @param value defines the value to store
  63791. * @param unit defines the unit to store
  63792. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  63793. */
  63794. constructor(value: number,
  63795. /** defines the unit to store */
  63796. unit?: number,
  63797. /** defines a boolean indicating if the value can be negative */
  63798. negativeValueAllowed?: boolean);
  63799. /** Gets a boolean indicating if the value is a percentage */
  63800. readonly isPercentage: boolean;
  63801. /** Gets a boolean indicating if the value is store as pixel */
  63802. readonly isPixel: boolean;
  63803. /** Gets direct internal value */
  63804. readonly internalValue: number;
  63805. /**
  63806. * Gets value as pixel
  63807. * @param host defines the root host
  63808. * @param refValue defines the reference value for percentages
  63809. * @returns the value as pixel
  63810. */
  63811. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  63812. /**
  63813. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  63814. * @param value defines the value to store
  63815. * @param unit defines the unit to store
  63816. * @returns the current ValueAndUnit
  63817. */
  63818. updateInPlace(value: number, unit?: number): ValueAndUnit;
  63819. /**
  63820. * Gets the value accordingly to its unit
  63821. * @param host defines the root host
  63822. * @returns the value
  63823. */
  63824. getValue(host: AdvancedDynamicTexture): number;
  63825. /**
  63826. * Gets a string representation of the value
  63827. * @param host defines the root host
  63828. * @param decimals defines an optional number of decimals to display
  63829. * @returns a string
  63830. */
  63831. toString(host: AdvancedDynamicTexture, decimals?: number): string;
  63832. /**
  63833. * Store a value parsed from a string
  63834. * @param source defines the source string
  63835. * @returns true if the value was successfully parsed
  63836. */
  63837. fromString(source: string | number): boolean;
  63838. private static _Regex;
  63839. private static _UNITMODE_PERCENTAGE;
  63840. private static _UNITMODE_PIXEL;
  63841. /** UNITMODE_PERCENTAGE */
  63842. static readonly UNITMODE_PERCENTAGE: number;
  63843. /** UNITMODE_PIXEL */
  63844. static readonly UNITMODE_PIXEL: number;
  63845. }
  63846. }
  63847. declare module BABYLON.GUI {
  63848. /**
  63849. * Define a style used by control to automatically setup properties based on a template.
  63850. * Only support font related properties so far
  63851. */
  63852. export class Style implements BABYLON.IDisposable {
  63853. private _fontFamily;
  63854. private _fontStyle;
  63855. private _fontWeight;
  63856. /** @hidden */
  63857. _host: AdvancedDynamicTexture;
  63858. /** @hidden */
  63859. _fontSize: ValueAndUnit;
  63860. /**
  63861. * BABYLON.Observable raised when the style values are changed
  63862. */
  63863. onChangedObservable: BABYLON.Observable<Style>;
  63864. /**
  63865. * Creates a new style object
  63866. * @param host defines the AdvancedDynamicTexture which hosts this style
  63867. */
  63868. constructor(host: AdvancedDynamicTexture);
  63869. /**
  63870. * Gets or sets the font size
  63871. */
  63872. fontSize: string | number;
  63873. /**
  63874. * Gets or sets the font family
  63875. */
  63876. fontFamily: string;
  63877. /**
  63878. * Gets or sets the font style
  63879. */
  63880. fontStyle: string;
  63881. /** Gets or sets font weight */
  63882. fontWeight: string;
  63883. /** Dispose all associated resources */
  63884. dispose(): void;
  63885. }
  63886. }
  63887. declare module BABYLON.GUI {
  63888. /**
  63889. * Class used to transport BABYLON.Vector2 information for pointer events
  63890. */
  63891. export class Vector2WithInfo extends BABYLON.Vector2 {
  63892. /** defines the current mouse button index */
  63893. buttonIndex: number;
  63894. /**
  63895. * Creates a new Vector2WithInfo
  63896. * @param source defines the vector2 data to transport
  63897. * @param buttonIndex defines the current mouse button index
  63898. */
  63899. constructor(source: BABYLON.Vector2,
  63900. /** defines the current mouse button index */
  63901. buttonIndex?: number);
  63902. }
  63903. /** Class used to provide 2D matrix features */
  63904. export class Matrix2D {
  63905. /** Gets the internal array of 6 floats used to store matrix data */
  63906. m: Float32Array;
  63907. /**
  63908. * Creates a new matrix
  63909. * @param m00 defines value for (0, 0)
  63910. * @param m01 defines value for (0, 1)
  63911. * @param m10 defines value for (1, 0)
  63912. * @param m11 defines value for (1, 1)
  63913. * @param m20 defines value for (2, 0)
  63914. * @param m21 defines value for (2, 1)
  63915. */
  63916. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  63917. /**
  63918. * Fills the matrix from direct values
  63919. * @param m00 defines value for (0, 0)
  63920. * @param m01 defines value for (0, 1)
  63921. * @param m10 defines value for (1, 0)
  63922. * @param m11 defines value for (1, 1)
  63923. * @param m20 defines value for (2, 0)
  63924. * @param m21 defines value for (2, 1)
  63925. * @returns the current modified matrix
  63926. */
  63927. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  63928. /**
  63929. * Gets matrix determinant
  63930. * @returns the determinant
  63931. */
  63932. determinant(): number;
  63933. /**
  63934. * Inverses the matrix and stores it in a target matrix
  63935. * @param result defines the target matrix
  63936. * @returns the current matrix
  63937. */
  63938. invertToRef(result: Matrix2D): Matrix2D;
  63939. /**
  63940. * Multiplies the current matrix with another one
  63941. * @param other defines the second operand
  63942. * @param result defines the target matrix
  63943. * @returns the current matrix
  63944. */
  63945. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  63946. /**
  63947. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  63948. * @param x defines the x coordinate to transform
  63949. * @param y defines the x coordinate to transform
  63950. * @param result defines the target vector2
  63951. * @returns the current matrix
  63952. */
  63953. transformCoordinates(x: number, y: number, result: BABYLON.Vector2): Matrix2D;
  63954. /**
  63955. * Creates an identity matrix
  63956. * @returns a new matrix
  63957. */
  63958. static Identity(): Matrix2D;
  63959. /**
  63960. * Creates a translation matrix and stores it in a target matrix
  63961. * @param x defines the x coordinate of the translation
  63962. * @param y defines the y coordinate of the translation
  63963. * @param result defines the target matrix
  63964. */
  63965. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  63966. /**
  63967. * Creates a scaling matrix and stores it in a target matrix
  63968. * @param x defines the x coordinate of the scaling
  63969. * @param y defines the y coordinate of the scaling
  63970. * @param result defines the target matrix
  63971. */
  63972. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  63973. /**
  63974. * Creates a rotation matrix and stores it in a target matrix
  63975. * @param angle defines the rotation angle
  63976. * @param result defines the target matrix
  63977. */
  63978. static RotationToRef(angle: number, result: Matrix2D): void;
  63979. private static _TempPreTranslationMatrix;
  63980. private static _TempPostTranslationMatrix;
  63981. private static _TempRotationMatrix;
  63982. private static _TempScalingMatrix;
  63983. private static _TempCompose0;
  63984. private static _TempCompose1;
  63985. private static _TempCompose2;
  63986. /**
  63987. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  63988. * @param tx defines the x coordinate of the translation
  63989. * @param ty defines the y coordinate of the translation
  63990. * @param angle defines the rotation angle
  63991. * @param scaleX defines the x coordinate of the scaling
  63992. * @param scaleY defines the y coordinate of the scaling
  63993. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  63994. * @param result defines the target matrix
  63995. */
  63996. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: BABYLON.Nullable<Matrix2D>, result: Matrix2D): void;
  63997. }
  63998. }
  63999. declare module BABYLON.GUI {
  64000. /**
  64001. * Class used to store 2D control sizes
  64002. */
  64003. export class Measure {
  64004. /** defines left coordinate */
  64005. left: number;
  64006. /** defines top coordinate */
  64007. top: number;
  64008. /** defines width dimension */
  64009. width: number;
  64010. /** defines height dimension */
  64011. height: number;
  64012. /**
  64013. * Creates a new measure
  64014. * @param left defines left coordinate
  64015. * @param top defines top coordinate
  64016. * @param width defines width dimension
  64017. * @param height defines height dimension
  64018. */
  64019. constructor(
  64020. /** defines left coordinate */
  64021. left: number,
  64022. /** defines top coordinate */
  64023. top: number,
  64024. /** defines width dimension */
  64025. width: number,
  64026. /** defines height dimension */
  64027. height: number);
  64028. /**
  64029. * Copy from another measure
  64030. * @param other defines the other measure to copy from
  64031. */
  64032. copyFrom(other: Measure): void;
  64033. /**
  64034. * Copy from a group of 4 floats
  64035. * @param left defines left coordinate
  64036. * @param top defines top coordinate
  64037. * @param width defines width dimension
  64038. * @param height defines height dimension
  64039. */
  64040. copyFromFloats(left: number, top: number, width: number, height: number): void;
  64041. /**
  64042. * Computes the axis aligned bounding box measure for two given measures
  64043. * @param a Input measure
  64044. * @param b Input measure
  64045. * @param result the resulting bounding measure
  64046. */
  64047. static CombineToRef(a: Measure, b: Measure, result: Measure): void;
  64048. /**
  64049. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  64050. * @param transform the matrix to transform the measure before computing the AABB
  64051. * @param result the resulting AABB
  64052. */
  64053. transformToRef(transform: Matrix2D, result: Measure): void;
  64054. /**
  64055. * Check equality between this measure and another one
  64056. * @param other defines the other measures
  64057. * @returns true if both measures are equals
  64058. */
  64059. isEqualsTo(other: Measure): boolean;
  64060. /**
  64061. * Creates an empty measure
  64062. * @returns a new measure
  64063. */
  64064. static Empty(): Measure;
  64065. }
  64066. }
  64067. declare module BABYLON.GUI {
  64068. /**
  64069. * Interface used to define a control that can receive focus
  64070. */
  64071. export interface IFocusableControl {
  64072. /**
  64073. * Function called when the control receives the focus
  64074. */
  64075. onFocus(): void;
  64076. /**
  64077. * Function called when the control loses the focus
  64078. */
  64079. onBlur(): void;
  64080. /**
  64081. * Function called to let the control handle keyboard events
  64082. * @param evt defines the current keyboard event
  64083. */
  64084. processKeyboard(evt: KeyboardEvent): void;
  64085. /**
  64086. * Function called to get the list of controls that should not steal the focus from this control
  64087. * @returns an array of controls
  64088. */
  64089. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  64090. }
  64091. /**
  64092. * Class used to create texture to support 2D GUI elements
  64093. * @see http://doc.babylonjs.com/how_to/gui
  64094. */
  64095. export class AdvancedDynamicTexture extends BABYLON.DynamicTexture {
  64096. private _isDirty;
  64097. private _renderObserver;
  64098. private _resizeObserver;
  64099. private _preKeyboardObserver;
  64100. private _pointerMoveObserver;
  64101. private _pointerObserver;
  64102. private _canvasPointerOutObserver;
  64103. private _background;
  64104. /** @hidden */
  64105. _rootContainer: Container;
  64106. /** @hidden */
  64107. _lastPickedControl: Control;
  64108. /** @hidden */
  64109. _lastControlOver: {
  64110. [pointerId: number]: Control;
  64111. };
  64112. /** @hidden */
  64113. _lastControlDown: {
  64114. [pointerId: number]: Control;
  64115. };
  64116. /** @hidden */
  64117. _capturingControl: {
  64118. [pointerId: number]: Control;
  64119. };
  64120. /** @hidden */
  64121. _shouldBlockPointer: boolean;
  64122. /** @hidden */
  64123. _layerToDispose: BABYLON.Nullable<BABYLON.Layer>;
  64124. /** @hidden */
  64125. _linkedControls: Control[];
  64126. private _isFullscreen;
  64127. private _fullscreenViewport;
  64128. private _idealWidth;
  64129. private _idealHeight;
  64130. private _useSmallestIdeal;
  64131. private _renderAtIdealSize;
  64132. private _focusedControl;
  64133. private _blockNextFocusCheck;
  64134. private _renderScale;
  64135. private _rootCanvas;
  64136. private _cursorChanged;
  64137. /**
  64138. * Define type to string to ensure compatibility across browsers
  64139. * Safari doesn't support DataTransfer constructor
  64140. */
  64141. private _clipboardData;
  64142. /**
  64143. * BABYLON.Observable event triggered each time an clipboard event is received from the rendering canvas
  64144. */
  64145. onClipboardObservable: BABYLON.Observable<BABYLON.ClipboardInfo>;
  64146. /**
  64147. * BABYLON.Observable event triggered each time a pointer down is intercepted by a control
  64148. */
  64149. onControlPickedObservable: BABYLON.Observable<Control>;
  64150. /**
  64151. * BABYLON.Observable event triggered before layout is evaluated
  64152. */
  64153. onBeginLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  64154. /**
  64155. * BABYLON.Observable event triggered after the layout was evaluated
  64156. */
  64157. onEndLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  64158. /**
  64159. * BABYLON.Observable event triggered before the texture is rendered
  64160. */
  64161. onBeginRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  64162. /**
  64163. * BABYLON.Observable event triggered after the texture was rendered
  64164. */
  64165. onEndRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  64166. /**
  64167. * Gets or sets a boolean defining if alpha is stored as premultiplied
  64168. */
  64169. premulAlpha: boolean;
  64170. /**
  64171. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  64172. * Useful when you want more antialiasing
  64173. */
  64174. renderScale: number;
  64175. /** Gets or sets the background color */
  64176. background: string;
  64177. /**
  64178. * Gets or sets the ideal width used to design controls.
  64179. * The GUI will then rescale everything accordingly
  64180. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  64181. */
  64182. idealWidth: number;
  64183. /**
  64184. * Gets or sets the ideal height used to design controls.
  64185. * The GUI will then rescale everything accordingly
  64186. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  64187. */
  64188. idealHeight: number;
  64189. /**
  64190. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  64191. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  64192. */
  64193. useSmallestIdeal: boolean;
  64194. /**
  64195. * Gets or sets a boolean indicating if adaptive scaling must be used
  64196. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  64197. */
  64198. renderAtIdealSize: boolean;
  64199. /**
  64200. * Gets the underlying layer used to render the texture when in fullscreen mode
  64201. */
  64202. readonly layer: BABYLON.Nullable<BABYLON.Layer>;
  64203. /**
  64204. * Gets the root container control
  64205. */
  64206. readonly rootContainer: Container;
  64207. /**
  64208. * Returns an array containing the root container.
  64209. * This is mostly used to let the Inspector introspects the ADT
  64210. * @returns an array containing the rootContainer
  64211. */
  64212. getChildren(): Array<Container>;
  64213. /**
  64214. * Will return all controls that are inside this texture
  64215. * @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
  64216. * @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
  64217. * @return all child controls
  64218. */
  64219. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  64220. /**
  64221. * Gets or sets the current focused control
  64222. */
  64223. focusedControl: BABYLON.Nullable<IFocusableControl>;
  64224. /**
  64225. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  64226. */
  64227. isForeground: boolean;
  64228. /**
  64229. * Gets or set information about clipboardData
  64230. */
  64231. clipboardData: string;
  64232. /**
  64233. * Creates a new AdvancedDynamicTexture
  64234. * @param name defines the name of the texture
  64235. * @param width defines the width of the texture
  64236. * @param height defines the height of the texture
  64237. * @param scene defines the hosting scene
  64238. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  64239. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  64240. */
  64241. constructor(name: string, width: number | undefined, height: number | undefined, scene: BABYLON.Nullable<BABYLON.Scene>, generateMipMaps?: boolean, samplingMode?: number);
  64242. /**
  64243. * Get the current class name of the texture useful for serialization or dynamic coding.
  64244. * @returns "AdvancedDynamicTexture"
  64245. */
  64246. getClassName(): string;
  64247. /**
  64248. * Function used to execute a function on all controls
  64249. * @param func defines the function to execute
  64250. * @param container defines the container where controls belong. If null the root container will be used
  64251. */
  64252. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  64253. private _useInvalidateRectOptimization;
  64254. /**
  64255. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  64256. */
  64257. useInvalidateRectOptimization: boolean;
  64258. private _invalidatedRectangle;
  64259. /**
  64260. * Invalidates a rectangle area on the gui texture
  64261. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  64262. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  64263. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  64264. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  64265. */
  64266. invalidateRect(invalidMinX: number, invalidMinY: number, invalidMaxX: number, invalidMaxY: number): void;
  64267. /**
  64268. * Marks the texture as dirty forcing a complete update
  64269. */
  64270. markAsDirty(): void;
  64271. /**
  64272. * Helper function used to create a new style
  64273. * @returns a new style
  64274. * @see http://doc.babylonjs.com/how_to/gui#styles
  64275. */
  64276. createStyle(): Style;
  64277. /**
  64278. * Adds a new control to the root container
  64279. * @param control defines the control to add
  64280. * @returns the current texture
  64281. */
  64282. addControl(control: Control): AdvancedDynamicTexture;
  64283. /**
  64284. * Removes a control from the root container
  64285. * @param control defines the control to remove
  64286. * @returns the current texture
  64287. */
  64288. removeControl(control: Control): AdvancedDynamicTexture;
  64289. /**
  64290. * Release all resources
  64291. */
  64292. dispose(): void;
  64293. private _onResize;
  64294. /** @hidden */
  64295. _getGlobalViewport(scene: BABYLON.Scene): BABYLON.Viewport;
  64296. /**
  64297. * Get screen coordinates for a vector3
  64298. * @param position defines the position to project
  64299. * @param worldMatrix defines the world matrix to use
  64300. * @returns the projected position
  64301. */
  64302. getProjectedPosition(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector2;
  64303. private _checkUpdate;
  64304. private _clearMeasure;
  64305. private _render;
  64306. /** @hidden */
  64307. _changeCursor(cursor: string): void;
  64308. /** @hidden */
  64309. _registerLastControlDown(control: Control, pointerId: number): void;
  64310. private _doPicking;
  64311. /** @hidden */
  64312. _cleanControlAfterRemovalFromList(list: {
  64313. [pointerId: number]: Control;
  64314. }, control: Control): void;
  64315. /** @hidden */
  64316. _cleanControlAfterRemoval(control: Control): void;
  64317. /** Attach to all scene events required to support pointer events */
  64318. attach(): void;
  64319. /** @hidden */
  64320. private onClipboardCopy;
  64321. /** @hidden */
  64322. private onClipboardCut;
  64323. /** @hidden */
  64324. private onClipboardPaste;
  64325. /**
  64326. * Register the clipboard Events onto the canvas
  64327. */
  64328. registerClipboardEvents(): void;
  64329. /**
  64330. * Unregister the clipboard Events from the canvas
  64331. */
  64332. unRegisterClipboardEvents(): void;
  64333. /**
  64334. * Connect the texture to a hosting mesh to enable interactions
  64335. * @param mesh defines the mesh to attach to
  64336. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  64337. */
  64338. attachToMesh(mesh: BABYLON.AbstractMesh, supportPointerMove?: boolean): void;
  64339. /**
  64340. * Move the focus to a specific control
  64341. * @param control defines the control which will receive the focus
  64342. */
  64343. moveFocusToControl(control: IFocusableControl): void;
  64344. private _manageFocus;
  64345. private _attachToOnPointerOut;
  64346. /**
  64347. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  64348. * @param mesh defines the mesh which will receive the texture
  64349. * @param width defines the texture width (1024 by default)
  64350. * @param height defines the texture height (1024 by default)
  64351. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  64352. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  64353. * @returns a new AdvancedDynamicTexture
  64354. */
  64355. static CreateForMesh(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, onlyAlphaTesting?: boolean): AdvancedDynamicTexture;
  64356. /**
  64357. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  64358. * In this mode the texture will rely on a layer for its rendering.
  64359. * This allows it to be treated like any other layer.
  64360. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  64361. * LayerMask is set through advancedTexture.layer.layerMask
  64362. * @param name defines name for the texture
  64363. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  64364. * @param scene defines the hsoting scene
  64365. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  64366. * @returns a new AdvancedDynamicTexture
  64367. */
  64368. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: BABYLON.Nullable<BABYLON.Scene>, sampling?: number): AdvancedDynamicTexture;
  64369. }
  64370. }
  64371. declare module BABYLON.GUI {
  64372. /**
  64373. * Root class used for all 2D controls
  64374. * @see http://doc.babylonjs.com/how_to/gui#controls
  64375. */
  64376. export class Control {
  64377. /** defines the name of the control */
  64378. name?: string | undefined;
  64379. /**
  64380. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  64381. */
  64382. static AllowAlphaInheritance: boolean;
  64383. private _alpha;
  64384. private _alphaSet;
  64385. private _zIndex;
  64386. /** @hidden */
  64387. _host: AdvancedDynamicTexture;
  64388. /** Gets or sets the control parent */
  64389. parent: BABYLON.Nullable<Container>;
  64390. /** @hidden */
  64391. _currentMeasure: Measure;
  64392. private _fontFamily;
  64393. private _fontStyle;
  64394. private _fontWeight;
  64395. private _fontSize;
  64396. private _font;
  64397. /** @hidden */
  64398. _width: ValueAndUnit;
  64399. /** @hidden */
  64400. _height: ValueAndUnit;
  64401. /** @hidden */
  64402. protected _fontOffset: {
  64403. ascent: number;
  64404. height: number;
  64405. descent: number;
  64406. };
  64407. private _color;
  64408. private _style;
  64409. private _styleObserver;
  64410. /** @hidden */
  64411. protected _horizontalAlignment: number;
  64412. /** @hidden */
  64413. protected _verticalAlignment: number;
  64414. /** @hidden */
  64415. protected _isDirty: boolean;
  64416. /** @hidden */
  64417. protected _wasDirty: boolean;
  64418. /** @hidden */
  64419. _tempParentMeasure: Measure;
  64420. /** @hidden */
  64421. _prevCurrentMeasureTransformedIntoGlobalSpace: Measure;
  64422. /** @hidden */
  64423. protected _cachedParentMeasure: Measure;
  64424. private _paddingLeft;
  64425. private _paddingRight;
  64426. private _paddingTop;
  64427. private _paddingBottom;
  64428. /** @hidden */
  64429. _left: ValueAndUnit;
  64430. /** @hidden */
  64431. _top: ValueAndUnit;
  64432. private _scaleX;
  64433. private _scaleY;
  64434. private _rotation;
  64435. private _transformCenterX;
  64436. private _transformCenterY;
  64437. /** @hidden */
  64438. _transformMatrix: Matrix2D;
  64439. /** @hidden */
  64440. protected _invertTransformMatrix: Matrix2D;
  64441. /** @hidden */
  64442. protected _transformedPosition: BABYLON.Vector2;
  64443. private _isMatrixDirty;
  64444. private _cachedOffsetX;
  64445. private _cachedOffsetY;
  64446. private _isVisible;
  64447. private _isHighlighted;
  64448. /** @hidden */
  64449. _linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  64450. private _fontSet;
  64451. private _dummyVector2;
  64452. private _downCount;
  64453. private _enterCount;
  64454. private _doNotRender;
  64455. private _downPointerIds;
  64456. protected _isEnabled: boolean;
  64457. protected _disabledColor: string;
  64458. /** @hidden */
  64459. protected _rebuildLayout: boolean;
  64460. /** @hidden */
  64461. _isClipped: boolean;
  64462. /** @hidden */
  64463. _tag: any;
  64464. /**
  64465. * 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
  64466. */
  64467. uniqueId: number;
  64468. /**
  64469. * Gets or sets an object used to store user defined information for the node
  64470. */
  64471. metadata: any;
  64472. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  64473. isHitTestVisible: boolean;
  64474. /** Gets or sets a boolean indicating if the control can block pointer events */
  64475. isPointerBlocker: boolean;
  64476. /** Gets or sets a boolean indicating if the control can be focusable */
  64477. isFocusInvisible: boolean;
  64478. /**
  64479. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  64480. * 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
  64481. */
  64482. clipChildren: boolean;
  64483. /**
  64484. * Gets or sets a boolean indicating that control content must be clipped
  64485. * 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
  64486. */
  64487. clipContent: boolean;
  64488. /**
  64489. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  64490. */
  64491. useBitmapCache: boolean;
  64492. private _cacheData;
  64493. private _shadowOffsetX;
  64494. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  64495. shadowOffsetX: number;
  64496. private _shadowOffsetY;
  64497. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  64498. shadowOffsetY: number;
  64499. private _shadowBlur;
  64500. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  64501. shadowBlur: number;
  64502. private _shadowColor;
  64503. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  64504. shadowColor: string;
  64505. /** Gets or sets the cursor to use when the control is hovered */
  64506. hoverCursor: string;
  64507. /** @hidden */
  64508. protected _linkOffsetX: ValueAndUnit;
  64509. /** @hidden */
  64510. protected _linkOffsetY: ValueAndUnit;
  64511. /** Gets the control type name */
  64512. readonly typeName: string;
  64513. /**
  64514. * Get the current class name of the control.
  64515. * @returns current class name
  64516. */
  64517. getClassName(): string;
  64518. /**
  64519. * An event triggered when the pointer move over the control.
  64520. */
  64521. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector2>;
  64522. /**
  64523. * An event triggered when the pointer move out of the control.
  64524. */
  64525. onPointerOutObservable: BABYLON.Observable<Control>;
  64526. /**
  64527. * An event triggered when the pointer taps the control
  64528. */
  64529. onPointerDownObservable: BABYLON.Observable<Vector2WithInfo>;
  64530. /**
  64531. * An event triggered when pointer up
  64532. */
  64533. onPointerUpObservable: BABYLON.Observable<Vector2WithInfo>;
  64534. /**
  64535. * An event triggered when a control is clicked on
  64536. */
  64537. onPointerClickObservable: BABYLON.Observable<Vector2WithInfo>;
  64538. /**
  64539. * An event triggered when pointer enters the control
  64540. */
  64541. onPointerEnterObservable: BABYLON.Observable<Control>;
  64542. /**
  64543. * An event triggered when the control is marked as dirty
  64544. */
  64545. onDirtyObservable: BABYLON.Observable<Control>;
  64546. /**
  64547. * An event triggered before drawing the control
  64548. */
  64549. onBeforeDrawObservable: BABYLON.Observable<Control>;
  64550. /**
  64551. * An event triggered after the control was drawn
  64552. */
  64553. onAfterDrawObservable: BABYLON.Observable<Control>;
  64554. /**
  64555. * Get the hosting AdvancedDynamicTexture
  64556. */
  64557. readonly host: AdvancedDynamicTexture;
  64558. /** Gets or set information about font offsets (used to render and align text) */
  64559. fontOffset: {
  64560. ascent: number;
  64561. height: number;
  64562. descent: number;
  64563. };
  64564. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  64565. alpha: number;
  64566. /**
  64567. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  64568. */
  64569. isHighlighted: boolean;
  64570. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  64571. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  64572. */
  64573. scaleX: number;
  64574. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  64575. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  64576. */
  64577. scaleY: number;
  64578. /** Gets or sets the rotation angle (0 by default)
  64579. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  64580. */
  64581. rotation: number;
  64582. /** Gets or sets the transformation center on Y axis (0 by default)
  64583. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  64584. */
  64585. transformCenterY: number;
  64586. /** Gets or sets the transformation center on X axis (0 by default)
  64587. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  64588. */
  64589. transformCenterX: number;
  64590. /**
  64591. * Gets or sets the horizontal alignment
  64592. * @see http://doc.babylonjs.com/how_to/gui#alignments
  64593. */
  64594. horizontalAlignment: number;
  64595. /**
  64596. * Gets or sets the vertical alignment
  64597. * @see http://doc.babylonjs.com/how_to/gui#alignments
  64598. */
  64599. verticalAlignment: number;
  64600. /**
  64601. * Gets or sets control width
  64602. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  64603. */
  64604. width: string | number;
  64605. /**
  64606. * Gets or sets the control width in pixel
  64607. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  64608. */
  64609. widthInPixels: number;
  64610. /**
  64611. * Gets or sets control height
  64612. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  64613. */
  64614. height: string | number;
  64615. /**
  64616. * Gets or sets control height in pixel
  64617. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  64618. */
  64619. heightInPixels: number;
  64620. /** Gets or set font family */
  64621. fontFamily: string;
  64622. /** Gets or sets font style */
  64623. fontStyle: string;
  64624. /** Gets or sets font weight */
  64625. fontWeight: string;
  64626. /**
  64627. * Gets or sets style
  64628. * @see http://doc.babylonjs.com/how_to/gui#styles
  64629. */
  64630. style: BABYLON.Nullable<Style>;
  64631. /** @hidden */
  64632. readonly _isFontSizeInPercentage: boolean;
  64633. /** Gets or sets font size in pixels */
  64634. fontSizeInPixels: number;
  64635. /** Gets or sets font size */
  64636. fontSize: string | number;
  64637. /** Gets or sets foreground color */
  64638. color: string;
  64639. /** Gets or sets z index which is used to reorder controls on the z axis */
  64640. zIndex: number;
  64641. /** Gets or sets a boolean indicating if the control can be rendered */
  64642. notRenderable: boolean;
  64643. /** Gets or sets a boolean indicating if the control is visible */
  64644. isVisible: boolean;
  64645. /** Gets a boolean indicating that the control needs to update its rendering */
  64646. readonly isDirty: boolean;
  64647. /**
  64648. * Gets the current linked mesh (or null if none)
  64649. */
  64650. readonly linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  64651. /**
  64652. * Gets or sets a value indicating the padding to use on the left of the control
  64653. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  64654. */
  64655. paddingLeft: string | number;
  64656. /**
  64657. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  64658. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  64659. */
  64660. paddingLeftInPixels: number;
  64661. /**
  64662. * Gets or sets a value indicating the padding to use on the right of the control
  64663. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  64664. */
  64665. paddingRight: string | number;
  64666. /**
  64667. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  64668. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  64669. */
  64670. paddingRightInPixels: number;
  64671. /**
  64672. * Gets or sets a value indicating the padding to use on the top of the control
  64673. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  64674. */
  64675. paddingTop: string | number;
  64676. /**
  64677. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  64678. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  64679. */
  64680. paddingTopInPixels: number;
  64681. /**
  64682. * Gets or sets a value indicating the padding to use on the bottom of the control
  64683. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  64684. */
  64685. paddingBottom: string | number;
  64686. /**
  64687. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  64688. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  64689. */
  64690. paddingBottomInPixels: number;
  64691. /**
  64692. * Gets or sets a value indicating the left coordinate of the control
  64693. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  64694. */
  64695. left: string | number;
  64696. /**
  64697. * Gets or sets a value indicating the left coordinate in pixels of the control
  64698. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  64699. */
  64700. leftInPixels: number;
  64701. /**
  64702. * Gets or sets a value indicating the top coordinate of the control
  64703. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  64704. */
  64705. top: string | number;
  64706. /**
  64707. * Gets or sets a value indicating the top coordinate in pixels of the control
  64708. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  64709. */
  64710. topInPixels: number;
  64711. /**
  64712. * Gets or sets a value indicating the offset on X axis to the linked mesh
  64713. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  64714. */
  64715. linkOffsetX: string | number;
  64716. /**
  64717. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  64718. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  64719. */
  64720. linkOffsetXInPixels: number;
  64721. /**
  64722. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  64723. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  64724. */
  64725. linkOffsetY: string | number;
  64726. /**
  64727. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  64728. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  64729. */
  64730. linkOffsetYInPixels: number;
  64731. /** Gets the center coordinate on X axis */
  64732. readonly centerX: number;
  64733. /** Gets the center coordinate on Y axis */
  64734. readonly centerY: number;
  64735. /** Gets or sets if control is Enabled*/
  64736. isEnabled: boolean;
  64737. /** Gets or sets background color of control if it's disabled*/
  64738. disabledColor: string;
  64739. /**
  64740. * Creates a new control
  64741. * @param name defines the name of the control
  64742. */
  64743. constructor(
  64744. /** defines the name of the control */
  64745. name?: string | undefined);
  64746. /** @hidden */
  64747. protected _getTypeName(): string;
  64748. /**
  64749. * Gets the first ascendant in the hierarchy of the given type
  64750. * @param className defines the required type
  64751. * @returns the ascendant or null if not found
  64752. */
  64753. getAscendantOfClass(className: string): BABYLON.Nullable<Control>;
  64754. /** @hidden */
  64755. _resetFontCache(): void;
  64756. /**
  64757. * Determines if a container is an ascendant of the current control
  64758. * @param container defines the container to look for
  64759. * @returns true if the container is one of the ascendant of the control
  64760. */
  64761. isAscendant(container: Control): boolean;
  64762. /**
  64763. * Gets coordinates in local control space
  64764. * @param globalCoordinates defines the coordinates to transform
  64765. * @returns the new coordinates in local space
  64766. */
  64767. getLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  64768. /**
  64769. * Gets coordinates in local control space
  64770. * @param globalCoordinates defines the coordinates to transform
  64771. * @param result defines the target vector2 where to store the result
  64772. * @returns the current control
  64773. */
  64774. getLocalCoordinatesToRef(globalCoordinates: BABYLON.Vector2, result: BABYLON.Vector2): Control;
  64775. /**
  64776. * Gets coordinates in parent local control space
  64777. * @param globalCoordinates defines the coordinates to transform
  64778. * @returns the new coordinates in parent local space
  64779. */
  64780. getParentLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  64781. /**
  64782. * Move the current control to a vector3 position projected onto the screen.
  64783. * @param position defines the target position
  64784. * @param scene defines the hosting scene
  64785. */
  64786. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene): void;
  64787. /** @hidden */
  64788. _getDescendants(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  64789. /**
  64790. * Will return all controls that have this control as ascendant
  64791. * @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
  64792. * @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
  64793. * @return all child controls
  64794. */
  64795. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  64796. /**
  64797. * Link current control with a target mesh
  64798. * @param mesh defines the mesh to link with
  64799. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  64800. */
  64801. linkWithMesh(mesh: BABYLON.Nullable<BABYLON.AbstractMesh>): void;
  64802. /** @hidden */
  64803. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3): void;
  64804. /** @hidden */
  64805. _offsetLeft(offset: number): void;
  64806. /** @hidden */
  64807. _offsetTop(offset: number): void;
  64808. /** @hidden */
  64809. _markMatrixAsDirty(): void;
  64810. /** @hidden */
  64811. _flagDescendantsAsMatrixDirty(): void;
  64812. /** @hidden */
  64813. _intersectsRect(rect: Measure): boolean;
  64814. /** @hidden */
  64815. protected invalidateRect(): void;
  64816. /** @hidden */
  64817. _markAsDirty(force?: boolean): void;
  64818. /** @hidden */
  64819. _markAllAsDirty(): void;
  64820. /** @hidden */
  64821. _link(host: AdvancedDynamicTexture): void;
  64822. /** @hidden */
  64823. protected _transform(context?: CanvasRenderingContext2D): void;
  64824. /** @hidden */
  64825. _renderHighlight(context: CanvasRenderingContext2D): void;
  64826. /** @hidden */
  64827. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  64828. /** @hidden */
  64829. protected _applyStates(context: CanvasRenderingContext2D): void;
  64830. /** @hidden */
  64831. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  64832. /** @hidden */
  64833. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  64834. protected _evaluateClippingState(parentMeasure: Measure): void;
  64835. /** @hidden */
  64836. _measure(): void;
  64837. /** @hidden */
  64838. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  64839. /** @hidden */
  64840. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  64841. /** @hidden */
  64842. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  64843. /** @hidden */
  64844. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  64845. private static _ClipMeasure;
  64846. private _tmpMeasureA;
  64847. private _clip;
  64848. /** @hidden */
  64849. _render(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): boolean;
  64850. /** @hidden */
  64851. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  64852. /**
  64853. * Tests if a given coordinates belong to the current control
  64854. * @param x defines x coordinate to test
  64855. * @param y defines y coordinate to test
  64856. * @returns true if the coordinates are inside the control
  64857. */
  64858. contains(x: number, y: number): boolean;
  64859. /** @hidden */
  64860. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  64861. /** @hidden */
  64862. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  64863. /** @hidden */
  64864. _onPointerEnter(target: Control): boolean;
  64865. /** @hidden */
  64866. _onPointerOut(target: Control, force?: boolean): void;
  64867. /** @hidden */
  64868. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  64869. /** @hidden */
  64870. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  64871. /** @hidden */
  64872. _forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  64873. /** @hidden */
  64874. _processObservables(type: number, x: number, y: number, pointerId: number, buttonIndex: number): boolean;
  64875. private _prepareFont;
  64876. /** Releases associated resources */
  64877. dispose(): void;
  64878. private static _HORIZONTAL_ALIGNMENT_LEFT;
  64879. private static _HORIZONTAL_ALIGNMENT_RIGHT;
  64880. private static _HORIZONTAL_ALIGNMENT_CENTER;
  64881. private static _VERTICAL_ALIGNMENT_TOP;
  64882. private static _VERTICAL_ALIGNMENT_BOTTOM;
  64883. private static _VERTICAL_ALIGNMENT_CENTER;
  64884. /** HORIZONTAL_ALIGNMENT_LEFT */
  64885. static readonly HORIZONTAL_ALIGNMENT_LEFT: number;
  64886. /** HORIZONTAL_ALIGNMENT_RIGHT */
  64887. static readonly HORIZONTAL_ALIGNMENT_RIGHT: number;
  64888. /** HORIZONTAL_ALIGNMENT_CENTER */
  64889. static readonly HORIZONTAL_ALIGNMENT_CENTER: number;
  64890. /** VERTICAL_ALIGNMENT_TOP */
  64891. static readonly VERTICAL_ALIGNMENT_TOP: number;
  64892. /** VERTICAL_ALIGNMENT_BOTTOM */
  64893. static readonly VERTICAL_ALIGNMENT_BOTTOM: number;
  64894. /** VERTICAL_ALIGNMENT_CENTER */
  64895. static readonly VERTICAL_ALIGNMENT_CENTER: number;
  64896. private static _FontHeightSizes;
  64897. /** @hidden */
  64898. static _GetFontOffset(font: string): {
  64899. ascent: number;
  64900. height: number;
  64901. descent: number;
  64902. };
  64903. /**
  64904. * Creates a stack panel that can be used to render headers
  64905. * @param control defines the control to associate with the header
  64906. * @param text defines the text of the header
  64907. * @param size defines the size of the header
  64908. * @param options defines options used to configure the header
  64909. * @returns a new StackPanel
  64910. * @ignore
  64911. * @hidden
  64912. */
  64913. static AddHeader: (control: Control, text: string, size: string | number, options: {
  64914. isHorizontal: boolean;
  64915. controlFirst: boolean;
  64916. }) => any;
  64917. /** @hidden */
  64918. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  64919. }
  64920. }
  64921. declare module BABYLON.GUI {
  64922. /**
  64923. * Root class for 2D containers
  64924. * @see http://doc.babylonjs.com/how_to/gui#containers
  64925. */
  64926. export class Container extends Control {
  64927. name?: string | undefined;
  64928. /** @hidden */
  64929. protected _children: Control[];
  64930. /** @hidden */
  64931. protected _measureForChildren: Measure;
  64932. /** @hidden */
  64933. protected _background: string;
  64934. /** @hidden */
  64935. protected _adaptWidthToChildren: boolean;
  64936. /** @hidden */
  64937. protected _adaptHeightToChildren: boolean;
  64938. /**
  64939. * Gets or sets a boolean indicating that layout cycle errors should be displayed on the console
  64940. */
  64941. logLayoutCycleErrors: boolean;
  64942. /**
  64943. * Gets or sets the number of layout cycles (a change involved by a control while evaluating the layout) allowed
  64944. */
  64945. maxLayoutCycle: number;
  64946. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  64947. adaptHeightToChildren: boolean;
  64948. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  64949. adaptWidthToChildren: boolean;
  64950. /** Gets or sets background color */
  64951. background: string;
  64952. /** Gets the list of children */
  64953. readonly children: Control[];
  64954. /**
  64955. * Creates a new Container
  64956. * @param name defines the name of the container
  64957. */
  64958. constructor(name?: string | undefined);
  64959. protected _getTypeName(): string;
  64960. _flagDescendantsAsMatrixDirty(): void;
  64961. /**
  64962. * Gets a child using its name
  64963. * @param name defines the child name to look for
  64964. * @returns the child control if found
  64965. */
  64966. getChildByName(name: string): BABYLON.Nullable<Control>;
  64967. /**
  64968. * Gets a child using its type and its name
  64969. * @param name defines the child name to look for
  64970. * @param type defines the child type to look for
  64971. * @returns the child control if found
  64972. */
  64973. getChildByType(name: string, type: string): BABYLON.Nullable<Control>;
  64974. /**
  64975. * Search for a specific control in children
  64976. * @param control defines the control to look for
  64977. * @returns true if the control is in child list
  64978. */
  64979. containsControl(control: Control): boolean;
  64980. /**
  64981. * Adds a new control to the current container
  64982. * @param control defines the control to add
  64983. * @returns the current container
  64984. */
  64985. addControl(control: BABYLON.Nullable<Control>): Container;
  64986. /**
  64987. * Removes all controls from the current container
  64988. * @returns the current container
  64989. */
  64990. clearControls(): Container;
  64991. /**
  64992. * Removes a control from the current container
  64993. * @param control defines the control to remove
  64994. * @returns the current container
  64995. */
  64996. removeControl(control: Control): Container;
  64997. /** @hidden */
  64998. _reOrderControl(control: Control): void;
  64999. /** @hidden */
  65000. _offsetLeft(offset: number): void;
  65001. /** @hidden */
  65002. _offsetTop(offset: number): void;
  65003. /** @hidden */
  65004. _markAllAsDirty(): void;
  65005. /** @hidden */
  65006. protected _localDraw(context: CanvasRenderingContext2D): void;
  65007. /** @hidden */
  65008. _link(host: AdvancedDynamicTexture): void;
  65009. /** @hidden */
  65010. protected _beforeLayout(): void;
  65011. /** @hidden */
  65012. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  65013. /** @hidden */
  65014. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  65015. protected _postMeasure(): void;
  65016. /** @hidden */
  65017. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  65018. /** @hidden */
  65019. _getDescendants(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  65020. /** @hidden */
  65021. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  65022. /** @hidden */
  65023. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  65024. /** Releases associated resources */
  65025. dispose(): void;
  65026. }
  65027. }
  65028. declare module BABYLON.GUI {
  65029. /** Class used to create rectangle container */
  65030. export class Rectangle extends Container {
  65031. name?: string | undefined;
  65032. private _thickness;
  65033. private _cornerRadius;
  65034. /** Gets or sets border thickness */
  65035. thickness: number;
  65036. /** Gets or sets the corner radius angle */
  65037. cornerRadius: number;
  65038. /**
  65039. * Creates a new Rectangle
  65040. * @param name defines the control name
  65041. */
  65042. constructor(name?: string | undefined);
  65043. protected _getTypeName(): string;
  65044. protected _localDraw(context: CanvasRenderingContext2D): void;
  65045. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  65046. private _drawRoundedRect;
  65047. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  65048. }
  65049. }
  65050. declare module BABYLON.GUI {
  65051. /**
  65052. * Enum that determines the text-wrapping mode to use.
  65053. */
  65054. export enum TextWrapping {
  65055. /**
  65056. * Clip the text when it's larger than Control.width; this is the default mode.
  65057. */
  65058. Clip = 0,
  65059. /**
  65060. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  65061. */
  65062. WordWrap = 1,
  65063. /**
  65064. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  65065. */
  65066. Ellipsis = 2
  65067. }
  65068. /**
  65069. * Class used to create text block control
  65070. */
  65071. export class TextBlock extends Control {
  65072. /**
  65073. * Defines the name of the control
  65074. */
  65075. name?: string | undefined;
  65076. private _text;
  65077. private _textWrapping;
  65078. private _textHorizontalAlignment;
  65079. private _textVerticalAlignment;
  65080. private _lines;
  65081. private _resizeToFit;
  65082. private _lineSpacing;
  65083. private _outlineWidth;
  65084. private _outlineColor;
  65085. /**
  65086. * An event triggered after the text is changed
  65087. */
  65088. onTextChangedObservable: BABYLON.Observable<TextBlock>;
  65089. /**
  65090. * An event triggered after the text was broken up into lines
  65091. */
  65092. onLinesReadyObservable: BABYLON.Observable<TextBlock>;
  65093. /**
  65094. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  65095. */
  65096. readonly lines: any[];
  65097. /**
  65098. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  65099. */
  65100. /**
  65101. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  65102. */
  65103. resizeToFit: boolean;
  65104. /**
  65105. * Gets or sets a boolean indicating if text must be wrapped
  65106. */
  65107. /**
  65108. * Gets or sets a boolean indicating if text must be wrapped
  65109. */
  65110. textWrapping: TextWrapping | boolean;
  65111. /**
  65112. * Gets or sets text to display
  65113. */
  65114. /**
  65115. * Gets or sets text to display
  65116. */
  65117. text: string;
  65118. /**
  65119. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  65120. */
  65121. /**
  65122. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  65123. */
  65124. textHorizontalAlignment: number;
  65125. /**
  65126. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  65127. */
  65128. /**
  65129. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  65130. */
  65131. textVerticalAlignment: number;
  65132. /**
  65133. * Gets or sets line spacing value
  65134. */
  65135. /**
  65136. * Gets or sets line spacing value
  65137. */
  65138. lineSpacing: string | number;
  65139. /**
  65140. * Gets or sets outlineWidth of the text to display
  65141. */
  65142. /**
  65143. * Gets or sets outlineWidth of the text to display
  65144. */
  65145. outlineWidth: number;
  65146. /**
  65147. * Gets or sets outlineColor of the text to display
  65148. */
  65149. /**
  65150. * Gets or sets outlineColor of the text to display
  65151. */
  65152. outlineColor: string;
  65153. /**
  65154. * Creates a new TextBlock object
  65155. * @param name defines the name of the control
  65156. * @param text defines the text to display (emptry string by default)
  65157. */
  65158. constructor(
  65159. /**
  65160. * Defines the name of the control
  65161. */
  65162. name?: string | undefined, text?: string);
  65163. protected _getTypeName(): string;
  65164. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  65165. private _drawText;
  65166. /** @hidden */
  65167. _draw(context: CanvasRenderingContext2D): void;
  65168. protected _applyStates(context: CanvasRenderingContext2D): void;
  65169. protected _breakLines(refWidth: number, context: CanvasRenderingContext2D): object[];
  65170. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  65171. protected _parseLineEllipsis(line: string | undefined, width: number, context: CanvasRenderingContext2D): object;
  65172. protected _parseLineWordWrap(line: string | undefined, width: number, context: CanvasRenderingContext2D): object[];
  65173. protected _renderLines(context: CanvasRenderingContext2D): void;
  65174. /**
  65175. * Given a width constraint applied on the text block, find the expected height
  65176. * @returns expected height
  65177. */
  65178. computeExpectedHeight(): number;
  65179. dispose(): void;
  65180. }
  65181. }
  65182. declare module BABYLON.GUI {
  65183. /**
  65184. * Class used to create 2D images
  65185. */
  65186. export class Image extends Control {
  65187. name?: string | undefined;
  65188. private static _WorkingCanvas;
  65189. private _domImage;
  65190. private _imageWidth;
  65191. private _imageHeight;
  65192. private _loaded;
  65193. private _stretch;
  65194. private _source;
  65195. private _autoScale;
  65196. private _sourceLeft;
  65197. private _sourceTop;
  65198. private _sourceWidth;
  65199. private _sourceHeight;
  65200. private _cellWidth;
  65201. private _cellHeight;
  65202. private _cellId;
  65203. private _populateNinePatchSlicesFromImage;
  65204. private _sliceLeft;
  65205. private _sliceRight;
  65206. private _sliceTop;
  65207. private _sliceBottom;
  65208. private _detectPointerOnOpaqueOnly;
  65209. /**
  65210. * BABYLON.Observable notified when the content is loaded
  65211. */
  65212. onImageLoadedObservable: BABYLON.Observable<Image>;
  65213. /**
  65214. * BABYLON.Observable notified when _sourceLeft, _sourceTop, _sourceWidth and _sourceHeight are computed
  65215. */
  65216. onSVGAttributesComputedObservable: BABYLON.Observable<Image>;
  65217. /**
  65218. * Gets a boolean indicating that the content is loaded
  65219. */
  65220. readonly isLoaded: boolean;
  65221. /**
  65222. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  65223. */
  65224. populateNinePatchSlicesFromImage: boolean;
  65225. /**
  65226. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  65227. * Beware using this as this will comsume more memory as the image has to be stored twice
  65228. */
  65229. detectPointerOnOpaqueOnly: boolean;
  65230. /**
  65231. * Gets or sets the left value for slicing (9-patch)
  65232. */
  65233. sliceLeft: number;
  65234. /**
  65235. * Gets or sets the right value for slicing (9-patch)
  65236. */
  65237. sliceRight: number;
  65238. /**
  65239. * Gets or sets the top value for slicing (9-patch)
  65240. */
  65241. sliceTop: number;
  65242. /**
  65243. * Gets or sets the bottom value for slicing (9-patch)
  65244. */
  65245. sliceBottom: number;
  65246. /**
  65247. * Gets or sets the left coordinate in the source image
  65248. */
  65249. sourceLeft: number;
  65250. /**
  65251. * Gets or sets the top coordinate in the source image
  65252. */
  65253. sourceTop: number;
  65254. /**
  65255. * Gets or sets the width to capture in the source image
  65256. */
  65257. sourceWidth: number;
  65258. /**
  65259. * Gets or sets the height to capture in the source image
  65260. */
  65261. sourceHeight: number;
  65262. /**
  65263. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  65264. * @see http://doc.babylonjs.com/how_to/gui#image
  65265. */
  65266. autoScale: boolean;
  65267. /** Gets or sets the streching mode used by the image */
  65268. stretch: number;
  65269. /**
  65270. * Gets or sets the internal DOM image used to render the control
  65271. */
  65272. domImage: HTMLImageElement;
  65273. private _onImageLoaded;
  65274. private _extractNinePatchSliceDataFromImage;
  65275. /**
  65276. * Gets or sets image source url
  65277. */
  65278. source: BABYLON.Nullable<string>;
  65279. /**
  65280. * Checks for svg document with icon id present
  65281. */
  65282. private _svgCheck;
  65283. /**
  65284. * Sets sourceLeft, sourceTop, sourceWidth, sourceHeight automatically
  65285. * given external svg file and icon id
  65286. */
  65287. private _getSVGAttribs;
  65288. /**
  65289. * Gets or sets the cell width to use when animation sheet is enabled
  65290. * @see http://doc.babylonjs.com/how_to/gui#image
  65291. */
  65292. cellWidth: number;
  65293. /**
  65294. * Gets or sets the cell height to use when animation sheet is enabled
  65295. * @see http://doc.babylonjs.com/how_to/gui#image
  65296. */
  65297. cellHeight: number;
  65298. /**
  65299. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  65300. * @see http://doc.babylonjs.com/how_to/gui#image
  65301. */
  65302. cellId: number;
  65303. /**
  65304. * Creates a new Image
  65305. * @param name defines the control name
  65306. * @param url defines the image url
  65307. */
  65308. constructor(name?: string | undefined, url?: BABYLON.Nullable<string>);
  65309. /**
  65310. * Tests if a given coordinates belong to the current control
  65311. * @param x defines x coordinate to test
  65312. * @param y defines y coordinate to test
  65313. * @returns true if the coordinates are inside the control
  65314. */
  65315. contains(x: number, y: number): boolean;
  65316. protected _getTypeName(): string;
  65317. /** Force the control to synchronize with its content */
  65318. synchronizeSizeWithContent(): void;
  65319. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  65320. private _prepareWorkingCanvasForOpaqueDetection;
  65321. private _drawImage;
  65322. _draw(context: CanvasRenderingContext2D): void;
  65323. private _renderCornerPatch;
  65324. private _renderNinePatch;
  65325. dispose(): void;
  65326. /** STRETCH_NONE */
  65327. static readonly STRETCH_NONE: number;
  65328. /** STRETCH_FILL */
  65329. static readonly STRETCH_FILL: number;
  65330. /** STRETCH_UNIFORM */
  65331. static readonly STRETCH_UNIFORM: number;
  65332. /** STRETCH_EXTEND */
  65333. static readonly STRETCH_EXTEND: number;
  65334. /** NINE_PATCH */
  65335. static readonly STRETCH_NINE_PATCH: number;
  65336. }
  65337. }
  65338. declare module BABYLON.GUI {
  65339. /**
  65340. * Class used to create 2D buttons
  65341. */
  65342. export class Button extends Rectangle {
  65343. name?: string | undefined;
  65344. /**
  65345. * Function called to generate a pointer enter animation
  65346. */
  65347. pointerEnterAnimation: () => void;
  65348. /**
  65349. * Function called to generate a pointer out animation
  65350. */
  65351. pointerOutAnimation: () => void;
  65352. /**
  65353. * Function called to generate a pointer down animation
  65354. */
  65355. pointerDownAnimation: () => void;
  65356. /**
  65357. * Function called to generate a pointer up animation
  65358. */
  65359. pointerUpAnimation: () => void;
  65360. /**
  65361. * Gets or sets a boolean indicating that the button will let internal controls handle picking instead of doing it directly using its bounding info
  65362. */
  65363. delegatePickingToChildren: boolean;
  65364. private _image;
  65365. /**
  65366. * Returns the image part of the button (if any)
  65367. */
  65368. readonly image: BABYLON.Nullable<Image>;
  65369. private _textBlock;
  65370. /**
  65371. * Returns the image part of the button (if any)
  65372. */
  65373. readonly textBlock: BABYLON.Nullable<TextBlock>;
  65374. /**
  65375. * Creates a new Button
  65376. * @param name defines the name of the button
  65377. */
  65378. constructor(name?: string | undefined);
  65379. protected _getTypeName(): string;
  65380. /** @hidden */
  65381. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  65382. /** @hidden */
  65383. _onPointerEnter(target: Control): boolean;
  65384. /** @hidden */
  65385. _onPointerOut(target: Control, force?: boolean): void;
  65386. /** @hidden */
  65387. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  65388. /** @hidden */
  65389. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  65390. /**
  65391. * Creates a new button made with an image and a text
  65392. * @param name defines the name of the button
  65393. * @param text defines the text of the button
  65394. * @param imageUrl defines the url of the image
  65395. * @returns a new Button
  65396. */
  65397. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  65398. /**
  65399. * Creates a new button made with an image
  65400. * @param name defines the name of the button
  65401. * @param imageUrl defines the url of the image
  65402. * @returns a new Button
  65403. */
  65404. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  65405. /**
  65406. * Creates a new button made with a text
  65407. * @param name defines the name of the button
  65408. * @param text defines the text of the button
  65409. * @returns a new Button
  65410. */
  65411. static CreateSimpleButton(name: string, text: string): Button;
  65412. /**
  65413. * Creates a new button made with an image and a centered text
  65414. * @param name defines the name of the button
  65415. * @param text defines the text of the button
  65416. * @param imageUrl defines the url of the image
  65417. * @returns a new Button
  65418. */
  65419. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  65420. }
  65421. }
  65422. declare module BABYLON.GUI {
  65423. /**
  65424. * Class used to create a 2D stack panel container
  65425. */
  65426. export class StackPanel extends Container {
  65427. name?: string | undefined;
  65428. private _isVertical;
  65429. private _manualWidth;
  65430. private _manualHeight;
  65431. private _doNotTrackManualChanges;
  65432. /**
  65433. * Gets or sets a boolean indicating that layou warnings should be ignored
  65434. */
  65435. ignoreLayoutWarnings: boolean;
  65436. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  65437. isVertical: boolean;
  65438. /**
  65439. * Gets or sets panel width.
  65440. * This value should not be set when in horizontal mode as it will be computed automatically
  65441. */
  65442. width: string | number;
  65443. /**
  65444. * Gets or sets panel height.
  65445. * This value should not be set when in vertical mode as it will be computed automatically
  65446. */
  65447. height: string | number;
  65448. /**
  65449. * Creates a new StackPanel
  65450. * @param name defines control name
  65451. */
  65452. constructor(name?: string | undefined);
  65453. protected _getTypeName(): string;
  65454. /** @hidden */
  65455. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  65456. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  65457. protected _postMeasure(): void;
  65458. }
  65459. }
  65460. declare module BABYLON.GUI {
  65461. /**
  65462. * Class used to represent a 2D checkbox
  65463. */
  65464. export class Checkbox extends Control {
  65465. name?: string | undefined;
  65466. private _isChecked;
  65467. private _background;
  65468. private _checkSizeRatio;
  65469. private _thickness;
  65470. /** Gets or sets border thickness */
  65471. thickness: number;
  65472. /**
  65473. * BABYLON.Observable raised when isChecked property changes
  65474. */
  65475. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  65476. /** Gets or sets a value indicating the ratio between overall size and check size */
  65477. checkSizeRatio: number;
  65478. /** Gets or sets background color */
  65479. background: string;
  65480. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  65481. isChecked: boolean;
  65482. /**
  65483. * Creates a new CheckBox
  65484. * @param name defines the control name
  65485. */
  65486. constructor(name?: string | undefined);
  65487. protected _getTypeName(): string;
  65488. /** @hidden */
  65489. _draw(context: CanvasRenderingContext2D): void;
  65490. /** @hidden */
  65491. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  65492. /**
  65493. * Utility function to easily create a checkbox with a header
  65494. * @param title defines the label to use for the header
  65495. * @param onValueChanged defines the callback to call when value changes
  65496. * @returns a StackPanel containing the checkbox and a textBlock
  65497. */
  65498. static AddCheckBoxWithHeader(title: string, onValueChanged: (value: boolean) => void): StackPanel;
  65499. }
  65500. }
  65501. declare module BABYLON.GUI {
  65502. /**
  65503. * Class used to store key control properties
  65504. */
  65505. export class KeyPropertySet {
  65506. /** Width */
  65507. width?: string;
  65508. /** Height */
  65509. height?: string;
  65510. /** Left padding */
  65511. paddingLeft?: string;
  65512. /** Right padding */
  65513. paddingRight?: string;
  65514. /** Top padding */
  65515. paddingTop?: string;
  65516. /** Bottom padding */
  65517. paddingBottom?: string;
  65518. /** Foreground color */
  65519. color?: string;
  65520. /** Background color */
  65521. background?: string;
  65522. }
  65523. /**
  65524. * Class used to create virtual keyboard
  65525. */
  65526. export class VirtualKeyboard extends StackPanel {
  65527. /** BABYLON.Observable raised when a key is pressed */
  65528. onKeyPressObservable: BABYLON.Observable<string>;
  65529. /** Gets or sets default key button width */
  65530. defaultButtonWidth: string;
  65531. /** Gets or sets default key button height */
  65532. defaultButtonHeight: string;
  65533. /** Gets or sets default key button left padding */
  65534. defaultButtonPaddingLeft: string;
  65535. /** Gets or sets default key button right padding */
  65536. defaultButtonPaddingRight: string;
  65537. /** Gets or sets default key button top padding */
  65538. defaultButtonPaddingTop: string;
  65539. /** Gets or sets default key button bottom padding */
  65540. defaultButtonPaddingBottom: string;
  65541. /** Gets or sets default key button foreground color */
  65542. defaultButtonColor: string;
  65543. /** Gets or sets default key button background color */
  65544. defaultButtonBackground: string;
  65545. /** Gets or sets shift button foreground color */
  65546. shiftButtonColor: string;
  65547. /** Gets or sets shift button thickness*/
  65548. selectedShiftThickness: number;
  65549. /** Gets shift key state */
  65550. shiftState: number;
  65551. protected _getTypeName(): string;
  65552. private _createKey;
  65553. /**
  65554. * Adds a new row of keys
  65555. * @param keys defines the list of keys to add
  65556. * @param propertySets defines the associated property sets
  65557. */
  65558. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  65559. /**
  65560. * Set the shift key to a specific state
  65561. * @param shiftState defines the new shift state
  65562. */
  65563. applyShiftState(shiftState: number): void;
  65564. private _currentlyConnectedInputText;
  65565. private _connectedInputTexts;
  65566. private _onKeyPressObserver;
  65567. /** Gets the input text control currently attached to the keyboard */
  65568. readonly connectedInputText: BABYLON.Nullable<InputText>;
  65569. /**
  65570. * Connects the keyboard with an input text control
  65571. *
  65572. * @param input defines the target control
  65573. */
  65574. connect(input: InputText): void;
  65575. /**
  65576. * Disconnects the keyboard from connected InputText controls
  65577. *
  65578. * @param input optionally defines a target control, otherwise all are disconnected
  65579. */
  65580. disconnect(input?: InputText): void;
  65581. private _removeConnectedInputObservables;
  65582. /**
  65583. * Release all resources
  65584. */
  65585. dispose(): void;
  65586. /**
  65587. * Creates a new keyboard using a default layout
  65588. *
  65589. * @param name defines control name
  65590. * @returns a new VirtualKeyboard
  65591. */
  65592. static CreateDefaultLayout(name?: string): VirtualKeyboard;
  65593. }
  65594. }
  65595. declare module BABYLON.GUI {
  65596. /**
  65597. * Class used to create input text control
  65598. */
  65599. export class InputText extends Control implements IFocusableControl {
  65600. name?: string | undefined;
  65601. private _text;
  65602. private _placeholderText;
  65603. private _background;
  65604. private _focusedBackground;
  65605. private _focusedColor;
  65606. private _placeholderColor;
  65607. private _thickness;
  65608. private _margin;
  65609. private _autoStretchWidth;
  65610. private _maxWidth;
  65611. private _isFocused;
  65612. private _blinkTimeout;
  65613. private _blinkIsEven;
  65614. private _cursorOffset;
  65615. private _scrollLeft;
  65616. private _textWidth;
  65617. private _clickedCoordinate;
  65618. private _deadKey;
  65619. private _addKey;
  65620. private _currentKey;
  65621. private _isTextHighlightOn;
  65622. private _textHighlightColor;
  65623. private _highligherOpacity;
  65624. private _highlightedText;
  65625. private _startHighlightIndex;
  65626. private _endHighlightIndex;
  65627. private _cursorIndex;
  65628. private _onFocusSelectAll;
  65629. private _isPointerDown;
  65630. private _onClipboardObserver;
  65631. private _onPointerDblTapObserver;
  65632. /** @hidden */
  65633. _connectedVirtualKeyboard: BABYLON.Nullable<VirtualKeyboard>;
  65634. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  65635. promptMessage: string;
  65636. /** Force disable prompt on mobile device */
  65637. disableMobilePrompt: boolean;
  65638. /** BABYLON.Observable raised when the text changes */
  65639. onTextChangedObservable: BABYLON.Observable<InputText>;
  65640. /** BABYLON.Observable raised just before an entered character is to be added */
  65641. onBeforeKeyAddObservable: BABYLON.Observable<InputText>;
  65642. /** BABYLON.Observable raised when the control gets the focus */
  65643. onFocusObservable: BABYLON.Observable<InputText>;
  65644. /** BABYLON.Observable raised when the control loses the focus */
  65645. onBlurObservable: BABYLON.Observable<InputText>;
  65646. /**Observable raised when the text is highlighted */
  65647. onTextHighlightObservable: BABYLON.Observable<InputText>;
  65648. /**Observable raised when copy event is triggered */
  65649. onTextCopyObservable: BABYLON.Observable<InputText>;
  65650. /** BABYLON.Observable raised when cut event is triggered */
  65651. onTextCutObservable: BABYLON.Observable<InputText>;
  65652. /** BABYLON.Observable raised when paste event is triggered */
  65653. onTextPasteObservable: BABYLON.Observable<InputText>;
  65654. /** BABYLON.Observable raised when a key event was processed */
  65655. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  65656. /** Gets or sets the maximum width allowed by the control */
  65657. maxWidth: string | number;
  65658. /** Gets the maximum width allowed by the control in pixels */
  65659. readonly maxWidthInPixels: number;
  65660. /** Gets or sets the text highlighter transparency; default: 0.4 */
  65661. highligherOpacity: number;
  65662. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  65663. onFocusSelectAll: boolean;
  65664. /** Gets or sets the text hightlight color */
  65665. textHighlightColor: string;
  65666. /** Gets or sets control margin */
  65667. margin: string;
  65668. /** Gets control margin in pixels */
  65669. readonly marginInPixels: number;
  65670. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  65671. autoStretchWidth: boolean;
  65672. /** Gets or sets border thickness */
  65673. thickness: number;
  65674. /** Gets or sets the background color when focused */
  65675. focusedBackground: string;
  65676. /** Gets or sets the background color when focused */
  65677. focusedColor: string;
  65678. /** Gets or sets the background color */
  65679. background: string;
  65680. /** Gets or sets the placeholder color */
  65681. placeholderColor: string;
  65682. /** Gets or sets the text displayed when the control is empty */
  65683. placeholderText: string;
  65684. /** Gets or sets the dead key flag */
  65685. deadKey: boolean;
  65686. /** Gets or sets the highlight text */
  65687. highlightedText: string;
  65688. /** Gets or sets if the current key should be added */
  65689. addKey: boolean;
  65690. /** Gets or sets the value of the current key being entered */
  65691. currentKey: string;
  65692. /** Gets or sets the text displayed in the control */
  65693. text: string;
  65694. /** Gets or sets control width */
  65695. width: string | number;
  65696. /**
  65697. * Creates a new InputText
  65698. * @param name defines the control name
  65699. * @param text defines the text of the control
  65700. */
  65701. constructor(name?: string | undefined, text?: string);
  65702. /** @hidden */
  65703. onBlur(): void;
  65704. /** @hidden */
  65705. onFocus(): void;
  65706. protected _getTypeName(): string;
  65707. /**
  65708. * Function called to get the list of controls that should not steal the focus from this control
  65709. * @returns an array of controls
  65710. */
  65711. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  65712. /** @hidden */
  65713. processKey(keyCode: number, key?: string, evt?: KeyboardEvent): void;
  65714. /** @hidden */
  65715. private _updateValueFromCursorIndex;
  65716. /** @hidden */
  65717. private _processDblClick;
  65718. /** @hidden */
  65719. private _selectAllText;
  65720. /**
  65721. * Handles the keyboard event
  65722. * @param evt Defines the KeyboardEvent
  65723. */
  65724. processKeyboard(evt: KeyboardEvent): void;
  65725. /** @hidden */
  65726. private _onCopyText;
  65727. /** @hidden */
  65728. private _onCutText;
  65729. /** @hidden */
  65730. private _onPasteText;
  65731. _draw(context: CanvasRenderingContext2D): void;
  65732. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  65733. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  65734. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  65735. protected _beforeRenderText(text: string): string;
  65736. dispose(): void;
  65737. }
  65738. }
  65739. declare module BABYLON.GUI {
  65740. /**
  65741. * Class used to create a 2D grid container
  65742. */
  65743. export class Grid extends Container {
  65744. name?: string | undefined;
  65745. private _rowDefinitions;
  65746. private _columnDefinitions;
  65747. private _cells;
  65748. private _childControls;
  65749. /**
  65750. * Gets the number of columns
  65751. */
  65752. readonly columnCount: number;
  65753. /**
  65754. * Gets the number of rows
  65755. */
  65756. readonly rowCount: number;
  65757. /** Gets the list of children */
  65758. readonly children: Control[];
  65759. /** Gets the list of cells (e.g. the containers) */
  65760. readonly cells: {
  65761. [key: string]: Container;
  65762. };
  65763. /**
  65764. * Gets the definition of a specific row
  65765. * @param index defines the index of the row
  65766. * @returns the row definition
  65767. */
  65768. getRowDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  65769. /**
  65770. * Gets the definition of a specific column
  65771. * @param index defines the index of the column
  65772. * @returns the column definition
  65773. */
  65774. getColumnDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  65775. /**
  65776. * Adds a new row to the grid
  65777. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  65778. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  65779. * @returns the current grid
  65780. */
  65781. addRowDefinition(height: number, isPixel?: boolean): Grid;
  65782. /**
  65783. * Adds a new column to the grid
  65784. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  65785. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  65786. * @returns the current grid
  65787. */
  65788. addColumnDefinition(width: number, isPixel?: boolean): Grid;
  65789. /**
  65790. * Update a row definition
  65791. * @param index defines the index of the row to update
  65792. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  65793. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  65794. * @returns the current grid
  65795. */
  65796. setRowDefinition(index: number, height: number, isPixel?: boolean): Grid;
  65797. /**
  65798. * Update a column definition
  65799. * @param index defines the index of the column to update
  65800. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  65801. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  65802. * @returns the current grid
  65803. */
  65804. setColumnDefinition(index: number, width: number, isPixel?: boolean): Grid;
  65805. /**
  65806. * Gets the list of children stored in a specific cell
  65807. * @param row defines the row to check
  65808. * @param column defines the column to check
  65809. * @returns the list of controls
  65810. */
  65811. getChildrenAt(row: number, column: number): BABYLON.Nullable<Array<Control>>;
  65812. /**
  65813. * Gets a string representing the child cell info (row x column)
  65814. * @param child defines the control to get info from
  65815. * @returns a string containing the child cell info (row x column)
  65816. */
  65817. getChildCellInfo(child: Control): string;
  65818. private _removeCell;
  65819. private _offsetCell;
  65820. /**
  65821. * Remove a column definition at specified index
  65822. * @param index defines the index of the column to remove
  65823. * @returns the current grid
  65824. */
  65825. removeColumnDefinition(index: number): Grid;
  65826. /**
  65827. * Remove a row definition at specified index
  65828. * @param index defines the index of the row to remove
  65829. * @returns the current grid
  65830. */
  65831. removeRowDefinition(index: number): Grid;
  65832. /**
  65833. * Adds a new control to the current grid
  65834. * @param control defines the control to add
  65835. * @param row defines the row where to add the control (0 by default)
  65836. * @param column defines the column where to add the control (0 by default)
  65837. * @returns the current grid
  65838. */
  65839. addControl(control: Control, row?: number, column?: number): Grid;
  65840. /**
  65841. * Removes a control from the current container
  65842. * @param control defines the control to remove
  65843. * @returns the current container
  65844. */
  65845. removeControl(control: Control): Container;
  65846. /**
  65847. * Creates a new Grid
  65848. * @param name defines control name
  65849. */
  65850. constructor(name?: string | undefined);
  65851. protected _getTypeName(): string;
  65852. protected _getGridDefinitions(definitionCallback: (lefts: number[], tops: number[], widths: number[], heights: number[]) => void): void;
  65853. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  65854. _flagDescendantsAsMatrixDirty(): void;
  65855. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  65856. /** Releases associated resources */
  65857. dispose(): void;
  65858. }
  65859. }
  65860. declare module BABYLON.GUI {
  65861. /** Class used to create color pickers */
  65862. export class ColorPicker extends Control {
  65863. name?: string | undefined;
  65864. private static _Epsilon;
  65865. private _colorWheelCanvas;
  65866. private _value;
  65867. private _tmpColor;
  65868. private _pointerStartedOnSquare;
  65869. private _pointerStartedOnWheel;
  65870. private _squareLeft;
  65871. private _squareTop;
  65872. private _squareSize;
  65873. private _h;
  65874. private _s;
  65875. private _v;
  65876. private _lastPointerDownID;
  65877. /**
  65878. * BABYLON.Observable raised when the value changes
  65879. */
  65880. onValueChangedObservable: BABYLON.Observable<BABYLON.Color3>;
  65881. /** Gets or sets the color of the color picker */
  65882. value: BABYLON.Color3;
  65883. /**
  65884. * Gets or sets control width
  65885. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  65886. */
  65887. width: string | number;
  65888. /**
  65889. * Gets or sets control height
  65890. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  65891. */
  65892. /** Gets or sets control height */
  65893. height: string | number;
  65894. /** Gets or sets control size */
  65895. size: string | number;
  65896. /**
  65897. * Creates a new ColorPicker
  65898. * @param name defines the control name
  65899. */
  65900. constructor(name?: string | undefined);
  65901. protected _getTypeName(): string;
  65902. /** @hidden */
  65903. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  65904. private _updateSquareProps;
  65905. private _drawGradientSquare;
  65906. private _drawCircle;
  65907. private _createColorWheelCanvas;
  65908. /** @hidden */
  65909. _draw(context: CanvasRenderingContext2D): void;
  65910. private _pointerIsDown;
  65911. private _updateValueFromPointer;
  65912. private _isPointOnSquare;
  65913. private _isPointOnWheel;
  65914. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  65915. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  65916. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  65917. /**
  65918. * This function expands the color picker by creating a color picker dialog with manual
  65919. * color value input and the ability to save colors into an array to be used later in
  65920. * subsequent launches of the dialogue.
  65921. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  65922. * @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.
  65923. * @returns picked color as a hex string and the saved colors array as hex strings.
  65924. */
  65925. static ShowPickerDialogAsync(advancedTexture: AdvancedDynamicTexture, options: {
  65926. pickerWidth?: string;
  65927. pickerHeight?: string;
  65928. headerHeight?: string;
  65929. lastColor?: string;
  65930. swatchLimit?: number;
  65931. numSwatchesPerLine?: number;
  65932. savedColors?: Array<string>;
  65933. }): Promise<{
  65934. savedColors?: string[];
  65935. pickedColor: string;
  65936. }>;
  65937. }
  65938. }
  65939. declare module BABYLON.GUI {
  65940. /** Class used to create 2D ellipse containers */
  65941. export class Ellipse extends Container {
  65942. name?: string | undefined;
  65943. private _thickness;
  65944. /** Gets or sets border thickness */
  65945. thickness: number;
  65946. /**
  65947. * Creates a new Ellipse
  65948. * @param name defines the control name
  65949. */
  65950. constructor(name?: string | undefined);
  65951. protected _getTypeName(): string;
  65952. protected _localDraw(context: CanvasRenderingContext2D): void;
  65953. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  65954. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  65955. }
  65956. }
  65957. declare module BABYLON.GUI {
  65958. /**
  65959. * Class used to create a password control
  65960. */
  65961. export class InputPassword extends InputText {
  65962. protected _beforeRenderText(text: string): string;
  65963. }
  65964. }
  65965. declare module BABYLON.GUI {
  65966. /** Class used to render 2D lines */
  65967. export class Line extends Control {
  65968. name?: string | undefined;
  65969. private _lineWidth;
  65970. private _x1;
  65971. private _y1;
  65972. private _x2;
  65973. private _y2;
  65974. private _dash;
  65975. private _connectedControl;
  65976. private _connectedControlDirtyObserver;
  65977. /** Gets or sets the dash pattern */
  65978. dash: Array<number>;
  65979. /** Gets or sets the control connected with the line end */
  65980. connectedControl: Control;
  65981. /** Gets or sets start coordinates on X axis */
  65982. x1: string | number;
  65983. /** Gets or sets start coordinates on Y axis */
  65984. y1: string | number;
  65985. /** Gets or sets end coordinates on X axis */
  65986. x2: string | number;
  65987. /** Gets or sets end coordinates on Y axis */
  65988. y2: string | number;
  65989. /** Gets or sets line width */
  65990. lineWidth: number;
  65991. /** Gets or sets horizontal alignment */
  65992. horizontalAlignment: number;
  65993. /** Gets or sets vertical alignment */
  65994. verticalAlignment: number;
  65995. private readonly _effectiveX2;
  65996. private readonly _effectiveY2;
  65997. /**
  65998. * Creates a new Line
  65999. * @param name defines the control name
  66000. */
  66001. constructor(name?: string | undefined);
  66002. protected _getTypeName(): string;
  66003. _draw(context: CanvasRenderingContext2D): void;
  66004. _measure(): void;
  66005. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  66006. /**
  66007. * Move one end of the line given 3D cartesian coordinates.
  66008. * @param position Targeted world position
  66009. * @param scene BABYLON.Scene
  66010. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  66011. */
  66012. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene, end?: boolean): void;
  66013. /**
  66014. * Move one end of the line to a position in screen absolute space.
  66015. * @param projectedPosition Position in screen absolute space (X, Y)
  66016. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  66017. */
  66018. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3, end?: boolean): void;
  66019. }
  66020. }
  66021. declare module BABYLON.GUI {
  66022. /**
  66023. * Class used to store a point for a MultiLine object.
  66024. * The point can be pure 2D coordinates, a mesh or a control
  66025. */
  66026. export class MultiLinePoint {
  66027. private _multiLine;
  66028. private _x;
  66029. private _y;
  66030. private _control;
  66031. private _mesh;
  66032. private _controlObserver;
  66033. private _meshObserver;
  66034. /** @hidden */
  66035. _point: BABYLON.Vector2;
  66036. /**
  66037. * Creates a new MultiLinePoint
  66038. * @param multiLine defines the source MultiLine object
  66039. */
  66040. constructor(multiLine: MultiLine);
  66041. /** Gets or sets x coordinate */
  66042. x: string | number;
  66043. /** Gets or sets y coordinate */
  66044. y: string | number;
  66045. /** Gets or sets the control associated with this point */
  66046. control: BABYLON.Nullable<Control>;
  66047. /** Gets or sets the mesh associated with this point */
  66048. mesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  66049. /** Resets links */
  66050. resetLinks(): void;
  66051. /**
  66052. * Gets a translation vector
  66053. * @returns the translation vector
  66054. */
  66055. translate(): BABYLON.Vector2;
  66056. private _translatePoint;
  66057. /** Release associated resources */
  66058. dispose(): void;
  66059. }
  66060. }
  66061. declare module BABYLON.GUI {
  66062. /**
  66063. * Class used to create multi line control
  66064. */
  66065. export class MultiLine extends Control {
  66066. name?: string | undefined;
  66067. private _lineWidth;
  66068. private _dash;
  66069. private _points;
  66070. private _minX;
  66071. private _minY;
  66072. private _maxX;
  66073. private _maxY;
  66074. /**
  66075. * Creates a new MultiLine
  66076. * @param name defines the control name
  66077. */
  66078. constructor(name?: string | undefined);
  66079. /** Gets or sets dash pattern */
  66080. dash: Array<number>;
  66081. /**
  66082. * Gets point stored at specified index
  66083. * @param index defines the index to look for
  66084. * @returns the requested point if found
  66085. */
  66086. getAt(index: number): MultiLinePoint;
  66087. /** Function called when a point is updated */
  66088. onPointUpdate: () => void;
  66089. /**
  66090. * Adds new points to the point collection
  66091. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  66092. * @returns the list of created MultiLinePoint
  66093. */
  66094. add(...items: (AbstractMesh | Control | {
  66095. x: string | number;
  66096. y: string | number;
  66097. })[]): MultiLinePoint[];
  66098. /**
  66099. * Adds a new point to the point collection
  66100. * @param item defines the item (mesh, control or 2d coordiantes) to add
  66101. * @returns the created MultiLinePoint
  66102. */
  66103. push(item?: (AbstractMesh | Control | {
  66104. x: string | number;
  66105. y: string | number;
  66106. })): MultiLinePoint;
  66107. /**
  66108. * Remove a specific value or point from the active point collection
  66109. * @param value defines the value or point to remove
  66110. */
  66111. remove(value: number | MultiLinePoint): void;
  66112. /**
  66113. * Resets this object to initial state (no point)
  66114. */
  66115. reset(): void;
  66116. /**
  66117. * Resets all links
  66118. */
  66119. resetLinks(): void;
  66120. /** Gets or sets line width */
  66121. lineWidth: number;
  66122. horizontalAlignment: number;
  66123. verticalAlignment: number;
  66124. protected _getTypeName(): string;
  66125. _draw(context: CanvasRenderingContext2D): void;
  66126. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  66127. _measure(): void;
  66128. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  66129. dispose(): void;
  66130. }
  66131. }
  66132. declare module BABYLON.GUI {
  66133. /**
  66134. * Class used to create radio button controls
  66135. */
  66136. export class RadioButton extends Control {
  66137. name?: string | undefined;
  66138. private _isChecked;
  66139. private _background;
  66140. private _checkSizeRatio;
  66141. private _thickness;
  66142. /** Gets or sets border thickness */
  66143. thickness: number;
  66144. /** Gets or sets group name */
  66145. group: string;
  66146. /** BABYLON.Observable raised when isChecked is changed */
  66147. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  66148. /** Gets or sets a value indicating the ratio between overall size and check size */
  66149. checkSizeRatio: number;
  66150. /** Gets or sets background color */
  66151. background: string;
  66152. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  66153. isChecked: boolean;
  66154. /**
  66155. * Creates a new RadioButton
  66156. * @param name defines the control name
  66157. */
  66158. constructor(name?: string | undefined);
  66159. protected _getTypeName(): string;
  66160. _draw(context: CanvasRenderingContext2D): void;
  66161. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  66162. /**
  66163. * Utility function to easily create a radio button with a header
  66164. * @param title defines the label to use for the header
  66165. * @param group defines the group to use for the radio button
  66166. * @param isChecked defines the initial state of the radio button
  66167. * @param onValueChanged defines the callback to call when value changes
  66168. * @returns a StackPanel containing the radio button and a textBlock
  66169. */
  66170. static AddRadioButtonWithHeader(title: string, group: string, isChecked: boolean, onValueChanged: (button: RadioButton, value: boolean) => void): StackPanel;
  66171. }
  66172. }
  66173. declare module BABYLON.GUI {
  66174. /**
  66175. * Class used to create slider controls
  66176. */
  66177. export class BaseSlider extends Control {
  66178. name?: string | undefined;
  66179. protected _thumbWidth: ValueAndUnit;
  66180. private _minimum;
  66181. private _maximum;
  66182. private _value;
  66183. private _isVertical;
  66184. protected _barOffset: ValueAndUnit;
  66185. private _isThumbClamped;
  66186. protected _displayThumb: boolean;
  66187. private _step;
  66188. private _lastPointerDownID;
  66189. protected _effectiveBarOffset: number;
  66190. protected _renderLeft: number;
  66191. protected _renderTop: number;
  66192. protected _renderWidth: number;
  66193. protected _renderHeight: number;
  66194. protected _backgroundBoxLength: number;
  66195. protected _backgroundBoxThickness: number;
  66196. protected _effectiveThumbThickness: number;
  66197. /** BABYLON.Observable raised when the sldier value changes */
  66198. onValueChangedObservable: BABYLON.Observable<number>;
  66199. /** Gets or sets a boolean indicating if the thumb must be rendered */
  66200. displayThumb: boolean;
  66201. /** Gets or sets a step to apply to values (0 by default) */
  66202. step: number;
  66203. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  66204. barOffset: string | number;
  66205. /** Gets main bar offset in pixels*/
  66206. readonly barOffsetInPixels: number;
  66207. /** Gets or sets thumb width */
  66208. thumbWidth: string | number;
  66209. /** Gets thumb width in pixels */
  66210. readonly thumbWidthInPixels: number;
  66211. /** Gets or sets minimum value */
  66212. minimum: number;
  66213. /** Gets or sets maximum value */
  66214. maximum: number;
  66215. /** Gets or sets current value */
  66216. value: number;
  66217. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  66218. isVertical: boolean;
  66219. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  66220. isThumbClamped: boolean;
  66221. /**
  66222. * Creates a new BaseSlider
  66223. * @param name defines the control name
  66224. */
  66225. constructor(name?: string | undefined);
  66226. protected _getTypeName(): string;
  66227. protected _getThumbPosition(): number;
  66228. protected _getThumbThickness(type: string): number;
  66229. protected _prepareRenderingData(type: string): void;
  66230. private _pointerIsDown;
  66231. /** @hidden */
  66232. protected _updateValueFromPointer(x: number, y: number): void;
  66233. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  66234. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  66235. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  66236. }
  66237. }
  66238. declare module BABYLON.GUI {
  66239. /**
  66240. * Class used to create slider controls
  66241. */
  66242. export class Slider extends BaseSlider {
  66243. name?: string | undefined;
  66244. private _background;
  66245. private _borderColor;
  66246. private _isThumbCircle;
  66247. protected _displayValueBar: boolean;
  66248. /** Gets or sets a boolean indicating if the value bar must be rendered */
  66249. displayValueBar: boolean;
  66250. /** Gets or sets border color */
  66251. borderColor: string;
  66252. /** Gets or sets background color */
  66253. background: string;
  66254. /** Gets or sets a boolean indicating if the thumb should be round or square */
  66255. isThumbCircle: boolean;
  66256. /**
  66257. * Creates a new Slider
  66258. * @param name defines the control name
  66259. */
  66260. constructor(name?: string | undefined);
  66261. protected _getTypeName(): string;
  66262. _draw(context: CanvasRenderingContext2D): void;
  66263. }
  66264. }
  66265. declare module BABYLON.GUI {
  66266. /** Class used to create a RadioGroup
  66267. * which contains groups of radio buttons
  66268. */
  66269. export class SelectorGroup {
  66270. /** name of SelectorGroup */
  66271. name: string;
  66272. private _groupPanel;
  66273. private _selectors;
  66274. private _groupHeader;
  66275. /**
  66276. * Creates a new SelectorGroup
  66277. * @param name of group, used as a group heading
  66278. */
  66279. constructor(
  66280. /** name of SelectorGroup */
  66281. name: string);
  66282. /** Gets the groupPanel of the SelectorGroup */
  66283. readonly groupPanel: StackPanel;
  66284. /** Gets the selectors array */
  66285. readonly selectors: StackPanel[];
  66286. /** Gets and sets the group header */
  66287. header: string;
  66288. /** @hidden */
  66289. private _addGroupHeader;
  66290. /** @hidden*/
  66291. _getSelector(selectorNb: number): StackPanel | undefined;
  66292. /** Removes the selector at the given position
  66293. * @param selectorNb the position of the selector within the group
  66294. */
  66295. removeSelector(selectorNb: number): void;
  66296. }
  66297. /** Class used to create a CheckboxGroup
  66298. * which contains groups of checkbox buttons
  66299. */
  66300. export class CheckboxGroup extends SelectorGroup {
  66301. /** Adds a checkbox as a control
  66302. * @param text is the label for the selector
  66303. * @param func is the function called when the Selector is checked
  66304. * @param checked is true when Selector is checked
  66305. */
  66306. addCheckbox(text: string, func?: (s: boolean) => void, checked?: boolean): void;
  66307. /** @hidden */
  66308. _setSelectorLabel(selectorNb: number, label: string): void;
  66309. /** @hidden */
  66310. _setSelectorLabelColor(selectorNb: number, color: string): void;
  66311. /** @hidden */
  66312. _setSelectorButtonColor(selectorNb: number, color: string): void;
  66313. /** @hidden */
  66314. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  66315. }
  66316. /** Class used to create a RadioGroup
  66317. * which contains groups of radio buttons
  66318. */
  66319. export class RadioGroup extends SelectorGroup {
  66320. private _selectNb;
  66321. /** Adds a radio button as a control
  66322. * @param label is the label for the selector
  66323. * @param func is the function called when the Selector is checked
  66324. * @param checked is true when Selector is checked
  66325. */
  66326. addRadio(label: string, func?: (n: number) => void, checked?: boolean): void;
  66327. /** @hidden */
  66328. _setSelectorLabel(selectorNb: number, label: string): void;
  66329. /** @hidden */
  66330. _setSelectorLabelColor(selectorNb: number, color: string): void;
  66331. /** @hidden */
  66332. _setSelectorButtonColor(selectorNb: number, color: string): void;
  66333. /** @hidden */
  66334. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  66335. }
  66336. /** Class used to create a SliderGroup
  66337. * which contains groups of slider buttons
  66338. */
  66339. export class SliderGroup extends SelectorGroup {
  66340. /**
  66341. * Adds a slider to the SelectorGroup
  66342. * @param label is the label for the SliderBar
  66343. * @param func is the function called when the Slider moves
  66344. * @param unit is a string describing the units used, eg degrees or metres
  66345. * @param min is the minimum value for the Slider
  66346. * @param max is the maximum value for the Slider
  66347. * @param value is the start value for the Slider between min and max
  66348. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  66349. */
  66350. addSlider(label: string, func?: (v: number) => void, unit?: string, min?: number, max?: number, value?: number, onValueChange?: (v: number) => number): void;
  66351. /** @hidden */
  66352. _setSelectorLabel(selectorNb: number, label: string): void;
  66353. /** @hidden */
  66354. _setSelectorLabelColor(selectorNb: number, color: string): void;
  66355. /** @hidden */
  66356. _setSelectorButtonColor(selectorNb: number, color: string): void;
  66357. /** @hidden */
  66358. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  66359. }
  66360. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  66361. * @see http://doc.babylonjs.com/how_to/selector
  66362. */
  66363. export class SelectionPanel extends Rectangle {
  66364. /** name of SelectionPanel */
  66365. name: string;
  66366. /** an array of SelectionGroups */
  66367. groups: SelectorGroup[];
  66368. private _panel;
  66369. private _buttonColor;
  66370. private _buttonBackground;
  66371. private _headerColor;
  66372. private _barColor;
  66373. private _barHeight;
  66374. private _spacerHeight;
  66375. private _labelColor;
  66376. private _groups;
  66377. private _bars;
  66378. /**
  66379. * Creates a new SelectionPanel
  66380. * @param name of SelectionPanel
  66381. * @param groups is an array of SelectionGroups
  66382. */
  66383. constructor(
  66384. /** name of SelectionPanel */
  66385. name: string,
  66386. /** an array of SelectionGroups */
  66387. groups?: SelectorGroup[]);
  66388. protected _getTypeName(): string;
  66389. /** Gets or sets the headerColor */
  66390. headerColor: string;
  66391. private _setHeaderColor;
  66392. /** Gets or sets the button color */
  66393. buttonColor: string;
  66394. private _setbuttonColor;
  66395. /** Gets or sets the label color */
  66396. labelColor: string;
  66397. private _setLabelColor;
  66398. /** Gets or sets the button background */
  66399. buttonBackground: string;
  66400. private _setButtonBackground;
  66401. /** Gets or sets the color of separator bar */
  66402. barColor: string;
  66403. private _setBarColor;
  66404. /** Gets or sets the height of separator bar */
  66405. barHeight: string;
  66406. private _setBarHeight;
  66407. /** Gets or sets the height of spacers*/
  66408. spacerHeight: string;
  66409. private _setSpacerHeight;
  66410. /** Adds a bar between groups */
  66411. private _addSpacer;
  66412. /** Add a group to the selection panel
  66413. * @param group is the selector group to add
  66414. */
  66415. addGroup(group: SelectorGroup): void;
  66416. /** Remove the group from the given position
  66417. * @param groupNb is the position of the group in the list
  66418. */
  66419. removeGroup(groupNb: number): void;
  66420. /** Change a group header label
  66421. * @param label is the new group header label
  66422. * @param groupNb is the number of the group to relabel
  66423. * */
  66424. setHeaderName(label: string, groupNb: number): void;
  66425. /** Change selector label to the one given
  66426. * @param label is the new selector label
  66427. * @param groupNb is the number of the groupcontaining the selector
  66428. * @param selectorNb is the number of the selector within a group to relabel
  66429. * */
  66430. relabel(label: string, groupNb: number, selectorNb: number): void;
  66431. /** For a given group position remove the selector at the given position
  66432. * @param groupNb is the number of the group to remove the selector from
  66433. * @param selectorNb is the number of the selector within the group
  66434. */
  66435. removeFromGroupSelector(groupNb: number, selectorNb: number): void;
  66436. /** For a given group position of correct type add a checkbox button
  66437. * @param groupNb is the number of the group to remove the selector from
  66438. * @param label is the label for the selector
  66439. * @param func is the function called when the Selector is checked
  66440. * @param checked is true when Selector is checked
  66441. */
  66442. addToGroupCheckbox(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  66443. /** For a given group position of correct type add a radio button
  66444. * @param groupNb is the number of the group to remove the selector from
  66445. * @param label is the label for the selector
  66446. * @param func is the function called when the Selector is checked
  66447. * @param checked is true when Selector is checked
  66448. */
  66449. addToGroupRadio(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  66450. /**
  66451. * For a given slider group add a slider
  66452. * @param groupNb is the number of the group to add the slider to
  66453. * @param label is the label for the Slider
  66454. * @param func is the function called when the Slider moves
  66455. * @param unit is a string describing the units used, eg degrees or metres
  66456. * @param min is the minimum value for the Slider
  66457. * @param max is the maximum value for the Slider
  66458. * @param value is the start value for the Slider between min and max
  66459. * @param onVal is the function used to format the value displayed, eg radians to degrees
  66460. */
  66461. addToGroupSlider(groupNb: number, label: string, func?: () => void, unit?: string, min?: number, max?: number, value?: number, onVal?: (v: number) => number): void;
  66462. }
  66463. }
  66464. declare module BABYLON.GUI {
  66465. /**
  66466. * Class used to hold a the container for ScrollViewer
  66467. * @hidden
  66468. */
  66469. export class _ScrollViewerWindow extends Container {
  66470. parentClientWidth: number;
  66471. parentClientHeight: number;
  66472. /**
  66473. * Creates a new ScrollViewerWindow
  66474. * @param name of ScrollViewerWindow
  66475. */
  66476. constructor(name?: string);
  66477. protected _getTypeName(): string;
  66478. /** @hidden */
  66479. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  66480. protected _postMeasure(): void;
  66481. }
  66482. }
  66483. declare module BABYLON.GUI {
  66484. /**
  66485. * Class used to create slider controls
  66486. */
  66487. export class ScrollBar extends BaseSlider {
  66488. name?: string | undefined;
  66489. private _background;
  66490. private _borderColor;
  66491. private _thumbMeasure;
  66492. /** Gets or sets border color */
  66493. borderColor: string;
  66494. /** Gets or sets background color */
  66495. background: string;
  66496. /**
  66497. * Creates a new Slider
  66498. * @param name defines the control name
  66499. */
  66500. constructor(name?: string | undefined);
  66501. protected _getTypeName(): string;
  66502. protected _getThumbThickness(): number;
  66503. _draw(context: CanvasRenderingContext2D): void;
  66504. private _first;
  66505. private _originX;
  66506. private _originY;
  66507. /** @hidden */
  66508. protected _updateValueFromPointer(x: number, y: number): void;
  66509. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  66510. }
  66511. }
  66512. declare module BABYLON.GUI {
  66513. /**
  66514. * Class used to hold a viewer window and sliders in a grid
  66515. */
  66516. export class ScrollViewer extends Rectangle {
  66517. private _grid;
  66518. private _horizontalBarSpace;
  66519. private _verticalBarSpace;
  66520. private _dragSpace;
  66521. private _horizontalBar;
  66522. private _verticalBar;
  66523. private _barColor;
  66524. private _barBackground;
  66525. private _barSize;
  66526. private _endLeft;
  66527. private _endTop;
  66528. private _window;
  66529. private _pointerIsOver;
  66530. private _wheelPrecision;
  66531. private _onPointerObserver;
  66532. private _clientWidth;
  66533. private _clientHeight;
  66534. /**
  66535. * Gets the horizontal scrollbar
  66536. */
  66537. readonly horizontalBar: ScrollBar;
  66538. /**
  66539. * Gets the vertical scrollbar
  66540. */
  66541. readonly verticalBar: ScrollBar;
  66542. /**
  66543. * Adds a new control to the current container
  66544. * @param control defines the control to add
  66545. * @returns the current container
  66546. */
  66547. addControl(control: BABYLON.Nullable<Control>): Container;
  66548. /**
  66549. * Removes a control from the current container
  66550. * @param control defines the control to remove
  66551. * @returns the current container
  66552. */
  66553. removeControl(control: Control): Container;
  66554. /** Gets the list of children */
  66555. readonly children: Control[];
  66556. _flagDescendantsAsMatrixDirty(): void;
  66557. /**
  66558. * Creates a new ScrollViewer
  66559. * @param name of ScrollViewer
  66560. */
  66561. constructor(name?: string);
  66562. /** Reset the scroll viewer window to initial size */
  66563. resetWindow(): void;
  66564. protected _getTypeName(): string;
  66565. private _buildClientSizes;
  66566. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  66567. protected _postMeasure(): void;
  66568. /**
  66569. * Gets or sets the mouse wheel precision
  66570. * from 0 to 1 with a default value of 0.05
  66571. * */
  66572. wheelPrecision: number;
  66573. /** Gets or sets the bar color */
  66574. barColor: string;
  66575. /** Gets or sets the size of the bar */
  66576. barSize: number;
  66577. /** Gets or sets the bar background */
  66578. barBackground: string;
  66579. /** @hidden */
  66580. private _updateScroller;
  66581. _link(host: AdvancedDynamicTexture): void;
  66582. /** @hidden */
  66583. private _attachWheel;
  66584. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  66585. /** Releases associated resources */
  66586. dispose(): void;
  66587. }
  66588. }
  66589. declare module BABYLON.GUI {
  66590. /** Class used to render a grid */
  66591. export class DisplayGrid extends Control {
  66592. name?: string | undefined;
  66593. private _cellWidth;
  66594. private _cellHeight;
  66595. private _minorLineTickness;
  66596. private _minorLineColor;
  66597. private _majorLineTickness;
  66598. private _majorLineColor;
  66599. private _majorLineFrequency;
  66600. private _background;
  66601. private _displayMajorLines;
  66602. private _displayMinorLines;
  66603. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  66604. displayMinorLines: boolean;
  66605. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  66606. displayMajorLines: boolean;
  66607. /** Gets or sets background color (Black by default) */
  66608. background: string;
  66609. /** Gets or sets the width of each cell (20 by default) */
  66610. cellWidth: number;
  66611. /** Gets or sets the height of each cell (20 by default) */
  66612. cellHeight: number;
  66613. /** Gets or sets the tickness of minor lines (1 by default) */
  66614. minorLineTickness: number;
  66615. /** Gets or sets the color of minor lines (DarkGray by default) */
  66616. minorLineColor: string;
  66617. /** Gets or sets the tickness of major lines (2 by default) */
  66618. majorLineTickness: number;
  66619. /** Gets or sets the color of major lines (White by default) */
  66620. majorLineColor: string;
  66621. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  66622. majorLineFrequency: number;
  66623. /**
  66624. * Creates a new GridDisplayRectangle
  66625. * @param name defines the control name
  66626. */
  66627. constructor(name?: string | undefined);
  66628. _draw(context: CanvasRenderingContext2D): void;
  66629. protected _getTypeName(): string;
  66630. }
  66631. }
  66632. declare module BABYLON.GUI {
  66633. /**
  66634. * Class used to create slider controls based on images
  66635. */
  66636. export class ImageBasedSlider extends BaseSlider {
  66637. name?: string | undefined;
  66638. private _backgroundImage;
  66639. private _thumbImage;
  66640. private _valueBarImage;
  66641. private _tempMeasure;
  66642. displayThumb: boolean;
  66643. /**
  66644. * Gets or sets the image used to render the background
  66645. */
  66646. backgroundImage: Image;
  66647. /**
  66648. * Gets or sets the image used to render the value bar
  66649. */
  66650. valueBarImage: Image;
  66651. /**
  66652. * Gets or sets the image used to render the thumb
  66653. */
  66654. thumbImage: Image;
  66655. /**
  66656. * Creates a new ImageBasedSlider
  66657. * @param name defines the control name
  66658. */
  66659. constructor(name?: string | undefined);
  66660. protected _getTypeName(): string;
  66661. _draw(context: CanvasRenderingContext2D): void;
  66662. }
  66663. }
  66664. declare module BABYLON.GUI {
  66665. /**
  66666. * Forcing an export so that this code will execute
  66667. * @hidden
  66668. */
  66669. const name = "Statics";
  66670. }
  66671. declare module BABYLON.GUI {
  66672. /**
  66673. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  66674. */
  66675. export class AdvancedDynamicTextureInstrumentation implements BABYLON.IDisposable {
  66676. /**
  66677. * Define the instrumented AdvancedDynamicTexture.
  66678. */
  66679. texture: AdvancedDynamicTexture;
  66680. private _captureRenderTime;
  66681. private _renderTime;
  66682. private _captureLayoutTime;
  66683. private _layoutTime;
  66684. private _onBeginRenderObserver;
  66685. private _onEndRenderObserver;
  66686. private _onBeginLayoutObserver;
  66687. private _onEndLayoutObserver;
  66688. /**
  66689. * Gets the perf counter used to capture render time
  66690. */
  66691. readonly renderTimeCounter: BABYLON.PerfCounter;
  66692. /**
  66693. * Gets the perf counter used to capture layout time
  66694. */
  66695. readonly layoutTimeCounter: BABYLON.PerfCounter;
  66696. /**
  66697. * Enable or disable the render time capture
  66698. */
  66699. captureRenderTime: boolean;
  66700. /**
  66701. * Enable or disable the layout time capture
  66702. */
  66703. captureLayoutTime: boolean;
  66704. /**
  66705. * Instantiates a new advanced dynamic texture instrumentation.
  66706. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  66707. * @param texture Defines the AdvancedDynamicTexture to instrument
  66708. */
  66709. constructor(
  66710. /**
  66711. * Define the instrumented AdvancedDynamicTexture.
  66712. */
  66713. texture: AdvancedDynamicTexture);
  66714. /**
  66715. * Dispose and release associated resources.
  66716. */
  66717. dispose(): void;
  66718. }
  66719. }
  66720. declare module BABYLON.GUI {
  66721. /**
  66722. * Class used to load GUI via XML.
  66723. */
  66724. export class XmlLoader {
  66725. private _nodes;
  66726. private _nodeTypes;
  66727. private _isLoaded;
  66728. private _objectAttributes;
  66729. private _parentClass;
  66730. /**
  66731. * Create a new xml loader
  66732. * @param parentClass Sets the class context. Used when the loader is instanced inside a class and not in a global context
  66733. */
  66734. constructor(parentClass?: null);
  66735. private _getChainElement;
  66736. private _getClassAttribute;
  66737. private _createGuiElement;
  66738. private _parseGrid;
  66739. private _parseElement;
  66740. private _prepareSourceElement;
  66741. private _parseElementsFromSource;
  66742. private _parseXml;
  66743. /**
  66744. * Gets if the loading has finished.
  66745. * @returns whether the loading has finished or not
  66746. */
  66747. isLoaded(): boolean;
  66748. /**
  66749. * Gets a loaded node / control by id.
  66750. * @param id the Controls id set in the xml
  66751. * @returns element of type Control
  66752. */
  66753. getNodeById(id: string): any;
  66754. /**
  66755. * Gets all loaded nodes / controls
  66756. * @returns Array of controls
  66757. */
  66758. getNodes(): any;
  66759. /**
  66760. * Initiates the xml layout loading
  66761. * @param xmlFile defines the xml layout to load
  66762. * @param rootNode defines the node / control to use as a parent for the loaded layout controls.
  66763. * @param callback defines the callback called on layout load.
  66764. */
  66765. loadLayout(xmlFile: any, rootNode: any, callback: any): void;
  66766. }
  66767. }
  66768. declare module BABYLON.GUI {
  66769. /**
  66770. * Class used to create containers for controls
  66771. */
  66772. export class Container3D extends Control3D {
  66773. private _blockLayout;
  66774. /**
  66775. * Gets the list of child controls
  66776. */
  66777. protected _children: Control3D[];
  66778. /**
  66779. * Gets the list of child controls
  66780. */
  66781. readonly children: Array<Control3D>;
  66782. /**
  66783. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  66784. * This is helpful to optimize layout operation when adding multiple children in a row
  66785. */
  66786. blockLayout: boolean;
  66787. /**
  66788. * Creates a new container
  66789. * @param name defines the container name
  66790. */
  66791. constructor(name?: string);
  66792. /**
  66793. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  66794. * @returns the current container
  66795. */
  66796. updateLayout(): Container3D;
  66797. /**
  66798. * Gets a boolean indicating if the given control is in the children of this control
  66799. * @param control defines the control to check
  66800. * @returns true if the control is in the child list
  66801. */
  66802. containsControl(control: Control3D): boolean;
  66803. /**
  66804. * Adds a control to the children of this control
  66805. * @param control defines the control to add
  66806. * @returns the current container
  66807. */
  66808. addControl(control: Control3D): Container3D;
  66809. /**
  66810. * This function will be called everytime a new control is added
  66811. */
  66812. protected _arrangeChildren(): void;
  66813. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  66814. /**
  66815. * Removes a control from the children of this control
  66816. * @param control defines the control to remove
  66817. * @returns the current container
  66818. */
  66819. removeControl(control: Control3D): Container3D;
  66820. protected _getTypeName(): string;
  66821. /**
  66822. * Releases all associated resources
  66823. */
  66824. dispose(): void;
  66825. /** Control rotation will remain unchanged */
  66826. static readonly UNSET_ORIENTATION: number;
  66827. /** Control will rotate to make it look at sphere central axis */
  66828. static readonly FACEORIGIN_ORIENTATION: number;
  66829. /** Control will rotate to make it look back at sphere central axis */
  66830. static readonly FACEORIGINREVERSED_ORIENTATION: number;
  66831. /** Control will rotate to look at z axis (0, 0, 1) */
  66832. static readonly FACEFORWARD_ORIENTATION: number;
  66833. /** Control will rotate to look at negative z axis (0, 0, -1) */
  66834. static readonly FACEFORWARDREVERSED_ORIENTATION: number;
  66835. }
  66836. }
  66837. declare module BABYLON.GUI {
  66838. /**
  66839. * Class used to manage 3D user interface
  66840. * @see http://doc.babylonjs.com/how_to/gui3d
  66841. */
  66842. export class GUI3DManager implements BABYLON.IDisposable {
  66843. private _scene;
  66844. private _sceneDisposeObserver;
  66845. private _utilityLayer;
  66846. private _rootContainer;
  66847. private _pointerObserver;
  66848. private _pointerOutObserver;
  66849. /** @hidden */
  66850. _lastPickedControl: Control3D;
  66851. /** @hidden */
  66852. _lastControlOver: {
  66853. [pointerId: number]: Control3D;
  66854. };
  66855. /** @hidden */
  66856. _lastControlDown: {
  66857. [pointerId: number]: Control3D;
  66858. };
  66859. /**
  66860. * BABYLON.Observable raised when the point picked by the pointer events changed
  66861. */
  66862. onPickedPointChangedObservable: BABYLON.Observable<BABYLON.Nullable<BABYLON.Vector3>>;
  66863. /** @hidden */
  66864. _sharedMaterials: {
  66865. [key: string]: BABYLON.Material;
  66866. };
  66867. /** Gets the hosting scene */
  66868. readonly scene: BABYLON.Scene;
  66869. /** Gets associated utility layer */
  66870. readonly utilityLayer: BABYLON.Nullable<BABYLON.UtilityLayerRenderer>;
  66871. /**
  66872. * Creates a new GUI3DManager
  66873. * @param scene
  66874. */
  66875. constructor(scene?: BABYLON.Scene);
  66876. private _handlePointerOut;
  66877. private _doPicking;
  66878. /**
  66879. * Gets the root container
  66880. */
  66881. readonly rootContainer: Container3D;
  66882. /**
  66883. * Gets a boolean indicating if the given control is in the root child list
  66884. * @param control defines the control to check
  66885. * @returns true if the control is in the root child list
  66886. */
  66887. containsControl(control: Control3D): boolean;
  66888. /**
  66889. * Adds a control to the root child list
  66890. * @param control defines the control to add
  66891. * @returns the current manager
  66892. */
  66893. addControl(control: Control3D): GUI3DManager;
  66894. /**
  66895. * Removes a control from the root child list
  66896. * @param control defines the control to remove
  66897. * @returns the current container
  66898. */
  66899. removeControl(control: Control3D): GUI3DManager;
  66900. /**
  66901. * Releases all associated resources
  66902. */
  66903. dispose(): void;
  66904. }
  66905. }
  66906. declare module BABYLON.GUI {
  66907. /**
  66908. * Class used to transport BABYLON.Vector3 information for pointer events
  66909. */
  66910. export class Vector3WithInfo extends BABYLON.Vector3 {
  66911. /** defines the current mouse button index */
  66912. buttonIndex: number;
  66913. /**
  66914. * Creates a new Vector3WithInfo
  66915. * @param source defines the vector3 data to transport
  66916. * @param buttonIndex defines the current mouse button index
  66917. */
  66918. constructor(source: BABYLON.Vector3,
  66919. /** defines the current mouse button index */
  66920. buttonIndex?: number);
  66921. }
  66922. }
  66923. declare module BABYLON.GUI {
  66924. /**
  66925. * Class used as base class for controls
  66926. */
  66927. export class Control3D implements BABYLON.IDisposable, BABYLON.IBehaviorAware<Control3D> {
  66928. /** Defines the control name */
  66929. name?: string | undefined;
  66930. /** @hidden */
  66931. _host: GUI3DManager;
  66932. private _node;
  66933. private _downCount;
  66934. private _enterCount;
  66935. private _downPointerIds;
  66936. private _isVisible;
  66937. /** Gets or sets the control position in world space */
  66938. position: BABYLON.Vector3;
  66939. /** Gets or sets the control scaling in world space */
  66940. scaling: BABYLON.Vector3;
  66941. /** Callback used to start pointer enter animation */
  66942. pointerEnterAnimation: () => void;
  66943. /** Callback used to start pointer out animation */
  66944. pointerOutAnimation: () => void;
  66945. /** Callback used to start pointer down animation */
  66946. pointerDownAnimation: () => void;
  66947. /** Callback used to start pointer up animation */
  66948. pointerUpAnimation: () => void;
  66949. /**
  66950. * An event triggered when the pointer move over the control
  66951. */
  66952. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector3>;
  66953. /**
  66954. * An event triggered when the pointer move out of the control
  66955. */
  66956. onPointerOutObservable: BABYLON.Observable<Control3D>;
  66957. /**
  66958. * An event triggered when the pointer taps the control
  66959. */
  66960. onPointerDownObservable: BABYLON.Observable<Vector3WithInfo>;
  66961. /**
  66962. * An event triggered when pointer is up
  66963. */
  66964. onPointerUpObservable: BABYLON.Observable<Vector3WithInfo>;
  66965. /**
  66966. * An event triggered when a control is clicked on (with a mouse)
  66967. */
  66968. onPointerClickObservable: BABYLON.Observable<Vector3WithInfo>;
  66969. /**
  66970. * An event triggered when pointer enters the control
  66971. */
  66972. onPointerEnterObservable: BABYLON.Observable<Control3D>;
  66973. /**
  66974. * Gets or sets the parent container
  66975. */
  66976. parent: BABYLON.Nullable<Container3D>;
  66977. private _behaviors;
  66978. /**
  66979. * Gets the list of attached behaviors
  66980. * @see http://doc.babylonjs.com/features/behaviour
  66981. */
  66982. readonly behaviors: BABYLON.Behavior<Control3D>[];
  66983. /**
  66984. * Attach a behavior to the control
  66985. * @see http://doc.babylonjs.com/features/behaviour
  66986. * @param behavior defines the behavior to attach
  66987. * @returns the current control
  66988. */
  66989. addBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  66990. /**
  66991. * Remove an attached behavior
  66992. * @see http://doc.babylonjs.com/features/behaviour
  66993. * @param behavior defines the behavior to attach
  66994. * @returns the current control
  66995. */
  66996. removeBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  66997. /**
  66998. * Gets an attached behavior by name
  66999. * @param name defines the name of the behavior to look for
  67000. * @see http://doc.babylonjs.com/features/behaviour
  67001. * @returns null if behavior was not found else the requested behavior
  67002. */
  67003. getBehaviorByName(name: string): BABYLON.Nullable<BABYLON.Behavior<Control3D>>;
  67004. /** Gets or sets a boolean indicating if the control is visible */
  67005. isVisible: boolean;
  67006. /**
  67007. * Creates a new control
  67008. * @param name defines the control name
  67009. */
  67010. constructor(
  67011. /** Defines the control name */
  67012. name?: string | undefined);
  67013. /**
  67014. * Gets a string representing the class name
  67015. */
  67016. readonly typeName: string;
  67017. /**
  67018. * Get the current class name of the control.
  67019. * @returns current class name
  67020. */
  67021. getClassName(): string;
  67022. protected _getTypeName(): string;
  67023. /**
  67024. * Gets the transform node used by this control
  67025. */
  67026. readonly node: BABYLON.Nullable<BABYLON.TransformNode>;
  67027. /**
  67028. * Gets the mesh used to render this control
  67029. */
  67030. readonly mesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  67031. /**
  67032. * Link the control as child of the given node
  67033. * @param node defines the node to link to. Use null to unlink the control
  67034. * @returns the current control
  67035. */
  67036. linkToTransformNode(node: BABYLON.Nullable<BABYLON.TransformNode>): Control3D;
  67037. /** @hidden **/
  67038. _prepareNode(scene: BABYLON.Scene): void;
  67039. /**
  67040. * Node creation.
  67041. * Can be overriden by children
  67042. * @param scene defines the scene where the node must be attached
  67043. * @returns the attached node or null if none. Must return a BABYLON.Mesh or BABYLON.AbstractMesh if there is an atttached visible object
  67044. */
  67045. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  67046. /**
  67047. * Affect a material to the given mesh
  67048. * @param mesh defines the mesh which will represent the control
  67049. */
  67050. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  67051. /** @hidden */
  67052. _onPointerMove(target: Control3D, coordinates: BABYLON.Vector3): void;
  67053. /** @hidden */
  67054. _onPointerEnter(target: Control3D): boolean;
  67055. /** @hidden */
  67056. _onPointerOut(target: Control3D): void;
  67057. /** @hidden */
  67058. _onPointerDown(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  67059. /** @hidden */
  67060. _onPointerUp(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  67061. /** @hidden */
  67062. forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  67063. /** @hidden */
  67064. _processObservables(type: number, pickedPoint: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  67065. /** @hidden */
  67066. _disposeNode(): void;
  67067. /**
  67068. * Releases all associated resources
  67069. */
  67070. dispose(): void;
  67071. }
  67072. }
  67073. declare module BABYLON.GUI {
  67074. /**
  67075. * Class used as a root to all buttons
  67076. */
  67077. export class AbstractButton3D extends Control3D {
  67078. /**
  67079. * Creates a new button
  67080. * @param name defines the control name
  67081. */
  67082. constructor(name?: string);
  67083. protected _getTypeName(): string;
  67084. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  67085. }
  67086. }
  67087. declare module BABYLON.GUI {
  67088. /**
  67089. * Class used to create a button in 3D
  67090. */
  67091. export class Button3D extends AbstractButton3D {
  67092. /** @hidden */
  67093. protected _currentMaterial: BABYLON.Material;
  67094. private _facadeTexture;
  67095. private _content;
  67096. private _contentResolution;
  67097. private _contentScaleRatio;
  67098. /**
  67099. * Gets or sets the texture resolution used to render content (512 by default)
  67100. */
  67101. contentResolution: BABYLON.int;
  67102. /**
  67103. * Gets or sets the texture scale ratio used to render content (2 by default)
  67104. */
  67105. contentScaleRatio: number;
  67106. protected _disposeFacadeTexture(): void;
  67107. protected _resetContent(): void;
  67108. /**
  67109. * Creates a new button
  67110. * @param name defines the control name
  67111. */
  67112. constructor(name?: string);
  67113. /**
  67114. * Gets or sets the GUI 2D content used to display the button's facade
  67115. */
  67116. content: Control;
  67117. /**
  67118. * Apply the facade texture (created from the content property).
  67119. * This function can be overloaded by child classes
  67120. * @param facadeTexture defines the AdvancedDynamicTexture to use
  67121. */
  67122. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  67123. protected _getTypeName(): string;
  67124. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  67125. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  67126. /**
  67127. * Releases all associated resources
  67128. */
  67129. dispose(): void;
  67130. }
  67131. }
  67132. declare module BABYLON.GUI {
  67133. /**
  67134. * Abstract class used to create a container panel deployed on the surface of a volume
  67135. */
  67136. export abstract class VolumeBasedPanel extends Container3D {
  67137. private _columns;
  67138. private _rows;
  67139. private _rowThenColum;
  67140. private _orientation;
  67141. protected _cellWidth: number;
  67142. protected _cellHeight: number;
  67143. /**
  67144. * Gets or sets the distance between elements
  67145. */
  67146. margin: number;
  67147. /**
  67148. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  67149. * | Value | Type | Description |
  67150. * | ----- | ----------------------------------- | ----------- |
  67151. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  67152. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  67153. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  67154. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  67155. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  67156. */
  67157. orientation: number;
  67158. /**
  67159. * Gets or sets the number of columns requested (10 by default).
  67160. * The panel will automatically compute the number of rows based on number of child controls.
  67161. */
  67162. columns: BABYLON.int;
  67163. /**
  67164. * Gets or sets a the number of rows requested.
  67165. * The panel will automatically compute the number of columns based on number of child controls.
  67166. */
  67167. rows: BABYLON.int;
  67168. /**
  67169. * Creates new VolumeBasedPanel
  67170. */
  67171. constructor();
  67172. protected _arrangeChildren(): void;
  67173. /** Child classes must implement this function to provide correct control positioning */
  67174. protected abstract _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  67175. /** Child classes can implement this function to provide additional processing */
  67176. protected _finalProcessing(): void;
  67177. }
  67178. }
  67179. declare module BABYLON.GUI {
  67180. /**
  67181. * Class used to create a container panel deployed on the surface of a cylinder
  67182. */
  67183. export class CylinderPanel extends VolumeBasedPanel {
  67184. private _radius;
  67185. /**
  67186. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  67187. */
  67188. radius: BABYLON.float;
  67189. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  67190. private _cylindricalMapping;
  67191. }
  67192. }
  67193. declare module BABYLON.GUI {
  67194. /** @hidden */
  67195. export var fluentVertexShader: {
  67196. name: string;
  67197. shader: string;
  67198. };
  67199. }
  67200. declare module BABYLON.GUI {
  67201. /** @hidden */
  67202. export var fluentPixelShader: {
  67203. name: string;
  67204. shader: string;
  67205. };
  67206. }
  67207. declare module BABYLON.GUI {
  67208. /** @hidden */
  67209. export class FluentMaterialDefines extends BABYLON.MaterialDefines {
  67210. INNERGLOW: boolean;
  67211. BORDER: boolean;
  67212. HOVERLIGHT: boolean;
  67213. TEXTURE: boolean;
  67214. constructor();
  67215. }
  67216. /**
  67217. * Class used to render controls with fluent desgin
  67218. */
  67219. export class FluentMaterial extends BABYLON.PushMaterial {
  67220. /**
  67221. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  67222. */
  67223. innerGlowColorIntensity: number;
  67224. /**
  67225. * Gets or sets the inner glow color (white by default)
  67226. */
  67227. innerGlowColor: BABYLON.Color3;
  67228. /**
  67229. * Gets or sets alpha value (default is 1.0)
  67230. */
  67231. alpha: number;
  67232. /**
  67233. * Gets or sets the albedo color (Default is BABYLON.Color3(0.3, 0.35, 0.4))
  67234. */
  67235. albedoColor: BABYLON.Color3;
  67236. /**
  67237. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  67238. */
  67239. renderBorders: boolean;
  67240. /**
  67241. * Gets or sets border width (default is 0.5)
  67242. */
  67243. borderWidth: number;
  67244. /**
  67245. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  67246. */
  67247. edgeSmoothingValue: number;
  67248. /**
  67249. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  67250. */
  67251. borderMinValue: number;
  67252. /**
  67253. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  67254. */
  67255. renderHoverLight: boolean;
  67256. /**
  67257. * Gets or sets the radius used to render the hover light (default is 1.0)
  67258. */
  67259. hoverRadius: number;
  67260. /**
  67261. * Gets or sets the color used to render the hover light (default is BABYLON.Color4(0.3, 0.3, 0.3, 1.0))
  67262. */
  67263. hoverColor: BABYLON.Color4;
  67264. /**
  67265. * Gets or sets the hover light position in world space (default is BABYLON.Vector3.Zero())
  67266. */
  67267. hoverPosition: BABYLON.Vector3;
  67268. private _albedoTexture;
  67269. /** Gets or sets the texture to use for albedo color */
  67270. albedoTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  67271. /**
  67272. * Creates a new Fluent material
  67273. * @param name defines the name of the material
  67274. * @param scene defines the hosting scene
  67275. */
  67276. constructor(name: string, scene: BABYLON.Scene);
  67277. needAlphaBlending(): boolean;
  67278. needAlphaTesting(): boolean;
  67279. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  67280. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  67281. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  67282. getActiveTextures(): BABYLON.BaseTexture[];
  67283. hasTexture(texture: BABYLON.BaseTexture): boolean;
  67284. dispose(forceDisposeEffect?: boolean): void;
  67285. clone(name: string): FluentMaterial;
  67286. serialize(): any;
  67287. getClassName(): string;
  67288. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FluentMaterial;
  67289. }
  67290. }
  67291. declare module BABYLON.GUI {
  67292. /**
  67293. * Class used to create a holographic button in 3D
  67294. */
  67295. export class HolographicButton extends Button3D {
  67296. private _backPlate;
  67297. private _textPlate;
  67298. private _frontPlate;
  67299. private _text;
  67300. private _imageUrl;
  67301. private _shareMaterials;
  67302. private _frontMaterial;
  67303. private _backMaterial;
  67304. private _plateMaterial;
  67305. private _pickedPointObserver;
  67306. private _tooltipFade;
  67307. private _tooltipTextBlock;
  67308. private _tooltipTexture;
  67309. private _tooltipMesh;
  67310. private _tooltipHoverObserver;
  67311. private _tooltipOutObserver;
  67312. private _disposeTooltip;
  67313. /**
  67314. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  67315. */
  67316. tooltipText: BABYLON.Nullable<string>;
  67317. /**
  67318. * Gets or sets text for the button
  67319. */
  67320. text: string;
  67321. /**
  67322. * Gets or sets the image url for the button
  67323. */
  67324. imageUrl: string;
  67325. /**
  67326. * Gets the back material used by this button
  67327. */
  67328. readonly backMaterial: FluentMaterial;
  67329. /**
  67330. * Gets the front material used by this button
  67331. */
  67332. readonly frontMaterial: FluentMaterial;
  67333. /**
  67334. * Gets the plate material used by this button
  67335. */
  67336. readonly plateMaterial: BABYLON.StandardMaterial;
  67337. /**
  67338. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  67339. */
  67340. readonly shareMaterials: boolean;
  67341. /**
  67342. * Creates a new button
  67343. * @param name defines the control name
  67344. */
  67345. constructor(name?: string, shareMaterials?: boolean);
  67346. protected _getTypeName(): string;
  67347. private _rebuildContent;
  67348. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  67349. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  67350. private _createBackMaterial;
  67351. private _createFrontMaterial;
  67352. private _createPlateMaterial;
  67353. protected _affectMaterial(mesh: BABYLON.Mesh): void;
  67354. /**
  67355. * Releases all associated resources
  67356. */
  67357. dispose(): void;
  67358. }
  67359. }
  67360. declare module BABYLON.GUI {
  67361. /**
  67362. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  67363. */
  67364. export class MeshButton3D extends Button3D {
  67365. /** @hidden */
  67366. protected _currentMesh: BABYLON.Mesh;
  67367. /**
  67368. * Creates a new 3D button based on a mesh
  67369. * @param mesh mesh to become a 3D button
  67370. * @param name defines the control name
  67371. */
  67372. constructor(mesh: BABYLON.Mesh, name?: string);
  67373. protected _getTypeName(): string;
  67374. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  67375. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  67376. }
  67377. }
  67378. declare module BABYLON.GUI {
  67379. /**
  67380. * Class used to create a container panel deployed on the surface of a plane
  67381. */
  67382. export class PlanePanel extends VolumeBasedPanel {
  67383. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  67384. }
  67385. }
  67386. declare module BABYLON.GUI {
  67387. /**
  67388. * Class used to create a container panel where items get randomized planar mapping
  67389. */
  67390. export class ScatterPanel extends VolumeBasedPanel {
  67391. private _iteration;
  67392. /**
  67393. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  67394. */
  67395. iteration: BABYLON.float;
  67396. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  67397. private _scatterMapping;
  67398. protected _finalProcessing(): void;
  67399. }
  67400. }
  67401. declare module BABYLON.GUI {
  67402. /**
  67403. * Class used to create a container panel deployed on the surface of a sphere
  67404. */
  67405. export class SpherePanel extends VolumeBasedPanel {
  67406. private _radius;
  67407. /**
  67408. * Gets or sets the radius of the sphere where to project controls (5 by default)
  67409. */
  67410. radius: BABYLON.float;
  67411. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  67412. private _sphericalMapping;
  67413. }
  67414. }
  67415. declare module BABYLON.GUI {
  67416. /**
  67417. * Class used to create a stack panel in 3D on XY plane
  67418. */
  67419. export class StackPanel3D extends Container3D {
  67420. private _isVertical;
  67421. /**
  67422. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  67423. */
  67424. isVertical: boolean;
  67425. /**
  67426. * Gets or sets the distance between elements
  67427. */
  67428. margin: number;
  67429. /**
  67430. * Creates new StackPanel
  67431. * @param isVertical
  67432. */
  67433. constructor(isVertical?: boolean);
  67434. protected _arrangeChildren(): void;
  67435. }
  67436. }
  67437. declare module BABYLON {
  67438. /**
  67439. * Mode that determines the coordinate system to use.
  67440. */
  67441. export enum GLTFLoaderCoordinateSystemMode {
  67442. /**
  67443. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  67444. */
  67445. AUTO = 0,
  67446. /**
  67447. * Sets the useRightHandedSystem flag on the scene.
  67448. */
  67449. FORCE_RIGHT_HANDED = 1
  67450. }
  67451. /**
  67452. * Mode that determines what animations will start.
  67453. */
  67454. export enum GLTFLoaderAnimationStartMode {
  67455. /**
  67456. * No animation will start.
  67457. */
  67458. NONE = 0,
  67459. /**
  67460. * The first animation will start.
  67461. */
  67462. FIRST = 1,
  67463. /**
  67464. * All animations will start.
  67465. */
  67466. ALL = 2
  67467. }
  67468. /**
  67469. * Interface that contains the data for the glTF asset.
  67470. */
  67471. export interface IGLTFLoaderData {
  67472. /**
  67473. * Object that represents the glTF JSON.
  67474. */
  67475. json: Object;
  67476. /**
  67477. * The BIN chunk of a binary glTF.
  67478. */
  67479. bin: Nullable<ArrayBufferView>;
  67480. }
  67481. /**
  67482. * Interface for extending the loader.
  67483. */
  67484. export interface IGLTFLoaderExtension {
  67485. /**
  67486. * The name of this extension.
  67487. */
  67488. readonly name: string;
  67489. /**
  67490. * Defines whether this extension is enabled.
  67491. */
  67492. enabled: boolean;
  67493. }
  67494. /**
  67495. * Loader state.
  67496. */
  67497. export enum GLTFLoaderState {
  67498. /**
  67499. * The asset is loading.
  67500. */
  67501. LOADING = 0,
  67502. /**
  67503. * The asset is ready for rendering.
  67504. */
  67505. READY = 1,
  67506. /**
  67507. * The asset is completely loaded.
  67508. */
  67509. COMPLETE = 2
  67510. }
  67511. /** @hidden */
  67512. export interface IGLTFLoader extends IDisposable {
  67513. readonly state: Nullable<GLTFLoaderState>;
  67514. importMeshAsync: (meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<{
  67515. meshes: AbstractMesh[];
  67516. particleSystems: IParticleSystem[];
  67517. skeletons: Skeleton[];
  67518. animationGroups: AnimationGroup[];
  67519. }>;
  67520. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  67521. }
  67522. /**
  67523. * File loader for loading glTF files into a scene.
  67524. */
  67525. export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  67526. /** @hidden */
  67527. static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  67528. /** @hidden */
  67529. static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  67530. /**
  67531. * Raised when the asset has been parsed
  67532. */
  67533. onParsedObservable: Observable<IGLTFLoaderData>;
  67534. private _onParsedObserver;
  67535. /**
  67536. * Raised when the asset has been parsed
  67537. */
  67538. onParsed: (loaderData: IGLTFLoaderData) => void;
  67539. /**
  67540. * 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.
  67541. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  67542. * Defaults to true.
  67543. * @hidden
  67544. */
  67545. static IncrementalLoading: boolean;
  67546. /**
  67547. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  67548. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  67549. * @hidden
  67550. */
  67551. static HomogeneousCoordinates: boolean;
  67552. /**
  67553. * The coordinate system mode. Defaults to AUTO.
  67554. */
  67555. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  67556. /**
  67557. * The animation start mode. Defaults to FIRST.
  67558. */
  67559. animationStartMode: GLTFLoaderAnimationStartMode;
  67560. /**
  67561. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  67562. */
  67563. compileMaterials: boolean;
  67564. /**
  67565. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  67566. */
  67567. useClipPlane: boolean;
  67568. /**
  67569. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  67570. */
  67571. compileShadowGenerators: boolean;
  67572. /**
  67573. * Defines if the Alpha blended materials are only applied as coverage.
  67574. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  67575. * If true, no extra effects are applied to transparent pixels.
  67576. */
  67577. transparencyAsCoverage: boolean;
  67578. /**
  67579. * Function called before loading a url referenced by the asset.
  67580. */
  67581. preprocessUrlAsync: (url: string) => Promise<string>;
  67582. /**
  67583. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  67584. */
  67585. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  67586. private _onMeshLoadedObserver;
  67587. /**
  67588. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  67589. */
  67590. onMeshLoaded: (mesh: AbstractMesh) => void;
  67591. /**
  67592. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  67593. */
  67594. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  67595. private _onTextureLoadedObserver;
  67596. /**
  67597. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  67598. */
  67599. onTextureLoaded: (texture: BaseTexture) => void;
  67600. /**
  67601. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  67602. */
  67603. readonly onMaterialLoadedObservable: Observable<Material>;
  67604. private _onMaterialLoadedObserver;
  67605. /**
  67606. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  67607. */
  67608. onMaterialLoaded: (material: Material) => void;
  67609. /**
  67610. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  67611. */
  67612. readonly onCameraLoadedObservable: Observable<Camera>;
  67613. private _onCameraLoadedObserver;
  67614. /**
  67615. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  67616. */
  67617. onCameraLoaded: (camera: Camera) => void;
  67618. /**
  67619. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  67620. * For assets with LODs, raised when all of the LODs are complete.
  67621. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  67622. */
  67623. readonly onCompleteObservable: Observable<void>;
  67624. private _onCompleteObserver;
  67625. /**
  67626. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  67627. * For assets with LODs, raised when all of the LODs are complete.
  67628. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  67629. */
  67630. onComplete: () => void;
  67631. /**
  67632. * Observable raised when an error occurs.
  67633. */
  67634. readonly onErrorObservable: Observable<any>;
  67635. private _onErrorObserver;
  67636. /**
  67637. * Callback raised when an error occurs.
  67638. */
  67639. onError: (reason: any) => void;
  67640. /**
  67641. * Observable raised after the loader is disposed.
  67642. */
  67643. readonly onDisposeObservable: Observable<void>;
  67644. private _onDisposeObserver;
  67645. /**
  67646. * Callback raised after the loader is disposed.
  67647. */
  67648. onDispose: () => void;
  67649. /**
  67650. * Observable raised after a loader extension is created.
  67651. * Set additional options for a loader extension in this event.
  67652. */
  67653. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  67654. private _onExtensionLoadedObserver;
  67655. /**
  67656. * Callback raised after a loader extension is created.
  67657. */
  67658. onExtensionLoaded: (extension: IGLTFLoaderExtension) => void;
  67659. /**
  67660. * Defines if the loader logging is enabled.
  67661. */
  67662. loggingEnabled: boolean;
  67663. /**
  67664. * Defines if the loader should capture performance counters.
  67665. */
  67666. capturePerformanceCounters: boolean;
  67667. /**
  67668. * Defines if the loader should validate the asset.
  67669. */
  67670. validate: boolean;
  67671. /**
  67672. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  67673. */
  67674. readonly onValidatedObservable: Observable<BABYLON.GLTF2.IGLTFValidationResults>;
  67675. private _onValidatedObserver;
  67676. /**
  67677. * Callback raised after a loader extension is created.
  67678. */
  67679. onValidated: (results: BABYLON.GLTF2.IGLTFValidationResults) => void;
  67680. private _loader;
  67681. /**
  67682. * Name of the loader ("gltf")
  67683. */
  67684. name: string;
  67685. /**
  67686. * Supported file extensions of the loader (.gltf, .glb)
  67687. */
  67688. extensions: ISceneLoaderPluginExtensions;
  67689. /**
  67690. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  67691. */
  67692. dispose(): void;
  67693. /** @hidden */
  67694. _clear(): void;
  67695. /**
  67696. * Imports one or more meshes from the loaded glTF data and adds them to the scene
  67697. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  67698. * @param scene the scene the meshes should be added to
  67699. * @param data the glTF data to load
  67700. * @param rootUrl root url to load from
  67701. * @param onProgress event that fires when loading progress has occured
  67702. * @param fileName Defines the name of the file to load
  67703. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  67704. */
  67705. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  67706. meshes: AbstractMesh[];
  67707. particleSystems: IParticleSystem[];
  67708. skeletons: Skeleton[];
  67709. animationGroups: AnimationGroup[];
  67710. }>;
  67711. /**
  67712. * Imports all objects from the loaded glTF data and adds them to the scene
  67713. * @param scene the scene the objects should be added to
  67714. * @param data the glTF data to load
  67715. * @param rootUrl root url to load from
  67716. * @param onProgress event that fires when loading progress has occured
  67717. * @param fileName Defines the name of the file to load
  67718. * @returns a promise which completes when objects have been loaded to the scene
  67719. */
  67720. loadAsync(scene: Scene, data: string | ArrayBuffer, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  67721. /**
  67722. * Load into an asset container.
  67723. * @param scene The scene to load into
  67724. * @param data The data to import
  67725. * @param rootUrl The root url for scene and resources
  67726. * @param onProgress The callback when the load progresses
  67727. * @param fileName Defines the name of the file to load
  67728. * @returns The loaded asset container
  67729. */
  67730. loadAssetContainerAsync(scene: Scene, data: string | ArrayBuffer, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  67731. /**
  67732. * If the data string can be loaded directly.
  67733. * @param data string contianing the file data
  67734. * @returns if the data can be loaded directly
  67735. */
  67736. canDirectLoad(data: string): boolean;
  67737. /**
  67738. * Rewrites a url by combining a root url and response url.
  67739. */
  67740. rewriteRootURL: (rootUrl: string, responseURL?: string) => string;
  67741. /**
  67742. * Instantiates a glTF file loader plugin.
  67743. * @returns the created plugin
  67744. */
  67745. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  67746. /**
  67747. * The loader state or null if the loader is not active.
  67748. */
  67749. readonly loaderState: Nullable<GLTFLoaderState>;
  67750. /**
  67751. * Returns a promise that resolves when the asset is completely loaded.
  67752. * @returns a promise that resolves when the asset is completely loaded.
  67753. */
  67754. whenCompleteAsync(): Promise<void>;
  67755. private _parseAsync;
  67756. private _validateAsync;
  67757. private _getLoader;
  67758. private _unpackBinary;
  67759. private _unpackBinaryV1;
  67760. private _unpackBinaryV2;
  67761. private static _parseVersion;
  67762. private static _compareVersion;
  67763. private static _decodeBufferToText;
  67764. private static readonly _logSpaces;
  67765. private _logIndentLevel;
  67766. private _loggingEnabled;
  67767. /** @hidden */
  67768. _log: (message: string) => void;
  67769. /** @hidden */
  67770. _logOpen(message: string): void;
  67771. /** @hidden */
  67772. _logClose(): void;
  67773. private _logEnabled;
  67774. private _logDisabled;
  67775. private _capturePerformanceCounters;
  67776. /** @hidden */
  67777. _startPerformanceCounter: (counterName: string) => void;
  67778. /** @hidden */
  67779. _endPerformanceCounter: (counterName: string) => void;
  67780. private _startPerformanceCounterEnabled;
  67781. private _startPerformanceCounterDisabled;
  67782. private _endPerformanceCounterEnabled;
  67783. private _endPerformanceCounterDisabled;
  67784. }
  67785. }
  67786. declare module BABYLON.GLTF1 {
  67787. /**
  67788. * Enums
  67789. * @hidden
  67790. */
  67791. export enum EComponentType {
  67792. BYTE = 5120,
  67793. UNSIGNED_BYTE = 5121,
  67794. SHORT = 5122,
  67795. UNSIGNED_SHORT = 5123,
  67796. FLOAT = 5126
  67797. }
  67798. /** @hidden */
  67799. export enum EShaderType {
  67800. FRAGMENT = 35632,
  67801. VERTEX = 35633
  67802. }
  67803. /** @hidden */
  67804. export enum EParameterType {
  67805. BYTE = 5120,
  67806. UNSIGNED_BYTE = 5121,
  67807. SHORT = 5122,
  67808. UNSIGNED_SHORT = 5123,
  67809. INT = 5124,
  67810. UNSIGNED_INT = 5125,
  67811. FLOAT = 5126,
  67812. FLOAT_VEC2 = 35664,
  67813. FLOAT_VEC3 = 35665,
  67814. FLOAT_VEC4 = 35666,
  67815. INT_VEC2 = 35667,
  67816. INT_VEC3 = 35668,
  67817. INT_VEC4 = 35669,
  67818. BOOL = 35670,
  67819. BOOL_VEC2 = 35671,
  67820. BOOL_VEC3 = 35672,
  67821. BOOL_VEC4 = 35673,
  67822. FLOAT_MAT2 = 35674,
  67823. FLOAT_MAT3 = 35675,
  67824. FLOAT_MAT4 = 35676,
  67825. SAMPLER_2D = 35678
  67826. }
  67827. /** @hidden */
  67828. export enum ETextureWrapMode {
  67829. CLAMP_TO_EDGE = 33071,
  67830. MIRRORED_REPEAT = 33648,
  67831. REPEAT = 10497
  67832. }
  67833. /** @hidden */
  67834. export enum ETextureFilterType {
  67835. NEAREST = 9728,
  67836. LINEAR = 9728,
  67837. NEAREST_MIPMAP_NEAREST = 9984,
  67838. LINEAR_MIPMAP_NEAREST = 9985,
  67839. NEAREST_MIPMAP_LINEAR = 9986,
  67840. LINEAR_MIPMAP_LINEAR = 9987
  67841. }
  67842. /** @hidden */
  67843. export enum ETextureFormat {
  67844. ALPHA = 6406,
  67845. RGB = 6407,
  67846. RGBA = 6408,
  67847. LUMINANCE = 6409,
  67848. LUMINANCE_ALPHA = 6410
  67849. }
  67850. /** @hidden */
  67851. export enum ECullingType {
  67852. FRONT = 1028,
  67853. BACK = 1029,
  67854. FRONT_AND_BACK = 1032
  67855. }
  67856. /** @hidden */
  67857. export enum EBlendingFunction {
  67858. ZERO = 0,
  67859. ONE = 1,
  67860. SRC_COLOR = 768,
  67861. ONE_MINUS_SRC_COLOR = 769,
  67862. DST_COLOR = 774,
  67863. ONE_MINUS_DST_COLOR = 775,
  67864. SRC_ALPHA = 770,
  67865. ONE_MINUS_SRC_ALPHA = 771,
  67866. DST_ALPHA = 772,
  67867. ONE_MINUS_DST_ALPHA = 773,
  67868. CONSTANT_COLOR = 32769,
  67869. ONE_MINUS_CONSTANT_COLOR = 32770,
  67870. CONSTANT_ALPHA = 32771,
  67871. ONE_MINUS_CONSTANT_ALPHA = 32772,
  67872. SRC_ALPHA_SATURATE = 776
  67873. }
  67874. /** @hidden */
  67875. export interface IGLTFProperty {
  67876. extensions?: {
  67877. [key: string]: any;
  67878. };
  67879. extras?: Object;
  67880. }
  67881. /** @hidden */
  67882. export interface IGLTFChildRootProperty extends IGLTFProperty {
  67883. name?: string;
  67884. }
  67885. /** @hidden */
  67886. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  67887. bufferView: string;
  67888. byteOffset: number;
  67889. byteStride: number;
  67890. count: number;
  67891. type: string;
  67892. componentType: EComponentType;
  67893. max?: number[];
  67894. min?: number[];
  67895. name?: string;
  67896. }
  67897. /** @hidden */
  67898. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  67899. buffer: string;
  67900. byteOffset: number;
  67901. byteLength: number;
  67902. byteStride: number;
  67903. target?: number;
  67904. }
  67905. /** @hidden */
  67906. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  67907. uri: string;
  67908. byteLength?: number;
  67909. type?: string;
  67910. }
  67911. /** @hidden */
  67912. export interface IGLTFShader extends IGLTFChildRootProperty {
  67913. uri: string;
  67914. type: EShaderType;
  67915. }
  67916. /** @hidden */
  67917. export interface IGLTFProgram extends IGLTFChildRootProperty {
  67918. attributes: string[];
  67919. fragmentShader: string;
  67920. vertexShader: string;
  67921. }
  67922. /** @hidden */
  67923. export interface IGLTFTechniqueParameter {
  67924. type: number;
  67925. count?: number;
  67926. semantic?: string;
  67927. node?: string;
  67928. value?: number | boolean | string | Array<any>;
  67929. source?: string;
  67930. babylonValue?: any;
  67931. }
  67932. /** @hidden */
  67933. export interface IGLTFTechniqueCommonProfile {
  67934. lightingModel: string;
  67935. texcoordBindings: Object;
  67936. parameters?: Array<any>;
  67937. }
  67938. /** @hidden */
  67939. export interface IGLTFTechniqueStatesFunctions {
  67940. blendColor?: number[];
  67941. blendEquationSeparate?: number[];
  67942. blendFuncSeparate?: number[];
  67943. colorMask: boolean[];
  67944. cullFace: number[];
  67945. }
  67946. /** @hidden */
  67947. export interface IGLTFTechniqueStates {
  67948. enable: number[];
  67949. functions: IGLTFTechniqueStatesFunctions;
  67950. }
  67951. /** @hidden */
  67952. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  67953. parameters: {
  67954. [key: string]: IGLTFTechniqueParameter;
  67955. };
  67956. program: string;
  67957. attributes: {
  67958. [key: string]: string;
  67959. };
  67960. uniforms: {
  67961. [key: string]: string;
  67962. };
  67963. states: IGLTFTechniqueStates;
  67964. }
  67965. /** @hidden */
  67966. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  67967. technique?: string;
  67968. values: string[];
  67969. }
  67970. /** @hidden */
  67971. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  67972. attributes: {
  67973. [key: string]: string;
  67974. };
  67975. indices: string;
  67976. material: string;
  67977. mode?: number;
  67978. }
  67979. /** @hidden */
  67980. export interface IGLTFMesh extends IGLTFChildRootProperty {
  67981. primitives: IGLTFMeshPrimitive[];
  67982. }
  67983. /** @hidden */
  67984. export interface IGLTFImage extends IGLTFChildRootProperty {
  67985. uri: string;
  67986. }
  67987. /** @hidden */
  67988. export interface IGLTFSampler extends IGLTFChildRootProperty {
  67989. magFilter?: number;
  67990. minFilter?: number;
  67991. wrapS?: number;
  67992. wrapT?: number;
  67993. }
  67994. /** @hidden */
  67995. export interface IGLTFTexture extends IGLTFChildRootProperty {
  67996. sampler: string;
  67997. source: string;
  67998. format?: ETextureFormat;
  67999. internalFormat?: ETextureFormat;
  68000. target?: number;
  68001. type?: number;
  68002. babylonTexture?: Texture;
  68003. }
  68004. /** @hidden */
  68005. export interface IGLTFAmbienLight {
  68006. color?: number[];
  68007. }
  68008. /** @hidden */
  68009. export interface IGLTFDirectionalLight {
  68010. color?: number[];
  68011. }
  68012. /** @hidden */
  68013. export interface IGLTFPointLight {
  68014. color?: number[];
  68015. constantAttenuation?: number;
  68016. linearAttenuation?: number;
  68017. quadraticAttenuation?: number;
  68018. }
  68019. /** @hidden */
  68020. export interface IGLTFSpotLight {
  68021. color?: number[];
  68022. constantAttenuation?: number;
  68023. fallOfAngle?: number;
  68024. fallOffExponent?: number;
  68025. linearAttenuation?: number;
  68026. quadraticAttenuation?: number;
  68027. }
  68028. /** @hidden */
  68029. export interface IGLTFLight extends IGLTFChildRootProperty {
  68030. type: string;
  68031. }
  68032. /** @hidden */
  68033. export interface IGLTFCameraOrthographic {
  68034. xmag: number;
  68035. ymag: number;
  68036. zfar: number;
  68037. znear: number;
  68038. }
  68039. /** @hidden */
  68040. export interface IGLTFCameraPerspective {
  68041. aspectRatio: number;
  68042. yfov: number;
  68043. zfar: number;
  68044. znear: number;
  68045. }
  68046. /** @hidden */
  68047. export interface IGLTFCamera extends IGLTFChildRootProperty {
  68048. type: string;
  68049. }
  68050. /** @hidden */
  68051. export interface IGLTFAnimationChannelTarget {
  68052. id: string;
  68053. path: string;
  68054. }
  68055. /** @hidden */
  68056. export interface IGLTFAnimationChannel {
  68057. sampler: string;
  68058. target: IGLTFAnimationChannelTarget;
  68059. }
  68060. /** @hidden */
  68061. export interface IGLTFAnimationSampler {
  68062. input: string;
  68063. output: string;
  68064. interpolation?: string;
  68065. }
  68066. /** @hidden */
  68067. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  68068. channels?: IGLTFAnimationChannel[];
  68069. parameters?: {
  68070. [key: string]: string;
  68071. };
  68072. samplers?: {
  68073. [key: string]: IGLTFAnimationSampler;
  68074. };
  68075. }
  68076. /** @hidden */
  68077. export interface IGLTFNodeInstanceSkin {
  68078. skeletons: string[];
  68079. skin: string;
  68080. meshes: string[];
  68081. }
  68082. /** @hidden */
  68083. export interface IGLTFSkins extends IGLTFChildRootProperty {
  68084. bindShapeMatrix: number[];
  68085. inverseBindMatrices: string;
  68086. jointNames: string[];
  68087. babylonSkeleton?: Skeleton;
  68088. }
  68089. /** @hidden */
  68090. export interface IGLTFNode extends IGLTFChildRootProperty {
  68091. camera?: string;
  68092. children: string[];
  68093. skin?: string;
  68094. jointName?: string;
  68095. light?: string;
  68096. matrix: number[];
  68097. mesh?: string;
  68098. meshes?: string[];
  68099. rotation?: number[];
  68100. scale?: number[];
  68101. translation?: number[];
  68102. babylonNode?: Node;
  68103. }
  68104. /** @hidden */
  68105. export interface IGLTFScene extends IGLTFChildRootProperty {
  68106. nodes: string[];
  68107. }
  68108. /** @hidden */
  68109. export interface IGLTFRuntime {
  68110. extensions: {
  68111. [key: string]: any;
  68112. };
  68113. accessors: {
  68114. [key: string]: IGLTFAccessor;
  68115. };
  68116. buffers: {
  68117. [key: string]: IGLTFBuffer;
  68118. };
  68119. bufferViews: {
  68120. [key: string]: IGLTFBufferView;
  68121. };
  68122. meshes: {
  68123. [key: string]: IGLTFMesh;
  68124. };
  68125. lights: {
  68126. [key: string]: IGLTFLight;
  68127. };
  68128. cameras: {
  68129. [key: string]: IGLTFCamera;
  68130. };
  68131. nodes: {
  68132. [key: string]: IGLTFNode;
  68133. };
  68134. images: {
  68135. [key: string]: IGLTFImage;
  68136. };
  68137. textures: {
  68138. [key: string]: IGLTFTexture;
  68139. };
  68140. shaders: {
  68141. [key: string]: IGLTFShader;
  68142. };
  68143. programs: {
  68144. [key: string]: IGLTFProgram;
  68145. };
  68146. samplers: {
  68147. [key: string]: IGLTFSampler;
  68148. };
  68149. techniques: {
  68150. [key: string]: IGLTFTechnique;
  68151. };
  68152. materials: {
  68153. [key: string]: IGLTFMaterial;
  68154. };
  68155. animations: {
  68156. [key: string]: IGLTFAnimation;
  68157. };
  68158. skins: {
  68159. [key: string]: IGLTFSkins;
  68160. };
  68161. currentScene?: Object;
  68162. scenes: {
  68163. [key: string]: IGLTFScene;
  68164. };
  68165. extensionsUsed: string[];
  68166. extensionsRequired?: string[];
  68167. buffersCount: number;
  68168. shaderscount: number;
  68169. scene: Scene;
  68170. rootUrl: string;
  68171. loadedBufferCount: number;
  68172. loadedBufferViews: {
  68173. [name: string]: ArrayBufferView;
  68174. };
  68175. loadedShaderCount: number;
  68176. importOnlyMeshes: boolean;
  68177. importMeshesNames?: string[];
  68178. dummyNodes: Node[];
  68179. }
  68180. /** @hidden */
  68181. export interface INodeToRoot {
  68182. bone: Bone;
  68183. node: IGLTFNode;
  68184. id: string;
  68185. }
  68186. /** @hidden */
  68187. export interface IJointNode {
  68188. node: IGLTFNode;
  68189. id: string;
  68190. }
  68191. }
  68192. declare module BABYLON.GLTF1 {
  68193. /**
  68194. * Utils functions for GLTF
  68195. * @hidden
  68196. */
  68197. export class GLTFUtils {
  68198. /**
  68199. * Sets the given "parameter" matrix
  68200. * @param scene: the Scene object
  68201. * @param source: the source node where to pick the matrix
  68202. * @param parameter: the GLTF technique parameter
  68203. * @param uniformName: the name of the shader's uniform
  68204. * @param shaderMaterial: the shader material
  68205. */
  68206. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  68207. /**
  68208. * Sets the given "parameter" matrix
  68209. * @param shaderMaterial: the shader material
  68210. * @param uniform: the name of the shader's uniform
  68211. * @param value: the value of the uniform
  68212. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  68213. */
  68214. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  68215. /**
  68216. * Returns the wrap mode of the texture
  68217. * @param mode: the mode value
  68218. */
  68219. static GetWrapMode(mode: number): number;
  68220. /**
  68221. * Returns the byte stride giving an accessor
  68222. * @param accessor: the GLTF accessor objet
  68223. */
  68224. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  68225. /**
  68226. * Returns the texture filter mode giving a mode value
  68227. * @param mode: the filter mode value
  68228. */
  68229. static GetTextureFilterMode(mode: number): ETextureFilterType;
  68230. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  68231. /**
  68232. * Returns a buffer from its accessor
  68233. * @param gltfRuntime: the GLTF runtime
  68234. * @param accessor: the GLTF accessor
  68235. */
  68236. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  68237. /**
  68238. * Decodes a buffer view into a string
  68239. * @param view: the buffer view
  68240. */
  68241. static DecodeBufferToText(view: ArrayBufferView): string;
  68242. /**
  68243. * Returns the default material of gltf. Related to
  68244. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  68245. * @param scene: the Babylon.js scene
  68246. */
  68247. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  68248. private static _DefaultMaterial;
  68249. }
  68250. }
  68251. declare module BABYLON.GLTF1 {
  68252. /**
  68253. * Implementation of the base glTF spec
  68254. * @hidden
  68255. */
  68256. export class GLTFLoaderBase {
  68257. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  68258. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  68259. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  68260. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  68261. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  68262. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  68263. }
  68264. /**
  68265. * glTF V1 Loader
  68266. * @hidden
  68267. */
  68268. export class GLTFLoader implements IGLTFLoader {
  68269. static Extensions: {
  68270. [name: string]: GLTFLoaderExtension;
  68271. };
  68272. static RegisterExtension(extension: GLTFLoaderExtension): void;
  68273. state: Nullable<GLTFLoaderState>;
  68274. dispose(): void;
  68275. private _importMeshAsync;
  68276. /**
  68277. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  68278. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  68279. * @param scene the scene the meshes should be added to
  68280. * @param data gltf data containing information of the meshes in a loaded file
  68281. * @param rootUrl root url to load from
  68282. * @param onProgress event that fires when loading progress has occured
  68283. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  68284. */
  68285. importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<{
  68286. meshes: AbstractMesh[];
  68287. particleSystems: IParticleSystem[];
  68288. skeletons: Skeleton[];
  68289. animationGroups: AnimationGroup[];
  68290. }>;
  68291. private _loadAsync;
  68292. /**
  68293. * Imports all objects from a loaded gltf file and adds them to the scene
  68294. * @param scene the scene the objects should be added to
  68295. * @param data gltf data containing information of the meshes in a loaded file
  68296. * @param rootUrl root url to load from
  68297. * @param onProgress event that fires when loading progress has occured
  68298. * @returns a promise which completes when objects have been loaded to the scene
  68299. */
  68300. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<void>;
  68301. private _loadShadersAsync;
  68302. private _loadBuffersAsync;
  68303. private _createNodes;
  68304. }
  68305. /** @hidden */
  68306. export abstract class GLTFLoaderExtension {
  68307. private _name;
  68308. constructor(name: string);
  68309. readonly name: string;
  68310. /**
  68311. * Defines an override for loading the runtime
  68312. * Return true to stop further extensions from loading the runtime
  68313. */
  68314. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  68315. /**
  68316. * Defines an onverride for creating gltf runtime
  68317. * Return true to stop further extensions from creating the runtime
  68318. */
  68319. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  68320. /**
  68321. * Defines an override for loading buffers
  68322. * Return true to stop further extensions from loading this buffer
  68323. */
  68324. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  68325. /**
  68326. * Defines an override for loading texture buffers
  68327. * Return true to stop further extensions from loading this texture data
  68328. */
  68329. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  68330. /**
  68331. * Defines an override for creating textures
  68332. * Return true to stop further extensions from loading this texture
  68333. */
  68334. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  68335. /**
  68336. * Defines an override for loading shader strings
  68337. * Return true to stop further extensions from loading this shader data
  68338. */
  68339. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  68340. /**
  68341. * Defines an override for loading materials
  68342. * Return true to stop further extensions from loading this material
  68343. */
  68344. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  68345. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  68346. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  68347. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  68348. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  68349. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  68350. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  68351. private static LoadTextureBufferAsync;
  68352. private static CreateTextureAsync;
  68353. private static ApplyExtensions;
  68354. }
  68355. }
  68356. declare module BABYLON.GLTF1 {
  68357. /** @hidden */
  68358. export class GLTFBinaryExtension extends GLTFLoaderExtension {
  68359. private _bin;
  68360. constructor();
  68361. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  68362. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  68363. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  68364. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  68365. }
  68366. }
  68367. declare module BABYLON.GLTF1 {
  68368. /** @hidden */
  68369. export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  68370. constructor();
  68371. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  68372. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  68373. private _loadTexture;
  68374. }
  68375. }
  68376. declare module BABYLON.GLTF2.Loader {
  68377. /**
  68378. * Loader interface with an index field.
  68379. */
  68380. export interface IArrayItem {
  68381. /**
  68382. * The index of this item in the array.
  68383. */
  68384. index: number;
  68385. }
  68386. /**
  68387. * Loader interface with additional members.
  68388. */
  68389. export interface IAccessor extends BABYLON.GLTF2.IAccessor, IArrayItem {
  68390. /** @hidden */
  68391. _data?: Promise<ArrayBufferView>;
  68392. /** @hidden */
  68393. _babylonVertexBuffer?: Promise<VertexBuffer>;
  68394. }
  68395. /**
  68396. * Loader interface with additional members.
  68397. */
  68398. export interface IAnimationChannel extends BABYLON.GLTF2.IAnimationChannel, IArrayItem {
  68399. }
  68400. /** @hidden */
  68401. export interface _IAnimationSamplerData {
  68402. input: Float32Array;
  68403. interpolation: BABYLON.GLTF2.AnimationSamplerInterpolation;
  68404. output: Float32Array;
  68405. }
  68406. /**
  68407. * Loader interface with additional members.
  68408. */
  68409. export interface IAnimationSampler extends BABYLON.GLTF2.IAnimationSampler, IArrayItem {
  68410. /** @hidden */
  68411. _data?: Promise<_IAnimationSamplerData>;
  68412. }
  68413. /**
  68414. * Loader interface with additional members.
  68415. */
  68416. export interface IAnimation extends BABYLON.GLTF2.IAnimation, IArrayItem {
  68417. channels: IAnimationChannel[];
  68418. samplers: IAnimationSampler[];
  68419. /** @hidden */
  68420. _babylonAnimationGroup?: AnimationGroup;
  68421. }
  68422. /**
  68423. * Loader interface with additional members.
  68424. */
  68425. export interface IBuffer extends BABYLON.GLTF2.IBuffer, IArrayItem {
  68426. /** @hidden */
  68427. _data?: Promise<ArrayBufferView>;
  68428. }
  68429. /**
  68430. * Loader interface with additional members.
  68431. */
  68432. export interface IBufferView extends BABYLON.GLTF2.IBufferView, IArrayItem {
  68433. /** @hidden */
  68434. _data?: Promise<ArrayBufferView>;
  68435. /** @hidden */
  68436. _babylonBuffer?: Promise<Buffer>;
  68437. }
  68438. /**
  68439. * Loader interface with additional members.
  68440. */
  68441. export interface ICamera extends BABYLON.GLTF2.ICamera, IArrayItem {
  68442. }
  68443. /**
  68444. * Loader interface with additional members.
  68445. */
  68446. export interface IImage extends BABYLON.GLTF2.IImage, IArrayItem {
  68447. /** @hidden */
  68448. _data?: Promise<ArrayBufferView>;
  68449. }
  68450. /**
  68451. * Loader interface with additional members.
  68452. */
  68453. export interface IMaterialNormalTextureInfo extends BABYLON.GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  68454. }
  68455. /**
  68456. * Loader interface with additional members.
  68457. */
  68458. export interface IMaterialOcclusionTextureInfo extends BABYLON.GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  68459. }
  68460. /**
  68461. * Loader interface with additional members.
  68462. */
  68463. export interface IMaterialPbrMetallicRoughness extends BABYLON.GLTF2.IMaterialPbrMetallicRoughness {
  68464. baseColorTexture?: ITextureInfo;
  68465. metallicRoughnessTexture?: ITextureInfo;
  68466. }
  68467. /**
  68468. * Loader interface with additional members.
  68469. */
  68470. export interface IMaterial extends BABYLON.GLTF2.IMaterial, IArrayItem {
  68471. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  68472. normalTexture?: IMaterialNormalTextureInfo;
  68473. occlusionTexture?: IMaterialOcclusionTextureInfo;
  68474. emissiveTexture?: ITextureInfo;
  68475. /** @hidden */
  68476. _data?: {
  68477. [babylonDrawMode: number]: {
  68478. babylonMaterial: Material;
  68479. babylonMeshes: AbstractMesh[];
  68480. promise: Promise<void>;
  68481. };
  68482. };
  68483. }
  68484. /**
  68485. * Loader interface with additional members.
  68486. */
  68487. export interface IMesh extends BABYLON.GLTF2.IMesh, IArrayItem {
  68488. primitives: IMeshPrimitive[];
  68489. }
  68490. /**
  68491. * Loader interface with additional members.
  68492. */
  68493. export interface IMeshPrimitive extends BABYLON.GLTF2.IMeshPrimitive, IArrayItem {
  68494. /** @hidden */
  68495. _instanceData?: {
  68496. babylonSourceMesh: Mesh;
  68497. promise: Promise<any>;
  68498. };
  68499. }
  68500. /**
  68501. * Loader interface with additional members.
  68502. */
  68503. export interface INode extends BABYLON.GLTF2.INode, IArrayItem {
  68504. /**
  68505. * The parent glTF node.
  68506. */
  68507. parent?: INode;
  68508. /** @hidden */
  68509. _babylonTransformNode?: TransformNode;
  68510. /** @hidden */
  68511. _primitiveBabylonMeshes?: AbstractMesh[];
  68512. /** @hidden */
  68513. _babylonBones?: Bone[];
  68514. /** @hidden */
  68515. _numMorphTargets?: number;
  68516. }
  68517. /** @hidden */
  68518. export interface _ISamplerData {
  68519. noMipMaps: boolean;
  68520. samplingMode: number;
  68521. wrapU: number;
  68522. wrapV: number;
  68523. }
  68524. /**
  68525. * Loader interface with additional members.
  68526. */
  68527. export interface ISampler extends BABYLON.GLTF2.ISampler, IArrayItem {
  68528. /** @hidden */
  68529. _data?: _ISamplerData;
  68530. }
  68531. /**
  68532. * Loader interface with additional members.
  68533. */
  68534. export interface IScene extends BABYLON.GLTF2.IScene, IArrayItem {
  68535. }
  68536. /**
  68537. * Loader interface with additional members.
  68538. */
  68539. export interface ISkin extends BABYLON.GLTF2.ISkin, IArrayItem {
  68540. /** @hidden */
  68541. _data?: {
  68542. babylonSkeleton: Skeleton;
  68543. promise: Promise<void>;
  68544. };
  68545. }
  68546. /**
  68547. * Loader interface with additional members.
  68548. */
  68549. export interface ITexture extends BABYLON.GLTF2.ITexture, IArrayItem {
  68550. }
  68551. /**
  68552. * Loader interface with additional members.
  68553. */
  68554. export interface ITextureInfo extends BABYLON.GLTF2.ITextureInfo {
  68555. }
  68556. /**
  68557. * Loader interface with additional members.
  68558. */
  68559. export interface IGLTF extends BABYLON.GLTF2.IGLTF {
  68560. accessors?: IAccessor[];
  68561. animations?: IAnimation[];
  68562. buffers?: IBuffer[];
  68563. bufferViews?: IBufferView[];
  68564. cameras?: ICamera[];
  68565. images?: IImage[];
  68566. materials?: IMaterial[];
  68567. meshes?: IMesh[];
  68568. nodes?: INode[];
  68569. samplers?: ISampler[];
  68570. scenes?: IScene[];
  68571. skins?: ISkin[];
  68572. textures?: ITexture[];
  68573. }
  68574. }
  68575. declare module BABYLON.GLTF2 {
  68576. /**
  68577. * Interface for a glTF loader extension.
  68578. */
  68579. export interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  68580. /**
  68581. * Called after the loader state changes to LOADING.
  68582. */
  68583. onLoading?(): void;
  68584. /**
  68585. * Called after the loader state changes to READY.
  68586. */
  68587. onReady?(): void;
  68588. /**
  68589. * Define this method to modify the default behavior when loading scenes.
  68590. * @param context The context when loading the asset
  68591. * @param scene The glTF scene property
  68592. * @returns A promise that resolves when the load is complete or null if not handled
  68593. */
  68594. loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
  68595. /**
  68596. * Define this method to modify the default behavior when loading nodes.
  68597. * @param context The context when loading the asset
  68598. * @param node The glTF node property
  68599. * @param assign A function called synchronously after parsing the glTF properties
  68600. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  68601. */
  68602. loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  68603. /**
  68604. * Define this method to modify the default behavior when loading cameras.
  68605. * @param context The context when loading the asset
  68606. * @param camera The glTF camera property
  68607. * @param assign A function called synchronously after parsing the glTF properties
  68608. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  68609. */
  68610. loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  68611. /**
  68612. * @hidden Define this method to modify the default behavior when loading vertex data for mesh primitives.
  68613. * @param context The context when loading the asset
  68614. * @param primitive The glTF mesh primitive property
  68615. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  68616. */
  68617. _loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  68618. /**
  68619. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  68620. * @param context The context when loading the asset
  68621. * @param name The mesh name when loading the asset
  68622. * @param node The glTF node when loading the asset
  68623. * @param mesh The glTF mesh when loading the asset
  68624. * @param primitive The glTF mesh primitive property
  68625. * @param assign A function called synchronously after parsing the glTF properties
  68626. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  68627. */
  68628. _loadMeshPrimitiveAsync?(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  68629. /**
  68630. * @hidden Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  68631. * @param context The context when loading the asset
  68632. * @param material The glTF material property
  68633. * @param assign A function called synchronously after parsing the glTF properties
  68634. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  68635. */
  68636. _loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  68637. /**
  68638. * Define this method to modify the default behavior when creating materials.
  68639. * @param context The context when loading the asset
  68640. * @param material The glTF material property
  68641. * @param babylonDrawMode The draw mode for the Babylon material
  68642. * @returns The Babylon material or null if not handled
  68643. */
  68644. createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  68645. /**
  68646. * Define this method to modify the default behavior when loading material properties.
  68647. * @param context The context when loading the asset
  68648. * @param material The glTF material property
  68649. * @param babylonMaterial The Babylon material
  68650. * @returns A promise that resolves when the load is complete or null if not handled
  68651. */
  68652. loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  68653. /**
  68654. * Define this method to modify the default behavior when loading texture infos.
  68655. * @param context The context when loading the asset
  68656. * @param textureInfo The glTF texture info property
  68657. * @param assign A function called synchronously after parsing the glTF properties
  68658. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  68659. */
  68660. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  68661. /**
  68662. * Define this method to modify the default behavior when loading animations.
  68663. * @param context The context when loading the asset
  68664. * @param animation The glTF animation property
  68665. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  68666. */
  68667. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  68668. /**
  68669. * @hidden Define this method to modify the default behavior when loading skins.
  68670. * @param context The context when loading the asset
  68671. * @param node The glTF node property
  68672. * @param skin The glTF skin property
  68673. * @returns A promise that resolves when the load is complete or null if not handled
  68674. */
  68675. _loadSkinAsync?(context: string, node: INode, skin: ISkin): Nullable<Promise<void>>;
  68676. /**
  68677. * @hidden Define this method to modify the default behavior when loading uris.
  68678. * @param context The context when loading the asset
  68679. * @param property The glTF property associated with the uri
  68680. * @param uri The uri to load
  68681. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  68682. */
  68683. _loadUriAsync?(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  68684. }
  68685. }
  68686. declare module BABYLON.GLTF2 {
  68687. /**
  68688. * Helper class for working with arrays when loading the glTF asset
  68689. */
  68690. export class ArrayItem {
  68691. /**
  68692. * Gets an item from the given array.
  68693. * @param context The context when loading the asset
  68694. * @param array The array to get the item from
  68695. * @param index The index to the array
  68696. * @returns The array item
  68697. */
  68698. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  68699. /**
  68700. * Assign an `index` field to each item of the given array.
  68701. * @param array The array of items
  68702. */
  68703. static Assign(array?: BABYLON.GLTF2.Loader.IArrayItem[]): void;
  68704. }
  68705. /**
  68706. * The glTF 2.0 loader
  68707. */
  68708. export class GLTFLoader implements IGLTFLoader {
  68709. /** @hidden */
  68710. _completePromises: Promise<any>[];
  68711. private _disposed;
  68712. private _parent;
  68713. private _state;
  68714. private _extensions;
  68715. private _rootUrl;
  68716. private _fileName;
  68717. private _uniqueRootUrl;
  68718. private _gltf;
  68719. private _babylonScene;
  68720. private _rootBabylonMesh;
  68721. private _defaultBabylonMaterialData;
  68722. private _progressCallback?;
  68723. private _requests;
  68724. private static readonly _DefaultSampler;
  68725. private static _ExtensionNames;
  68726. private static _ExtensionFactories;
  68727. /**
  68728. * Registers a loader extension.
  68729. * @param name The name of the loader extension.
  68730. * @param factory The factory function that creates the loader extension.
  68731. */
  68732. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  68733. /**
  68734. * Unregisters a loader extension.
  68735. * @param name The name of the loader extenion.
  68736. * @returns A boolean indicating whether the extension has been unregistered
  68737. */
  68738. static UnregisterExtension(name: string): boolean;
  68739. /**
  68740. * Gets the loader state.
  68741. */
  68742. readonly state: Nullable<GLTFLoaderState>;
  68743. /**
  68744. * The glTF object parsed from the JSON.
  68745. */
  68746. readonly gltf: IGLTF;
  68747. /**
  68748. * The Babylon scene when loading the asset.
  68749. */
  68750. readonly babylonScene: Scene;
  68751. /**
  68752. * The root Babylon mesh when loading the asset.
  68753. */
  68754. readonly rootBabylonMesh: Mesh;
  68755. /** @hidden */
  68756. constructor(parent: GLTFFileLoader);
  68757. /** @hidden */
  68758. dispose(): void;
  68759. /** @hidden */
  68760. importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  68761. meshes: AbstractMesh[];
  68762. particleSystems: IParticleSystem[];
  68763. skeletons: Skeleton[];
  68764. animationGroups: AnimationGroup[];
  68765. }>;
  68766. /** @hidden */
  68767. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  68768. private _loadAsync;
  68769. private _loadData;
  68770. private _setupData;
  68771. private _loadExtensions;
  68772. private _checkExtensions;
  68773. private _setState;
  68774. private _createRootNode;
  68775. /**
  68776. * Loads a glTF scene.
  68777. * @param context The context when loading the asset
  68778. * @param scene The glTF scene property
  68779. * @returns A promise that resolves when the load is complete
  68780. */
  68781. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  68782. private _forEachPrimitive;
  68783. private _getMeshes;
  68784. private _getSkeletons;
  68785. private _getAnimationGroups;
  68786. private _startAnimations;
  68787. /**
  68788. * Loads a glTF node.
  68789. * @param context The context when loading the asset
  68790. * @param node The glTF node property
  68791. * @param assign A function called synchronously after parsing the glTF properties
  68792. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  68793. */
  68794. loadNodeAsync(context: string, node: INode, assign?: (babylonTransformNode: TransformNode) => void): Promise<TransformNode>;
  68795. private _loadMeshAsync;
  68796. /**
  68797. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  68798. * @param context The context when loading the asset
  68799. * @param name The mesh name when loading the asset
  68800. * @param node The glTF node when loading the asset
  68801. * @param mesh The glTF mesh when loading the asset
  68802. * @param primitive The glTF mesh primitive property
  68803. * @param assign A function called synchronously after parsing the glTF properties
  68804. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  68805. */
  68806. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  68807. private _loadVertexDataAsync;
  68808. private _createMorphTargets;
  68809. private _loadMorphTargetsAsync;
  68810. private _loadMorphTargetVertexDataAsync;
  68811. private static _LoadTransform;
  68812. private _loadSkinAsync;
  68813. private _loadBones;
  68814. private _loadBone;
  68815. private _loadSkinInverseBindMatricesDataAsync;
  68816. private _updateBoneMatrices;
  68817. private _getNodeMatrix;
  68818. /**
  68819. * Loads a glTF camera.
  68820. * @param context The context when loading the asset
  68821. * @param camera The glTF camera property
  68822. * @param assign A function called synchronously after parsing the glTF properties
  68823. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  68824. */
  68825. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  68826. private _loadAnimationsAsync;
  68827. /**
  68828. * Loads a glTF animation.
  68829. * @param context The context when loading the asset
  68830. * @param animation The glTF animation property
  68831. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  68832. */
  68833. loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
  68834. /**
  68835. * @hidden Loads a glTF animation channel.
  68836. * @param context The context when loading the asset
  68837. * @param animationContext The context of the animation when loading the asset
  68838. * @param animation The glTF animation property
  68839. * @param channel The glTF animation channel property
  68840. * @param babylonAnimationGroup The babylon animation group property
  68841. * @param animationTargetOverride The babylon animation channel target override property. My be null.
  68842. * @returns A void promise when the channel load is complete
  68843. */
  68844. _loadAnimationChannelAsync(context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: AnimationGroup, animationTargetOverride?: Nullable<IAnimatable>): Promise<void>;
  68845. private _loadAnimationSamplerAsync;
  68846. private _loadBufferAsync;
  68847. /**
  68848. * Loads a glTF buffer view.
  68849. * @param context The context when loading the asset
  68850. * @param bufferView The glTF buffer view property
  68851. * @returns A promise that resolves with the loaded data when the load is complete
  68852. */
  68853. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  68854. private _loadAccessorAsync;
  68855. private _loadFloatAccessorAsync;
  68856. private _loadIndicesAccessorAsync;
  68857. private _loadVertexBufferViewAsync;
  68858. private _loadVertexAccessorAsync;
  68859. private _loadMaterialMetallicRoughnessPropertiesAsync;
  68860. /** @hidden */
  68861. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  68862. private _createDefaultMaterial;
  68863. /**
  68864. * Creates a Babylon material from a glTF material.
  68865. * @param context The context when loading the asset
  68866. * @param material The glTF material property
  68867. * @param babylonDrawMode The draw mode for the Babylon material
  68868. * @returns The Babylon material
  68869. */
  68870. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  68871. /**
  68872. * Loads properties from a glTF material into a Babylon material.
  68873. * @param context The context when loading the asset
  68874. * @param material The glTF material property
  68875. * @param babylonMaterial The Babylon material
  68876. * @returns A promise that resolves when the load is complete
  68877. */
  68878. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  68879. /**
  68880. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  68881. * @param context The context when loading the asset
  68882. * @param material The glTF material property
  68883. * @param babylonMaterial The Babylon material
  68884. * @returns A promise that resolves when the load is complete
  68885. */
  68886. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  68887. /**
  68888. * Loads the alpha properties from a glTF material into a Babylon material.
  68889. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  68890. * @param context The context when loading the asset
  68891. * @param material The glTF material property
  68892. * @param babylonMaterial The Babylon material
  68893. */
  68894. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  68895. /**
  68896. * Loads a glTF texture info.
  68897. * @param context The context when loading the asset
  68898. * @param textureInfo The glTF texture info property
  68899. * @param assign A function called synchronously after parsing the glTF properties
  68900. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  68901. */
  68902. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  68903. private _loadTextureAsync;
  68904. private _loadSampler;
  68905. /**
  68906. * Loads a glTF image.
  68907. * @param context The context when loading the asset
  68908. * @param image The glTF image property
  68909. * @returns A promise that resolves with the loaded data when the load is complete
  68910. */
  68911. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  68912. /**
  68913. * Loads a glTF uri.
  68914. * @param context The context when loading the asset
  68915. * @param property The glTF property associated with the uri
  68916. * @param uri The base64 or relative uri
  68917. * @returns A promise that resolves with the loaded data when the load is complete
  68918. */
  68919. loadUriAsync(context: string, property: IProperty, uri: string): Promise<ArrayBufferView>;
  68920. private _onProgress;
  68921. /**
  68922. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  68923. * @param babylonObject the Babylon object with metadata
  68924. * @param pointer the JSON pointer
  68925. */
  68926. static AddPointerMetadata(babylonObject: {
  68927. metadata: any;
  68928. }, pointer: string): void;
  68929. private static _GetTextureWrapMode;
  68930. private static _GetTextureSamplingMode;
  68931. private static _GetTypedArrayConstructor;
  68932. private static _GetTypedArray;
  68933. private static _GetNumComponents;
  68934. private static _ValidateUri;
  68935. private static _GetDrawMode;
  68936. private _compileMaterialsAsync;
  68937. private _compileShadowGeneratorsAsync;
  68938. private _forEachExtensions;
  68939. private _applyExtensions;
  68940. private _extensionsOnLoading;
  68941. private _extensionsOnReady;
  68942. private _extensionsLoadSceneAsync;
  68943. private _extensionsLoadNodeAsync;
  68944. private _extensionsLoadCameraAsync;
  68945. private _extensionsLoadVertexDataAsync;
  68946. private _extensionsLoadMeshPrimitiveAsync;
  68947. private _extensionsLoadMaterialAsync;
  68948. private _extensionsCreateMaterial;
  68949. private _extensionsLoadMaterialPropertiesAsync;
  68950. private _extensionsLoadTextureInfoAsync;
  68951. private _extensionsLoadAnimationAsync;
  68952. private _extensionsLoadSkinAsync;
  68953. private _extensionsLoadUriAsync;
  68954. /**
  68955. * Helper method called by a loader extension to load an glTF extension.
  68956. * @param context The context when loading the asset
  68957. * @param property The glTF property to load the extension from
  68958. * @param extensionName The name of the extension to load
  68959. * @param actionAsync The action to run
  68960. * @returns The promise returned by actionAsync or null if the extension does not exist
  68961. */
  68962. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  68963. /**
  68964. * Helper method called by a loader extension to load a glTF extra.
  68965. * @param context The context when loading the asset
  68966. * @param property The glTF property to load the extra from
  68967. * @param extensionName The name of the extension to load
  68968. * @param actionAsync The action to run
  68969. * @returns The promise returned by actionAsync or null if the extra does not exist
  68970. */
  68971. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  68972. /**
  68973. * Increments the indentation level and logs a message.
  68974. * @param message The message to log
  68975. */
  68976. logOpen(message: string): void;
  68977. /**
  68978. * Decrements the indentation level.
  68979. */
  68980. logClose(): void;
  68981. /**
  68982. * Logs a message
  68983. * @param message The message to log
  68984. */
  68985. log(message: string): void;
  68986. /**
  68987. * Starts a performance counter.
  68988. * @param counterName The name of the performance counter
  68989. */
  68990. startPerformanceCounter(counterName: string): void;
  68991. /**
  68992. * Ends a performance counter.
  68993. * @param counterName The name of the performance counter
  68994. */
  68995. endPerformanceCounter(counterName: string): void;
  68996. }
  68997. }
  68998. declare module BABYLON.GLTF2.Loader.Extensions {
  68999. /**
  69000. * [Specification](https://github.com/KhronosGroup/glTF/blob/eb3e32332042e04691a5f35103f8c261e50d8f1e/extensions/2.0/Khronos/EXT_lights_image_based/README.md) (Experimental)
  69001. */
  69002. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  69003. /** The name of this extension. */
  69004. readonly name: string;
  69005. /** Defines whether this extension is enabled. */
  69006. enabled: boolean;
  69007. private _loader;
  69008. private _lights?;
  69009. /** @hidden */
  69010. constructor(loader: GLTFLoader);
  69011. /** @hidden */
  69012. dispose(): void;
  69013. /** @hidden */
  69014. onLoading(): void;
  69015. /** @hidden */
  69016. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  69017. private _loadLightAsync;
  69018. }
  69019. }
  69020. declare module BABYLON.GLTF2.Loader.Extensions {
  69021. /**
  69022. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  69023. */
  69024. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  69025. /** The name of this extension. */
  69026. readonly name: string;
  69027. /** The draco compression used to decode vertex data or DracoCompression.Default if not defined */
  69028. dracoCompression?: DracoCompression;
  69029. /** Defines whether this extension is enabled. */
  69030. enabled: boolean;
  69031. private _loader;
  69032. /** @hidden */
  69033. constructor(loader: GLTFLoader);
  69034. /** @hidden */
  69035. dispose(): void;
  69036. /** @hidden */
  69037. _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  69038. }
  69039. }
  69040. declare module BABYLON.GLTF2.Loader.Extensions {
  69041. /**
  69042. * [Specification](https://github.com/KhronosGroup/glTF/blob/1048d162a44dbcb05aefc1874bfd423cf60135a6/extensions/2.0/Khronos/KHR_lights_punctual/README.md) (Experimental)
  69043. */
  69044. export class KHR_lights implements IGLTFLoaderExtension {
  69045. /** The name of this extension. */
  69046. readonly name: string;
  69047. /** Defines whether this extension is enabled. */
  69048. enabled: boolean;
  69049. private _loader;
  69050. private _lights?;
  69051. /** @hidden */
  69052. constructor(loader: GLTFLoader);
  69053. /** @hidden */
  69054. dispose(): void;
  69055. /** @hidden */
  69056. onLoading(): void;
  69057. /** @hidden */
  69058. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  69059. }
  69060. }
  69061. declare module BABYLON.GLTF2.Loader.Extensions {
  69062. /**
  69063. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  69064. */
  69065. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  69066. /** The name of this extension. */
  69067. readonly name: string;
  69068. /** Defines whether this extension is enabled. */
  69069. enabled: boolean;
  69070. private _loader;
  69071. /** @hidden */
  69072. constructor(loader: GLTFLoader);
  69073. /** @hidden */
  69074. dispose(): void;
  69075. /** @hidden */
  69076. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  69077. private _loadSpecularGlossinessPropertiesAsync;
  69078. }
  69079. }
  69080. declare module BABYLON.GLTF2.Loader.Extensions {
  69081. /**
  69082. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  69083. */
  69084. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  69085. /** The name of this extension. */
  69086. readonly name: string;
  69087. /** Defines whether this extension is enabled. */
  69088. enabled: boolean;
  69089. private _loader;
  69090. /** @hidden */
  69091. constructor(loader: GLTFLoader);
  69092. /** @hidden */
  69093. dispose(): void;
  69094. /** @hidden */
  69095. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  69096. private _loadUnlitPropertiesAsync;
  69097. }
  69098. }
  69099. declare module BABYLON.GLTF2.Loader.Extensions {
  69100. /**
  69101. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform/README.md)
  69102. */
  69103. export class KHR_texture_transform implements IGLTFLoaderExtension {
  69104. /** The name of this extension. */
  69105. readonly name: string;
  69106. /** Defines whether this extension is enabled. */
  69107. enabled: boolean;
  69108. private _loader;
  69109. /** @hidden */
  69110. constructor(loader: GLTFLoader);
  69111. /** @hidden */
  69112. dispose(): void;
  69113. /** @hidden */
  69114. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  69115. }
  69116. }
  69117. declare module BABYLON.GLTF2.Loader.Extensions {
  69118. /**
  69119. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  69120. */
  69121. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  69122. /** The name of this extension. */
  69123. readonly name: string;
  69124. /** Defines whether this extension is enabled. */
  69125. enabled: boolean;
  69126. private _loader;
  69127. private _clips;
  69128. private _emitters;
  69129. /** @hidden */
  69130. constructor(loader: GLTFLoader);
  69131. /** @hidden */
  69132. dispose(): void;
  69133. /** @hidden */
  69134. onLoading(): void;
  69135. /** @hidden */
  69136. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  69137. /** @hidden */
  69138. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  69139. /** @hidden */
  69140. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  69141. private _loadClipAsync;
  69142. private _loadEmitterAsync;
  69143. private _getEventAction;
  69144. private _loadAnimationEventAsync;
  69145. }
  69146. }
  69147. declare module BABYLON.GLTF2.Loader.Extensions {
  69148. /**
  69149. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  69150. */
  69151. export class MSFT_lod implements IGLTFLoaderExtension {
  69152. /** The name of this extension. */
  69153. readonly name: string;
  69154. /** Defines whether this extension is enabled. */
  69155. enabled: boolean;
  69156. /**
  69157. * Maximum number of LODs to load, starting from the lowest LOD.
  69158. */
  69159. maxLODsToLoad: number;
  69160. /**
  69161. * Observable raised when all node LODs of one level are loaded.
  69162. * The event data is the index of the loaded LOD starting from zero.
  69163. * Dispose the loader to cancel the loading of the next level of LODs.
  69164. */
  69165. onNodeLODsLoadedObservable: Observable<number>;
  69166. /**
  69167. * Observable raised when all material LODs of one level are loaded.
  69168. * The event data is the index of the loaded LOD starting from zero.
  69169. * Dispose the loader to cancel the loading of the next level of LODs.
  69170. */
  69171. onMaterialLODsLoadedObservable: Observable<number>;
  69172. private _loader;
  69173. private _nodeIndexLOD;
  69174. private _nodeSignalLODs;
  69175. private _nodePromiseLODs;
  69176. private _materialIndexLOD;
  69177. private _materialSignalLODs;
  69178. private _materialPromiseLODs;
  69179. /** @hidden */
  69180. constructor(loader: GLTFLoader);
  69181. /** @hidden */
  69182. dispose(): void;
  69183. /** @hidden */
  69184. onReady(): void;
  69185. /** @hidden */
  69186. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  69187. /** @hidden */
  69188. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  69189. /** @hidden */
  69190. _loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  69191. /**
  69192. * Gets an array of LOD properties from lowest to highest.
  69193. */
  69194. private _getLODs;
  69195. private _disposeUnusedMaterials;
  69196. }
  69197. }
  69198. declare module BABYLON.GLTF2.Loader.Extensions {
  69199. /** @hidden */
  69200. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  69201. readonly name: string;
  69202. enabled: boolean;
  69203. private _loader;
  69204. constructor(loader: GLTFLoader);
  69205. dispose(): void;
  69206. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  69207. }
  69208. }
  69209. declare module BABYLON.GLTF2.Loader.Extensions {
  69210. /** @hidden */
  69211. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  69212. readonly name: string;
  69213. enabled: boolean;
  69214. private _loader;
  69215. constructor(loader: GLTFLoader);
  69216. dispose(): void;
  69217. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  69218. }
  69219. }
  69220. declare module BABYLON.GLTF2.Loader.Extensions {
  69221. /**
  69222. * Store glTF extras (if present) in BJS objects' metadata
  69223. */
  69224. export class ExtrasAsMetadata implements IGLTFLoaderExtension {
  69225. /** The name of this extension. */
  69226. readonly name: string;
  69227. /** Defines whether this extension is enabled. */
  69228. enabled: boolean;
  69229. private _loader;
  69230. private _assignExtras;
  69231. /** @hidden */
  69232. constructor(loader: GLTFLoader);
  69233. /** @hidden */
  69234. dispose(): void;
  69235. /** @hidden */
  69236. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  69237. /** @hidden */
  69238. loadCameraAsync(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  69239. /** @hidden */
  69240. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  69241. }
  69242. }
  69243. declare module BABYLON {
  69244. /**
  69245. * Class reading and parsing the MTL file bundled with the obj file.
  69246. */
  69247. export class MTLFileLoader {
  69248. /**
  69249. * All material loaded from the mtl will be set here
  69250. */
  69251. materials: StandardMaterial[];
  69252. /**
  69253. * This function will read the mtl file and create each material described inside
  69254. * This function could be improve by adding :
  69255. * -some component missing (Ni, Tf...)
  69256. * -including the specific options available
  69257. *
  69258. * @param scene defines the scene the material will be created in
  69259. * @param data defines the mtl data to parse
  69260. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  69261. */
  69262. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string): void;
  69263. /**
  69264. * Gets the texture for the material.
  69265. *
  69266. * If the material is imported from input file,
  69267. * We sanitize the url to ensure it takes the textre from aside the material.
  69268. *
  69269. * @param rootUrl The root url to load from
  69270. * @param value The value stored in the mtl
  69271. * @return The Texture
  69272. */
  69273. private static _getTexture;
  69274. }
  69275. /**
  69276. * Options for loading OBJ/MTL files
  69277. */
  69278. type MeshLoadOptions = {
  69279. /**
  69280. * Defines if UVs are optimized by default during load.
  69281. */
  69282. OptimizeWithUV: boolean;
  69283. /**
  69284. * Defines custom scaling of UV coordinates of loaded meshes.
  69285. */
  69286. UVScaling: Vector2;
  69287. /**
  69288. * Invert model on y-axis (does a model scaling inversion)
  69289. */
  69290. InvertY: boolean;
  69291. /**
  69292. * Invert Y-Axis of referenced textures on load
  69293. */
  69294. InvertTextureY: boolean;
  69295. /**
  69296. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  69297. */
  69298. ImportVertexColors: boolean;
  69299. /**
  69300. * Compute the normals for the model, even if normals are present in the file.
  69301. */
  69302. ComputeNormals: boolean;
  69303. /**
  69304. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  69305. */
  69306. SkipMaterials: boolean;
  69307. /**
  69308. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  69309. */
  69310. MaterialLoadingFailsSilently: boolean;
  69311. };
  69312. /**
  69313. * OBJ file type loader.
  69314. * This is a babylon scene loader plugin.
  69315. */
  69316. export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  69317. /**
  69318. * Defines if UVs are optimized by default during load.
  69319. */
  69320. static OPTIMIZE_WITH_UV: boolean;
  69321. /**
  69322. * Invert model on y-axis (does a model scaling inversion)
  69323. */
  69324. static INVERT_Y: boolean;
  69325. /**
  69326. * Invert Y-Axis of referenced textures on load
  69327. */
  69328. static INVERT_TEXTURE_Y: boolean;
  69329. /**
  69330. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  69331. */
  69332. static IMPORT_VERTEX_COLORS: boolean;
  69333. /**
  69334. * Compute the normals for the model, even if normals are present in the file.
  69335. */
  69336. static COMPUTE_NORMALS: boolean;
  69337. /**
  69338. * Defines custom scaling of UV coordinates of loaded meshes.
  69339. */
  69340. static UV_SCALING: Vector2;
  69341. /**
  69342. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  69343. */
  69344. static SKIP_MATERIALS: boolean;
  69345. /**
  69346. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  69347. *
  69348. * Defaults to true for backwards compatibility.
  69349. */
  69350. static MATERIAL_LOADING_FAILS_SILENTLY: boolean;
  69351. /**
  69352. * Defines the name of the plugin.
  69353. */
  69354. name: string;
  69355. /**
  69356. * Defines the extension the plugin is able to load.
  69357. */
  69358. extensions: string;
  69359. /** @hidden */
  69360. obj: RegExp;
  69361. /** @hidden */
  69362. group: RegExp;
  69363. /** @hidden */
  69364. mtllib: RegExp;
  69365. /** @hidden */
  69366. usemtl: RegExp;
  69367. /** @hidden */
  69368. smooth: RegExp;
  69369. /** @hidden */
  69370. vertexPattern: RegExp;
  69371. /** @hidden */
  69372. normalPattern: RegExp;
  69373. /** @hidden */
  69374. uvPattern: RegExp;
  69375. /** @hidden */
  69376. facePattern1: RegExp;
  69377. /** @hidden */
  69378. facePattern2: RegExp;
  69379. /** @hidden */
  69380. facePattern3: RegExp;
  69381. /** @hidden */
  69382. facePattern4: RegExp;
  69383. /** @hidden */
  69384. facePattern5: RegExp;
  69385. private _meshLoadOptions;
  69386. /**
  69387. * Creates loader for .OBJ files
  69388. *
  69389. * @param meshLoadOptions options for loading and parsing OBJ/MTL files.
  69390. */
  69391. constructor(meshLoadOptions?: MeshLoadOptions);
  69392. private static readonly currentMeshLoadOptions;
  69393. /**
  69394. * Calls synchronously the MTL file attached to this obj.
  69395. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  69396. * Without this function materials are not displayed in the first frame (but displayed after).
  69397. * In consequence it is impossible to get material information in your HTML file
  69398. *
  69399. * @param url The URL of the MTL file
  69400. * @param rootUrl
  69401. * @param onSuccess Callback function to be called when the MTL file is loaded
  69402. * @private
  69403. */
  69404. private _loadMTL;
  69405. /**
  69406. * Instantiates a OBJ file loader plugin.
  69407. * @returns the created plugin
  69408. */
  69409. createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
  69410. /**
  69411. * If the data string can be loaded directly.
  69412. *
  69413. * @param data string containing the file data
  69414. * @returns if the data can be loaded directly
  69415. */
  69416. canDirectLoad(data: string): boolean;
  69417. /**
  69418. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  69419. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  69420. * @param scene the scene the meshes should be added to
  69421. * @param data the OBJ data to load
  69422. * @param rootUrl root url to load from
  69423. * @param onProgress event that fires when loading progress has occured
  69424. * @param fileName Defines the name of the file to load
  69425. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  69426. */
  69427. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  69428. meshes: AbstractMesh[];
  69429. particleSystems: IParticleSystem[];
  69430. skeletons: Skeleton[];
  69431. animationGroups: AnimationGroup[];
  69432. }>;
  69433. /**
  69434. * Imports all objects from the loaded OBJ data and adds them to the scene
  69435. * @param scene the scene the objects should be added to
  69436. * @param data the OBJ data to load
  69437. * @param rootUrl root url to load from
  69438. * @param onProgress event that fires when loading progress has occured
  69439. * @param fileName Defines the name of the file to load
  69440. * @returns a promise which completes when objects have been loaded to the scene
  69441. */
  69442. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  69443. /**
  69444. * Load into an asset container.
  69445. * @param scene The scene to load into
  69446. * @param data The data to import
  69447. * @param rootUrl The root url for scene and resources
  69448. * @param onProgress The callback when the load progresses
  69449. * @param fileName Defines the name of the file to load
  69450. * @returns The loaded asset container
  69451. */
  69452. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  69453. /**
  69454. * Read the OBJ file and create an Array of meshes.
  69455. * Each mesh contains all information given by the OBJ and the MTL file.
  69456. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  69457. *
  69458. * @param meshesNames
  69459. * @param scene Scene The scene where are displayed the data
  69460. * @param data String The content of the obj file
  69461. * @param rootUrl String The path to the folder
  69462. * @returns Array<AbstractMesh>
  69463. * @private
  69464. */
  69465. private _parseSolid;
  69466. }
  69467. }
  69468. declare module BABYLON {
  69469. /**
  69470. * STL file type loader.
  69471. * This is a babylon scene loader plugin.
  69472. */
  69473. export class STLFileLoader implements ISceneLoaderPlugin {
  69474. /** @hidden */
  69475. solidPattern: RegExp;
  69476. /** @hidden */
  69477. facetsPattern: RegExp;
  69478. /** @hidden */
  69479. normalPattern: RegExp;
  69480. /** @hidden */
  69481. vertexPattern: RegExp;
  69482. /**
  69483. * Defines the name of the plugin.
  69484. */
  69485. name: string;
  69486. /**
  69487. * Defines the extensions the stl loader is able to load.
  69488. * force data to come in as an ArrayBuffer
  69489. * we'll convert to string if it looks like it's an ASCII .stl
  69490. */
  69491. extensions: ISceneLoaderPluginExtensions;
  69492. /**
  69493. * Import meshes into a scene.
  69494. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  69495. * @param scene The scene to import into
  69496. * @param data The data to import
  69497. * @param rootUrl The root url for scene and resources
  69498. * @param meshes The meshes array to import into
  69499. * @param particleSystems The particle systems array to import into
  69500. * @param skeletons The skeletons array to import into
  69501. * @param onError The callback when import fails
  69502. * @returns True if successful or false otherwise
  69503. */
  69504. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  69505. /**
  69506. * Load into a scene.
  69507. * @param scene The scene to load into
  69508. * @param data The data to import
  69509. * @param rootUrl The root url for scene and resources
  69510. * @param onError The callback when import fails
  69511. * @returns true if successful or false otherwise
  69512. */
  69513. load(scene: Scene, data: any, rootUrl: string): boolean;
  69514. /**
  69515. * Load into an asset container.
  69516. * @param scene The scene to load into
  69517. * @param data The data to import
  69518. * @param rootUrl The root url for scene and resources
  69519. * @param onError The callback when import fails
  69520. * @returns The loaded asset container
  69521. */
  69522. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  69523. private _isBinary;
  69524. private _parseBinary;
  69525. private _parseASCII;
  69526. }
  69527. }
  69528. declare module BABYLON {
  69529. /**
  69530. * Class for generating OBJ data from a Babylon scene.
  69531. */
  69532. export class OBJExport {
  69533. /**
  69534. * Exports the geometry of a Mesh array in .OBJ file format (text)
  69535. * @param mesh defines the list of meshes to serialize
  69536. * @param materials defines if materials should be exported
  69537. * @param matlibname defines the name of the associated mtl file
  69538. * @param globalposition defines if the exported positions are globals or local to the exported mesh
  69539. * @returns the OBJ content
  69540. */
  69541. static OBJ(mesh: Mesh[], materials?: boolean, matlibname?: string, globalposition?: boolean): string;
  69542. /**
  69543. * Exports the material(s) of a mesh in .MTL file format (text)
  69544. * @param mesh defines the mesh to extract the material from
  69545. * @returns the mtl content
  69546. */
  69547. static MTL(mesh: Mesh): string;
  69548. }
  69549. }
  69550. declare module BABYLON {
  69551. /** @hidden */
  69552. export var __IGLTFExporterExtension: number;
  69553. /**
  69554. * Interface for extending the exporter
  69555. * @hidden
  69556. */
  69557. export interface IGLTFExporterExtension {
  69558. /**
  69559. * The name of this extension
  69560. */
  69561. readonly name: string;
  69562. /**
  69563. * Defines whether this extension is enabled
  69564. */
  69565. enabled: boolean;
  69566. /**
  69567. * Defines whether this extension is required
  69568. */
  69569. required: boolean;
  69570. }
  69571. }
  69572. declare module BABYLON.GLTF2.Exporter {
  69573. /** @hidden */
  69574. export var __IGLTFExporterExtensionV2: number;
  69575. /**
  69576. * Interface for a glTF exporter extension
  69577. * @hidden
  69578. */
  69579. export interface IGLTFExporterExtensionV2 extends IGLTFExporterExtension, IDisposable {
  69580. /**
  69581. * Define this method to modify the default behavior before exporting a texture
  69582. * @param context The context when loading the asset
  69583. * @param babylonTexture The glTF texture info property
  69584. * @param mimeType The mime-type of the generated image
  69585. * @returns A promise that resolves with the exported glTF texture info when the export is complete, or null if not handled
  69586. */
  69587. preExportTextureAsync?(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Nullable<Promise<Texture>>;
  69588. /**
  69589. * Define this method to modify the default behavior when exporting texture info
  69590. * @param context The context when loading the asset
  69591. * @param meshPrimitive glTF mesh primitive
  69592. * @param babylonSubMesh Babylon submesh
  69593. * @param binaryWriter glTF serializer binary writer instance
  69594. * @returns nullable IMeshPrimitive promise
  69595. */
  69596. postExportMeshPrimitiveAsync?(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Nullable<Promise<IMeshPrimitive>>;
  69597. /**
  69598. * Define this method to modify the default behavior when exporting a node
  69599. * @param context The context when exporting the node
  69600. * @param node glTF node
  69601. * @param babylonNode BabylonJS node
  69602. * @returns nullable INode promise
  69603. */
  69604. postExportNodeAsync?(context: string, node: INode, babylonNode: Node): Nullable<Promise<INode>>;
  69605. /**
  69606. * Called after the exporter state changes to EXPORTING
  69607. */
  69608. onExporting?(): void;
  69609. }
  69610. }
  69611. declare module BABYLON.GLTF2.Exporter {
  69612. /**
  69613. * Utility methods for working with glTF material conversion properties. This class should only be used internally
  69614. * @hidden
  69615. */
  69616. export class _GLTFMaterialExporter {
  69617. /**
  69618. * Represents the dielectric specular values for R, G and B
  69619. */
  69620. private static readonly _DielectricSpecular;
  69621. /**
  69622. * Allows the maximum specular power to be defined for material calculations
  69623. */
  69624. private static readonly _MaxSpecularPower;
  69625. /**
  69626. * Mapping to store textures
  69627. */
  69628. private _textureMap;
  69629. /**
  69630. * Numeric tolerance value
  69631. */
  69632. private static readonly _Epsilon;
  69633. /**
  69634. * Reference to the glTF Exporter
  69635. */
  69636. private _exporter;
  69637. constructor(exporter: _Exporter);
  69638. /**
  69639. * Specifies if two colors are approximately equal in value
  69640. * @param color1 first color to compare to
  69641. * @param color2 second color to compare to
  69642. * @param epsilon threshold value
  69643. */
  69644. private static FuzzyEquals;
  69645. /**
  69646. * Gets the materials from a Babylon scene and converts them to glTF materials
  69647. * @param scene babylonjs scene
  69648. * @param mimeType texture mime type
  69649. * @param images array of images
  69650. * @param textures array of textures
  69651. * @param materials array of materials
  69652. * @param imageData mapping of texture names to base64 textures
  69653. * @param hasTextureCoords specifies if texture coordinates are present on the material
  69654. */
  69655. _convertMaterialsToGLTFAsync(babylonMaterials: Material[], mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  69656. /**
  69657. * Makes a copy of the glTF material without the texture parameters
  69658. * @param originalMaterial original glTF material
  69659. * @returns glTF material without texture parameters
  69660. */
  69661. _stripTexturesFromMaterial(originalMaterial: IMaterial): IMaterial;
  69662. /**
  69663. * Specifies if the material has any texture parameters present
  69664. * @param material glTF Material
  69665. * @returns boolean specifying if texture parameters are present
  69666. */
  69667. _hasTexturesPresent(material: IMaterial): boolean;
  69668. /**
  69669. * Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material
  69670. * @param babylonStandardMaterial
  69671. * @returns glTF Metallic Roughness Material representation
  69672. */
  69673. _convertToGLTFPBRMetallicRoughness(babylonStandardMaterial: StandardMaterial): IMaterialPbrMetallicRoughness;
  69674. /**
  69675. * Computes the metallic factor
  69676. * @param diffuse diffused value
  69677. * @param specular specular value
  69678. * @param oneMinusSpecularStrength one minus the specular strength
  69679. * @returns metallic value
  69680. */
  69681. static _SolveMetallic(diffuse: number, specular: number, oneMinusSpecularStrength: number): number;
  69682. /**
  69683. * Sets the glTF alpha mode to a glTF material from the Babylon Material
  69684. * @param glTFMaterial glTF material
  69685. * @param babylonMaterial Babylon material
  69686. */
  69687. private static _SetAlphaMode;
  69688. /**
  69689. * Converts a Babylon Standard Material to a glTF Material
  69690. * @param babylonStandardMaterial BJS Standard Material
  69691. * @param mimeType mime type to use for the textures
  69692. * @param images array of glTF image interfaces
  69693. * @param textures array of glTF texture interfaces
  69694. * @param materials array of glTF material interfaces
  69695. * @param imageData map of image file name to data
  69696. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  69697. */
  69698. _convertStandardMaterialAsync(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  69699. /**
  69700. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  69701. * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
  69702. * @param mimeType mime type to use for the textures
  69703. * @param images array of glTF image interfaces
  69704. * @param textures array of glTF texture interfaces
  69705. * @param materials array of glTF material interfaces
  69706. * @param imageData map of image file name to data
  69707. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  69708. */
  69709. _convertPBRMetallicRoughnessMaterialAsync(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  69710. /**
  69711. * Converts an image typed array buffer to a base64 image
  69712. * @param buffer typed array buffer
  69713. * @param width width of the image
  69714. * @param height height of the image
  69715. * @param mimeType mimetype of the image
  69716. * @returns base64 image string
  69717. */
  69718. private _createBase64FromCanvasAsync;
  69719. /**
  69720. * Generates a white texture based on the specified width and height
  69721. * @param width width of the texture in pixels
  69722. * @param height height of the texture in pixels
  69723. * @param scene babylonjs scene
  69724. * @returns white texture
  69725. */
  69726. private _createWhiteTexture;
  69727. /**
  69728. * 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
  69729. * @param texture1 first texture to resize
  69730. * @param texture2 second texture to resize
  69731. * @param scene babylonjs scene
  69732. * @returns resized textures or null
  69733. */
  69734. private _resizeTexturesToSameDimensions;
  69735. /**
  69736. * Converts an array of pixels to a Float32Array
  69737. * Throws an error if the pixel format is not supported
  69738. * @param pixels - array buffer containing pixel values
  69739. * @returns Float32 of pixels
  69740. */
  69741. private _convertPixelArrayToFloat32;
  69742. /**
  69743. * Convert Specular Glossiness Textures to Metallic Roughness
  69744. * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
  69745. * @link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows-bjs/js/babylon.pbrUtilities.js
  69746. * @param diffuseTexture texture used to store diffuse information
  69747. * @param specularGlossinessTexture texture used to store specular and glossiness information
  69748. * @param factors specular glossiness material factors
  69749. * @param mimeType the mime type to use for the texture
  69750. * @returns pbr metallic roughness interface or null
  69751. */
  69752. private _convertSpecularGlossinessTexturesToMetallicRoughnessAsync;
  69753. /**
  69754. * Converts specular glossiness material properties to metallic roughness
  69755. * @param specularGlossiness interface with specular glossiness material properties
  69756. * @returns interface with metallic roughness material properties
  69757. */
  69758. private _convertSpecularGlossinessToMetallicRoughness;
  69759. /**
  69760. * Calculates the surface reflectance, independent of lighting conditions
  69761. * @param color Color source to calculate brightness from
  69762. * @returns number representing the perceived brightness, or zero if color is undefined
  69763. */
  69764. private _getPerceivedBrightness;
  69765. /**
  69766. * Returns the maximum color component value
  69767. * @param color
  69768. * @returns maximum color component value, or zero if color is null or undefined
  69769. */
  69770. private _getMaxComponent;
  69771. /**
  69772. * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
  69773. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  69774. * @param mimeType mime type to use for the textures
  69775. * @param images array of glTF image interfaces
  69776. * @param textures array of glTF texture interfaces
  69777. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  69778. * @param imageData map of image file name to data
  69779. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  69780. * @returns glTF PBR Metallic Roughness factors
  69781. */
  69782. private _convertMetalRoughFactorsToMetallicRoughnessAsync;
  69783. private _getGLTFTextureSampler;
  69784. private _getGLTFTextureWrapMode;
  69785. private _getGLTFTextureWrapModesSampler;
  69786. /**
  69787. * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
  69788. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  69789. * @param mimeType mime type to use for the textures
  69790. * @param images array of glTF image interfaces
  69791. * @param textures array of glTF texture interfaces
  69792. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  69793. * @param imageData map of image file name to data
  69794. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  69795. * @returns glTF PBR Metallic Roughness factors
  69796. */
  69797. private _convertSpecGlossFactorsToMetallicRoughnessAsync;
  69798. /**
  69799. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  69800. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  69801. * @param mimeType mime type to use for the textures
  69802. * @param images array of glTF image interfaces
  69803. * @param textures array of glTF texture interfaces
  69804. * @param materials array of glTF material interfaces
  69805. * @param imageData map of image file name to data
  69806. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  69807. */
  69808. _convertPBRMaterialAsync(babylonPBRMaterial: PBRMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  69809. private setMetallicRoughnessPbrMaterial;
  69810. private getPixelsFromTexture;
  69811. /**
  69812. * Extracts a texture from a Babylon texture into file data and glTF data
  69813. * @param babylonTexture Babylon texture to extract
  69814. * @param mimeType Mime Type of the babylonTexture
  69815. * @return glTF texture info, or null if the texture format is not supported
  69816. */
  69817. _exportTextureAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  69818. _exportTextureInfoAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  69819. /**
  69820. * Builds a texture from base64 string
  69821. * @param base64Texture base64 texture string
  69822. * @param baseTextureName Name to use for the texture
  69823. * @param mimeType image mime type for the texture
  69824. * @param images array of images
  69825. * @param textures array of textures
  69826. * @param imageData map of image data
  69827. * @returns glTF texture info, or null if the texture format is not supported
  69828. */
  69829. private _getTextureInfoFromBase64;
  69830. }
  69831. }
  69832. declare module BABYLON {
  69833. /**
  69834. * Class for holding and downloading glTF file data
  69835. */
  69836. export class GLTFData {
  69837. /**
  69838. * Object which contains the file name as the key and its data as the value
  69839. */
  69840. glTFFiles: {
  69841. [fileName: string]: string | Blob;
  69842. };
  69843. /**
  69844. * Initializes the glTF file object
  69845. */
  69846. constructor();
  69847. /**
  69848. * Downloads the glTF data as files based on their names and data
  69849. */
  69850. downloadFiles(): void;
  69851. }
  69852. }
  69853. declare module BABYLON {
  69854. /**
  69855. * Holds a collection of exporter options and parameters
  69856. */
  69857. export interface IExportOptions {
  69858. /**
  69859. * Function which indicates whether a babylon node should be exported or not
  69860. * @param node source Babylon node. It is used to check whether it should be exported to glTF or not
  69861. * @returns boolean, which indicates whether the node should be exported (true) or not (false)
  69862. */
  69863. shouldExportNode?(node: Node): boolean;
  69864. /**
  69865. * Function used to extract the part of node's metadata that will be exported into glTF node extras
  69866. * @param metadata source metadata to read from
  69867. * @returns the data to store to glTF node extras
  69868. */
  69869. metadataSelector?(metadata: any): any;
  69870. /**
  69871. * The sample rate to bake animation curves
  69872. */
  69873. animationSampleRate?: number;
  69874. /**
  69875. * Begin serialization without waiting for the scene to be ready
  69876. */
  69877. exportWithoutWaitingForScene?: boolean;
  69878. }
  69879. /**
  69880. * Class for generating glTF data from a Babylon scene.
  69881. */
  69882. export class GLTF2Export {
  69883. /**
  69884. * Exports the geometry of the scene to .gltf file format asynchronously
  69885. * @param scene Babylon scene with scene hierarchy information
  69886. * @param filePrefix File prefix to use when generating the glTF file
  69887. * @param options Exporter options
  69888. * @returns Returns an object with a .gltf file and associates texture names
  69889. * as keys and their data and paths as values
  69890. */
  69891. static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  69892. private static _PreExportAsync;
  69893. private static _PostExportAsync;
  69894. /**
  69895. * Exports the geometry of the scene to .glb file format asychronously
  69896. * @param scene Babylon scene with scene hierarchy information
  69897. * @param filePrefix File prefix to use when generating glb file
  69898. * @param options Exporter options
  69899. * @returns Returns an object with a .glb filename as key and data as value
  69900. */
  69901. static GLBAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  69902. }
  69903. }
  69904. declare module BABYLON.GLTF2.Exporter {
  69905. /**
  69906. * @hidden
  69907. */
  69908. export class _GLTFUtilities {
  69909. /**
  69910. * Creates a buffer view based on the supplied arguments
  69911. * @param bufferIndex index value of the specified buffer
  69912. * @param byteOffset byte offset value
  69913. * @param byteLength byte length of the bufferView
  69914. * @param byteStride byte distance between conequential elements
  69915. * @param name name of the buffer view
  69916. * @returns bufferView for glTF
  69917. */
  69918. static _CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number, name?: string): IBufferView;
  69919. /**
  69920. * Creates an accessor based on the supplied arguments
  69921. * @param bufferviewIndex The index of the bufferview referenced by this accessor
  69922. * @param name The name of the accessor
  69923. * @param type The type of the accessor
  69924. * @param componentType The datatype of components in the attribute
  69925. * @param count The number of attributes referenced by this accessor
  69926. * @param byteOffset The offset relative to the start of the bufferView in bytes
  69927. * @param min Minimum value of each component in this attribute
  69928. * @param max Maximum value of each component in this attribute
  69929. * @returns accessor for glTF
  69930. */
  69931. static _CreateAccessor(bufferviewIndex: number, name: string, type: AccessorType, componentType: AccessorComponentType, count: number, byteOffset: Nullable<number>, min: Nullable<number[]>, max: Nullable<number[]>): IAccessor;
  69932. /**
  69933. * Calculates the minimum and maximum values of an array of position floats
  69934. * @param positions Positions array of a mesh
  69935. * @param vertexStart Starting vertex offset to calculate min and max values
  69936. * @param vertexCount Number of vertices to check for min and max values
  69937. * @returns min number array and max number array
  69938. */
  69939. static _CalculateMinMaxPositions(positions: FloatArray, vertexStart: number, vertexCount: number, convertToRightHandedSystem: boolean): {
  69940. min: number[];
  69941. max: number[];
  69942. };
  69943. /**
  69944. * Converts a new right-handed Vector3
  69945. * @param vector vector3 array
  69946. * @returns right-handed Vector3
  69947. */
  69948. static _GetRightHandedPositionVector3(vector: Vector3): Vector3;
  69949. /**
  69950. * Converts a Vector3 to right-handed
  69951. * @param vector Vector3 to convert to right-handed
  69952. */
  69953. static _GetRightHandedPositionVector3FromRef(vector: Vector3): void;
  69954. /**
  69955. * Converts a three element number array to right-handed
  69956. * @param vector number array to convert to right-handed
  69957. */
  69958. static _GetRightHandedPositionArray3FromRef(vector: number[]): void;
  69959. /**
  69960. * Converts a new right-handed Vector3
  69961. * @param vector vector3 array
  69962. * @returns right-handed Vector3
  69963. */
  69964. static _GetRightHandedNormalVector3(vector: Vector3): Vector3;
  69965. /**
  69966. * Converts a Vector3 to right-handed
  69967. * @param vector Vector3 to convert to right-handed
  69968. */
  69969. static _GetRightHandedNormalVector3FromRef(vector: Vector3): void;
  69970. /**
  69971. * Converts a three element number array to right-handed
  69972. * @param vector number array to convert to right-handed
  69973. */
  69974. static _GetRightHandedNormalArray3FromRef(vector: number[]): void;
  69975. /**
  69976. * Converts a Vector4 to right-handed
  69977. * @param vector Vector4 to convert to right-handed
  69978. */
  69979. static _GetRightHandedVector4FromRef(vector: Vector4): void;
  69980. /**
  69981. * Converts a Vector4 to right-handed
  69982. * @param vector Vector4 to convert to right-handed
  69983. */
  69984. static _GetRightHandedArray4FromRef(vector: number[]): void;
  69985. /**
  69986. * Converts a Quaternion to right-handed
  69987. * @param quaternion Source quaternion to convert to right-handed
  69988. */
  69989. static _GetRightHandedQuaternionFromRef(quaternion: Quaternion): void;
  69990. /**
  69991. * Converts a Quaternion to right-handed
  69992. * @param quaternion Source quaternion to convert to right-handed
  69993. */
  69994. static _GetRightHandedQuaternionArrayFromRef(quaternion: number[]): void;
  69995. static _NormalizeTangentFromRef(tangent: Vector4): void;
  69996. }
  69997. }
  69998. declare module BABYLON.GLTF2.Exporter {
  69999. /**
  70000. * Converts Babylon Scene into glTF 2.0.
  70001. * @hidden
  70002. */
  70003. export class _Exporter {
  70004. /**
  70005. * Stores the glTF to export
  70006. */
  70007. _glTF: IGLTF;
  70008. /**
  70009. * Stores all generated buffer views, which represents views into the main glTF buffer data
  70010. */
  70011. _bufferViews: IBufferView[];
  70012. /**
  70013. * Stores all the generated accessors, which is used for accessing the data within the buffer views in glTF
  70014. */
  70015. _accessors: IAccessor[];
  70016. /**
  70017. * Stores all the generated nodes, which contains transform and/or mesh information per node
  70018. */
  70019. private _nodes;
  70020. /**
  70021. * Stores all the generated glTF scenes, which stores multiple node hierarchies
  70022. */
  70023. private _scenes;
  70024. /**
  70025. * Stores all the generated mesh information, each containing a set of primitives to render in glTF
  70026. */
  70027. private _meshes;
  70028. /**
  70029. * Stores all the generated material information, which represents the appearance of each primitive
  70030. */
  70031. _materials: IMaterial[];
  70032. _materialMap: {
  70033. [materialID: number]: number;
  70034. };
  70035. /**
  70036. * Stores all the generated texture information, which is referenced by glTF materials
  70037. */
  70038. _textures: ITexture[];
  70039. /**
  70040. * Stores all the generated image information, which is referenced by glTF textures
  70041. */
  70042. _images: IImage[];
  70043. /**
  70044. * Stores all the texture samplers
  70045. */
  70046. _samplers: ISampler[];
  70047. /**
  70048. * Stores all the generated animation samplers, which is referenced by glTF animations
  70049. */
  70050. /**
  70051. * Stores the animations for glTF models
  70052. */
  70053. private _animations;
  70054. /**
  70055. * Stores the total amount of bytes stored in the glTF buffer
  70056. */
  70057. private _totalByteLength;
  70058. /**
  70059. * Stores a reference to the Babylon scene containing the source geometry and material information
  70060. */
  70061. _babylonScene: Scene;
  70062. /**
  70063. * Stores a map of the image data, where the key is the file name and the value
  70064. * is the image data
  70065. */
  70066. _imageData: {
  70067. [fileName: string]: {
  70068. data: Uint8Array;
  70069. mimeType: ImageMimeType;
  70070. };
  70071. };
  70072. /**
  70073. * Stores a map of the unique id of a node to its index in the node array
  70074. */
  70075. private _nodeMap;
  70076. /**
  70077. * Specifies if the Babylon scene should be converted to right-handed on export
  70078. */
  70079. _convertToRightHandedSystem: boolean;
  70080. /**
  70081. * Baked animation sample rate
  70082. */
  70083. private _animationSampleRate;
  70084. private _options;
  70085. private _localEngine;
  70086. _glTFMaterialExporter: _GLTFMaterialExporter;
  70087. private _extensions;
  70088. private static _ExtensionNames;
  70089. private static _ExtensionFactories;
  70090. private _applyExtensions;
  70091. _extensionsPreExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Nullable<Promise<BaseTexture>>;
  70092. _extensionsPostExportMeshPrimitiveAsync(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Nullable<Promise<IMeshPrimitive>>;
  70093. _extensionsPostExportNodeAsync(context: string, node: INode, babylonNode: Node): Nullable<Promise<INode>>;
  70094. private _forEachExtensions;
  70095. private _extensionsOnExporting;
  70096. /**
  70097. * Load glTF serializer extensions
  70098. */
  70099. private _loadExtensions;
  70100. /**
  70101. * Creates a glTF Exporter instance, which can accept optional exporter options
  70102. * @param babylonScene Babylon scene object
  70103. * @param options Options to modify the behavior of the exporter
  70104. */
  70105. constructor(babylonScene: Scene, options?: IExportOptions);
  70106. /**
  70107. * Registers a glTF exporter extension
  70108. * @param name Name of the extension to export
  70109. * @param factory The factory function that creates the exporter extension
  70110. */
  70111. static RegisterExtension(name: string, factory: (exporter: _Exporter) => IGLTFExporterExtensionV2): void;
  70112. /**
  70113. * Un-registers an exporter extension
  70114. * @param name The name fo the exporter extension
  70115. * @returns A boolean indicating whether the extension has been un-registered
  70116. */
  70117. static UnregisterExtension(name: string): boolean;
  70118. /**
  70119. * Lazy load a local engine with premultiplied alpha set to false
  70120. */
  70121. _getLocalEngine(): Engine;
  70122. private reorderIndicesBasedOnPrimitiveMode;
  70123. /**
  70124. * Reorders the vertex attribute data based on the primitive mode. This is necessary when indices are not available and the winding order is
  70125. * clock-wise during export to glTF
  70126. * @param submesh BabylonJS submesh
  70127. * @param primitiveMode Primitive mode of the mesh
  70128. * @param sideOrientation the winding order of the submesh
  70129. * @param vertexBufferKind The type of vertex attribute
  70130. * @param meshAttributeArray The vertex attribute data
  70131. * @param byteOffset The offset to the binary data
  70132. * @param binaryWriter The binary data for the glTF file
  70133. */
  70134. private reorderVertexAttributeDataBasedOnPrimitiveMode;
  70135. /**
  70136. * Reorders the vertex attributes in the correct triangle mode order . This is necessary when indices are not available and the winding order is
  70137. * clock-wise during export to glTF
  70138. * @param submesh BabylonJS submesh
  70139. * @param primitiveMode Primitive mode of the mesh
  70140. * @param sideOrientation the winding order of the submesh
  70141. * @param vertexBufferKind The type of vertex attribute
  70142. * @param meshAttributeArray The vertex attribute data
  70143. * @param byteOffset The offset to the binary data
  70144. * @param binaryWriter The binary data for the glTF file
  70145. */
  70146. private reorderTriangleFillMode;
  70147. /**
  70148. * Reorders the vertex attributes in the correct triangle strip order. This is necessary when indices are not available and the winding order is
  70149. * clock-wise during export to glTF
  70150. * @param submesh BabylonJS submesh
  70151. * @param primitiveMode Primitive mode of the mesh
  70152. * @param sideOrientation the winding order of the submesh
  70153. * @param vertexBufferKind The type of vertex attribute
  70154. * @param meshAttributeArray The vertex attribute data
  70155. * @param byteOffset The offset to the binary data
  70156. * @param binaryWriter The binary data for the glTF file
  70157. */
  70158. private reorderTriangleStripDrawMode;
  70159. /**
  70160. * Reorders the vertex attributes in the correct triangle fan order. This is necessary when indices are not available and the winding order is
  70161. * clock-wise during export to glTF
  70162. * @param submesh BabylonJS submesh
  70163. * @param primitiveMode Primitive mode of the mesh
  70164. * @param sideOrientation the winding order of the submesh
  70165. * @param vertexBufferKind The type of vertex attribute
  70166. * @param meshAttributeArray The vertex attribute data
  70167. * @param byteOffset The offset to the binary data
  70168. * @param binaryWriter The binary data for the glTF file
  70169. */
  70170. private reorderTriangleFanMode;
  70171. /**
  70172. * Writes the vertex attribute data to binary
  70173. * @param vertices The vertices to write to the binary writer
  70174. * @param byteOffset The offset into the binary writer to overwrite binary data
  70175. * @param vertexAttributeKind The vertex attribute type
  70176. * @param meshAttributeArray The vertex attribute data
  70177. * @param binaryWriter The writer containing the binary data
  70178. */
  70179. private writeVertexAttributeData;
  70180. /**
  70181. * Writes mesh attribute data to a data buffer
  70182. * Returns the bytelength of the data
  70183. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  70184. * @param meshAttributeArray Array containing the attribute data
  70185. * @param binaryWriter The buffer to write the binary data to
  70186. * @param indices Used to specify the order of the vertex data
  70187. */
  70188. writeAttributeData(vertexBufferKind: string, meshAttributeArray: FloatArray, byteStride: number, binaryWriter: _BinaryWriter): void;
  70189. /**
  70190. * Generates glTF json data
  70191. * @param shouldUseGlb Indicates whether the json should be written for a glb file
  70192. * @param glTFPrefix Text to use when prefixing a glTF file
  70193. * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false)
  70194. * @returns json data as string
  70195. */
  70196. private generateJSON;
  70197. /**
  70198. * Generates data for .gltf and .bin files based on the glTF prefix string
  70199. * @param glTFPrefix Text to use when prefixing a glTF file
  70200. * @returns GLTFData with glTF file data
  70201. */
  70202. _generateGLTFAsync(glTFPrefix: string): Promise<GLTFData>;
  70203. /**
  70204. * Creates a binary buffer for glTF
  70205. * @returns array buffer for binary data
  70206. */
  70207. private _generateBinaryAsync;
  70208. /**
  70209. * Pads the number to a multiple of 4
  70210. * @param num number to pad
  70211. * @returns padded number
  70212. */
  70213. private _getPadding;
  70214. /**
  70215. * Generates a glb file from the json and binary data
  70216. * Returns an object with the glb file name as the key and data as the value
  70217. * @param glTFPrefix
  70218. * @returns object with glb filename as key and data as value
  70219. */
  70220. _generateGLBAsync(glTFPrefix: string): Promise<GLTFData>;
  70221. /**
  70222. * Sets the TRS for each node
  70223. * @param node glTF Node for storing the transformation data
  70224. * @param babylonTransformNode Babylon mesh used as the source for the transformation data
  70225. */
  70226. private setNodeTransformation;
  70227. private getVertexBufferFromMesh;
  70228. /**
  70229. * Creates a bufferview based on the vertices type for the Babylon mesh
  70230. * @param kind Indicates the type of vertices data
  70231. * @param babylonTransformNode The Babylon mesh to get the vertices data from
  70232. * @param binaryWriter The buffer to write the bufferview data to
  70233. */
  70234. private createBufferViewKind;
  70235. /**
  70236. * The primitive mode of the Babylon mesh
  70237. * @param babylonMesh The BabylonJS mesh
  70238. */
  70239. private getMeshPrimitiveMode;
  70240. /**
  70241. * Sets the primitive mode of the glTF mesh primitive
  70242. * @param meshPrimitive glTF mesh primitive
  70243. * @param primitiveMode The primitive mode
  70244. */
  70245. private setPrimitiveMode;
  70246. /**
  70247. * Sets the vertex attribute accessor based of the glTF mesh primitive
  70248. * @param meshPrimitive glTF mesh primitive
  70249. * @param attributeKind vertex attribute
  70250. * @returns boolean specifying if uv coordinates are present
  70251. */
  70252. private setAttributeKind;
  70253. /**
  70254. * Sets data for the primitive attributes of each submesh
  70255. * @param mesh glTF Mesh object to store the primitive attribute information
  70256. * @param babylonTransformNode Babylon mesh to get the primitive attribute data from
  70257. * @param binaryWriter Buffer to write the attribute data to
  70258. */
  70259. private setPrimitiveAttributesAsync;
  70260. /**
  70261. * Creates a glTF scene based on the array of meshes
  70262. * Returns the the total byte offset
  70263. * @param babylonScene Babylon scene to get the mesh data from
  70264. * @param binaryWriter Buffer to write binary data to
  70265. */
  70266. private createSceneAsync;
  70267. /**
  70268. * Creates a mapping of Node unique id to node index and handles animations
  70269. * @param babylonScene Babylon Scene
  70270. * @param nodes Babylon transform nodes
  70271. * @param binaryWriter Buffer to write binary data to
  70272. * @returns Node mapping of unique id to index
  70273. */
  70274. private createNodeMapAndAnimationsAsync;
  70275. /**
  70276. * Creates a glTF node from a Babylon mesh
  70277. * @param babylonMesh Source Babylon mesh
  70278. * @param binaryWriter Buffer for storing geometry data
  70279. * @returns glTF node
  70280. */
  70281. private createNodeAsync;
  70282. }
  70283. /**
  70284. * @hidden
  70285. *
  70286. * Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically
  70287. */
  70288. export class _BinaryWriter {
  70289. /**
  70290. * Array buffer which stores all binary data
  70291. */
  70292. private _arrayBuffer;
  70293. /**
  70294. * View of the array buffer
  70295. */
  70296. private _dataView;
  70297. /**
  70298. * byte offset of data in array buffer
  70299. */
  70300. private _byteOffset;
  70301. /**
  70302. * Initialize binary writer with an initial byte length
  70303. * @param byteLength Initial byte length of the array buffer
  70304. */
  70305. constructor(byteLength: number);
  70306. /**
  70307. * Resize the array buffer to the specified byte length
  70308. * @param byteLength
  70309. */
  70310. private resizeBuffer;
  70311. /**
  70312. * Get an array buffer with the length of the byte offset
  70313. * @returns ArrayBuffer resized to the byte offset
  70314. */
  70315. getArrayBuffer(): ArrayBuffer;
  70316. /**
  70317. * Get the byte offset of the array buffer
  70318. * @returns byte offset
  70319. */
  70320. getByteOffset(): number;
  70321. /**
  70322. * Stores an UInt8 in the array buffer
  70323. * @param entry
  70324. * @param byteOffset If defined, specifies where to set the value as an offset.
  70325. */
  70326. setUInt8(entry: number, byteOffset?: number): void;
  70327. /**
  70328. * Gets an UInt32 in the array buffer
  70329. * @param entry
  70330. * @param byteOffset If defined, specifies where to set the value as an offset.
  70331. */
  70332. getUInt32(byteOffset: number): number;
  70333. getVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  70334. setVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  70335. getVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  70336. setVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  70337. /**
  70338. * Stores a Float32 in the array buffer
  70339. * @param entry
  70340. */
  70341. setFloat32(entry: number, byteOffset?: number): void;
  70342. /**
  70343. * Stores an UInt32 in the array buffer
  70344. * @param entry
  70345. * @param byteOffset If defined, specifies where to set the value as an offset.
  70346. */
  70347. setUInt32(entry: number, byteOffset?: number): void;
  70348. }
  70349. }
  70350. declare module BABYLON.GLTF2.Exporter {
  70351. /**
  70352. * @hidden
  70353. * Interface to store animation data.
  70354. */
  70355. export interface _IAnimationData {
  70356. /**
  70357. * Keyframe data.
  70358. */
  70359. inputs: number[];
  70360. /**
  70361. * Value data.
  70362. */
  70363. outputs: number[][];
  70364. /**
  70365. * Animation interpolation data.
  70366. */
  70367. samplerInterpolation: AnimationSamplerInterpolation;
  70368. /**
  70369. * Minimum keyframe value.
  70370. */
  70371. inputsMin: number;
  70372. /**
  70373. * Maximum keyframe value.
  70374. */
  70375. inputsMax: number;
  70376. }
  70377. /**
  70378. * @hidden
  70379. */
  70380. export interface _IAnimationInfo {
  70381. /**
  70382. * The target channel for the animation
  70383. */
  70384. animationChannelTargetPath: AnimationChannelTargetPath;
  70385. /**
  70386. * The glTF accessor type for the data.
  70387. */
  70388. dataAccessorType: AccessorType.VEC3 | AccessorType.VEC4;
  70389. /**
  70390. * Specifies if quaternions should be used.
  70391. */
  70392. useQuaternion: boolean;
  70393. }
  70394. /**
  70395. * @hidden
  70396. * Utility class for generating glTF animation data from BabylonJS.
  70397. */
  70398. export class _GLTFAnimation {
  70399. /**
  70400. * @ignore
  70401. *
  70402. * Creates glTF channel animation from BabylonJS animation.
  70403. * @param babylonTransformNode - BabylonJS mesh.
  70404. * @param animation - animation.
  70405. * @param animationChannelTargetPath - The target animation channel.
  70406. * @param convertToRightHandedSystem - Specifies if the values should be converted to right-handed.
  70407. * @param useQuaternion - Specifies if quaternions are used.
  70408. * @returns nullable IAnimationData
  70409. */
  70410. static _CreateNodeAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData>;
  70411. private static _DeduceAnimationInfo;
  70412. /**
  70413. * @ignore
  70414. * Create node animations from the transform node animations
  70415. * @param babylonNode
  70416. * @param runtimeGLTFAnimation
  70417. * @param idleGLTFAnimations
  70418. * @param nodeMap
  70419. * @param nodes
  70420. * @param binaryWriter
  70421. * @param bufferViews
  70422. * @param accessors
  70423. * @param convertToRightHandedSystem
  70424. */
  70425. static _CreateNodeAnimationFromNodeAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  70426. [key: number]: number;
  70427. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  70428. /**
  70429. * @ignore
  70430. * Create node animations from the animation groups
  70431. * @param babylonScene
  70432. * @param glTFAnimations
  70433. * @param nodeMap
  70434. * @param nodes
  70435. * @param binaryWriter
  70436. * @param bufferViews
  70437. * @param accessors
  70438. * @param convertToRightHandedSystem
  70439. */
  70440. static _CreateNodeAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: {
  70441. [key: number]: number;
  70442. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  70443. private static AddAnimation;
  70444. /**
  70445. * Create a baked animation
  70446. * @param babylonTransformNode BabylonJS mesh
  70447. * @param animation BabylonJS animation corresponding to the BabylonJS mesh
  70448. * @param animationChannelTargetPath animation target channel
  70449. * @param minFrame minimum animation frame
  70450. * @param maxFrame maximum animation frame
  70451. * @param fps frames per second of the animation
  70452. * @param inputs input key frames of the animation
  70453. * @param outputs output key frame data of the animation
  70454. * @param convertToRightHandedSystem converts the values to right-handed
  70455. * @param useQuaternion specifies if quaternions should be used
  70456. */
  70457. private static _CreateBakedAnimation;
  70458. private static _ConvertFactorToVector3OrQuaternion;
  70459. private static _SetInterpolatedValue;
  70460. /**
  70461. * Creates linear animation from the animation key frames
  70462. * @param babylonTransformNode BabylonJS mesh
  70463. * @param animation BabylonJS animation
  70464. * @param animationChannelTargetPath The target animation channel
  70465. * @param frameDelta The difference between the last and first frame of the animation
  70466. * @param inputs Array to store the key frame times
  70467. * @param outputs Array to store the key frame data
  70468. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  70469. * @param useQuaternion Specifies if quaternions are used in the animation
  70470. */
  70471. private static _CreateLinearOrStepAnimation;
  70472. /**
  70473. * Creates cubic spline animation from the animation key frames
  70474. * @param babylonTransformNode BabylonJS mesh
  70475. * @param animation BabylonJS animation
  70476. * @param animationChannelTargetPath The target animation channel
  70477. * @param frameDelta The difference between the last and first frame of the animation
  70478. * @param inputs Array to store the key frame times
  70479. * @param outputs Array to store the key frame data
  70480. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  70481. * @param useQuaternion Specifies if quaternions are used in the animation
  70482. */
  70483. private static _CreateCubicSplineAnimation;
  70484. private static _GetBasePositionRotationOrScale;
  70485. /**
  70486. * Adds a key frame value
  70487. * @param keyFrame
  70488. * @param animation
  70489. * @param outputs
  70490. * @param animationChannelTargetPath
  70491. * @param basePositionRotationOrScale
  70492. * @param convertToRightHandedSystem
  70493. * @param useQuaternion
  70494. */
  70495. private static _AddKeyframeValue;
  70496. /**
  70497. * Determine the interpolation based on the key frames
  70498. * @param keyFrames
  70499. * @param animationChannelTargetPath
  70500. * @param useQuaternion
  70501. */
  70502. private static _DeduceInterpolation;
  70503. /**
  70504. * Adds an input tangent or output tangent to the output data
  70505. * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion
  70506. * @param tangentType Specifies which type of tangent to handle (inTangent or outTangent)
  70507. * @param outputs The animation data by keyframe
  70508. * @param animationChannelTargetPath The target animation channel
  70509. * @param interpolation The interpolation type
  70510. * @param keyFrame The key frame with the animation data
  70511. * @param frameDelta Time difference between two frames used to scale the tangent by the frame delta
  70512. * @param useQuaternion Specifies if quaternions are used
  70513. * @param convertToRightHandedSystem Specifies if the values should be converted to right-handed
  70514. */
  70515. private static AddSplineTangent;
  70516. /**
  70517. * Get the minimum and maximum key frames' frame values
  70518. * @param keyFrames animation key frames
  70519. * @returns the minimum and maximum key frame value
  70520. */
  70521. private static calculateMinMaxKeyFrames;
  70522. }
  70523. }
  70524. declare module BABYLON.GLTF2.Exporter {
  70525. /** @hidden */
  70526. export var textureTransformPixelShader: {
  70527. name: string;
  70528. shader: string;
  70529. };
  70530. }
  70531. declare module BABYLON.GLTF2.Exporter.Extensions {
  70532. /**
  70533. * @hidden
  70534. */
  70535. export class KHR_texture_transform implements IGLTFExporterExtensionV2 {
  70536. /** Name of this extension */
  70537. readonly name: string;
  70538. /** Defines whether this extension is enabled */
  70539. enabled: boolean;
  70540. /** Defines whether this extension is required */
  70541. required: boolean;
  70542. /** Reference to the glTF exporter */
  70543. private _exporter;
  70544. constructor(exporter: _Exporter);
  70545. dispose(): void;
  70546. preExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Nullable<Promise<Texture>>;
  70547. /**
  70548. * Transform the babylon texture by the offset, rotation and scale parameters using a procedural texture
  70549. * @param babylonTexture
  70550. * @param offset
  70551. * @param rotation
  70552. * @param scale
  70553. * @param scene
  70554. */
  70555. private _textureTransformTextureAsync;
  70556. }
  70557. }
  70558. declare module BABYLON.GLTF2.Exporter.Extensions {
  70559. /**
  70560. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  70561. */
  70562. export class KHR_lights_punctual implements IGLTFExporterExtensionV2 {
  70563. /** The name of this extension. */
  70564. readonly name: string;
  70565. /** Defines whether this extension is enabled. */
  70566. enabled: boolean;
  70567. /** Defines whether this extension is required */
  70568. required: boolean;
  70569. /** Reference to the glTF exporter */
  70570. private _exporter;
  70571. private _lights;
  70572. /** @hidden */
  70573. constructor(exporter: _Exporter);
  70574. /** @hidden */
  70575. dispose(): void;
  70576. /** @hidden */
  70577. onExporting(): void;
  70578. /**
  70579. * Define this method to modify the default behavior when exporting a node
  70580. * @param context The context when exporting the node
  70581. * @param node glTF node
  70582. * @param babylonNode BabylonJS node
  70583. * @returns nullable INode promise
  70584. */
  70585. postExportNodeAsync(context: string, node: INode, babylonNode: Node): Nullable<Promise<INode>>;
  70586. }
  70587. }
  70588. declare module BABYLON {
  70589. /**
  70590. * Class for generating STL data from a Babylon scene.
  70591. */
  70592. export class STLExport {
  70593. /**
  70594. * Exports the geometry of a Mesh array in .STL file format (ASCII)
  70595. * @param meshes list defines the mesh to serialize
  70596. * @param download triggers the automatic download of the file.
  70597. * @param fileName changes the downloads fileName.
  70598. * @param binary changes the STL to a binary type.
  70599. * @param isLittleEndian toggle for binary type exporter.
  70600. * @returns the STL as UTF8 string
  70601. */
  70602. static CreateSTL(meshes: Mesh[], download?: boolean, fileName?: string, binary?: boolean, isLittleEndian?: boolean): any;
  70603. }
  70604. }
  70605. declare module "babylonjs-gltf2interface" {
  70606. export = BABYLON.GLTF2;
  70607. }
  70608. /**
  70609. * Module for glTF 2.0 Interface
  70610. */
  70611. declare module BABYLON.GLTF2 {
  70612. /**
  70613. * The datatype of the components in the attribute
  70614. */
  70615. const enum AccessorComponentType {
  70616. /**
  70617. * Byte
  70618. */
  70619. BYTE = 5120,
  70620. /**
  70621. * Unsigned Byte
  70622. */
  70623. UNSIGNED_BYTE = 5121,
  70624. /**
  70625. * Short
  70626. */
  70627. SHORT = 5122,
  70628. /**
  70629. * Unsigned Short
  70630. */
  70631. UNSIGNED_SHORT = 5123,
  70632. /**
  70633. * Unsigned Int
  70634. */
  70635. UNSIGNED_INT = 5125,
  70636. /**
  70637. * Float
  70638. */
  70639. FLOAT = 5126,
  70640. }
  70641. /**
  70642. * Specifies if the attirbute is a scalar, vector, or matrix
  70643. */
  70644. const enum AccessorType {
  70645. /**
  70646. * Scalar
  70647. */
  70648. SCALAR = "SCALAR",
  70649. /**
  70650. * Vector2
  70651. */
  70652. VEC2 = "VEC2",
  70653. /**
  70654. * Vector3
  70655. */
  70656. VEC3 = "VEC3",
  70657. /**
  70658. * Vector4
  70659. */
  70660. VEC4 = "VEC4",
  70661. /**
  70662. * Matrix2x2
  70663. */
  70664. MAT2 = "MAT2",
  70665. /**
  70666. * Matrix3x3
  70667. */
  70668. MAT3 = "MAT3",
  70669. /**
  70670. * Matrix4x4
  70671. */
  70672. MAT4 = "MAT4",
  70673. }
  70674. /**
  70675. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  70676. */
  70677. const enum AnimationChannelTargetPath {
  70678. /**
  70679. * Translation
  70680. */
  70681. TRANSLATION = "translation",
  70682. /**
  70683. * Rotation
  70684. */
  70685. ROTATION = "rotation",
  70686. /**
  70687. * Scale
  70688. */
  70689. SCALE = "scale",
  70690. /**
  70691. * Weights
  70692. */
  70693. WEIGHTS = "weights",
  70694. }
  70695. /**
  70696. * Interpolation algorithm
  70697. */
  70698. const enum AnimationSamplerInterpolation {
  70699. /**
  70700. * The animated values are linearly interpolated between keyframes
  70701. */
  70702. LINEAR = "LINEAR",
  70703. /**
  70704. * The animated values remain constant to the output of the first keyframe, until the next keyframe
  70705. */
  70706. STEP = "STEP",
  70707. /**
  70708. * The animation's interpolation is computed using a cubic spline with specified tangents
  70709. */
  70710. CUBICSPLINE = "CUBICSPLINE",
  70711. }
  70712. /**
  70713. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  70714. */
  70715. const enum CameraType {
  70716. /**
  70717. * A perspective camera containing properties to create a perspective projection matrix
  70718. */
  70719. PERSPECTIVE = "perspective",
  70720. /**
  70721. * An orthographic camera containing properties to create an orthographic projection matrix
  70722. */
  70723. ORTHOGRAPHIC = "orthographic",
  70724. }
  70725. /**
  70726. * The mime-type of the image
  70727. */
  70728. const enum ImageMimeType {
  70729. /**
  70730. * JPEG Mime-type
  70731. */
  70732. JPEG = "image/jpeg",
  70733. /**
  70734. * PNG Mime-type
  70735. */
  70736. PNG = "image/png",
  70737. }
  70738. /**
  70739. * The alpha rendering mode of the material
  70740. */
  70741. const enum MaterialAlphaMode {
  70742. /**
  70743. * The alpha value is ignored and the rendered output is fully opaque
  70744. */
  70745. OPAQUE = "OPAQUE",
  70746. /**
  70747. * The rendered output is either fully opaque or fully transparent depending on the alpha value and the specified alpha cutoff value
  70748. */
  70749. MASK = "MASK",
  70750. /**
  70751. * 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)
  70752. */
  70753. BLEND = "BLEND",
  70754. }
  70755. /**
  70756. * The type of the primitives to render
  70757. */
  70758. const enum MeshPrimitiveMode {
  70759. /**
  70760. * Points
  70761. */
  70762. POINTS = 0,
  70763. /**
  70764. * Lines
  70765. */
  70766. LINES = 1,
  70767. /**
  70768. * Line Loop
  70769. */
  70770. LINE_LOOP = 2,
  70771. /**
  70772. * Line Strip
  70773. */
  70774. LINE_STRIP = 3,
  70775. /**
  70776. * Triangles
  70777. */
  70778. TRIANGLES = 4,
  70779. /**
  70780. * Triangle Strip
  70781. */
  70782. TRIANGLE_STRIP = 5,
  70783. /**
  70784. * Triangle Fan
  70785. */
  70786. TRIANGLE_FAN = 6,
  70787. }
  70788. /**
  70789. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  70790. */
  70791. const enum TextureMagFilter {
  70792. /**
  70793. * Nearest
  70794. */
  70795. NEAREST = 9728,
  70796. /**
  70797. * Linear
  70798. */
  70799. LINEAR = 9729,
  70800. }
  70801. /**
  70802. * Minification filter. All valid values correspond to WebGL enums
  70803. */
  70804. const enum TextureMinFilter {
  70805. /**
  70806. * Nearest
  70807. */
  70808. NEAREST = 9728,
  70809. /**
  70810. * Linear
  70811. */
  70812. LINEAR = 9729,
  70813. /**
  70814. * Nearest Mip-Map Nearest
  70815. */
  70816. NEAREST_MIPMAP_NEAREST = 9984,
  70817. /**
  70818. * Linear Mipmap Nearest
  70819. */
  70820. LINEAR_MIPMAP_NEAREST = 9985,
  70821. /**
  70822. * Nearest Mipmap Linear
  70823. */
  70824. NEAREST_MIPMAP_LINEAR = 9986,
  70825. /**
  70826. * Linear Mipmap Linear
  70827. */
  70828. LINEAR_MIPMAP_LINEAR = 9987,
  70829. }
  70830. /**
  70831. * S (U) wrapping mode. All valid values correspond to WebGL enums
  70832. */
  70833. const enum TextureWrapMode {
  70834. /**
  70835. * Clamp to Edge
  70836. */
  70837. CLAMP_TO_EDGE = 33071,
  70838. /**
  70839. * Mirrored Repeat
  70840. */
  70841. MIRRORED_REPEAT = 33648,
  70842. /**
  70843. * Repeat
  70844. */
  70845. REPEAT = 10497,
  70846. }
  70847. /**
  70848. * glTF Property
  70849. */
  70850. interface IProperty {
  70851. /**
  70852. * Dictionary object with extension-specific objects
  70853. */
  70854. extensions?: {
  70855. [key: string]: any;
  70856. };
  70857. /**
  70858. * Application-Specific data
  70859. */
  70860. extras?: any;
  70861. }
  70862. /**
  70863. * glTF Child of Root Property
  70864. */
  70865. interface IChildRootProperty extends IProperty {
  70866. /**
  70867. * The user-defined name of this object
  70868. */
  70869. name?: string;
  70870. }
  70871. /**
  70872. * Indices of those attributes that deviate from their initialization value
  70873. */
  70874. interface IAccessorSparseIndices extends IProperty {
  70875. /**
  70876. * The index of the bufferView with sparse indices. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  70877. */
  70878. bufferView: number;
  70879. /**
  70880. * The offset relative to the start of the bufferView in bytes. Must be aligned
  70881. */
  70882. byteOffset?: number;
  70883. /**
  70884. * The indices data type. Valid values correspond to WebGL enums: 5121 (UNSIGNED_BYTE), 5123 (UNSIGNED_SHORT), 5125 (UNSIGNED_INT)
  70885. */
  70886. componentType: AccessorComponentType;
  70887. }
  70888. /**
  70889. * Array of size accessor.sparse.count times number of components storing the displaced accessor attributes pointed by accessor.sparse.indices
  70890. */
  70891. interface IAccessorSparseValues extends IProperty {
  70892. /**
  70893. * The index of the bufferView with sparse values. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  70894. */
  70895. bufferView: number;
  70896. /**
  70897. * The offset relative to the start of the bufferView in bytes. Must be aligned
  70898. */
  70899. byteOffset?: number;
  70900. }
  70901. /**
  70902. * Sparse storage of attributes that deviate from their initialization value
  70903. */
  70904. interface IAccessorSparse extends IProperty {
  70905. /**
  70906. * The number of attributes encoded in this sparse accessor
  70907. */
  70908. count: number;
  70909. /**
  70910. * Index array of size count that points to those accessor attributes that deviate from their initialization value. Indices must strictly increase
  70911. */
  70912. indices: IAccessorSparseIndices;
  70913. /**
  70914. * 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
  70915. */
  70916. values: IAccessorSparseValues;
  70917. }
  70918. /**
  70919. * 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
  70920. */
  70921. interface IAccessor extends IChildRootProperty {
  70922. /**
  70923. * The index of the bufferview
  70924. */
  70925. bufferView?: number;
  70926. /**
  70927. * The offset relative to the start of the bufferView in bytes
  70928. */
  70929. byteOffset?: number;
  70930. /**
  70931. * The datatype of components in the attribute
  70932. */
  70933. componentType: AccessorComponentType;
  70934. /**
  70935. * Specifies whether integer data values should be normalized
  70936. */
  70937. normalized?: boolean;
  70938. /**
  70939. * The number of attributes referenced by this accessor
  70940. */
  70941. count: number;
  70942. /**
  70943. * Specifies if the attribute is a scalar, vector, or matrix
  70944. */
  70945. type: AccessorType;
  70946. /**
  70947. * Maximum value of each component in this attribute
  70948. */
  70949. max?: number[];
  70950. /**
  70951. * Minimum value of each component in this attribute
  70952. */
  70953. min?: number[];
  70954. /**
  70955. * Sparse storage of attributes that deviate from their initialization value
  70956. */
  70957. sparse?: IAccessorSparse;
  70958. }
  70959. /**
  70960. * Targets an animation's sampler at a node's property
  70961. */
  70962. interface IAnimationChannel extends IProperty {
  70963. /**
  70964. * The index of a sampler in this animation used to compute the value for the target
  70965. */
  70966. sampler: number;
  70967. /**
  70968. * The index of the node and TRS property to target
  70969. */
  70970. target: IAnimationChannelTarget;
  70971. }
  70972. /**
  70973. * The index of the node and TRS property that an animation channel targets
  70974. */
  70975. interface IAnimationChannelTarget extends IProperty {
  70976. /**
  70977. * The index of the node to target
  70978. */
  70979. node: number;
  70980. /**
  70981. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  70982. */
  70983. path: AnimationChannelTargetPath;
  70984. }
  70985. /**
  70986. * Combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  70987. */
  70988. interface IAnimationSampler extends IProperty {
  70989. /**
  70990. * The index of an accessor containing keyframe input values, e.g., time
  70991. */
  70992. input: number;
  70993. /**
  70994. * Interpolation algorithm
  70995. */
  70996. interpolation?: AnimationSamplerInterpolation;
  70997. /**
  70998. * The index of an accessor, containing keyframe output values
  70999. */
  71000. output: number;
  71001. }
  71002. /**
  71003. * A keyframe animation
  71004. */
  71005. interface IAnimation extends IChildRootProperty {
  71006. /**
  71007. * An array of channels, each of which targets an animation's sampler at a node's property
  71008. */
  71009. channels: IAnimationChannel[];
  71010. /**
  71011. * An array of samplers that combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  71012. */
  71013. samplers: IAnimationSampler[];
  71014. }
  71015. /**
  71016. * Metadata about the glTF asset
  71017. */
  71018. interface IAsset extends IChildRootProperty {
  71019. /**
  71020. * A copyright message suitable for display to credit the content creator
  71021. */
  71022. copyright?: string;
  71023. /**
  71024. * Tool that generated this glTF model. Useful for debugging
  71025. */
  71026. generator?: string;
  71027. /**
  71028. * The glTF version that this asset targets
  71029. */
  71030. version: string;
  71031. /**
  71032. * The minimum glTF version that this asset targets
  71033. */
  71034. minVersion?: string;
  71035. }
  71036. /**
  71037. * A buffer points to binary geometry, animation, or skins
  71038. */
  71039. interface IBuffer extends IChildRootProperty {
  71040. /**
  71041. * 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
  71042. */
  71043. uri?: string;
  71044. /**
  71045. * The length of the buffer in bytes
  71046. */
  71047. byteLength: number;
  71048. }
  71049. /**
  71050. * A view into a buffer generally representing a subset of the buffer
  71051. */
  71052. interface IBufferView extends IChildRootProperty {
  71053. /**
  71054. * The index of the buffer
  71055. */
  71056. buffer: number;
  71057. /**
  71058. * The offset into the buffer in bytes
  71059. */
  71060. byteOffset?: number;
  71061. /**
  71062. * The lenth of the bufferView in bytes
  71063. */
  71064. byteLength: number;
  71065. /**
  71066. * The stride, in bytes
  71067. */
  71068. byteStride?: number;
  71069. }
  71070. /**
  71071. * An orthographic camera containing properties to create an orthographic projection matrix
  71072. */
  71073. interface ICameraOrthographic extends IProperty {
  71074. /**
  71075. * The floating-point horizontal magnification of the view. Must not be zero
  71076. */
  71077. xmag: number;
  71078. /**
  71079. * The floating-point vertical magnification of the view. Must not be zero
  71080. */
  71081. ymag: number;
  71082. /**
  71083. * The floating-point distance to the far clipping plane. zfar must be greater than znear
  71084. */
  71085. zfar: number;
  71086. /**
  71087. * The floating-point distance to the near clipping plane
  71088. */
  71089. znear: number;
  71090. }
  71091. /**
  71092. * A perspective camera containing properties to create a perspective projection matrix
  71093. */
  71094. interface ICameraPerspective extends IProperty {
  71095. /**
  71096. * The floating-point aspect ratio of the field of view
  71097. */
  71098. aspectRatio?: number;
  71099. /**
  71100. * The floating-point vertical field of view in radians
  71101. */
  71102. yfov: number;
  71103. /**
  71104. * The floating-point distance to the far clipping plane
  71105. */
  71106. zfar?: number;
  71107. /**
  71108. * The floating-point distance to the near clipping plane
  71109. */
  71110. znear: number;
  71111. }
  71112. /**
  71113. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  71114. */
  71115. interface ICamera extends IChildRootProperty {
  71116. /**
  71117. * An orthographic camera containing properties to create an orthographic projection matrix
  71118. */
  71119. orthographic?: ICameraOrthographic;
  71120. /**
  71121. * A perspective camera containing properties to create a perspective projection matrix
  71122. */
  71123. perspective?: ICameraPerspective;
  71124. /**
  71125. * Specifies if the camera uses a perspective or orthographic projection
  71126. */
  71127. type: CameraType;
  71128. }
  71129. /**
  71130. * Image data used to create a texture. Image can be referenced by URI or bufferView index. mimeType is required in the latter case
  71131. */
  71132. interface IImage extends IChildRootProperty {
  71133. /**
  71134. * 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
  71135. */
  71136. uri?: string;
  71137. /**
  71138. * The image's MIME type
  71139. */
  71140. mimeType?: ImageMimeType;
  71141. /**
  71142. * The index of the bufferView that contains the image. Use this instead of the image's uri property
  71143. */
  71144. bufferView?: number;
  71145. }
  71146. /**
  71147. * Material Normal Texture Info
  71148. */
  71149. interface IMaterialNormalTextureInfo extends ITextureInfo {
  71150. /**
  71151. * The scalar multiplier applied to each normal vector of the normal texture
  71152. */
  71153. scale?: number;
  71154. }
  71155. /**
  71156. * Material Occlusion Texture Info
  71157. */
  71158. interface IMaterialOcclusionTextureInfo extends ITextureInfo {
  71159. /**
  71160. * A scalar multiplier controlling the amount of occlusion applied
  71161. */
  71162. strength?: number;
  71163. }
  71164. /**
  71165. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology
  71166. */
  71167. interface IMaterialPbrMetallicRoughness {
  71168. /**
  71169. * The material's base color factor
  71170. */
  71171. baseColorFactor?: number[];
  71172. /**
  71173. * The base color texture
  71174. */
  71175. baseColorTexture?: ITextureInfo;
  71176. /**
  71177. * The metalness of the material
  71178. */
  71179. metallicFactor?: number;
  71180. /**
  71181. * The roughness of the material
  71182. */
  71183. roughnessFactor?: number;
  71184. /**
  71185. * The metallic-roughness texture
  71186. */
  71187. metallicRoughnessTexture?: ITextureInfo;
  71188. }
  71189. /**
  71190. * The material appearance of a primitive
  71191. */
  71192. interface IMaterial extends IChildRootProperty {
  71193. /**
  71194. * 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
  71195. */
  71196. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  71197. /**
  71198. * The normal map texture
  71199. */
  71200. normalTexture?: IMaterialNormalTextureInfo;
  71201. /**
  71202. * The occlusion map texture
  71203. */
  71204. occlusionTexture?: IMaterialOcclusionTextureInfo;
  71205. /**
  71206. * The emissive map texture
  71207. */
  71208. emissiveTexture?: ITextureInfo;
  71209. /**
  71210. * 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
  71211. */
  71212. emissiveFactor?: number[];
  71213. /**
  71214. * The alpha rendering mode of the material
  71215. */
  71216. alphaMode?: MaterialAlphaMode;
  71217. /**
  71218. * The alpha cutoff value of the material
  71219. */
  71220. alphaCutoff?: number;
  71221. /**
  71222. * Specifies whether the material is double sided
  71223. */
  71224. doubleSided?: boolean;
  71225. }
  71226. /**
  71227. * Geometry to be rendered with the given material
  71228. */
  71229. interface IMeshPrimitive extends IProperty {
  71230. /**
  71231. * A dictionary object, where each key corresponds to mesh attribute semantic and each value is the index of the accessor containing attribute's data
  71232. */
  71233. attributes: {
  71234. [name: string]: number;
  71235. };
  71236. /**
  71237. * The index of the accessor that contains the indices
  71238. */
  71239. indices?: number;
  71240. /**
  71241. * The index of the material to apply to this primitive when rendering
  71242. */
  71243. material?: number;
  71244. /**
  71245. * The type of primitives to render. All valid values correspond to WebGL enums
  71246. */
  71247. mode?: MeshPrimitiveMode;
  71248. /**
  71249. * 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
  71250. */
  71251. targets?: {
  71252. [name: string]: number;
  71253. }[];
  71254. }
  71255. /**
  71256. * A set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene
  71257. */
  71258. interface IMesh extends IChildRootProperty {
  71259. /**
  71260. * An array of primitives, each defining geometry to be rendered with a material
  71261. */
  71262. primitives: IMeshPrimitive[];
  71263. /**
  71264. * Array of weights to be applied to the Morph Targets
  71265. */
  71266. weights?: number[];
  71267. }
  71268. /**
  71269. * A node in the node hierarchy
  71270. */
  71271. interface INode extends IChildRootProperty {
  71272. /**
  71273. * The index of the camera referenced by this node
  71274. */
  71275. camera?: number;
  71276. /**
  71277. * The indices of this node's children
  71278. */
  71279. children?: number[];
  71280. /**
  71281. * The index of the skin referenced by this node
  71282. */
  71283. skin?: number;
  71284. /**
  71285. * A floating-point 4x4 transformation matrix stored in column-major order
  71286. */
  71287. matrix?: number[];
  71288. /**
  71289. * The index of the mesh in this node
  71290. */
  71291. mesh?: number;
  71292. /**
  71293. * The node's unit quaternion rotation in the order (x, y, z, w), where w is the scalar
  71294. */
  71295. rotation?: number[];
  71296. /**
  71297. * The node's non-uniform scale, given as the scaling factors along the x, y, and z axes
  71298. */
  71299. scale?: number[];
  71300. /**
  71301. * The node's translation along the x, y, and z axes
  71302. */
  71303. translation?: number[];
  71304. /**
  71305. * The weights of the instantiated Morph Target. Number of elements must match number of Morph Targets of used mesh
  71306. */
  71307. weights?: number[];
  71308. }
  71309. /**
  71310. * Texture sampler properties for filtering and wrapping modes
  71311. */
  71312. interface ISampler extends IChildRootProperty {
  71313. /**
  71314. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  71315. */
  71316. magFilter?: TextureMagFilter;
  71317. /**
  71318. * Minification filter. All valid values correspond to WebGL enums
  71319. */
  71320. minFilter?: TextureMinFilter;
  71321. /**
  71322. * S (U) wrapping mode. All valid values correspond to WebGL enums
  71323. */
  71324. wrapS?: TextureWrapMode;
  71325. /**
  71326. * T (V) wrapping mode. All valid values correspond to WebGL enums
  71327. */
  71328. wrapT?: TextureWrapMode;
  71329. }
  71330. /**
  71331. * The root nodes of a scene
  71332. */
  71333. interface IScene extends IChildRootProperty {
  71334. /**
  71335. * The indices of each root node
  71336. */
  71337. nodes: number[];
  71338. }
  71339. /**
  71340. * Joints and matrices defining a skin
  71341. */
  71342. interface ISkin extends IChildRootProperty {
  71343. /**
  71344. * 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
  71345. */
  71346. inverseBindMatrices?: number;
  71347. /**
  71348. * The index of the node used as a skeleton root. When undefined, joints transforms resolve to scene root
  71349. */
  71350. skeleton?: number;
  71351. /**
  71352. * 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)
  71353. */
  71354. joints: number[];
  71355. }
  71356. /**
  71357. * A texture and its sampler
  71358. */
  71359. interface ITexture extends IChildRootProperty {
  71360. /**
  71361. * The index of the sampler used by this texture. When undefined, a sampler with repeat wrapping and auto filtering should be used
  71362. */
  71363. sampler?: number;
  71364. /**
  71365. * The index of the image used by this texture
  71366. */
  71367. source: number;
  71368. }
  71369. /**
  71370. * Reference to a texture
  71371. */
  71372. interface ITextureInfo extends IProperty {
  71373. /**
  71374. * The index of the texture
  71375. */
  71376. index: number;
  71377. /**
  71378. * The set index of texture's TEXCOORD attribute used for texture coordinate mapping
  71379. */
  71380. texCoord?: number;
  71381. }
  71382. /**
  71383. * The root object for a glTF asset
  71384. */
  71385. interface IGLTF extends IProperty {
  71386. /**
  71387. * An array of accessors. An accessor is a typed view into a bufferView
  71388. */
  71389. accessors?: IAccessor[];
  71390. /**
  71391. * An array of keyframe animations
  71392. */
  71393. animations?: IAnimation[];
  71394. /**
  71395. * Metadata about the glTF asset
  71396. */
  71397. asset: IAsset;
  71398. /**
  71399. * An array of buffers. A buffer points to binary geometry, animation, or skins
  71400. */
  71401. buffers?: IBuffer[];
  71402. /**
  71403. * An array of bufferViews. A bufferView is a view into a buffer generally representing a subset of the buffer
  71404. */
  71405. bufferViews?: IBufferView[];
  71406. /**
  71407. * An array of cameras
  71408. */
  71409. cameras?: ICamera[];
  71410. /**
  71411. * Names of glTF extensions used somewhere in this asset
  71412. */
  71413. extensionsUsed?: string[];
  71414. /**
  71415. * Names of glTF extensions required to properly load this asset
  71416. */
  71417. extensionsRequired?: string[];
  71418. /**
  71419. * An array of images. An image defines data used to create a texture
  71420. */
  71421. images?: IImage[];
  71422. /**
  71423. * An array of materials. A material defines the appearance of a primitive
  71424. */
  71425. materials?: IMaterial[];
  71426. /**
  71427. * An array of meshes. A mesh is a set of primitives to be rendered
  71428. */
  71429. meshes?: IMesh[];
  71430. /**
  71431. * An array of nodes
  71432. */
  71433. nodes?: INode[];
  71434. /**
  71435. * An array of samplers. A sampler contains properties for texture filtering and wrapping modes
  71436. */
  71437. samplers?: ISampler[];
  71438. /**
  71439. * The index of the default scene
  71440. */
  71441. scene?: number;
  71442. /**
  71443. * An array of scenes
  71444. */
  71445. scenes?: IScene[];
  71446. /**
  71447. * An array of skins. A skin is defined by joints and matrices
  71448. */
  71449. skins?: ISkin[];
  71450. /**
  71451. * An array of textures
  71452. */
  71453. textures?: ITexture[];
  71454. }
  71455. /**
  71456. * The glTF validation results
  71457. * @ignore
  71458. */
  71459. interface IGLTFValidationResults {
  71460. info: {
  71461. generator: string;
  71462. hasAnimations: boolean;
  71463. hasDefaultScene: boolean;
  71464. hasMaterials: boolean;
  71465. hasMorphTargets: boolean;
  71466. hasSkins: boolean;
  71467. hasTextures: boolean;
  71468. maxAttributesUsed: number;
  71469. primitivesCount: number
  71470. };
  71471. issues: {
  71472. messages: Array<string>;
  71473. numErrors: number;
  71474. numHints: number;
  71475. numInfos: number;
  71476. numWarnings: number;
  71477. truncated: boolean
  71478. };
  71479. mimeType: string;
  71480. uri: string;
  71481. validatedAt: string;
  71482. validatorVersion: string;
  71483. }
  71484. /**
  71485. * The glTF validation options
  71486. */
  71487. interface IGLTFValidationOptions {
  71488. /** Uri to use */
  71489. uri?: string;
  71490. /** Function used to load external resources */
  71491. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  71492. /** Boolean indicating that we need to validate accessor data */
  71493. validateAccessorData?: boolean;
  71494. /** max number of issues allowed */
  71495. maxIssues?: number;
  71496. /** Ignored issues */
  71497. ignoredIssues?: Array<string>;
  71498. /** Value to override severy settings */
  71499. severityOverrides?: Object;
  71500. }
  71501. /**
  71502. * The glTF validator object
  71503. * @ignore
  71504. */
  71505. interface IGLTFValidator {
  71506. validateBytes: (data: Uint8Array, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  71507. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  71508. }
  71509. }
  71510. declare module BABYLON {
  71511. /** @hidden */
  71512. export var cellPixelShader: {
  71513. name: string;
  71514. shader: string;
  71515. };
  71516. }
  71517. declare module BABYLON {
  71518. /** @hidden */
  71519. export var cellVertexShader: {
  71520. name: string;
  71521. shader: string;
  71522. };
  71523. }
  71524. declare module BABYLON {
  71525. export class CellMaterial extends BABYLON.PushMaterial {
  71526. private _diffuseTexture;
  71527. diffuseTexture: BABYLON.BaseTexture;
  71528. diffuseColor: BABYLON.Color3;
  71529. _computeHighLevel: boolean;
  71530. computeHighLevel: boolean;
  71531. private _disableLighting;
  71532. disableLighting: boolean;
  71533. private _maxSimultaneousLights;
  71534. maxSimultaneousLights: number;
  71535. private _renderId;
  71536. constructor(name: string, scene: BABYLON.Scene);
  71537. needAlphaBlending(): boolean;
  71538. needAlphaTesting(): boolean;
  71539. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  71540. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  71541. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  71542. getAnimatables(): BABYLON.IAnimatable[];
  71543. getActiveTextures(): BABYLON.BaseTexture[];
  71544. hasTexture(texture: BABYLON.BaseTexture): boolean;
  71545. dispose(forceDisposeEffect?: boolean): void;
  71546. getClassName(): string;
  71547. clone(name: string): CellMaterial;
  71548. serialize(): any;
  71549. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): CellMaterial;
  71550. }
  71551. }
  71552. declare module BABYLON {
  71553. export class CustomShaderStructure {
  71554. FragmentStore: string;
  71555. VertexStore: string;
  71556. constructor();
  71557. }
  71558. export class ShaderSpecialParts {
  71559. constructor();
  71560. Fragment_Begin: string;
  71561. Fragment_Definitions: string;
  71562. Fragment_MainBegin: string;
  71563. Fragment_Custom_Diffuse: string;
  71564. Fragment_Before_Lights: string;
  71565. Fragment_Before_Fog: string;
  71566. Fragment_Custom_Alpha: string;
  71567. Fragment_Before_FragColor: string;
  71568. Vertex_Begin: string;
  71569. Vertex_Definitions: string;
  71570. Vertex_MainBegin: string;
  71571. Vertex_Before_PositionUpdated: string;
  71572. Vertex_Before_NormalUpdated: string;
  71573. Vertex_MainEnd: string;
  71574. }
  71575. export class CustomMaterial extends BABYLON.StandardMaterial {
  71576. static ShaderIndexer: number;
  71577. CustomParts: ShaderSpecialParts;
  71578. _isCreatedShader: boolean;
  71579. _createdShaderName: string;
  71580. _customUniform: string[];
  71581. _newUniforms: string[];
  71582. _newUniformInstances: any[];
  71583. _newSamplerInstances: BABYLON.Texture[];
  71584. FragmentShader: string;
  71585. VertexShader: string;
  71586. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  71587. ReviewUniform(name: string, arr: string[]): string[];
  71588. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.StandardMaterialDefines): string;
  71589. constructor(name: string, scene: BABYLON.Scene);
  71590. AddUniform(name: string, kind: string, param: any): CustomMaterial;
  71591. Fragment_Begin(shaderPart: string): CustomMaterial;
  71592. Fragment_Definitions(shaderPart: string): CustomMaterial;
  71593. Fragment_MainBegin(shaderPart: string): CustomMaterial;
  71594. Fragment_Custom_Diffuse(shaderPart: string): CustomMaterial;
  71595. Fragment_Custom_Alpha(shaderPart: string): CustomMaterial;
  71596. Fragment_Before_Lights(shaderPart: string): CustomMaterial;
  71597. Fragment_Before_Fog(shaderPart: string): CustomMaterial;
  71598. Fragment_Before_FragColor(shaderPart: string): CustomMaterial;
  71599. Vertex_Begin(shaderPart: string): CustomMaterial;
  71600. Vertex_Definitions(shaderPart: string): CustomMaterial;
  71601. Vertex_MainBegin(shaderPart: string): CustomMaterial;
  71602. Vertex_Before_PositionUpdated(shaderPart: string): CustomMaterial;
  71603. Vertex_Before_NormalUpdated(shaderPart: string): CustomMaterial;
  71604. Vertex_MainEnd(shaderPart: string): CustomMaterial;
  71605. }
  71606. }
  71607. declare module BABYLON {
  71608. export class ShaderAlebdoParts {
  71609. constructor();
  71610. Fragment_Begin: string;
  71611. Fragment_Definitions: string;
  71612. Fragment_MainBegin: string;
  71613. Fragment_Custom_Albedo: string;
  71614. Fragment_Before_Lights: string;
  71615. Fragment_Custom_MetallicRoughness: string;
  71616. Fragment_Custom_MicroSurface: string;
  71617. Fragment_Before_Fog: string;
  71618. Fragment_Custom_Alpha: string;
  71619. Fragment_Before_FragColor: string;
  71620. Vertex_Begin: string;
  71621. Vertex_Definitions: string;
  71622. Vertex_MainBegin: string;
  71623. Vertex_Before_PositionUpdated: string;
  71624. Vertex_Before_NormalUpdated: string;
  71625. Vertex_MainEnd: string;
  71626. }
  71627. export class PBRCustomMaterial extends BABYLON.PBRMaterial {
  71628. static ShaderIndexer: number;
  71629. CustomParts: ShaderAlebdoParts;
  71630. _isCreatedShader: boolean;
  71631. _createdShaderName: string;
  71632. _customUniform: string[];
  71633. _newUniforms: string[];
  71634. _newUniformInstances: any[];
  71635. _newSamplerInstances: BABYLON.Texture[];
  71636. FragmentShader: string;
  71637. VertexShader: string;
  71638. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  71639. ReviewUniform(name: string, arr: string[]): string[];
  71640. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.PBRMaterialDefines): string;
  71641. constructor(name: string, scene: BABYLON.Scene);
  71642. AddUniform(name: string, kind: string, param: any): PBRCustomMaterial;
  71643. Fragment_Begin(shaderPart: string): PBRCustomMaterial;
  71644. Fragment_Definitions(shaderPart: string): PBRCustomMaterial;
  71645. Fragment_MainBegin(shaderPart: string): PBRCustomMaterial;
  71646. Fragment_Custom_Albedo(shaderPart: string): PBRCustomMaterial;
  71647. Fragment_Custom_Alpha(shaderPart: string): PBRCustomMaterial;
  71648. Fragment_Before_Lights(shaderPart: string): PBRCustomMaterial;
  71649. Fragment_Custom_MetallicRoughness(shaderPart: string): PBRCustomMaterial;
  71650. Fragment_Custom_MicroSurface(shaderPart: string): PBRCustomMaterial;
  71651. Fragment_Before_Fog(shaderPart: string): PBRCustomMaterial;
  71652. Fragment_Before_FragColor(shaderPart: string): PBRCustomMaterial;
  71653. Vertex_Begin(shaderPart: string): PBRCustomMaterial;
  71654. Vertex_Definitions(shaderPart: string): PBRCustomMaterial;
  71655. Vertex_MainBegin(shaderPart: string): PBRCustomMaterial;
  71656. Vertex_Before_PositionUpdated(shaderPart: string): PBRCustomMaterial;
  71657. Vertex_Before_NormalUpdated(shaderPart: string): PBRCustomMaterial;
  71658. Vertex_MainEnd(shaderPart: string): PBRCustomMaterial;
  71659. }
  71660. }
  71661. declare module BABYLON {
  71662. /** @hidden */
  71663. export var firePixelShader: {
  71664. name: string;
  71665. shader: string;
  71666. };
  71667. }
  71668. declare module BABYLON {
  71669. /** @hidden */
  71670. export var fireVertexShader: {
  71671. name: string;
  71672. shader: string;
  71673. };
  71674. }
  71675. declare module BABYLON {
  71676. export class FireMaterial extends BABYLON.PushMaterial {
  71677. private _diffuseTexture;
  71678. diffuseTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  71679. private _distortionTexture;
  71680. distortionTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  71681. private _opacityTexture;
  71682. opacityTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  71683. diffuseColor: BABYLON.Color3;
  71684. speed: number;
  71685. private _scaledDiffuse;
  71686. private _renderId;
  71687. private _lastTime;
  71688. constructor(name: string, scene: BABYLON.Scene);
  71689. needAlphaBlending(): boolean;
  71690. needAlphaTesting(): boolean;
  71691. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  71692. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  71693. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  71694. getAnimatables(): BABYLON.IAnimatable[];
  71695. getActiveTextures(): BABYLON.BaseTexture[];
  71696. hasTexture(texture: BABYLON.BaseTexture): boolean;
  71697. getClassName(): string;
  71698. dispose(forceDisposeEffect?: boolean): void;
  71699. clone(name: string): FireMaterial;
  71700. serialize(): any;
  71701. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FireMaterial;
  71702. }
  71703. }
  71704. declare module BABYLON {
  71705. /** @hidden */
  71706. export var furPixelShader: {
  71707. name: string;
  71708. shader: string;
  71709. };
  71710. }
  71711. declare module BABYLON {
  71712. /** @hidden */
  71713. export var furVertexShader: {
  71714. name: string;
  71715. shader: string;
  71716. };
  71717. }
  71718. declare module BABYLON {
  71719. export class FurMaterial extends BABYLON.PushMaterial {
  71720. private _diffuseTexture;
  71721. diffuseTexture: BABYLON.BaseTexture;
  71722. private _heightTexture;
  71723. heightTexture: BABYLON.BaseTexture;
  71724. diffuseColor: BABYLON.Color3;
  71725. furLength: number;
  71726. furAngle: number;
  71727. furColor: BABYLON.Color3;
  71728. furOffset: number;
  71729. furSpacing: number;
  71730. furGravity: BABYLON.Vector3;
  71731. furSpeed: number;
  71732. furDensity: number;
  71733. furOcclusion: number;
  71734. furTexture: BABYLON.DynamicTexture;
  71735. private _disableLighting;
  71736. disableLighting: boolean;
  71737. private _maxSimultaneousLights;
  71738. maxSimultaneousLights: number;
  71739. highLevelFur: boolean;
  71740. _meshes: BABYLON.AbstractMesh[];
  71741. private _renderId;
  71742. private _furTime;
  71743. constructor(name: string, scene: BABYLON.Scene);
  71744. furTime: number;
  71745. needAlphaBlending(): boolean;
  71746. needAlphaTesting(): boolean;
  71747. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  71748. updateFur(): void;
  71749. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  71750. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  71751. getAnimatables(): BABYLON.IAnimatable[];
  71752. getActiveTextures(): BABYLON.BaseTexture[];
  71753. hasTexture(texture: BABYLON.BaseTexture): boolean;
  71754. dispose(forceDisposeEffect?: boolean): void;
  71755. clone(name: string): FurMaterial;
  71756. serialize(): any;
  71757. getClassName(): string;
  71758. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FurMaterial;
  71759. static GenerateTexture(name: string, scene: BABYLON.Scene): BABYLON.DynamicTexture;
  71760. static FurifyMesh(sourceMesh: BABYLON.Mesh, quality: number): BABYLON.Mesh[];
  71761. }
  71762. }
  71763. declare module BABYLON {
  71764. /** @hidden */
  71765. export var gradientPixelShader: {
  71766. name: string;
  71767. shader: string;
  71768. };
  71769. }
  71770. declare module BABYLON {
  71771. /** @hidden */
  71772. export var gradientVertexShader: {
  71773. name: string;
  71774. shader: string;
  71775. };
  71776. }
  71777. declare module BABYLON {
  71778. export class GradientMaterial extends BABYLON.PushMaterial {
  71779. private _maxSimultaneousLights;
  71780. maxSimultaneousLights: number;
  71781. topColor: BABYLON.Color3;
  71782. topColorAlpha: number;
  71783. bottomColor: BABYLON.Color3;
  71784. bottomColorAlpha: number;
  71785. offset: number;
  71786. scale: number;
  71787. smoothness: number;
  71788. private _disableLighting;
  71789. disableLighting: boolean;
  71790. private _renderId;
  71791. constructor(name: string, scene: BABYLON.Scene);
  71792. needAlphaBlending(): boolean;
  71793. needAlphaTesting(): boolean;
  71794. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  71795. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  71796. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  71797. getAnimatables(): BABYLON.IAnimatable[];
  71798. dispose(forceDisposeEffect?: boolean): void;
  71799. clone(name: string): GradientMaterial;
  71800. serialize(): any;
  71801. getClassName(): string;
  71802. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GradientMaterial;
  71803. }
  71804. }
  71805. declare module BABYLON {
  71806. /** @hidden */
  71807. export var gridPixelShader: {
  71808. name: string;
  71809. shader: string;
  71810. };
  71811. }
  71812. declare module BABYLON {
  71813. /** @hidden */
  71814. export var gridVertexShader: {
  71815. name: string;
  71816. shader: string;
  71817. };
  71818. }
  71819. declare module BABYLON {
  71820. /**
  71821. * The grid materials allows you to wrap any shape with a grid.
  71822. * Colors are customizable.
  71823. */
  71824. export class GridMaterial extends BABYLON.PushMaterial {
  71825. /**
  71826. * Main color of the grid (e.g. between lines)
  71827. */
  71828. mainColor: BABYLON.Color3;
  71829. /**
  71830. * Color of the grid lines.
  71831. */
  71832. lineColor: BABYLON.Color3;
  71833. /**
  71834. * The scale of the grid compared to unit.
  71835. */
  71836. gridRatio: number;
  71837. /**
  71838. * Allows setting an offset for the grid lines.
  71839. */
  71840. gridOffset: BABYLON.Vector3;
  71841. /**
  71842. * The frequency of thicker lines.
  71843. */
  71844. majorUnitFrequency: number;
  71845. /**
  71846. * The visibility of minor units in the grid.
  71847. */
  71848. minorUnitVisibility: number;
  71849. /**
  71850. * The grid opacity outside of the lines.
  71851. */
  71852. opacity: number;
  71853. /**
  71854. * Determine RBG output is premultiplied by alpha value.
  71855. */
  71856. preMultiplyAlpha: boolean;
  71857. private _opacityTexture;
  71858. opacityTexture: BABYLON.BaseTexture;
  71859. private _gridControl;
  71860. private _renderId;
  71861. /**
  71862. * constructor
  71863. * @param name The name given to the material in order to identify it afterwards.
  71864. * @param scene The scene the material is used in.
  71865. */
  71866. constructor(name: string, scene: BABYLON.Scene);
  71867. /**
  71868. * Returns wehter or not the grid requires alpha blending.
  71869. */
  71870. needAlphaBlending(): boolean;
  71871. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  71872. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  71873. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  71874. /**
  71875. * Dispose the material and its associated resources.
  71876. * @param forceDisposeEffect will also dispose the used effect when true
  71877. */
  71878. dispose(forceDisposeEffect?: boolean): void;
  71879. clone(name: string): GridMaterial;
  71880. serialize(): any;
  71881. getClassName(): string;
  71882. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GridMaterial;
  71883. }
  71884. }
  71885. declare module BABYLON {
  71886. /** @hidden */
  71887. export var lavaPixelShader: {
  71888. name: string;
  71889. shader: string;
  71890. };
  71891. }
  71892. declare module BABYLON {
  71893. /** @hidden */
  71894. export var lavaVertexShader: {
  71895. name: string;
  71896. shader: string;
  71897. };
  71898. }
  71899. declare module BABYLON {
  71900. export class LavaMaterial extends BABYLON.PushMaterial {
  71901. private _diffuseTexture;
  71902. diffuseTexture: BABYLON.BaseTexture;
  71903. noiseTexture: BABYLON.BaseTexture;
  71904. fogColor: BABYLON.Color3;
  71905. speed: number;
  71906. movingSpeed: number;
  71907. lowFrequencySpeed: number;
  71908. fogDensity: number;
  71909. private _lastTime;
  71910. diffuseColor: BABYLON.Color3;
  71911. private _disableLighting;
  71912. disableLighting: boolean;
  71913. private _unlit;
  71914. unlit: boolean;
  71915. private _maxSimultaneousLights;
  71916. maxSimultaneousLights: number;
  71917. private _scaledDiffuse;
  71918. private _renderId;
  71919. constructor(name: string, scene: BABYLON.Scene);
  71920. needAlphaBlending(): boolean;
  71921. needAlphaTesting(): boolean;
  71922. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  71923. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  71924. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  71925. getAnimatables(): BABYLON.IAnimatable[];
  71926. getActiveTextures(): BABYLON.BaseTexture[];
  71927. hasTexture(texture: BABYLON.BaseTexture): boolean;
  71928. dispose(forceDisposeEffect?: boolean): void;
  71929. clone(name: string): LavaMaterial;
  71930. serialize(): any;
  71931. getClassName(): string;
  71932. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): LavaMaterial;
  71933. }
  71934. }
  71935. declare module BABYLON {
  71936. /** @hidden */
  71937. export var mixPixelShader: {
  71938. name: string;
  71939. shader: string;
  71940. };
  71941. }
  71942. declare module BABYLON {
  71943. /** @hidden */
  71944. export var mixVertexShader: {
  71945. name: string;
  71946. shader: string;
  71947. };
  71948. }
  71949. declare module BABYLON {
  71950. export class MixMaterial extends BABYLON.PushMaterial {
  71951. /**
  71952. * Mix textures
  71953. */
  71954. private _mixTexture1;
  71955. mixTexture1: BABYLON.BaseTexture;
  71956. private _mixTexture2;
  71957. mixTexture2: BABYLON.BaseTexture;
  71958. /**
  71959. * Diffuse textures
  71960. */
  71961. private _diffuseTexture1;
  71962. diffuseTexture1: BABYLON.Texture;
  71963. private _diffuseTexture2;
  71964. diffuseTexture2: BABYLON.Texture;
  71965. private _diffuseTexture3;
  71966. diffuseTexture3: BABYLON.Texture;
  71967. private _diffuseTexture4;
  71968. diffuseTexture4: BABYLON.Texture;
  71969. private _diffuseTexture5;
  71970. diffuseTexture5: BABYLON.Texture;
  71971. private _diffuseTexture6;
  71972. diffuseTexture6: BABYLON.Texture;
  71973. private _diffuseTexture7;
  71974. diffuseTexture7: BABYLON.Texture;
  71975. private _diffuseTexture8;
  71976. diffuseTexture8: BABYLON.Texture;
  71977. /**
  71978. * Uniforms
  71979. */
  71980. diffuseColor: BABYLON.Color3;
  71981. specularColor: BABYLON.Color3;
  71982. specularPower: number;
  71983. private _disableLighting;
  71984. disableLighting: boolean;
  71985. private _maxSimultaneousLights;
  71986. maxSimultaneousLights: number;
  71987. private _renderId;
  71988. constructor(name: string, scene: BABYLON.Scene);
  71989. needAlphaBlending(): boolean;
  71990. needAlphaTesting(): boolean;
  71991. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  71992. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  71993. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  71994. getAnimatables(): BABYLON.IAnimatable[];
  71995. getActiveTextures(): BABYLON.BaseTexture[];
  71996. hasTexture(texture: BABYLON.BaseTexture): boolean;
  71997. dispose(forceDisposeEffect?: boolean): void;
  71998. clone(name: string): MixMaterial;
  71999. serialize(): any;
  72000. getClassName(): string;
  72001. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): MixMaterial;
  72002. }
  72003. }
  72004. declare module BABYLON {
  72005. /** @hidden */
  72006. export var normalPixelShader: {
  72007. name: string;
  72008. shader: string;
  72009. };
  72010. }
  72011. declare module BABYLON {
  72012. /** @hidden */
  72013. export var normalVertexShader: {
  72014. name: string;
  72015. shader: string;
  72016. };
  72017. }
  72018. declare module BABYLON {
  72019. export class NormalMaterial extends BABYLON.PushMaterial {
  72020. private _diffuseTexture;
  72021. diffuseTexture: BABYLON.BaseTexture;
  72022. diffuseColor: BABYLON.Color3;
  72023. private _disableLighting;
  72024. disableLighting: boolean;
  72025. private _maxSimultaneousLights;
  72026. maxSimultaneousLights: number;
  72027. private _renderId;
  72028. constructor(name: string, scene: BABYLON.Scene);
  72029. needAlphaBlending(): boolean;
  72030. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  72031. needAlphaTesting(): boolean;
  72032. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  72033. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  72034. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  72035. getAnimatables(): BABYLON.IAnimatable[];
  72036. getActiveTextures(): BABYLON.BaseTexture[];
  72037. hasTexture(texture: BABYLON.BaseTexture): boolean;
  72038. dispose(forceDisposeEffect?: boolean): void;
  72039. clone(name: string): NormalMaterial;
  72040. serialize(): any;
  72041. getClassName(): string;
  72042. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): NormalMaterial;
  72043. }
  72044. }
  72045. declare module BABYLON {
  72046. /** @hidden */
  72047. export var shadowOnlyPixelShader: {
  72048. name: string;
  72049. shader: string;
  72050. };
  72051. }
  72052. declare module BABYLON {
  72053. /** @hidden */
  72054. export var shadowOnlyVertexShader: {
  72055. name: string;
  72056. shader: string;
  72057. };
  72058. }
  72059. declare module BABYLON {
  72060. export class ShadowOnlyMaterial extends BABYLON.PushMaterial {
  72061. private _renderId;
  72062. private _activeLight;
  72063. constructor(name: string, scene: BABYLON.Scene);
  72064. shadowColor: BABYLON.Color3;
  72065. needAlphaBlending(): boolean;
  72066. needAlphaTesting(): boolean;
  72067. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  72068. activeLight: BABYLON.IShadowLight;
  72069. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  72070. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  72071. clone(name: string): ShadowOnlyMaterial;
  72072. serialize(): any;
  72073. getClassName(): string;
  72074. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): ShadowOnlyMaterial;
  72075. }
  72076. }
  72077. declare module BABYLON {
  72078. /** @hidden */
  72079. export var simplePixelShader: {
  72080. name: string;
  72081. shader: string;
  72082. };
  72083. }
  72084. declare module BABYLON {
  72085. /** @hidden */
  72086. export var simpleVertexShader: {
  72087. name: string;
  72088. shader: string;
  72089. };
  72090. }
  72091. declare module BABYLON {
  72092. export class SimpleMaterial extends BABYLON.PushMaterial {
  72093. private _diffuseTexture;
  72094. diffuseTexture: BABYLON.BaseTexture;
  72095. diffuseColor: BABYLON.Color3;
  72096. private _disableLighting;
  72097. disableLighting: boolean;
  72098. private _maxSimultaneousLights;
  72099. maxSimultaneousLights: number;
  72100. private _renderId;
  72101. constructor(name: string, scene: BABYLON.Scene);
  72102. needAlphaBlending(): boolean;
  72103. needAlphaTesting(): boolean;
  72104. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  72105. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  72106. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  72107. getAnimatables(): BABYLON.IAnimatable[];
  72108. getActiveTextures(): BABYLON.BaseTexture[];
  72109. hasTexture(texture: BABYLON.BaseTexture): boolean;
  72110. dispose(forceDisposeEffect?: boolean): void;
  72111. clone(name: string): SimpleMaterial;
  72112. serialize(): any;
  72113. getClassName(): string;
  72114. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SimpleMaterial;
  72115. }
  72116. }
  72117. declare module BABYLON {
  72118. /** @hidden */
  72119. export var skyPixelShader: {
  72120. name: string;
  72121. shader: string;
  72122. };
  72123. }
  72124. declare module BABYLON {
  72125. /** @hidden */
  72126. export var skyVertexShader: {
  72127. name: string;
  72128. shader: string;
  72129. };
  72130. }
  72131. declare module BABYLON {
  72132. /**
  72133. * This is the sky material which allows to create dynamic and texture free effects for skyboxes.
  72134. * @see https://doc.babylonjs.com/extensions/sky
  72135. */
  72136. export class SkyMaterial extends BABYLON.PushMaterial {
  72137. /**
  72138. * Defines the overall luminance of sky in interval ]0, 1[.
  72139. */
  72140. luminance: number;
  72141. /**
  72142. * Defines the amount (scattering) of haze as opposed to molecules in atmosphere.
  72143. */
  72144. turbidity: number;
  72145. /**
  72146. * Defines the sky appearance (light intensity).
  72147. */
  72148. rayleigh: number;
  72149. /**
  72150. * Defines the mieCoefficient in interval [0, 0.1] which affects the property .mieDirectionalG.
  72151. */
  72152. mieCoefficient: number;
  72153. /**
  72154. * Defines the amount of haze particles following the Mie scattering theory.
  72155. */
  72156. mieDirectionalG: number;
  72157. /**
  72158. * Defines the distance of the sun according to the active scene camera.
  72159. */
  72160. distance: number;
  72161. /**
  72162. * Defines the sun inclination, in interval [-0.5, 0.5]. When the inclination is not 0, the sun is said
  72163. * "inclined".
  72164. */
  72165. inclination: number;
  72166. /**
  72167. * Defines the solar azimuth in interval [0, 1]. The azimuth is the angle in the horizontal plan between
  72168. * an object direction and a reference direction.
  72169. */
  72170. azimuth: number;
  72171. /**
  72172. * Defines the sun position in the sky on (x,y,z). If the property .useSunPosition is set to false, then
  72173. * the property is overriden by the inclination and the azimuth and can be read at any moment.
  72174. */
  72175. sunPosition: BABYLON.Vector3;
  72176. /**
  72177. * Defines if the sun position should be computed (inclination and azimuth) according to the given
  72178. * .sunPosition property.
  72179. */
  72180. useSunPosition: boolean;
  72181. /**
  72182. * Defines an offset vector used to get a horizon offset.
  72183. * @example skyMaterial.cameraOffset.y = camera.globalPosition.y // Set horizon relative to 0 on the Y axis
  72184. */
  72185. cameraOffset: BABYLON.Vector3;
  72186. private _cameraPosition;
  72187. private _renderId;
  72188. /**
  72189. * Instantiates a new sky material.
  72190. * This material allows to create dynamic and texture free
  72191. * effects for skyboxes by taking care of the atmosphere state.
  72192. * @see https://doc.babylonjs.com/extensions/sky
  72193. * @param name Define the name of the material in the scene
  72194. * @param scene Define the scene the material belong to
  72195. */
  72196. constructor(name: string, scene: BABYLON.Scene);
  72197. /**
  72198. * Specifies if the material will require alpha blending
  72199. * @returns a boolean specifying if alpha blending is needed
  72200. */
  72201. needAlphaBlending(): boolean;
  72202. /**
  72203. * Specifies if this material should be rendered in alpha test mode
  72204. * @returns false as the sky material doesn't need alpha testing.
  72205. */
  72206. needAlphaTesting(): boolean;
  72207. /**
  72208. * Get the texture used for alpha test purpose.
  72209. * @returns null as the sky material has no texture.
  72210. */
  72211. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  72212. /**
  72213. * Get if the submesh is ready to be used and all its information available.
  72214. * Child classes can use it to update shaders
  72215. * @param mesh defines the mesh to check
  72216. * @param subMesh defines which submesh to check
  72217. * @param useInstances specifies that instances should be used
  72218. * @returns a boolean indicating that the submesh is ready or not
  72219. */
  72220. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  72221. /**
  72222. * Binds the submesh to this material by preparing the effect and shader to draw
  72223. * @param world defines the world transformation matrix
  72224. * @param mesh defines the mesh containing the submesh
  72225. * @param subMesh defines the submesh to bind the material to
  72226. */
  72227. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  72228. /**
  72229. * Get the list of animatables in the material.
  72230. * @returns the list of animatables object used in the material
  72231. */
  72232. getAnimatables(): BABYLON.IAnimatable[];
  72233. /**
  72234. * Disposes the material
  72235. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  72236. */
  72237. dispose(forceDisposeEffect?: boolean): void;
  72238. /**
  72239. * Makes a duplicate of the material, and gives it a new name
  72240. * @param name defines the new name for the duplicated material
  72241. * @returns the cloned material
  72242. */
  72243. clone(name: string): SkyMaterial;
  72244. /**
  72245. * Serializes this material in a JSON representation
  72246. * @returns the serialized material object
  72247. */
  72248. serialize(): any;
  72249. /**
  72250. * Gets the current class name of the material e.g. "SkyMaterial"
  72251. * Mainly use in serialization.
  72252. * @returns the class name
  72253. */
  72254. getClassName(): string;
  72255. /**
  72256. * Creates a sky material from parsed material data
  72257. * @param source defines the JSON representation of the material
  72258. * @param scene defines the hosting scene
  72259. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  72260. * @returns a new sky material
  72261. */
  72262. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SkyMaterial;
  72263. }
  72264. }
  72265. declare module BABYLON {
  72266. /** @hidden */
  72267. export var terrainPixelShader: {
  72268. name: string;
  72269. shader: string;
  72270. };
  72271. }
  72272. declare module BABYLON {
  72273. /** @hidden */
  72274. export var terrainVertexShader: {
  72275. name: string;
  72276. shader: string;
  72277. };
  72278. }
  72279. declare module BABYLON {
  72280. export class TerrainMaterial extends BABYLON.PushMaterial {
  72281. private _mixTexture;
  72282. mixTexture: BABYLON.BaseTexture;
  72283. private _diffuseTexture1;
  72284. diffuseTexture1: BABYLON.Texture;
  72285. private _diffuseTexture2;
  72286. diffuseTexture2: BABYLON.Texture;
  72287. private _diffuseTexture3;
  72288. diffuseTexture3: BABYLON.Texture;
  72289. private _bumpTexture1;
  72290. bumpTexture1: BABYLON.Texture;
  72291. private _bumpTexture2;
  72292. bumpTexture2: BABYLON.Texture;
  72293. private _bumpTexture3;
  72294. bumpTexture3: BABYLON.Texture;
  72295. diffuseColor: BABYLON.Color3;
  72296. specularColor: BABYLON.Color3;
  72297. specularPower: number;
  72298. private _disableLighting;
  72299. disableLighting: boolean;
  72300. private _maxSimultaneousLights;
  72301. maxSimultaneousLights: number;
  72302. private _renderId;
  72303. constructor(name: string, scene: BABYLON.Scene);
  72304. needAlphaBlending(): boolean;
  72305. needAlphaTesting(): boolean;
  72306. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  72307. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  72308. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  72309. getAnimatables(): BABYLON.IAnimatable[];
  72310. getActiveTextures(): BABYLON.BaseTexture[];
  72311. hasTexture(texture: BABYLON.BaseTexture): boolean;
  72312. dispose(forceDisposeEffect?: boolean): void;
  72313. clone(name: string): TerrainMaterial;
  72314. serialize(): any;
  72315. getClassName(): string;
  72316. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TerrainMaterial;
  72317. }
  72318. }
  72319. declare module BABYLON {
  72320. /** @hidden */
  72321. export var triplanarPixelShader: {
  72322. name: string;
  72323. shader: string;
  72324. };
  72325. }
  72326. declare module BABYLON {
  72327. /** @hidden */
  72328. export var triplanarVertexShader: {
  72329. name: string;
  72330. shader: string;
  72331. };
  72332. }
  72333. declare module BABYLON {
  72334. export class TriPlanarMaterial extends BABYLON.PushMaterial {
  72335. mixTexture: BABYLON.BaseTexture;
  72336. private _diffuseTextureX;
  72337. diffuseTextureX: BABYLON.BaseTexture;
  72338. private _diffuseTextureY;
  72339. diffuseTextureY: BABYLON.BaseTexture;
  72340. private _diffuseTextureZ;
  72341. diffuseTextureZ: BABYLON.BaseTexture;
  72342. private _normalTextureX;
  72343. normalTextureX: BABYLON.BaseTexture;
  72344. private _normalTextureY;
  72345. normalTextureY: BABYLON.BaseTexture;
  72346. private _normalTextureZ;
  72347. normalTextureZ: BABYLON.BaseTexture;
  72348. tileSize: number;
  72349. diffuseColor: BABYLON.Color3;
  72350. specularColor: BABYLON.Color3;
  72351. specularPower: number;
  72352. private _disableLighting;
  72353. disableLighting: boolean;
  72354. private _maxSimultaneousLights;
  72355. maxSimultaneousLights: number;
  72356. private _renderId;
  72357. constructor(name: string, scene: BABYLON.Scene);
  72358. needAlphaBlending(): boolean;
  72359. needAlphaTesting(): boolean;
  72360. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  72361. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  72362. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  72363. getAnimatables(): BABYLON.IAnimatable[];
  72364. getActiveTextures(): BABYLON.BaseTexture[];
  72365. hasTexture(texture: BABYLON.BaseTexture): boolean;
  72366. dispose(forceDisposeEffect?: boolean): void;
  72367. clone(name: string): TriPlanarMaterial;
  72368. serialize(): any;
  72369. getClassName(): string;
  72370. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TriPlanarMaterial;
  72371. }
  72372. }
  72373. declare module BABYLON {
  72374. /** @hidden */
  72375. export var waterPixelShader: {
  72376. name: string;
  72377. shader: string;
  72378. };
  72379. }
  72380. declare module BABYLON {
  72381. /** @hidden */
  72382. export var waterVertexShader: {
  72383. name: string;
  72384. shader: string;
  72385. };
  72386. }
  72387. declare module BABYLON {
  72388. export class WaterMaterial extends BABYLON.PushMaterial {
  72389. renderTargetSize: BABYLON.Vector2;
  72390. private _bumpTexture;
  72391. bumpTexture: BABYLON.BaseTexture;
  72392. diffuseColor: BABYLON.Color3;
  72393. specularColor: BABYLON.Color3;
  72394. specularPower: number;
  72395. private _disableLighting;
  72396. disableLighting: boolean;
  72397. private _maxSimultaneousLights;
  72398. maxSimultaneousLights: number;
  72399. /**
  72400. * @param {number}: Represents the wind force
  72401. */
  72402. windForce: number;
  72403. /**
  72404. * @param {Vector2}: The direction of the wind in the plane (X, Z)
  72405. */
  72406. windDirection: BABYLON.Vector2;
  72407. /**
  72408. * @param {number}: Wave height, represents the height of the waves
  72409. */
  72410. waveHeight: number;
  72411. /**
  72412. * @param {number}: Bump height, represents the bump height related to the bump map
  72413. */
  72414. bumpHeight: number;
  72415. /**
  72416. * @param {boolean}: Add a smaller moving bump to less steady waves.
  72417. */
  72418. private _bumpSuperimpose;
  72419. bumpSuperimpose: boolean;
  72420. /**
  72421. * @param {boolean}: Color refraction and reflection differently with .waterColor2 and .colorBlendFactor2. Non-linear (physically correct) fresnel.
  72422. */
  72423. private _fresnelSeparate;
  72424. fresnelSeparate: boolean;
  72425. /**
  72426. * @param {boolean}: bump Waves modify the reflection.
  72427. */
  72428. private _bumpAffectsReflection;
  72429. bumpAffectsReflection: boolean;
  72430. /**
  72431. * @param {number}: The water color blended with the refraction (near)
  72432. */
  72433. waterColor: BABYLON.Color3;
  72434. /**
  72435. * @param {number}: The blend factor related to the water color
  72436. */
  72437. colorBlendFactor: number;
  72438. /**
  72439. * @param {number}: The water color blended with the reflection (far)
  72440. */
  72441. waterColor2: BABYLON.Color3;
  72442. /**
  72443. * @param {number}: The blend factor related to the water color (reflection, far)
  72444. */
  72445. colorBlendFactor2: number;
  72446. /**
  72447. * @param {number}: Represents the maximum length of a wave
  72448. */
  72449. waveLength: number;
  72450. /**
  72451. * @param {number}: Defines the waves speed
  72452. */
  72453. waveSpeed: number;
  72454. /**
  72455. * Sets or gets wether or not automatic clipping should be enabled or not. Setting to true will save performances and
  72456. * will avoid calculating useless pixels in the pixel shader of the water material.
  72457. */
  72458. disableClipPlane: boolean;
  72459. protected _renderTargets: BABYLON.SmartArray<BABYLON.RenderTargetTexture>;
  72460. private _mesh;
  72461. private _refractionRTT;
  72462. private _reflectionRTT;
  72463. private _reflectionTransform;
  72464. private _lastTime;
  72465. private _lastDeltaTime;
  72466. private _renderId;
  72467. private _useLogarithmicDepth;
  72468. private _waitingRenderList;
  72469. private _imageProcessingConfiguration;
  72470. private _imageProcessingObserver;
  72471. /**
  72472. * Gets a boolean indicating that current material needs to register RTT
  72473. */
  72474. readonly hasRenderTargetTextures: boolean;
  72475. /**
  72476. * Constructor
  72477. */
  72478. constructor(name: string, scene: BABYLON.Scene, renderTargetSize?: BABYLON.Vector2);
  72479. useLogarithmicDepth: boolean;
  72480. readonly refractionTexture: BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  72481. readonly reflectionTexture: BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  72482. addToRenderList(node: any): void;
  72483. enableRenderTargets(enable: boolean): void;
  72484. getRenderList(): BABYLON.Nullable<BABYLON.AbstractMesh[]>;
  72485. readonly renderTargetsEnabled: boolean;
  72486. needAlphaBlending(): boolean;
  72487. needAlphaTesting(): boolean;
  72488. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  72489. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  72490. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  72491. private _createRenderTargets;
  72492. getAnimatables(): BABYLON.IAnimatable[];
  72493. getActiveTextures(): BABYLON.BaseTexture[];
  72494. hasTexture(texture: BABYLON.BaseTexture): boolean;
  72495. dispose(forceDisposeEffect?: boolean): void;
  72496. clone(name: string): WaterMaterial;
  72497. serialize(): any;
  72498. getClassName(): string;
  72499. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): WaterMaterial;
  72500. static CreateDefaultMesh(name: string, scene: BABYLON.Scene): BABYLON.Mesh;
  72501. }
  72502. }
  72503. declare module BABYLON {
  72504. /** @hidden */
  72505. export var asciiartPixelShader: {
  72506. name: string;
  72507. shader: string;
  72508. };
  72509. }
  72510. declare module BABYLON {
  72511. /**
  72512. * AsciiArtFontTexture is the helper class used to easily create your ascii art font texture.
  72513. *
  72514. * It basically takes care rendering the font front the given font size to a texture.
  72515. * This is used later on in the postprocess.
  72516. */
  72517. export class AsciiArtFontTexture extends BABYLON.BaseTexture {
  72518. private _font;
  72519. private _text;
  72520. private _charSize;
  72521. /**
  72522. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  72523. */
  72524. readonly charSize: number;
  72525. /**
  72526. * Create a new instance of the Ascii Art FontTexture class
  72527. * @param name the name of the texture
  72528. * @param font the font to use, use the W3C CSS notation
  72529. * @param text the caracter set to use in the rendering.
  72530. * @param scene the scene that owns the texture
  72531. */
  72532. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  72533. /**
  72534. * Gets the max char width of a font.
  72535. * @param font the font to use, use the W3C CSS notation
  72536. * @return the max char width
  72537. */
  72538. private getFontWidth;
  72539. /**
  72540. * Gets the max char height of a font.
  72541. * @param font the font to use, use the W3C CSS notation
  72542. * @return the max char height
  72543. */
  72544. private getFontHeight;
  72545. /**
  72546. * Clones the current AsciiArtTexture.
  72547. * @return the clone of the texture.
  72548. */
  72549. clone(): AsciiArtFontTexture;
  72550. /**
  72551. * Parses a json object representing the texture and returns an instance of it.
  72552. * @param source the source JSON representation
  72553. * @param scene the scene to create the texture for
  72554. * @return the parsed texture
  72555. */
  72556. static Parse(source: any, scene: BABYLON.Scene): AsciiArtFontTexture;
  72557. }
  72558. /**
  72559. * Option available in the Ascii Art Post Process.
  72560. */
  72561. export interface IAsciiArtPostProcessOptions {
  72562. /**
  72563. * The font to use following the w3c font definition.
  72564. */
  72565. font?: string;
  72566. /**
  72567. * The character set to use in the postprocess.
  72568. */
  72569. characterSet?: string;
  72570. /**
  72571. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  72572. * This number is defined between 0 and 1;
  72573. */
  72574. mixToTile?: number;
  72575. /**
  72576. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  72577. * This number is defined between 0 and 1;
  72578. */
  72579. mixToNormal?: number;
  72580. }
  72581. /**
  72582. * AsciiArtPostProcess helps rendering everithing in Ascii Art.
  72583. *
  72584. * Simmply add it to your scene and let the nerd that lives in you have fun.
  72585. * Example usage: var pp = new AsciiArtPostProcess("myAscii", "20px Monospace", camera);
  72586. */
  72587. export class AsciiArtPostProcess extends BABYLON.PostProcess {
  72588. /**
  72589. * The font texture used to render the char in the post process.
  72590. */
  72591. private _asciiArtFontTexture;
  72592. /**
  72593. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  72594. * This number is defined between 0 and 1;
  72595. */
  72596. mixToTile: number;
  72597. /**
  72598. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  72599. * This number is defined between 0 and 1;
  72600. */
  72601. mixToNormal: number;
  72602. /**
  72603. * Instantiates a new Ascii Art Post Process.
  72604. * @param name the name to give to the postprocess
  72605. * @camera the camera to apply the post process to.
  72606. * @param options can either be the font name or an option object following the IAsciiArtPostProcessOptions format
  72607. */
  72608. constructor(name: string, camera: BABYLON.Camera, options?: string | IAsciiArtPostProcessOptions);
  72609. }
  72610. }
  72611. declare module BABYLON {
  72612. /** @hidden */
  72613. export var digitalrainPixelShader: {
  72614. name: string;
  72615. shader: string;
  72616. };
  72617. }
  72618. declare module BABYLON {
  72619. /**
  72620. * DigitalRainFontTexture is the helper class used to easily create your digital rain font texture.
  72621. *
  72622. * It basically takes care rendering the font front the given font size to a texture.
  72623. * This is used later on in the postprocess.
  72624. */
  72625. export class DigitalRainFontTexture extends BABYLON.BaseTexture {
  72626. private _font;
  72627. private _text;
  72628. private _charSize;
  72629. /**
  72630. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  72631. */
  72632. readonly charSize: number;
  72633. /**
  72634. * Create a new instance of the Digital Rain FontTexture class
  72635. * @param name the name of the texture
  72636. * @param font the font to use, use the W3C CSS notation
  72637. * @param text the caracter set to use in the rendering.
  72638. * @param scene the scene that owns the texture
  72639. */
  72640. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  72641. /**
  72642. * Gets the max char width of a font.
  72643. * @param font the font to use, use the W3C CSS notation
  72644. * @return the max char width
  72645. */
  72646. private getFontWidth;
  72647. /**
  72648. * Gets the max char height of a font.
  72649. * @param font the font to use, use the W3C CSS notation
  72650. * @return the max char height
  72651. */
  72652. private getFontHeight;
  72653. /**
  72654. * Clones the current DigitalRainFontTexture.
  72655. * @return the clone of the texture.
  72656. */
  72657. clone(): DigitalRainFontTexture;
  72658. /**
  72659. * Parses a json object representing the texture and returns an instance of it.
  72660. * @param source the source JSON representation
  72661. * @param scene the scene to create the texture for
  72662. * @return the parsed texture
  72663. */
  72664. static Parse(source: any, scene: BABYLON.Scene): DigitalRainFontTexture;
  72665. }
  72666. /**
  72667. * Option available in the Digital Rain Post Process.
  72668. */
  72669. export interface IDigitalRainPostProcessOptions {
  72670. /**
  72671. * The font to use following the w3c font definition.
  72672. */
  72673. font?: string;
  72674. /**
  72675. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  72676. * This number is defined between 0 and 1;
  72677. */
  72678. mixToTile?: number;
  72679. /**
  72680. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  72681. * This number is defined between 0 and 1;
  72682. */
  72683. mixToNormal?: number;
  72684. }
  72685. /**
  72686. * DigitalRainPostProcess helps rendering everithing in digital rain.
  72687. *
  72688. * Simmply add it to your scene and let the nerd that lives in you have fun.
  72689. * Example usage: var pp = new DigitalRainPostProcess("digitalRain", "20px Monospace", camera);
  72690. */
  72691. export class DigitalRainPostProcess extends BABYLON.PostProcess {
  72692. /**
  72693. * The font texture used to render the char in the post process.
  72694. */
  72695. private _digitalRainFontTexture;
  72696. /**
  72697. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  72698. * This number is defined between 0 and 1;
  72699. */
  72700. mixToTile: number;
  72701. /**
  72702. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  72703. * This number is defined between 0 and 1;
  72704. */
  72705. mixToNormal: number;
  72706. /**
  72707. * Instantiates a new Digital Rain Post Process.
  72708. * @param name the name to give to the postprocess
  72709. * @camera the camera to apply the post process to.
  72710. * @param options can either be the font name or an option object following the IDigitalRainPostProcessOptions format
  72711. */
  72712. constructor(name: string, camera: BABYLON.Camera, options?: string | IDigitalRainPostProcessOptions);
  72713. }
  72714. }
  72715. declare module BABYLON {
  72716. /** @hidden */
  72717. export var oceanPostProcessPixelShader: {
  72718. name: string;
  72719. shader: string;
  72720. };
  72721. }
  72722. declare module BABYLON {
  72723. /**
  72724. * Option available in the Ocean Post Process.
  72725. */
  72726. export interface IOceanPostProcessOptions {
  72727. /**
  72728. * The size of the reflection RTT (number if square, or {width: number, height:number} or {ratio:} to define a ratio from the main scene)
  72729. */
  72730. reflectionSize?: number | {
  72731. width: number;
  72732. height: number;
  72733. } | {
  72734. ratio: number;
  72735. };
  72736. /**
  72737. * The size of the refraction RTT (number if square, or {width: number, height:number} or {ratio:} to define a ratio from the main scene)
  72738. */
  72739. refractionSize?: number | {
  72740. width: number;
  72741. height: number;
  72742. } | {
  72743. ratio: number;
  72744. };
  72745. }
  72746. /**
  72747. * OceanPostProcess helps rendering an infinite ocean surface that can reflect and refract environment.
  72748. *
  72749. * Simmply add it to your scene and let the nerd that lives in you have fun.
  72750. * Example usage:
  72751. * var pp = new OceanPostProcess("myOcean", camera);
  72752. * pp.reflectionEnabled = true;
  72753. * pp.refractionEnabled = true;
  72754. */
  72755. export class OceanPostProcess extends BABYLON.PostProcess {
  72756. /**
  72757. * Gets a boolean indicating if the real-time reflection is enabled on the ocean.
  72758. */
  72759. /**
  72760. * Sets weither or not the real-time reflection is enabled on the ocean.
  72761. * Is set to true, the reflection mirror texture will be used as reflection texture.
  72762. */
  72763. reflectionEnabled: boolean;
  72764. /**
  72765. * Gets a boolean indicating if the real-time refraction is enabled on the ocean.
  72766. */
  72767. /**
  72768. * Sets weither or not the real-time refraction is enabled on the ocean.
  72769. * Is set to true, the refraction render target texture will be used as refraction texture.
  72770. */
  72771. refractionEnabled: boolean;
  72772. /**
  72773. * Gets wether or not the post-processes is supported by the running hardware.
  72774. * This requires draw buffer supports.
  72775. */
  72776. readonly isSupported: boolean;
  72777. /**
  72778. * This is the reflection mirror texture used to display reflections on the ocean.
  72779. * By default, render list is empty.
  72780. */
  72781. reflectionTexture: BABYLON.MirrorTexture;
  72782. /**
  72783. * This is the refraction render target texture used to display refraction on the ocean.
  72784. * By default, render list is empty.
  72785. */
  72786. refractionTexture: BABYLON.RenderTargetTexture;
  72787. private _time;
  72788. private _cameraRotation;
  72789. private _cameraViewMatrix;
  72790. private _reflectionEnabled;
  72791. private _refractionEnabled;
  72792. private _geometryRenderer;
  72793. /**
  72794. * Instantiates a new Ocean Post Process.
  72795. * @param name the name to give to the postprocess.
  72796. * @camera the camera to apply the post process to.
  72797. * @param options optional object following the IOceanPostProcessOptions format used to customize reflection and refraction render targets sizes.
  72798. */
  72799. constructor(name: string, camera: BABYLON.TargetCamera, options?: IOceanPostProcessOptions);
  72800. /**
  72801. * Returns the appropriate defines according to the current configuration.
  72802. */
  72803. private _getDefines;
  72804. /**
  72805. * Computes the current camera rotation as the shader requires a camera rotation.
  72806. */
  72807. private _computeCameraRotation;
  72808. }
  72809. }
  72810. declare module BABYLON {
  72811. /** @hidden */
  72812. export var brickProceduralTexturePixelShader: {
  72813. name: string;
  72814. shader: string;
  72815. };
  72816. }
  72817. declare module BABYLON {
  72818. export class BrickProceduralTexture extends BABYLON.ProceduralTexture {
  72819. private _numberOfBricksHeight;
  72820. private _numberOfBricksWidth;
  72821. private _jointColor;
  72822. private _brickColor;
  72823. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  72824. updateShaderUniforms(): void;
  72825. numberOfBricksHeight: number;
  72826. numberOfBricksWidth: number;
  72827. jointColor: BABYLON.Color3;
  72828. brickColor: BABYLON.Color3;
  72829. /**
  72830. * Serializes this brick procedural texture
  72831. * @returns a serialized brick procedural texture object
  72832. */
  72833. serialize(): any;
  72834. /**
  72835. * Creates a Brick Procedural BABYLON.Texture from parsed brick procedural texture data
  72836. * @param parsedTexture defines parsed texture data
  72837. * @param scene defines the current scene
  72838. * @param rootUrl defines the root URL containing brick procedural texture information
  72839. * @returns a parsed Brick Procedural BABYLON.Texture
  72840. */
  72841. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): BrickProceduralTexture;
  72842. }
  72843. }
  72844. declare module BABYLON {
  72845. /** @hidden */
  72846. export var cloudProceduralTexturePixelShader: {
  72847. name: string;
  72848. shader: string;
  72849. };
  72850. }
  72851. declare module BABYLON {
  72852. export class CloudProceduralTexture extends BABYLON.ProceduralTexture {
  72853. private _skyColor;
  72854. private _cloudColor;
  72855. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  72856. updateShaderUniforms(): void;
  72857. skyColor: BABYLON.Color4;
  72858. cloudColor: BABYLON.Color4;
  72859. /**
  72860. * Serializes this cloud procedural texture
  72861. * @returns a serialized cloud procedural texture object
  72862. */
  72863. serialize(): any;
  72864. /**
  72865. * Creates a Cloud Procedural BABYLON.Texture from parsed cloud procedural texture data
  72866. * @param parsedTexture defines parsed texture data
  72867. * @param scene defines the current scene
  72868. * @param rootUrl defines the root URL containing cloud procedural texture information
  72869. * @returns a parsed Cloud Procedural BABYLON.Texture
  72870. */
  72871. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): CloudProceduralTexture;
  72872. }
  72873. }
  72874. declare module BABYLON {
  72875. /** @hidden */
  72876. export var fireProceduralTexturePixelShader: {
  72877. name: string;
  72878. shader: string;
  72879. };
  72880. }
  72881. declare module BABYLON {
  72882. export class FireProceduralTexture extends BABYLON.ProceduralTexture {
  72883. private _time;
  72884. private _speed;
  72885. private _autoGenerateTime;
  72886. private _fireColors;
  72887. private _alphaThreshold;
  72888. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  72889. updateShaderUniforms(): void;
  72890. render(useCameraPostProcess?: boolean): void;
  72891. static readonly PurpleFireColors: BABYLON.Color3[];
  72892. static readonly GreenFireColors: BABYLON.Color3[];
  72893. static readonly RedFireColors: BABYLON.Color3[];
  72894. static readonly BlueFireColors: BABYLON.Color3[];
  72895. autoGenerateTime: boolean;
  72896. fireColors: BABYLON.Color3[];
  72897. time: number;
  72898. speed: BABYLON.Vector2;
  72899. alphaThreshold: number;
  72900. /**
  72901. * Serializes this fire procedural texture
  72902. * @returns a serialized fire procedural texture object
  72903. */
  72904. serialize(): any;
  72905. /**
  72906. * Creates a Fire Procedural BABYLON.Texture from parsed fire procedural texture data
  72907. * @param parsedTexture defines parsed texture data
  72908. * @param scene defines the current scene
  72909. * @param rootUrl defines the root URL containing fire procedural texture information
  72910. * @returns a parsed Fire Procedural BABYLON.Texture
  72911. */
  72912. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): FireProceduralTexture;
  72913. }
  72914. }
  72915. declare module BABYLON {
  72916. /** @hidden */
  72917. export var grassProceduralTexturePixelShader: {
  72918. name: string;
  72919. shader: string;
  72920. };
  72921. }
  72922. declare module BABYLON {
  72923. export class GrassProceduralTexture extends BABYLON.ProceduralTexture {
  72924. private _grassColors;
  72925. private _groundColor;
  72926. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  72927. updateShaderUniforms(): void;
  72928. grassColors: BABYLON.Color3[];
  72929. groundColor: BABYLON.Color3;
  72930. /**
  72931. * Serializes this grass procedural texture
  72932. * @returns a serialized grass procedural texture object
  72933. */
  72934. serialize(): any;
  72935. /**
  72936. * Creates a Grass Procedural BABYLON.Texture from parsed grass procedural texture data
  72937. * @param parsedTexture defines parsed texture data
  72938. * @param scene defines the current scene
  72939. * @param rootUrl defines the root URL containing grass procedural texture information
  72940. * @returns a parsed Grass Procedural BABYLON.Texture
  72941. */
  72942. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): GrassProceduralTexture;
  72943. }
  72944. }
  72945. declare module BABYLON {
  72946. /** @hidden */
  72947. export var marbleProceduralTexturePixelShader: {
  72948. name: string;
  72949. shader: string;
  72950. };
  72951. }
  72952. declare module BABYLON {
  72953. export class MarbleProceduralTexture extends BABYLON.ProceduralTexture {
  72954. private _numberOfTilesHeight;
  72955. private _numberOfTilesWidth;
  72956. private _amplitude;
  72957. private _jointColor;
  72958. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  72959. updateShaderUniforms(): void;
  72960. numberOfTilesHeight: number;
  72961. amplitude: number;
  72962. numberOfTilesWidth: number;
  72963. jointColor: BABYLON.Color3;
  72964. /**
  72965. * Serializes this marble procedural texture
  72966. * @returns a serialized marble procedural texture object
  72967. */
  72968. serialize(): any;
  72969. /**
  72970. * Creates a Marble Procedural BABYLON.Texture from parsed marble procedural texture data
  72971. * @param parsedTexture defines parsed texture data
  72972. * @param scene defines the current scene
  72973. * @param rootUrl defines the root URL containing marble procedural texture information
  72974. * @returns a parsed Marble Procedural BABYLON.Texture
  72975. */
  72976. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): MarbleProceduralTexture;
  72977. }
  72978. }
  72979. declare module BABYLON {
  72980. /** @hidden */
  72981. export var normalMapProceduralTexturePixelShader: {
  72982. name: string;
  72983. shader: string;
  72984. };
  72985. }
  72986. declare module BABYLON {
  72987. export class NormalMapProceduralTexture extends BABYLON.ProceduralTexture {
  72988. private _baseTexture;
  72989. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  72990. updateShaderUniforms(): void;
  72991. render(useCameraPostProcess?: boolean): void;
  72992. resize(size: any, generateMipMaps: any): void;
  72993. baseTexture: BABYLON.Texture;
  72994. /**
  72995. * Serializes this normal map procedural texture
  72996. * @returns a serialized normal map procedural texture object
  72997. */
  72998. serialize(): any;
  72999. /**
  73000. * Creates a Normal Map Procedural BABYLON.Texture from parsed normal map procedural texture data
  73001. * @param parsedTexture defines parsed texture data
  73002. * @param scene defines the current scene
  73003. * @param rootUrl defines the root URL containing normal map procedural texture information
  73004. * @returns a parsed Normal Map Procedural BABYLON.Texture
  73005. */
  73006. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): NormalMapProceduralTexture;
  73007. }
  73008. }
  73009. declare module BABYLON {
  73010. /** @hidden */
  73011. export var perlinNoiseProceduralTexturePixelShader: {
  73012. name: string;
  73013. shader: string;
  73014. };
  73015. }
  73016. declare module BABYLON {
  73017. export class PerlinNoiseProceduralTexture extends BABYLON.ProceduralTexture {
  73018. time: number;
  73019. timeScale: number;
  73020. translationSpeed: number;
  73021. private _currentTranslation;
  73022. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  73023. updateShaderUniforms(): void;
  73024. render(useCameraPostProcess?: boolean): void;
  73025. resize(size: any, generateMipMaps: any): void;
  73026. /**
  73027. * Serializes this perlin noise procedural texture
  73028. * @returns a serialized perlin noise procedural texture object
  73029. */
  73030. serialize(): any;
  73031. /**
  73032. * Creates a Perlin Noise Procedural BABYLON.Texture from parsed perlin noise procedural texture data
  73033. * @param parsedTexture defines parsed texture data
  73034. * @param scene defines the current scene
  73035. * @param rootUrl defines the root URL containing perlin noise procedural texture information
  73036. * @returns a parsed Perlin Noise Procedural BABYLON.Texture
  73037. */
  73038. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): PerlinNoiseProceduralTexture;
  73039. }
  73040. }
  73041. declare module BABYLON {
  73042. /** @hidden */
  73043. export var roadProceduralTexturePixelShader: {
  73044. name: string;
  73045. shader: string;
  73046. };
  73047. }
  73048. declare module BABYLON {
  73049. export class RoadProceduralTexture extends BABYLON.ProceduralTexture {
  73050. private _roadColor;
  73051. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  73052. updateShaderUniforms(): void;
  73053. roadColor: BABYLON.Color3;
  73054. /**
  73055. * Serializes this road procedural texture
  73056. * @returns a serialized road procedural texture object
  73057. */
  73058. serialize(): any;
  73059. /**
  73060. * Creates a Road Procedural BABYLON.Texture from parsed road procedural texture data
  73061. * @param parsedTexture defines parsed texture data
  73062. * @param scene defines the current scene
  73063. * @param rootUrl defines the root URL containing road procedural texture information
  73064. * @returns a parsed Road Procedural BABYLON.Texture
  73065. */
  73066. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): RoadProceduralTexture;
  73067. }
  73068. }
  73069. declare module BABYLON {
  73070. /** @hidden */
  73071. export var starfieldProceduralTexturePixelShader: {
  73072. name: string;
  73073. shader: string;
  73074. };
  73075. }
  73076. declare module BABYLON {
  73077. export class StarfieldProceduralTexture extends BABYLON.ProceduralTexture {
  73078. private _time;
  73079. private _alpha;
  73080. private _beta;
  73081. private _zoom;
  73082. private _formuparam;
  73083. private _stepsize;
  73084. private _tile;
  73085. private _brightness;
  73086. private _darkmatter;
  73087. private _distfading;
  73088. private _saturation;
  73089. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  73090. updateShaderUniforms(): void;
  73091. time: number;
  73092. alpha: number;
  73093. beta: number;
  73094. formuparam: number;
  73095. stepsize: number;
  73096. zoom: number;
  73097. tile: number;
  73098. brightness: number;
  73099. darkmatter: number;
  73100. distfading: number;
  73101. saturation: number;
  73102. /**
  73103. * Serializes this starfield procedural texture
  73104. * @returns a serialized starfield procedural texture object
  73105. */
  73106. serialize(): any;
  73107. /**
  73108. * Creates a Starfield Procedural BABYLON.Texture from parsed startfield procedural texture data
  73109. * @param parsedTexture defines parsed texture data
  73110. * @param scene defines the current scene
  73111. * @param rootUrl defines the root URL containing startfield procedural texture information
  73112. * @returns a parsed Starfield Procedural BABYLON.Texture
  73113. */
  73114. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): StarfieldProceduralTexture;
  73115. }
  73116. }
  73117. declare module BABYLON {
  73118. /** @hidden */
  73119. export var woodProceduralTexturePixelShader: {
  73120. name: string;
  73121. shader: string;
  73122. };
  73123. }
  73124. declare module BABYLON {
  73125. export class WoodProceduralTexture extends BABYLON.ProceduralTexture {
  73126. private _ampScale;
  73127. private _woodColor;
  73128. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  73129. updateShaderUniforms(): void;
  73130. ampScale: number;
  73131. woodColor: BABYLON.Color3;
  73132. /**
  73133. * Serializes this wood procedural texture
  73134. * @returns a serialized wood procedural texture object
  73135. */
  73136. serialize(): any;
  73137. /**
  73138. * Creates a Wood Procedural BABYLON.Texture from parsed wood procedural texture data
  73139. * @param parsedTexture defines parsed texture data
  73140. * @param scene defines the current scene
  73141. * @param rootUrl defines the root URL containing wood procedural texture information
  73142. * @returns a parsed Wood Procedural BABYLON.Texture
  73143. */
  73144. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): WoodProceduralTexture;
  73145. }
  73146. }